Commit Graph

1650 Commits

Author SHA1 Message Date
Edênis Freindorfer Azevedo 6de45d4ed2 Set default binding for keyboard.
We set using the QWERT keyboard as a reference. These keys should
be located at fixed positions on most QWERT keyboards.

KEY    | KEYBOARD
-------|----------
UP     | W
DOWN   | S
LEFT   | A
RIGHT  | D
A      | L
B      | K
R      | O
L      | I
SELECT | Backspace
START  | Enter

- Fix #463.
2019-07-25 00:41:34 +00:00
Edênis Freindorfer Azevedo 78bbe1487a Add individual clear buttons for input config.
Besides that, we also rename the button for all input to `Clear All`.

- Fix #416.
2019-07-25 00:41:34 +00:00
Edênis Freindorfer Azevedo 53002e54db Use hats from joystick as default D-PAD. 2019-07-25 00:41:34 +00:00
Edênis Freindorfer Azevedo 57b7ddf592 Fix small memory leak. 2019-07-25 00:41:34 +00:00
Edênis Freindorfer Azevedo 060da968eb [LINUX] Add option to disable the online updater.
Add option to remove all configuration related to checking for updates
online. Although it is not implemented at the moment, these options
appeared on our menu `Options` > `General ...`.

- Fix need of patch on #140.
2019-07-25 00:41:34 +00:00
Edênis Freindorfer Azevedo dbb5914fa4 Show which BIOS file is currently selected.
It is not possible to pre-select a file with `wxFilePickerCtrl`. Hence,
we add a label to show the current gopts.{gba_bios,gb_bios,gbc_bios} is
being used, if any.

- Fix remaining of #196.
2019-07-25 00:41:34 +00:00
Edênis Freindorfer Azevedo 76756ef916 Fix key shortcuts for toggle menu actions.
Several toggle options from the main menu could not be handled by the
key shortcuts. This was mainly because the code was only checking if
they were ticked or not.

When a key shortcut was pressed, the key itself did not trigger the
tick of the box from the menu, hence nothing was being done.

We are not setting the debug ones because they are not being missed
by the users (yet).

- Fix remaining of #88.
2019-07-25 00:41:34 +00:00
Edênis Freindorfer Azevedo 4622f1b833 Whitespace fix. 2019-07-25 00:41:34 +00:00
Edênis Freindorfer Azevedo 3dc738b5c5 Set default keys for input on first run.
We use the following key input if the config `vbam.ini` does not exist:

input  | keyboard
A      | A
B      | S
L      | Q
R      | W
SELECT | Z
START  | X

We also set a joystick default, using the XBOX 360 controller as a
base.

- Fix #463.
2019-07-25 00:41:34 +00:00
Edênis Freindorfer Azevedo 9bc8f33c40 Disable using volume {+,-} actions in main menu.
The idea of these was to show them available in `Options` >
`Key shortcuts` and allow the user to rebind them. We want the users to
use the keys rather than trying to change the volume via menu actions.
2019-07-25 00:41:34 +00:00
Twinaphex d1fcffc8c4
Merge pull request #63 from retro-wertz/fix_gba_siocnt
libretro: add SIO Control, normal mode reg
2019-07-23 13:47:12 +02:00
retro-wertz 53ce6fb054 libretro: add SIO Control register (GBA)
- emulate SIOCNT reg, which is still needed for some games to trigger IRQ's even in single, non-link mode
- Fixes Digimon Racing (Europe) stuck in intro as reported in libretro docs page https://docs.libretro.com/library/vba_m/#compatibility
- Related PR: f9efb79a7d (diff-385704891f00846c986e9056b5d7c5a5)
2019-07-23 19:15:45 +08:00
retro-wertz e50812dc79 GB: input, audio, video timing updates 2019-07-23 01:18:13 +08:00
retro-wertz 1532f555fe GB: Reduce input lag by 1 frame, video and audio timing updates...
Similar update to GBA which does the following:
- reduces input lag by 1 frame by reading user input at beginning of cpu loop
- audio and video timing update, which sends audio and video at every frame possible
- add missing sound state variable, soundTicks for gb and gba
2019-07-23 00:40:28 +08:00
Rafael Kitover 2fcad3f813
joysticks: hack to better support 360 triggers
Map initial state of axis to 0. This is sufficient for the time being
for the 360 triggers to work better.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-07-19 12:43:47 +00:00
Rafael Kitover 352eb149ae
Merge remote-tracking branch 'vbam-libretro/master' 2019-07-19 12:12:49 +00:00
Edênis Freindorfer Azevedo 2e97b27ffa Use --config option to load configuration file. 2019-07-18 19:40:42 +00:00
retro-wertz bd5ba43122 Cleanup: Remove previous core option struct and unused variables etc 2019-07-18 19:34:20 +08:00
retro-wertz aac30c72d3 Add GB Color Correction core option 2019-07-18 18:07:00 +08:00
retro-wertz 02a7a48bf3 GB: Fix selected palette not applied when loading content...
- Prevent GB type hardware change during runtime.
2019-07-18 17:35:54 +08:00
retro-wertz 1fa78e69c5 Fix android build 2019-07-18 11:57:42 +08:00
retro-wertz 6dcf016d20 GB: Allow support for colorizer patched games
- a new core option is provided since enabling this support
means allowing invalid access to vram and palette
- works in GBC/GBA hardware mode only
2019-07-18 10:41:59 +08:00
retro-wertz 85bd86cf5f GB: Send LCD interrupt only if there is no INT 48h signal
- Fixes Speedy Gonzales status bar in GB emulated hardware type.
2019-07-18 08:31:33 +08:00
retro-wertz d808297bc6 Fix crash caused by incorrect variable index for analog sticks 2019-07-18 01:02:17 +08:00
retro-wertz 7e8828986e libretro: Add core option sublabels 2019-07-18 00:56:58 +08:00
retro-wertz c5e6a3409a Libretro: Update GBC memory map 2019-07-16 22:51:07 +08:00
Rafael Kitover 296255d492
handle SDL joystick query errors #451
SDL APIs like `SDL_JoystickNumAxes(dev)` can return a negative error
code. Handle this case better.

This should fix the fatal exception from trying to allocate an array
with an illegal size (negative, due to the error.)

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-07-11 21:25:51 +00:00
Edênis Freindorfer Azevedo 7569242f77 Fix pause behaviour with `Pause when inactive`.
If the user pauses with the keybinding or the menu `Emulation` > `Pause`
while `Pause when inactive` is enabled, the game should not unpause when
the window receives focus again. It should wait for the user to trigger
the manual unpause.

- Fix #460.
2019-07-04 04:42:32 +00:00
Edênis Freindorfer Azevedo 030740ee34 Fix some memory leak. 2019-07-04 04:41:26 +00:00
Edênis Freindorfer Azevedo 8ea607e1c7 remove translation from joystick keys
Avoid issues with translation, at least for now,
by not translating joystick button/axis names.
2019-07-04 04:26:48 +00:00
Rafael Kitover e2f06210e0
update Visual Studio support
Replace the vcpkg code with a newer and better version. In this version
the `vcpkg` directory is on the same level as the source directory, so
that IntelliSense does not get confused scanning for files.

The cmake variable `VCPKG_TARGET_TRIPLET` is required to activate vcpkg
support, it must be set to e.g. `x64-windows` or `x86-windows`.

Update `CMakeSettings.json` for the new code for the GUI.

Fix a problem copying the `SDL2.dll` file to the binary directory.

Update `README.md` with commandline instructions.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-07-03 23:28:48 +00:00
Edênis Freindorfer Azevedo 91501becf6 Fix small memory leak. 2019-07-03 19:25:11 +00:00
Edênis Freindorfer Azevedo c366907f64 Temporary fix for #65.
It looks like that when we use the `Simple` output module, we get
weird errors when trying to load state for any game, most likely due to
memory corruption. AFAIK, it seems the frame buffer is not large enough
to render all components.

This issues does not appear when using OpenGL, or using the Simple with
any display filter available.
2019-07-03 19:25:11 +00:00
Rafael Kitover d585a61049
followup on kbd trans issues fix in 30b92724
Use the table to to replace both the translated string and the English
string.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-07-03 02:17:13 +00:00
Rafael Kitover eaf1ad2429
Merge remote-tracking branch 'vbam-libretro/master' 2019-07-01 08:00:30 +00:00
Rafael Kitover 30b9272412
hopefully fix kbd control translation issues
Add missing gettext calls for the game controls code.

Seems to work correctly in the Russian locale with special keys.

Also add CLion files to `.gitignore`.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-07-01 07:53:23 +00:00
Edênis Freindorfer Azevedo 90b3f35408 Add hotkeys for changing sizes (1x ... 6x).
Use a accelerator to quickly provide a way to change to/from multipliers
of the original size.

- Fix #415.
2019-06-29 14:04:04 +00:00
Edênis Freindorfer Azevedo fa77010f23 Fix pause toggle keybinding when unmuting.
We use the same event for both keybinding and `Emulation` > `Pause`
actions. The issue here is that the menu item is checkable, meaning
that you toggle its value and then run the handler.

The handler checks the value of the menu item `Emulation` > `Pause`,
and toggle the game pause accordingly. Such thing does not happen when
using the keybinding. Hence, it did not toggle the pause as expected.

- Related to #454.
2019-06-29 14:01:21 +00:00
Edênis Freindorfer Azevedo 8b8efa1b2d fix key shortcuts for save/load states
* Fix key shortcuts for save/load states.

We show the wrong description for these shortcuts, although it works
correctly for the keybinding.

* Use the proper labels for save/load states.
2019-06-26 02:30:31 +00:00
Rafael Kitover 9fa20b49ca
joystick cleanups #444
Check that SDL reports any available controls for a joystick, otherwise
mark it invalid and close it.

When processing events for joysticks, check that each one is valid.

Set initial value of controls to zero initially not after getting the
initial state, previously we were getting the initial state and
overwriting it with zeroes, defeating the purpose.

Fix memory leak, `curval` array of controls not being cleared.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-06-24 20:36:21 +00:00
Rafael Kitover 684b1bb7aa
fix mem error for config global `homeDir`
Fix `homeDir` `ConfigManager` global pointing to freed memory.

Thanks to @FredericHamel for catching this.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-06-23 20:08:23 +00:00
Edênis Freindorfer Azevedo ccc91fa04b quick fix for unicode filenames on windows 2019-06-23 10:59:13 +00:00
Edênis Freindorfer Azevedo dfa4fec3d5 Fix missing shortcuts from key bindings.
Correct set WXK_NUMPAD_{ADD,SUBTRACT} for default volume controls and
enable users to change it via menu "Options > Key Shortcuts".

Also allow users to use both these buttons for other input.
2019-06-23 10:50:52 +00:00
Edênis Freindorfer Azevedo 69b581f7e5 Handle key{bindings,shortcuts} correctly on frame.
Some keybindings were not handled by the frame. That includes some
wxAcceleratorEntry keys. On Linux, if you set a key shortcut using a key
with no modifier ("U" for "Input > Configure"), pressing the key would
not lead to anything.

This is very likely related to wxGTK, although it is not possible to
confirm this at the moment.
2019-06-23 10:50:52 +00:00
Edênis Freindorfer Azevedo cec1dbfd36 Split configuration for default keys.
Split for keyboard and joystick with two arrays variables for
refactoring purposes.
2019-06-23 10:50:52 +00:00
Edênis Freindorfer Azevedo d655031a8f Fix removing multiple system keys shortcuts.
Whenever users try to remove the system keys shortcuts, the
configuration file is overwritten and only records the last erase.

For example, if we wish to remove all the auto{A,B,L,R} keys at once,
we get the following writes on the configuration file:

