Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard shortcuts don't work #88

Closed
BeyondTheHorizon opened this issue Feb 25, 2017 · 28 comments
Closed

Keyboard shortcuts don't work #88

BeyondTheHorizon opened this issue Feb 25, 2017 · 28 comments
Assignees

Comments

@BeyondTheHorizon
Copy link

I've tried using keyboard shortcuts with VBA-M, but for some reason they don't do jack. For example, when using CTRL+P while playing a game, this should pause the game, but it doesn't.

I'm using the latest release—6ecab80—with Windows. I can't find the interface (wx or SDL).

Thank you for your time.

@bryc
Copy link

bryc commented Feb 25, 2017

I am experiencing the same issue. In the latest two releases 931fda4 and 6ecab80, I am unable to use CTRL+R for reset and save state shortcuts SHIFT+F1/F1. The older Beta-3 release f7f67ff is unaffected.

Also it's probably worth noting that the "Keyboardfixes" release also affects gamepads - without that fix, games that require multiple directions (e.g. any 8-direction RPG) are almost unplayable because the controls are crippled.

@rkitover
Copy link
Collaborator

@BeyondTheHorizon @bryc

I've been doing lots of work on the keyboard related code, I will try to look at this soon.

@rkitover
Copy link
Collaborator

@BeyondTheHorizon @bryc

I cannot reproduce this, in my msys2 built binary and the latest release shortcuts like CTRL+P and ALT+ENTER work fine.

Can you make sure that you don't have any part of the shortcut mapped to a game key, e.g. if you mapped CTRL or P then CTRL+P will NOT work.

Also can you please provide some details about your environment, whether you are using any special keyboard software like AutoHotKey etc.

@bryc
Copy link

bryc commented Mar 1, 2017

