Commit Graph

603 Commits

Author SHA1 Message Date
Squall Leonhart 1741fa32db Fix autosaveloadcheat and rename pref 2021-09-23 18:56:32 +10:00
Squall Leonhart a31a7a3086 in Wx, the Option is Enable MMX, make the variable also enableMMX and set its default to on.
The present ini variable is from vbam 1.x and is behaviourally backwards where setting disablemmx to true actually enables mmx, 2.x builds should not be using the ini from 1.x for various reasons.
2021-08-13 13:28:56 +10:00
Zach Bacon 157277e028
Merge pull request #838 from Steelskin/fix-ret-value-filter-event
Use constant aliases in MainFrame::FilterEvent()
2021-08-10 23:41:52 -04:00
Rafael Kitover f23fae6559
Add nuget package source for Windows build.
This fixes the "Unable to find package ..." error.

Thanks to:

https://stackoverflow.com/a/65012088/262458

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2021-07-21 12:55:15 +00:00
Fabrice de Gans-Riberi e91b5e1eac Use constant aliases in MainFrame::FilterEvent()
Previously, this function returned -1 or "true" but wxWidgets
defines constants for the returned values for FilterEvent()
overrides so use these instead.
2021-04-28 16:06:38 -07:00
Rafael Kitover 8a3456f823
Default to not change battery on state load.
This is a more reasonable and less destructive default.

Fix #781.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2021-02-09 15:01:22 +00:00
Rafael Kitover ab68794361
cmake: Fix mac app zip + misc..
Remove keychain unlock for codesigning, that doesn't work anymore, the
key has to be in the system keychain.

Use `zip -9yr` instead of `zip -9r` to make the .zip file of the .app so
that symlinks are preserved, this was creating a corrupted .app.

Don't build zip in the mac builder, use the system zip instead.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2021-02-02 01:49:16 -08:00
Rafael Kitover 7aa0509e0e
Update copyright year in about dialog to 2020.
- Fix #783.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-11-29 18:40:51 +00:00
Rafael Kitover ecdaf6df23
MSVC+vcpkg build update.
Remove the `find_package(unofficial-gettext ...)` invocation for vcpkg
as it is no longer required, the normal `find_package(Gettext ...)`
mechanism works.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-11-25 15:44:10 +00:00
Fabrice de Gans-Riberi edc34942a8 Refactor wxSDLJoy
This is a major refactor of the wxSDLJoy class.
* Move handling of SDL objects creation and destruction to its own
  class. This simplifies the lifespan of SDL-related objects.
* Re-add handling of HATs. This is necessary for DirectInput
  controllers.
* Rename the public API for wxSDLJoy to be clearer.
* Add documentation for every class related to wxSDLJoy.
2020-10-19 08:11:38 +00:00
Rafael Kitover e1fd75629f
Link Windows Media Foundation libs with ffmpeg.
Link some Media Foundation libs required by newer versions of FFmpeg on
Windows.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-10-13 12:51:26 +00:00
Rafael Kitover 13854135a9
Write CFBundleShortVersionString to Info.plist.
CFBundleVersion is already being written since denisfa's Sparkle
changes.

- Fix #750.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-09-29 14:13:26 -07:00
Joseph Griego 65a67f219a Don't set wx-config prefix from CMAKE_PREFIX_PATH
I'm not sure what purpose this currently serves but I know that it
breaks the build when CMAKE_PREFIX_PATH is set to something nontrivial.
Stop doing that.
2020-09-28 23:25:19 +00:00
Brian Searls 80634683b1 Force a panel update when configuring bilinear.
- Fix #727
2020-09-05 21:45:17 +00:00
Rafael Kitover 6a7142813d Differentiate between SDL joy index/instance_id.
Hopefully fix various bugs caused by not differentiating between SDL
joystick_index and SDL_JoystickID (the joystick instance id.)

On controller disconnect, disconnect and reconnect all configured
devices because the SDL joystick index may change, and this will update
the mapping.

Also fix creating a state entry for the configured joystick even when
it's not connected, add the controller/joystick name to the connected
message and increase the poll time from 10ms to 25ms.

- Fix #718.
- Fix #726.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-09-05 19:06:48 +00:00
Rafael Kitover 020daad85f
Fix joy accels when emulation is paused.
Start the joystick polling timer on pause and stop it on resume, so that
accelerators bound to joystick events are still processed.

Followup on def5d3e4.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-09-02 00:50:45 +00:00
Rafael Kitover def5d3e486
Stop timer when game is loaded again.
Followup on 7031c1d1, which for some reason removed the calls to stop
the timer when a game is loaded and restart it when it is unloaded.