NOOP=ALT+1,ALT+2,ALT+3,ALT+4
NOOP=ALT+2,ALT+3,ALT+4
NOOP=ALT+3,ALT+4
NOOP=ALT+4

Only `NOOP=ALT+4` stays for the following execution.
2019-06-23 10:50:52 +00:00
Edênis Freindorfer Azevedo 996d5b9df8 Do not set these options on `MainMenu.xrc`.
We already set the default values on `opts.cpp`, therefore these
values are not needed here.
2019-06-23 10:50:52 +00:00
Edênis Freindorfer Azevedo 019ab5a7e1 Fix "Joybus host invalid; disabling" warning.
Whenever there is a link connection for GBA, we check if "GBA/LinkHost"
is an empty string. If it is, we send this warning. This is unnecessary
because most connections are assumed to be for localhost, otherwise the
user would set a server ip address and not see this warning.
2019-06-23 10:07:24 +00:00
Edênis Freindorfer Azevedo f6bfe67632 Have better support for maximized window.
Currently, if we maximize the window, our windowPosition{X,Y} become 0.
When reopening the app, we have a window with the same size of a
maximized, but without this property toggled on. This is not intuitive
for users, since it is expected to have the last non-maximized size
to be restored.
2019-06-23 10:04:37 +00:00
Edênis Freindorfer Azevedo dcc0afa0d4 Fix window size when {en,dis}abling status bar.
If the status bar option is enabled or disabled, there is a trigger that
resizes the current window geometry to its zoom configuration. What
should happen instead is the size remain the same.
2019-06-23 10:04:37 +00:00
Edênis Freindorfer Azevedo bf6f2d4ac2 Change where the config dir is created.
On Windows, if there is a `vbam.ini` where the exe is, we should not
create the configuration directory `%LOCALAPPDATA%\visualboyadvance-m`.
2019-05-31 00:42:08 -07:00
Edênis Freindorfer Azevedo b0ec84693e fix stuck keys on ubuntu and on focus loss #142
In the `OnKeyDown` event handler, check if the key is actually pressed
using `wxGetKeyState()`, because for some reason on Ubuntu 18
spurious events are generated when the key is not actually pressed.

Also, if a game is paused by the frontend while a key is being pressed,
the key will remain active for the game when unpaused. This is an
issue because the key will likely be released outside of the game zone;
therefore, we would not process the key release for the game itself.

The same bug happens if clicking outside of the game zone while
holding a key.

