Rename the joystick polling timer accessors and add a predicate.
Check it and make sure the timer is running in the input and accelerator
config dialogs.
- Fix#711.
- Fix#716.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
- Removing mapperSeconds and mapperLSeconds since both of these can be
zero at any time since they are seconds timer, not seconds since
epoch.
- This leaves only mapperLastTime as this is the number of seconds since
last epoch. If this value is zero, then initialize rtc.
It is now installed as `libexpatMD.lib` for release and
`libexpatdMD.lib` for debug and not `expat.lib`.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Fix the problem with vcpkg installs including both wxWidgets and ffmpeg
overrunning the one hour time limit, by making ffmpeg optional and only
building it if the other builds are under 30 minutes.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Use the vcpkg installed wxrc, from a tools subdirectory, instead of
copying it out of the build tree.
Except when running on appveyor, for some reason the vcpkg wxrc does not
work there, so use our own from the dependencies submodule.
Support vcpkg mingw triplets, they don't work yet however.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
- This is done so we can poll inputs from one place all at once for all
player ports instead of calling the function multiple times for each player port.
Stereo buffer is not remade in the case of audio plugin
switch (only affects GBA, not GB). This results in a crash.
We need to remake the stereo buffer and reinit the pointers
in Gba_Pcm.output or they will be dangling, and lead to a
crash. Also, cleaning up the Multi_Buffer class a bit.
Just a hack to fix a problem with vcpkg upgrades, in this case the
version of the zlib port being too old breaks another upgrade, so we
will check if zlib is in the list of packages to upgrade and upgrade it
before anything else.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Don't disable ccache for msys+ninja anymore, since the mingw ccache
works now and there is no reason to use the msys ccache anymore.
Use RULE_LAUNCH_COMPILE only on cmake versions < 3.4.0, because this
currently breaks resource compilation with visual studio and the windows
native ccache from chocolatey, this needs to be fixed in ccache.
On cmake 3.4.0 and greater, set the variables
CMAKE_<LANG>_COMPILER_LAUNCHER instead. This has the effect of using
ccache for C, C++ and nasm, but not for the resource file, avoiding the
problem with visual studio, which has a more recent cmake. This must be
done before the project() call.
TODO: Currently the Visual Studio build with ccache from chocolatey
works correctly, ccache is being invoked from ninja, but no cache files
are being created. This is being followed up with the chocolatey package
maintainer and upstream if necessary. The resource compiler issue also
needs to be fixed upstream.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Add the Catch2 headers to third_party/include/catch2.
Add Catch.cmake and CatchAddTests.cmake to cmake/.
Add unit tests src/wx/tests/strutils.cpp using Catch2 to test
src/wx/strutils.cpp.
Make some code changes to strutils.cpp to make the tests pass.
See src/wx/tests/CMakeLists.txt for how to set up unit test files; they
plug into the normal CTest mechanism in cmake.
The test binaries are written to the tests/ subdirectory of the build
directory.
Building the tests and enabling the CTest support can be turned off by
passing -DBUILD_TESTING=OFF to cmake, the default is ON, this is the
standard mechanism.
Start running ctest on travis and appveyor.
Move stb to third_party/include where Catch2 is now as well.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Build on bionic with downloaded stow packages in /usr/local.
f51e1ee4 is actually a fix for a wx with --enable-utf8 and NOT for a wx
with --disable-stl, as it turns out.
FreeBSD uses --enable-utf8, while Linux distributions generally don't.
Tested by reverting f51e1ee4.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Followup on baa0341b.
Reintroduce checking if a key is actually pressed in the panel OnKeyDown
event with wxGetKeyState(key_code).
Introduced in b0ec846 and removed in baa0341b.
wxGetKeyState() does not work on Wayland and does not work for Unicode
keys, support for which was introduced in baa0341b, which is why the
call was removed.
Add two static functions is_key_pressed(ev) and is_key_released(ev) that
return true under Wayland or if the key is Unicode, and call
wxGetKeyState() otherwise.
The reason this call was introduced in b0ec846 was to work around a bug
in some Linux distributions that caused spurious keyboard events to be
generated. The bug apparently still persists, see #689.
Because the two additional checks were necessarily added, the bug may
persist on Wayland, if it exists there, and for Unicode keys, but will
be fixed in the more common case of Latin keys under Xorg.
Tested on Linux with both Latin and Unicode game input keyboard keys.
- Fix#689.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Followup on baa0341b.
Use ToStdWstring() instead of wc_str() to look up strings in the map,
the key for the map is std::wstring.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
- Allow some control chars to be used as input.
This is actually a regression, since our default config uses some of
these chars.
- Allow default keys bindings to be used elsewhere.
If we try to use keys such as `KP_ADD`, `KP_ENTER` as game input, we
actually execute a `NOOP` command accelerator (nothing done), as we
associate the key with it to disable the accel.
Due to this, we do not allow any further processing of this key, such
as game input.
- Allow key shortcuts to run with loaded game.
For example, when we set `CTRL+A` for `load most recent save state` and
use `A` for some input command, holding `CTRL` and then pressing `A`
will not execute the shortcut. Instead, the key press `A` will be used
only as the input and nothing else.
With this, we use both the input and shortcut key.
- Isolate function to get keyboard key codes.
As explained on [1]:
"Using `GetUnicodeKey()` is in general the right thing to do if you are
interested in the characters typed by the user, `GetKeyCode()` should
be only used for special keys (for which `GetUnicodeKey()` returns
`WXK_NONE`)."
We also allow special keys to be mapped, hence the requirement of using
both functions.
[1] https://docs.wxwidgets.org/3.1/classwx_key_event.html
- Allow use of unicode keys for input and shortcut.
Use format `KeyCode:Modifier` for saving/loading unicode keys.
`WxWidgets=3.{0,1}` does not create an accelerator from strings with
unicode keys such as `ç` (`FromString` function). It fails with an
assertion error and stops execution. At the same time, we use the keys'
strings that are known for WxWidgets, such as `A`, `CTRL+O`,
`PAGEUP` etc.
Use both `EVT_KEY_DOWN` and `EVT_CHAR`.
`EVT_CHAR` is better than `EVT_KEY_DOWN` here because it is where the
raw key events will have been cooked using whatever recipes are in
effect from the os, locale, international keyboard settings, etc.
- Enable SDL joysticks input as key shortcuts.
Start/Stop polling joysticks on Unload/load game.
Our main loop already polls the joystick, we don't need the timer
while a game is running.
- Create function `str_split_with_sep` and use it.
For when we parse strings that may include the sep string, such as
game input and key shortcuts.
It is not needed to set `throttle` on neither case. There is actually a
bug when using turbo/speedup and closing the emulator. The test case
is the following:
https://github.com/visualboyadvance-m/visualboyadvance-m/issues/627
On Windows:
1. use opengl;
2. load GBA game;
3. set throttle to `100%`;
4. set turbo throttle to `200%`;
5. enable turbo on menu;
6. save game;
7. close emulator && open emulator;
8. load GBA game;
==>
throttle is `200%`.
This is definitely not expected.
Before, if we tried changing the connection type without closing vbam,
we would get an error about a connection already existing. We needed
to restart vbam to change it.
Ignore mouse movements of less than 11 pixels, to avoid spurious events
from mice in high DPI mode etc..
- Fix#675.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>