Add the calls back.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-08-31 07:25:38 +00:00
Rafael Kitover 546c9d3a11 Minor joystick event handler finding refactor.
Remove the `evthandler` member and `Attach()` method from `wxSDLJoy`.

Add the `GetJoyEventHandler()` method to `MainFrame`, which returns the
window in focus, or the panel if the option for joystick background
input is enabled.

Remove the handler parameter in `wxSDLJoy::CreateAndSendEvent()` and
call `wxGetApp().frame->GetJoyEventHandler()` to get the handler.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-08-29 20:53:49 +00:00
Edênis Freindorfer Azevedo e0816b0e10 Fix weird input/buttons memory leak.
Deleting the vector was not enough, although it was not clear what else
was causing the leak.
2020-08-29 20:53:49 +00:00
Edênis Freindorfer Azevedo cc5ddd1bb7 Isolate x11 keymap to its own header. 2020-08-29 20:53:49 +00:00
Edênis Freindorfer Azevedo 790628961d Include X11 libs and header without screensaver.
We need to always include these files and libs now due to using them
on our keyboard background input solution.
2020-08-29 20:53:49 +00:00
Edênis Freindorfer Azevedo 7031c1d155 [LINUX,WINDOWS] Key/Joy background input.
- Joystick background input.

Set as enabled by default.

- Linux: `X11` and `Wayland` done.

1. `Wayland` does not allow to listen for keypresses for security reasons.

Discussion here: https://github.com/albertlauncher/albert/issues/309

2. For `X11` we can use `XQueryKeymap` to check keyboard state.

- Windows: done.

We use `GetAsyncKeyState` most significant bit to check if the key
is being pressed.
2020-08-29 20:53:49 +00:00
Edênis Freindorfer Azevedo 84f3e8ce67 Allow joystick background input.
Refactor function to send joy events to `GameArea` even if vbam is not
focused.
2020-08-29 20:53:49 +00:00
Rafael Kitover bce91d1722
Run wxrc from the source dir.
Followup on ff03bcc1.

Running wxrc from the build directory turned out to be unnecessary,
because the dlls were not there anyway, and we added them to the PATH.

And using absolute paths for the xrc sources puts them into the gettext
pot comments which is not what we want.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-08-29 19:44:15 +00:00
Fabrice de Gans-Riberi 4074158061
Add GUI cmd line option for config file. (#724)
This adds the command-line option `-c` or `--config` to specify a custom
configuration file.

Co-authored-by: Fabrice de Gans-Riberi <steelskin+github@gmail.com>
2020-08-28 22:26:07 +00:00
Rafael Kitover a305f550e1
Replace Catch2 with doctest for unit tests.
Pretty much the same usage and functionality.

Add `tests.hpp` to configure doctest.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-08-28 05:14:22 +00:00
Rafael Kitover 22a3524c66
Fix linking on Msys2.
Do not link `SDL2main` on any WIN32, not just MSVC.

Define `WIN32_CONSOLE_APP` for Debug mode builds on any WIN32, not just
MSVC.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-08-28 05:09:58 +00:00
Rafael Kitover ff03bcc1e0
Better fix for wxrc with vcpkg.
When doing a dynamic build, the wxWidgets dlls are needed by the wxrc
executable.

Invoke wxrc with the target triplet debug and release bin directory
prepended to the PATH, this is where the dlls are.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-08-23 05:56:32 +00:00
Rafael Kitover c169420fbc Turbo/throttle config and DirectSound fixes.
Make `speedup_frame_skip` and `speedup_throttle` independent settings,
with `speedup_frame_skip == 0` when `speedup_throttle` is not in effect,
and `speedup_throttle == 100` when `speedup_frame_skip` is in effect.

This fixes a previously introduced bug where `speedup == true &&
speedup_frame_skip = X` was never enabled.

This also allows `speedup_throttle == 0` for no throttle and no frame
skip during speedup.

Also set the upper bound on `throttle` and `speedup_throttle` to `450`
instead of `600`, as the DirectSound driver does not support values
higher than that.

In the DirectSound implementation of `setThrottle`, for `throttle == 0`
use a `throttle == 450` frequency multiplier, because a zero frequency
does nothing.

- Fix #719.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-08-22 20:25:05 +00:00
Rafael Kitover 84d406ac0e
Temporary fix for wxrc on MSVC/vcpkg builds.
When the wxrc installed by vcpkg into tools was made with the non-static
wxWidgets, and the build is static, it will not find the wxWidgets dlls
and fail.

Use our own wxrc.exe from the dependencies submodule for the time being.

This is a temporary fix, a proper fix would be adding the dlls, if they
are installed, to the PATH.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-08-20 23:28:42 +00:00
Rafael Kitover 378c9493e9
Fix joystick config when game is loaded.
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>
2020-08-19 11:32:38 +00:00
Rafael Kitover fb9e7e2059
Fix expat lib name for vcpkg.
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>
2020-08-17 22:05:01 +00:00
Rafael Kitover b23d463652
Use vcpkg installed wxrc, support mingw triplet.
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>
2020-08-14 13:16:37 +00:00
Edênis Freindorfer Azevedo 9c314a155d
Use proper string `"wglGetExtensionsStringEXT"`.
`"wglGetExtensionsString"` is not valid on Windows.
2020-08-09 07:01:34 +00:00
Rafael Kitover 81c88227fa Add Catch2 unit testing framework + some tests.
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>
2020-07-10 13:43:48 +00:00
Rafael Kitover 306f92f5d7 Check game kbd input with wxGetKeyState() again.
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>
2020-06-29 01:24:40 +00:00
Rafael Kitover f51e1ee4ec Fix for non-stl wx builds.
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>
2020-06-26 06:51:27 +00:00
Rafael Kitover 121013c534
Transifex push + fix for a couple of strings.
Fix a couple of strings noted by @Ds886.

Generate new pot and push to transifex.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-06-21 19:42:52 +00:00
Edênis Freindorfer Azevedo 91a6b53e02
Input followup (#687)
- 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.
2020-06-20 19:36:24 -03:00
Edênis Freindorfer Azevedo baa0341bd5
Input refactor.
- 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.
2020-06-18 20:47:47 -03:00
Edênis Freindorfer Azevedo bd2483cae7
Allow changing connection type without restart.
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.
2020-06-17 13:23:14 -03:00
Rafael Kitover d379a076df Decrease mouse sensitivity for menu hiding.
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>
2020-06-15 19:32:33 +00:00
Rafael Kitover 1347026d40 Turbo config refactor followup.
In the Turbo config dialog, remove the selection list for entering the
value and leave only the spin control. Allow values above 600%, up to
4000%.

Reintroduce the speedup_frame_skip config variable, defaulting to 9, use
it for turbo selection values > 600%, with speedup_throttle == 0.

The rationale for this is that on average modern hardware, throttle
values above 500% or 600% will not be effective.

The default is now shown as 1000%, which is:

frame_skip == 9 && speedup == 1,

where:

speedup == 1 is equivalent to throttle == 0,

as was the case before the turbo config changes.

Values above 600% are automatically rounded up or down to the nearest
100%, on entry and on click of the up/down arrows of the spin control.

The frame skip checkbox is cleared and disabled for the "Unlimited"
setting (throttle == 0), and set and disabled for values > 600%, to
reflect the mechanism to the user.

When the value again enters the modifiable range in the spin control,
the previous value of the checkbox is restored.

Misc:

- Turn off translation of percentage values in the xrc.

- Remove the size element for the throttle selection list in the general
  config dialog xrc, it breaks the layout on GTK3.

- Add a note about passing wxWidgets_CONFIG_EXECUTABLE to cmake to
  select wxWidgets version to README.md.

Hopefully this will reduce confusion and present a nicer UI.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-05-15 02:01:57 +00:00
Rafael Kitover 1bced474a2
Codesign fix for mac.
Followup on 07064c87.

Use codesign --deep to sign the .app before signing all the frameworks,
otherwise codesign will refuse to sign the app due to unsigned dylibs
when not making a static build.

The error is:

./visualboyadvance-m.app: code object is not signed at all
In subcomponent: ...libtheoraenc.1.dylib

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-05-08 13:26:20 -07:00
Edênis Freindorfer Azevedo 07064c8714
[Windows,MacOS] Auto-updater refactoring. (#639)
Create and enable auto-updater for MacOS using `Sparkle=1.23`. We need
to sign our app using an `Apple Developer Key` for it to work properly,
since we are not going to sign updates with the Sparkle key.

Add all auto-updater files to `gettext`'s pot.

Use `str_split` to always get related stable version. We do not want
to check for nightly builds.

For Windows, we create the flag `-DHTTPS` to select between using an
HTTPS or HTTP URL for the auto-updater checks. We use this to keep
support for Windows XP (HTTP only) while all others should be HTTPS.

Also, use `::FreeLibrary` to allow us to remove the temporary file
that stores the `WinSparkle.dll`. Previously, we could not get it to
work with `wine`.
2020-05-07 23:06:00 -03:00
Rafael Kitover 09e8da43db Joystick refactor pt. Deux: Support Joysticks.
Add support for non-GameController SDL Joysticks.

Add proxy class wxSDLJoyDev to support using either SDL_GameController*
or SDL_Joystick* values in joystate.dev.

Add pretty much identical SDL code to support SDL_Joystick* when the
device cannot be opened as an SDL_GameController*, without changing the
API. SDL_Joystick* devices operate almost identically to SDL_Controller*
devices with their own default mappings, for both events and polling.

Filter axis motion events in the bindings editor widget for subsequent
events within 300ms. This gets rid of the double binding for +1/-1 when
the stick is moved to a direction.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-05-05 08:47:52 +00:00
Rafael Kitover 504ca08b6b Hide menubar + minor UI refactor.
Add ui/hideMenuBar boolean option, defaulting to on, which hides the
main menubar when the mouse is idle or outside the frame.

This is disabled on mac, because on macs the main menubar is not part of
the application window.

Fix pointer hiding/unhiding by connecting panel events to the gamearea
mouse event handler.

Clean up the pausing when menus are opened code, make it actually work
on Windows.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-05-02 13:14:46 +00:00
Rafael Kitover 2868c1b753 Fix changing aspect ratio option.
When toggling "retain aspect ratio", destroy the drawing panel so it is
recreated with the desired aspect ratio settings.

Only add the vertical spacers when aspect ratio is on, they are not
needed when it's off.

Set the sizer priority of the DrawingPanel to 1 if aspect ratio is off
so that wxEXPAND always works.

Clear the GameArea sizer when attaching a new DrawingPanel, this is so
that the vertical spacers used when aspect ratio is on are not included
when aspect ratio is off.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-05-02 13:08:34 +00:00
Edênis Freindorfer Azevedo 0b14e9f885
[WINDOWS] Add function to open unicode files. (#644)
We have some issues when trying to open files on Windows that contains
characters not included in the current codepage. Using `fopen` fails
when that happens.

One example is using the `pt_BR` codepage and then using a name with
japanese chars for the battery file.

The games and BIOS work since they use `blargg_open`. It converts a
`const char *` to `const wchat_t *` and uses `_wfopen` for windows.
(doing a multibyte to widechar conversion)

Since we want to avoid doing many code changes on our cores, we need
some `util*` functions for the matter.

Replace `mb_fn_str` by UTF-8 strings.

Replace all occurrences of `fopen` for `utilOpenFile` on GBA core.

Replace all occurrences of `fopen` for `utilOpenFile` on GBA e-reader.

Adjust e-readers calls on wx frontend.

Replace all occurrences of `fopen` for `utilOpenFile` on Patcher files.

Always apply UTF-8 when dealing with path strings.

On our wx frontend we should always send UTF-8 `char *` to our cores
functions. This way we can have consistency when dealing with them for
each platform.

On Windows, we will convert all multibyte to wide chars and use proper
functions for I/O operation.

Create function to deal with unicode calls of `gzopen`.

We use `gzopen_w` (`zlib>=1.27`).

Replace all occurrences of `fopen` for `utilOpenFile` on Config Manager.

Replace all occurrences of `fopen` for `utilOpenFile` on Cheat files.

Use proper functions for unicode on GB core.

Use function instead of macro for `UTF8()`.

Use `nullptr` instead of `NULL`.

Print wide char strings on status bar.
2020-04-21 10:24:28 -03:00
Rafael Kitover 8e3978b314 Speedup/Turbo/Throttle fixes.
Fix throttle=0 (unlimited speed) settings for both the Speedup/Turbo
config panel and the general throttle setting and make 100 the default.

Replace the speedup frame skip option with a "Frame skip" checkbox,
which enables skipping the appropriate number of frames if vsync or very
low system performance is in effect. The systemFrameSkip (under video
config) is added to this value.

With speedup_throttle=100, the old speedup behavior is used with 9
frames skipped.

With speedup_throttle == 0 && speedup_throttle_frame_skip, skip 9
frames at full speed, which is exactly the same as the old behavior,
since throttle == 0 is equivalent to speedup == true.

Hopefully these changes will make the turbo config dialog more useful
for users, by default frame skipping to work around vsync will be
enabled, and users can uncheck the "Frame skip" checkbox for a smoother
experience.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-04-10 10:19:03 +00:00