For the case of a directional key, this means a continuous movement
in the direction of the key pressed before the pause until the key
is pressed and released.
2019-05-29 12:08:18 -07:00
Edênis Freindorfer Azevedo 3d57750c16
Follow-up work on #142.
Joysticks have their own set of {KEY,MOD,JOY}, what means that setting
everything for MOD=0 is a mistake. We need to deal only with keyboard
mappings here.
2019-05-23 20:04:18 -03:00
Aaron Kling 055b7c4d49 libretro: jni: Switch to clang compiler in preparation for ndk r20 2019-05-23 15:29:16 -05:00
Aaron Kling 2e1333e1bb regparm is an x86 only attribute, only define it there 2019-05-23 15:28:09 -05:00
Edênis Freindorfer Azevedo 22307de6c8 Fix continuous sprinting when using a modifier key
as a mapping key (#142).

When holding a key(W,A,S,D) and then pressing a modifier(SHIFT,CTRL,ALT),
we get two sets {MOD,MOD,0} and {KEY,MOD,0} with MOD > 0 after a
{KEY,0,0}. When releasing the initial key while holding the modifier,
we search for {KEY,MOD,0} instead of {KEY,0,0} to be removed.

Finally, when releasing the modifier, we remove {MOD,MOD,0} from our
stack. This means the {KEY,0,0} stays "pressed", although no input
is being taken from the keyboard.

Full example using WASD as movement keys and L_SHIFT as our B button.
1. Press and hold "A" --> add {A,0,0} to stack;
2. Press "L_SHIFT" --> add {L_SHIFT,4,0} and {A,4,0} to stack;
3. Release "A" --> remove {A,4,0} from stack (no effect);
4. Release "L_SHIFT" --> remove {L_SHIFT,4,0} from stack;
5. {A,0,0} still on stack.

No keyboard button is being pressed anymore, but there is a continuous
movement towards the direction mapped by "A" {A,0,0}. It is only fixed
when "A" is pressed two times in succession, because we don't add
duplicate sets to our stack, but try to remove them anyway.
2019-05-22 10:59:16 -07:00
Rafael Kitover 504597120f
wx: only rename config if new file doesn't exist
Before trying to rename `vbam.conf` to `vbam.ini`, as we decided during
the XDG support work, first check if `vbam.ini` does not already exist.

If it already exists, use `vbam.ini` and do nothing with the
`vbam.conf`.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-04-28 12:35:27 +00:00
retro-wertz 0a95486fd8 Sound.cpp: Update
- minor, non-function changing updates like float value changes, some unrolled sections
- break soundEvent into separate 8 / 16 bit data writes.
2019-04-28 04:02:45 -07:00
retro-wertz 240257a01b wx: Change max volume from 400 to 200
- global implementation has set max at 200% (2.0 float), its already loud enough at 100%
2019-04-27 15:49:55 -07:00
Rafael Kitover 2fedaa63a6
support FreeBSD
Make some changes to support out-of-the-box builds on FreeBSD:

- set cmake OpenGL type to `LEGACY`, the new `GLVND` type produces
  unusable binaries on FreeBSD

- on FreeBSD add -I/usr/local/include to compiler flags, why this is
  necessary I don't know

- look for llvm tools such as `llvm-ar` in `/usr/local/llvm-devel/bin`,
  LTO works

- improve the `find_wx_util()` cmake function to handle `wx-config`
  scripts named in the form e.g. `wxgtk3u-3.1-config`

- add FreeBSD support to `installdeps`

- make some minor changes to included headers based on macros such as
  `__FreeBSD__` to compile on FreeBSD, including adding a `BSD.h` header
  with some defines for e.g. `fseeko64`

- move the cmake X11 detection to before the wx compile tests, because
  otherwise the extra compile flags for the wx tests make the X11 tests
  fail

- make some minor changes to fix wx 2.8 compatibilty again, we don't
  actually use 2.8 for FreeBSD but I was testing it

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-04-25 16:22:07 +00:00
Rafael Kitover a0c375b6e4
Merge remote-tracking branch 'vbam-libretro/master'
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-04-20 08:39:54 +00:00
Rafael Kitover ac35e37ca0
fix game geometry on windows
Previously when working on Visual Studio support I noticed an XRC error
dialog when adding the game area to the BoxSizer.

I tried removing the wxEXPAND flag with insufficient testing, the flag
is actually necessary.

The error is actually an incorrect debug assertion that is present in
3.1.2 and later fixed in master. The assertion is not triggered when
the project is built in release mode.

Remove the windows conditional code that removes the wxEXPAND flag.

TODO: silence assertion in debug mode or patch the wxWidgets vcpkg port.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-04-17 13:38:29 +00:00
Rafael Kitover 9fa544d1bb
cmake: wxWidgets Release config for visual studio
Fix the cmake code that sets up wxWidgets when using vcpkg with Visual
Studio so that the Release configuration also works. Use variables
instead of an if statement.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-04-17 13:15:13 +00:00
Rafael Kitover 3cacb363a6
libretro: put " " between version and git sha
To make the version string consistent with other cores, make it of the
form "<VER> <SHORT-SHA>" with a space in-between.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-04-16 15:51:30 +00:00
Rafael Kitover c2656f1375
libretro: remove "-" between version and git sha
To make the libretro core consistent with other cores, remove the "-"
between the version and the git short sha for git builds.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-04-16 15:46:32 +00:00
Rafael Kitover 4203bb53f2
libretro: set version with git sha
Read version from `CHANGELOG.md` and append the short git sha if not on
the released commit.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-04-16 14:13:22 +00:00
Wes Smith b6bb24e016
Merge pull request #1 from libretro/master
Rebase
2019-04-15 22:27:52 -04:00
Rafael Kitover ed16d625e3
add unistd.h compat header for visual studio
Using:

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

Revert 5019a201.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-04-13 22:50:05 +00:00
Zach Bacon 5019a20165
[SDL Front] MSVC doesn't have an unistd.h system file, closest is io.h, this will fix building the SDL frontend with msvc again. 2019-04-10 17:27:45 -04:00
Edênis Freindorfer Azevedo 2ae72f38cd fix starting game pos and geometry #406
Fix display when loading ROMs with custom geometry.

This issue was a combination of `wxSHAPED` and its effect on the custom
geometry. It is necessary to force a dummy resize so the display adjusts
itself.

Align game frame on center, both horizontal and vertical.
2019-04-09 15:49:13 +00:00
Rafael Kitover 2beb561838
cmake: move wx funcs and macros into separate file
In 2097b5aa I added a function that is used both in the non-vcpkg block
and outside of it, but the function was defined in the non-vcpkg block,
and this broke the visual studio build.

Move functions and macros into an include file so that they are globally
available.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-04-09 02:04:50 +00:00
retro-wertz 5012969a59 Bump version to 2.1.1 2019-04-06 20:11:14 +02:00
retro-wertz 755f476799 Fix #52 2019-04-06 20:11:13 +02:00
Rafael Kitover 5b9d1a7174
cmake: improve finding wx utils
Clear the `find_program()` cache variable before each use.

On win32 prefer unqualified utility executables.

Add special handling for msys2, where wx-config is a shell script that
cannot be directly run from native cmake.

This is a followup on 2097b5aa.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-04-06 01:37:02 +00:00
Rafael Kitover 836b74a162
remove DOS line-ends from src/wx/xrc/*.xrc
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-04-04 19:21:20 +00:00
Rafael Kitover 49205bf28a
remove unused "multithread filter" menu item
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-04-04 19:20:20 +00:00
Edênis Freindorfer Azevedo 331d9d331c Fix compilation warnings for MacOS build. 2019-04-04 18:01:05 -01:00
Edênis Freindorfer Azevedo 5540790ff1
fix some compilation warnings
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Merged #396
2019-04-03 17:32:25 +00:00
Edênis Freindorfer Azevedo d919728138 Fix for resizing window geometry when loading games. 2019-04-03 11:51:56 +00:00
Rafael Kitover 64a9c0945f
fix analog stick regression from e57beed8 #400
Instead of ignoring the initial state of axes, which I did to make
triggers work on the 360 controller, set the initial previous value to
the initial state instead.

This fixes the original problem without breaking analog stick movement.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-04-01 09:38:51 -07:00
Rafael Kitover 0f0d2400bc
more specific check for 3.1.2 xrc error
The `wxEXPAND` flag is necessary for the game area in wxWidgets 3.0 and
earlier, it may be necessary in 3.1.2 as well, but it throws an xrc
error, so we check for windows and at least 3.1.2 to test for the visual
studio and vcpkg environment to avoid the xrc error.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-04-01 09:28:19 -07:00
Rafael Kitover d9a7df6105
fix if statement in SDL sound driver #396
@denisfa found this due to a warning, this should improve the
functionality of the SDL sound driver.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-04-01 08:42:52 -07:00
Rafael Kitover 2097b5aaa5
wx 2.8 compat fixes, centos support, cmake fixes
Add support for RHEL/centos to installdeps. There is no SFML package.

Add some string compatibility stuff so that everything builds on wx 2.8
unicode builds.

TODO: add travis slaves for 2.8, with and without unicode

Disable the game frame spacer code on 2.8 because it does not work (the
frame does not expand.)

cmake improvements:

- set ENABLE_LTO=OFF for Debug builds by default

- set ENABLE_LINK=OFF if SFML cannot be found and continue

- use better logic for finding wx utilities wx-config and wxrc

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Closes #395
Closes #297
2019-03-28 21:45:06 +00:00
Rafael Kitover b69fced749
cmake: refactor, better clang support
Do some reformatting towards the more modern cmake style.

Clean up some code.

Support linking to gcc compiled wxWidgets by setting
`-D__GXX_ABI_VERSION=` appropriately for clang.

Use the new method of calling `FindwxWidgets.cmake`, the old method
causes some problems now.

Set all necessary policies in both cmake files.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-03-27 03:25:43 +00:00
Rafael Kitover f2e9dc5530
cmake: check for policy CMP0077 existence
Check `if(POLICY CMP0077)` before trying to set it, because setting a
policy a version of cmake does not know about is an error.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-03-26 13:40:35 +00:00
Rafael Kitover ae38a70d1e
cmake: gcc/clang colors with ninja, fix warnings
Ninja requires `-fdiagnostics-color=always` instead of
`-fdiagnostics-color=auto` with gcc because it pipes output from the
compiler unlike regular makes.

Use `-fcolor-diagnostics` for clang, which also works correctly with
ninja to show colors.

Information for this taken from here:

https://medium.com/@alasher/colored-c-compiler-output-with-ninja-clang-gcc-10bfe7f2b949

Set all cmake policies in both the root `CMakeLists.txt` and
`src/wx/CMakeLists.txt` to silence warnings about unset policies from
cmake.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-03-26 00:35:23 +00:00
Rafael Kitover 59e9c69097
reset Xorg screensaver on joy events
Use the libXss Xorg screensaver extension library to call
`XResetScreenSaver()` on joystick events to inhibit screen blanking when
for whatever reason the joystick driver or DE (xboxdrv and KDE in this
case) does not do this.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-03-22 11:30:31 -07:00
Rafael Kitover a0283eadb6
fix game panel size on wxGTK #325
On wxWidgets 3.1.2, which is what vcpkg uses (and we use vcpkg for
Visual Studio) the wxEXPAND flag for the game area in the sizer throws
an XRC error dialog, removing the flag works correctly on Windows, but
not on wxGTK.

As a workaround, do not use the wxEXPAND flag on Windows.

TODO: with max zoom set, the game area is not centered vertically in
wxGTK.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-03-22 11:24:56 -07:00
Rafael Kitover f1ecd7c322
auto deps for visual studio, take 1
Use vcpkg to build deps when Visual Studio on Windows is detected, this
only happens on first build, but does take a while because things like
wxWidgets need to be built. Building from the developer command line is
also supported.

I considered making a pre-built tarball available, but the resulting
files are just too big for this to be practical.

Make the necessary cmake code changes for this to work and to use the
vcpkg packages, which work just like on linux or have other cmake glue
code available.

To do this, we make vcpkg a submodule, use git to checkout all
submodules, then just build and use the `vcpkg.exe`. Then we set the
CMAKE_TOOLCHAIN_FILE to the vcpkg toolchain and also include it
directly, why this is necessary I don't know, without it it doesn't work
in the IDE but does on the command line.

All of this requires no vcpkg integration with either the user or the
project. A user-wide `ENV{VCPKG_ROOT}` is also supported.

Fix the dynamic arrays in the GBA core, MSVC follows the C++ standard on
this and gcc does not.

TODO: add the necessary gcc flags to make this an error in cmake.

Use `wxArrayString` instead of `std::vector<wxString>` in
`src/wx/strutils.cpp` which is used in options parsing. This was
necessary because of a bizarre linker error with wxWidgets when using
Visual Studio:

https://trac.wxwidgets.org/ticket/10884#comment:46

In `src/wx/panel.cpp` make sure the unimplemented D3D renderer code does
not get compiled if it's actually `OFF`.

Also fix the new spacer code for the drawing panel to not combine
`wxEXPAND` with `wxALIGN_CENTER`, which is an error on wxWidgets 3.1.2,
which is what vcpkg uses. The drawing panel seems to be automatically
stretched to the max size automatically anyway.

TODO: if all of this works, we'll need an Appveyor set up for visual
studio.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-03-21 16:01:46 -07:00
Edênis Freindorfer Azevedo c714ff825a fix problems of command line parameters
* Fix return code for wrong command line parameters.

* Update return code for incorrect command line option on WX port.
2019-03-18 20:38:42 -07:00
Edênis Freindorfer Azevedo a1f0c34ace XDG followup work #94
* Apply save order for save states and batteries.
The order for save state/battery:
1. StateDir / BatteryDir;
2. The path of the current loaded game;
3. XDG Base Dir fallback.

* Use XDG Base Dir fallback to save screenshots and recordings.

* Apply search order for all dirs except recording (not implemented yet) of SDL port.
The order for battery/save state/screenshot is:
1. StateDir/BatteryDir/ScreenshotDir;
2. The path of the current loaded game;
3. XDG Base Dir (or equivalent) fallback.

* Refactor code.

* Fix freeing and setting pointer to NULL of SDL port.
2019-03-18 01:08:53 -07:00
Edênis Freindorfer Azevedo a57e51f699 Return non-error code for given command line parameters. 2019-03-14 16:17:45 -07:00
Edênis Freindorfer Azevedo 3fd444da91 XDG related cleanups #94
* Add migration support for 'vbam.cfg' to 'vbam.ini' on MacOS and Windows.

* Cleanup from XDG Base Dir code.

* Set home to NULL after using free().
2019-03-13 22:05:02 -07:00
Edênis Freindorfer Azevedo 1ebb8efdb6 Fix to set correctly position Y. 2019-03-12 11:16:09 -07:00
Edênis Freindorfer Azevedo 944c263e7f auto save/load geometry for wx GUI #94
* Add support to save/load geometry options for GUI window.

* Refactor code to use wxWidgets functions to get window geometry.

* Call update_opts() from ::OnSize and ::OnMove functions.
2019-03-11 10:32:39 -07:00
Rafael Kitover 530af14030
rpi plugins fix + paths enhancements #94
Store the full relative path to found `.rpi` plugins, relative to the
standard Plugins directory, as specified by wxWidgets.

This fixes the problem of plugins being in a subdirectory while only the
basename was stored, making the plugins unusable.

This is done by using `wxFileName::GetFullPath()` instead of
`wxFileName::GetFullName()` with a relative filename instance.

Make a `GetPluginsDir()` method on the app class to simplify getting
this directory, and for possible future overrides.

Also make some minor, functionally equivalent changes to
`get_config_path()` in `wxvbam.cpp`:

- use the new `GetPluginsDir()` method for the plugins directory when
  building the config file search path

- print the XdgConfigDir on all platforms, since the function works on
  all platforms

- make a `add_nonstandard_path` macro which duplicates the `add_path`
  macro for wxWidgets standard paths but for any arbitrary string path

- use `wxFileName` methods to make the XDG config directory path instead
  of string concatenation

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-03-07 07:13:07 -08:00
Rafael Kitover 6a98f3c200
define S_ISDIR for win32 #94
Followup on #383.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-03-06 18:53:22 -08:00
Edênis Freindorfer Azevedo 7373da1528 Fix segmentation fault issue when using WX port command line
on Linux and MacOS.
2019-03-06 18:03:37 -08:00
Edênis Freindorfer Azevedo 36453885fc XDG Base Dir Spec followup #383
* Add XDG Base Dir Spec for other Unix alike platform.

* Add XDG Base Dir support for the fallback on SDL port.

* Add migration for Unix configuration file.
We migrate from 'vbam.conf' to 'vbam.ini' automatically.

* Refactor code for portability of dir creation functions.

* Fix for MacOS compilation directive.
2019-03-06 15:38:57 -08:00
Wes Smith f87e085079 added a8a35 2019-03-05 15:22:21 -05:00