Well damn, I also cannot seem to reproduce it anymore. (Nvm read on. It's an issue with an INI setting?)

Let me take a few steps back and analyze what I did:

When I first tested the latest builds, everything seemed to work - i distinctly remember using keyboard shortcuts for reset and pause.

Then I tried using save states in Mega Man V. It seemed to save fine, but upon loading, it corrupted the game. I thought maybe I was using an incompatible save state between versions. Or maybe it was an issue with i686 or x86-64 specifically. I couldn't determine exactly what was going on, but I knew that freshly created save states were failing to load on certain builds.

Then, out of nowhere, keyboard shortcuts just stopped working. I found this bug and immediately related to it. And noticed that beta-3 worked fine.

In fact, I can reproduce that fact: MMV save states work in beta-3 but not the newest two builds.

I think it affects all SGB games.. they boot slowly and save states are corrupt when loaded.
When in classic GB mode, save states work fine. (Tested using Latest 2 builds, beta-3 is unaffected).
This could be a seperate bug worth looking into....

However I cannot reproduce the keyboard issue anymore.

I did notice this, at the same time the bug occured:

image

The key shortcut dialog has incorrect text labels. No clue if its related, but "Reset All" neither fixed it when it was broken (I tried that to see if it'd fix it), or causing it now.

I think I was trying to associate keys using my gamepad using that key config dialog, specifically, save state on my gamepad. It didn't seem to work - is it possible that junk data was saved in config that invalidated all key shortcuts?

Edit: I just reproduced the keyboard bug. Apparently I was right - I tried to associate Load State F1 to my gamepad, and CTRL+R doesn't work now. Here is the vba.ini: http://paste2.org/4xKtFU1N, hopefully it makes sense. I don't immediately see the problem in the ini. Also, like I mentioned, "Reset All" doesn't fix it. Also, beta-3 is indeed unaffected by whatever went wrong in the ini.

Edit2: Is there VBA-M config anywhere else besides %AppData%/visualboyadvance-m/vba.ini? Deleting the ini doesn't fix the bug! It still occurs.

@rkitover
Copy link
Collaborator

rkitover commented Mar 1, 2017

@bryc thanks for the detailed info, I don't know what is going on here myself, it seems the shortcuts are not written to the .ini at all but somewhere else.

@bryc
Copy link

bryc commented Mar 1, 2017

@rkitover can you reproduce it?

I have more information:

CTRL+Q (Exit) and CTRL+O (Open) works when first starting the program, but once a game starts, it cannot be used anymore. It appears that all keyboard shortcuts get disabled. If the ROM is closed, the keyboard shortcuts seem to be usable again.

I also noticed that when I unplug my controller and restart the emulator, the issue is nonexistent, I can use shortcuts when a ROM is loaded.

In fact, when I unplug my controller, even when the emulator is currently running a game, it immediately lets me use keyboard shortcuts again.

When I plug back my controller, keyboard shortcuts still work, but VBA-M cannot detect my controller or set gamepad inputs.

(Edit: It seems when I close the input dialog and switch to game screen, it reinitializes my gamepad, and disables keyboard shortcuts again)

When I re-open emulator with controller plugged in, it again disables keyboard shortcuts like before.


User bindings are stored in the INI it seems, but somehow by using my gamepad in the keyboard shortcut window, something screws up possibly in Registry? Because deleting the vbam.ini doesn't fix the bug.

An important question is: Does the Key Shortcut window react to gamepad input? Can pressing a gamepad key in any way affect something?

@rkitover
Copy link
Collaborator

rkitover commented Mar 1, 2017

@bryc yeah there may be some leftover cruft that writes to the registry, will need to investigate.

It looks like the accel dialog uses wxKeyTextCtrl while the game key dialog uses wxJoyKeyTextCtrl, this is in the xrc.

The widgets themselves are in src/wx/widgets

I don't think the code itself has any support for binding accels that are not game keys to joystick controls because the joystick controls are done with SDL and handled separately.

@BeyondTheHorizon
Copy link
Author

@rkitover Reading this has been very insightful. And @bryc, you are right about it working when the emulator hasn't loaded a game or has a controller in.

UPDATE: I think I've found the problem! It has something to do with the default input for the Special controls (as you probably already know, the Input Configure option brings up a window with two tabs, "Standard" and "Special", along with tabs to select each player). Once I cleared the Special controls except for "Speed Up" and "Screenshot", I could use keyboard shortcuts once I restarted VBA-M.

I hope this solution is universal and works for everybody.

@bryc
Copy link

bryc commented Mar 1, 2017

@BeyondTheHorizon I can reproduce it. It seems to work but reverts back if defaults are used again.

I isolated "Joy1-Axis2-" as the culprit for me (default binding for Motion Down). It is the only binding that needs to be removed to invoke the workaround:

image

Did the keyboard shortcuts ever work i.e. when you first started using the newest builds were keyboard shortcuts broken to begin with, or only after tinkering with settings?

@BeyondTheHorizon
Copy link
Author

BeyondTheHorizon commented Mar 1, 2017

@bryc If it helps, the keyboard shortcuts were broken when I first started using the latest release. Oh, and out of curiosity, what does KP mean? Keypad? When I press 8 on the numeric keyboard, it says "KP_8" instead of "KP_UP", for example.

@peldas
Copy link

peldas commented May 1, 2017

I've figured out the exact culprit. It seems previous VBA-M versions were much less picky about controls. When a trigger is pressed past its halfway point, its value is registered under (for example) Joy1-Axis2+, whereas if it hasn't reached the halfway point yet, its value is registered as Joy1-Axis2-. This normally works fine, except this version of VBA-M has included not being pressed at all as being -, so when that state is registered to an action, the action will be consistently fired (unless the trigger is once again moved past its halfway point to untrigger the - action and instead trigger the + action). It also seems that when an action is continuously fired in this way, standard keyboard shortcuts like Alt+Enter and Ctrl+Q are disallowed from working.
I believe previous versions of VBA-M may not have even accepted - actions and so this is a bug resulting from the messing around with keyboard shortcuts.

@Ivandsi2211
Copy link

Ivandsi2211 commented Mar 29, 2018

I'm also having issues with the shortcut keys in the latest release, it might be because of what you said (@kelpso) but I'm not really sure. Also the fact that it randomly works and sometimes it doesn't, could point that maybe sometimes it's reading + or - on the trigger and sometimes something else.
As an extra thing, the shortcuts work perfectly before running any games so, basically, before the emulator needs to check for the input you use in a game.

@nicklemarr
Copy link

Same issue.

@AquaSurge101
Copy link

I solved the issue by clearing all the special keys except Speed up and screenshot. I hope this works for everyone :)

@Bjonnfesk
Copy link

I appear to have experienced the exact same problem as @bryc describes: Keyboard shortcuts work fine when VBA-M is started sans controller, but with a controller connected, CTRL+O and CTRL+Q work (although I usually have CTRL+Q and CTRL+W unbound as I have been burned by accidentally pressing these combinations instead of CTRL+S after difficult Pokèmon fights) before loading a ROM, but once a ROM is loaded, all keyboard shortcuts are disabled.

Unbinding Joy1-Axis2- fixed the issue.

Oddly enough, I cannot recall ever having experienced this while using an original Sony PlayStation 4 controller. It only happened after I misplaced my genuine DualShock and started using a cheap aftermarket controller branded, rather surprisingly, "Arrogant Bastard". However, from the previous comments here, it appears this must have been coincidence; I included it anyway because with programming, you quite frankly never know what might turn out to be relevant.

@ghost
Copy link

ghost commented Aug 19, 2018

as a workaround for shortcuts not working when game is already running, the culprit here is due to the nature of some analog triggers (at least on my case with xbox360). removing remaps(was set default for Motion Up/Down) for any triggers should resolve most shortcut key issues.

@ghost ghost closed this as completed Aug 19, 2018
@ghost ghost reopened this Aug 19, 2018
@rkitover rkitover self-assigned this Aug 20, 2018
@rkitover
Copy link
Collaborator

I will try to rewrite the SDL joystick API usage from SDL1 calls to SDL2 calls for the next release, hopefully that will help. SDL2 has better support for axis etc..

@Manka-Muakido
Copy link

well just have some problems with bios of gba and some games and finally update from 1.8 for the most recent 2.1.0 but this problem with shortcuts really are worst than the bios problem the workaround do not work for me but waiting the new build with the fix

but aside this little bug, GREAT WORK GUYS!!!really thanks for the updates!!

@ghost
Copy link

ghost commented Dec 9, 2018

#276 (comment)

MORE INFORMATION:
Hotkeys also do not work,when you are pressing/holding a key on gamepad (which is what is similarly happening when the analog triggers are still assigned to joypad buttons)

@ghost ghost added the input label Dec 9, 2018
@Bjonnfesk
Copy link

#276 (comment)

MORE INFORMATION:
Hotkeys also do not work,when you are pressing/holding a key on gamepad (which is what is similarly happening when the analog triggers are still assigned to joypad buttons)

Correct.

rkitover added a commit that referenced this issue Dec 26, 2018
The default keyboard/joystick bindings for the "special" keys have
assumptions about axis numbers that do not hold with modern game pads.

For reference, the 360 controller has the following mappings:

Axis 0/1: left stick
Axis 3/4: right stick
Axis 2:   left trigger
Axis 5:   right trigger

This triggers another bug causing the depressed state of a trigger axis
to fire continuously. In this case, this is the left trigger on a 360
controller which is axis 2.

This triggers yet another bug where a stream of joystick events blocks
keyboard events from registering, resulting in hotkeys like ctrl+p to
pause not working.

Replace all joystick binds for special keys with null values.

With this change, a default installation of vbam will not trigger the
hotkeys not working bug when a joystick is plugged in.

The other bugs here mentioned also need to be fixed.
rkitover added a commit that referenced this issue Dec 28, 2018
On joystick event notification, filter out axis values that are equal to
their initial state.

The reason for doing this is explained in 539027c. Triggers on e.g. the
360 controller are an axis that are the max negative value in the
depressed state, and for some reason a constant stream of events are
generated for them, that's another issue that needs to be addressed.

For the time being, this fixes the other half of the main issue in #88:
users with an old config with the default special key bindings will now
be able to use keyboard hotkeys as these spurious joystick events will
be filtered out and will not block keyboard events.

TODO:

- stop generating events for depressed triggers in the first place

- fix joystick events completely blocking keyboard events
@rkitover
Copy link
Collaborator

This is essentially fixed in master now, although there is a lot more work to do to fix things properly and make some improvements to the joystick code.

rkitover added a commit that referenced this issue Dec 29, 2018
One bug noted in the #88 discussion is that when a joystick button is
held down, keyboard shortcuts do not work.

Rewrite the logic for process_key_press() to only block further
wxWidgets event propagation if the actual key pressed is a game key, not
if any game keys are being held down.

This takes care of all the issues in #88.

TODO:

- investigate other joystick issues
@rkitover rkitover added the fixed label Dec 29, 2018
@rkitover
Copy link
Collaborator

The last issue was joystick buttons blocking hotkeys and that's now fixed in master, looking at other joystick issues.

Me and @ZachBacon will try to get a release out soon.

@503geek
Copy link

503geek commented Jan 15, 2019

Using latest release (2.1.0) Note that this appears to also be related to whether or not the game is launched from the command-line. If I open VBA-M and launch a ROM, shortcuts and xinput work, but from the command line xinput continues to work but keyboard shortcuts do not (launching this way is necessary to use external library managers such as PlayNite)

@ghost
Copy link

ghost commented Jan 15, 2019

this should be fixed in latest commit....

@Stargateur
Copy link

Stargateur commented Apr 4, 2019

turbo mode assign to D doesn't work, but alt+D works on 2.1.1 64bit windows precompiled build. Nothing is bind to D except turbo mode and D is not used in my input key.

denisfa added a commit that referenced this issue Jul 6, 2019
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.
@denisfa denisfa added this to To Do in release v2.1.7 via automation Jul 18, 2019
@denisfa
Copy link
Collaborator

denisfa commented Jul 18, 2019

@rkitover This was very like fixed at some moment in the past. I can't reproduce the joystick issue, and the keybinding was done not so long ago.

@Stargateur If you are still around, your keybinding issue was fixed and it will be available on next release!

@rkitover
Copy link
Collaborator

The only remaining issue is that the keybind editor is too sensitive when picking up the analog axis, it binds e.g. axis+ and then immediately adds axis-.

@rkitover
Copy link
Collaborator

Ok I added a better hack for 360 triggers in 2fcad3f and that problem is gone.

I think we can close this now.

release v2.1.7 automation moved this from To Do to Done Jul 19, 2019
denisfa added a commit that referenced this issue Jul 21, 2019
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.
rkitover pushed a commit that referenced this issue Jul 25, 2019
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.
rkitover pushed a commit that referenced this issue Aug 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests