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

Button presses getting stuck when using keyboard #142

Closed
ShadowStkr opened this issue Aug 16, 2017 · 61 comments
Assignees
Labels

Comments

@ShadowStkr
Copy link

@ShadowStkr ShadowStkr commented Aug 16, 2017

Expected behavior

Once a key on the keyboard which is configured to a certain button is released, it shouldn't be registered as released and not being pressed/held anymore.

Actual behavior

Once releasing a certain key (say, left directional, which is configured to the left button), at most times the corresponding button is also registered as not being pressed anymore. However, at certain times (which seem to be random), even after being released, the button corresponding to the key which was pressed still registers as if it was being pressed/hold. If the key is pressed and released again, its release is registered and everything comes back to normal.

I've tried reproducing the problem with a Dualshock 3 (aka PS3 controller) but it seems to not happen with it. Also, something curious is that if I press and release the button on the DS3 which corresponds in the input options to the same button which got "stuck" when using the keyboard, it doesn't get registered as released, as opposed to when doing the same in the keyboard itself.

Steps to reproduce the behavior

Either press a key a certain number of times with some pauses between the presses to check whether its input got "stuck" or alternate between buttons until one of them gets stuck. It seems to be easier to reproduce by pressing directional keys randomly on a menu screen with a lot of options which can be switched horizontally and vertically (such as a naming screen in a game, for example). Turbo mode may also help.

ROM details

I experienced this with Harvest Moon: Friends of Mineral Town (US version). I was able to reproduce the problem in both the initial naming screen and while controlling the character at random. I also tried it with the english version of Golden Sun, in the initial naming screen, and was able to reproduce the problem, so I assume it's not a problem limited to a certain ROM.

Option details

Video driver (simple, opengl or cairo): OpenGL

Sound driver (directsound, xaudio, openal, SDL): Problem happens with both OpenAL/SDL

Build details

Commit 4d7e102, built and tested on Arch Linux. Using xorg.

@rkitover rkitover self-assigned this Aug 16, 2017
@rkitover rkitover added the bug label Aug 16, 2017
@rkitover

This comment has been minimized.

Copy link
Collaborator

@rkitover rkitover commented Aug 16, 2017

Possibly will need to inspect physical keyboard on key events, maybe even switch to using SDL for keyboard game keys.

SDL is already being used for joystick events.

@Yoshimaster96

This comment has been minimized.

Copy link

@Yoshimaster96 Yoshimaster96 commented Aug 29, 2017

This happens to me too. I'm on Linux Mint Cinnamon 64-bit, using VBA-M 2.0.0 beta 3.
The game doesn't seem to matter, and it happens on GB, GBC, and GBA games.
Video: (Simple/OpenGL): OpenGL
Audio: (SDL/OpenAL): OpenAL

@rkitover

This comment has been minimized.

Copy link
Collaborator

@rkitover rkitover commented Aug 29, 2017

@Yoshimaster96 please build from source or use the ubuntu nightly PPA.

@Yoshimaster96

This comment has been minimized.

Copy link

@Yoshimaster96 Yoshimaster96 commented Aug 31, 2017

@rkitover The nightly build still has the bug.
Building gives me this error when running:

Fatal Error: Mismatch between the program and library build versions detected.
The library used 3.0 (wchar_t,compiler with C++ ABI 1002,wx containers,compatible with 2.8),
and your program used 3.0 (wchar_t,compiler with C++ ABI 1009,wx containers,compatible with 2.8).
Aborted
@ZachBacon

This comment has been minimized.

Copy link
Contributor

@ZachBacon ZachBacon commented Aug 31, 2017

Sounds like your distro is using a version of wxwidgets that differs from the one the PPA compiles against.

@ArtiiP

This comment has been minimized.

Copy link
Contributor

@ArtiiP ArtiiP commented Sep 1, 2017

@Yoshimaster96 try add -fabi-version=2 to GCCFLAGS(or something ;p ) and full clean&build
https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gcc/C_002b_002b-Dialect-Options.html

it work's for me, but i have 1010 vs 1011 (and in another project).

and for nighty binary build it's better use static option.

rkitover added a commit that referenced this issue Sep 1, 2017
Use the g++ `-fabi-version=2` compiler option, as suggested by @ArtiiP
to fix problems similar to:

```
Fatal Error: Mismatch between the program and library build versions
detected.
The library used 3.0 (wchar_t,compiler with C++ ABI 1002,wx
containers,compatible with 2.8),
and your program used 3.0 (wchar_t,compiler with C++ ABI 1009,wx
containers,compatible with 2.8).
Aborted
```

Turn LTO off by default until I fix it for newer gcc/binutils, currently
with gcc7 ar segfaults linking vbamcore.
@rkitover

This comment has been minimized.

Copy link
Collaborator

@rkitover rkitover commented Sep 1, 2017

@ArtiiP thanks for the info! I added the flag to the cmake code for gcc.

@rkitover

This comment has been minimized.

Copy link
Collaborator

@rkitover rkitover commented Sep 1, 2017

@Yoshimaster96 try backing up and deleting your config file:

mv ~/.vbam/vbam.conf ~/.vbam/vbam.conf.old

let me know if that helps. If it does, please post your old config file here.

@ArtiiP

This comment has been minimized.

Copy link
Contributor

@ArtiiP ArtiiP commented Sep 1, 2017

@ArtiiP thanks for the info! I added the flag to the cmake code for gcc.

but you know, this broke for people with wx compiled with other abi version ;/

it's not easy fix, maybe expose opiton (and info) for cmake
(ofc better fix is autodetection, but i don't know how, and google don't help either)

edit: i have wx with abi 1010, and propably, i get this fatal error

@Yoshimaster96

This comment has been minimized.

Copy link

@Yoshimaster96 Yoshimaster96 commented Sep 1, 2017

Yup, bug still occurs when building from source.

@rkitover

This comment has been minimized.

Copy link
Collaborator

@rkitover rkitover commented Sep 1, 2017

@Yoshimaster96 can you try removing your config file? See above.

@rkitover

This comment has been minimized.

Copy link
Collaborator

@rkitover rkitover commented Sep 1, 2017

@ArtiiP I will write a compile/link/run test to determine the correct ABI version later on today and will let you know, thanks!

rkitover added a commit that referenced this issue Sep 2, 2017
In 4e665ae I hardcoded -fabi-version=2 for g++ flags, and @ArtiiP
pointed out that this is wrong, because Wx may be compiled with other
ABI versions.

Add cmake check_cxx_source_runs() tests to determine the correct ABI
version flag to use with Wx.
@rkitover

This comment has been minimized.

Copy link
Collaborator

@rkitover rkitover commented Sep 2, 2017

@ArtiiP got it working, see 2ad2046. Yes cmake is an ugly language 😃

rkitover added a commit that referenced this issue Sep 3, 2017
Start checking the ABI version at -fabi-version=0, which is the default,
and if that succeeds don't set the flag at all.

This will allow the code to work properly if and when Wx removes the ABI
check alltogether.
rkitover added a commit that referenced this issue Sep 4, 2017
Following some suggestions from @ArtiiP, first check if there are no
issues without an -fabi-version flag, and then instead of incrementing
from 0, decrement from 15 to find the highest working ABI version.

This is very slow if the needed ABI version is 2 for example, but not
much to do about that for the time being.
@Yoshimaster96

This comment has been minimized.

Copy link

@Yoshimaster96 Yoshimaster96 commented Sep 19, 2017

Please consider fixing the button issue however. I am still experiencing this bug.

@Yoshimaster96

This comment has been minimized.

Copy link

@Yoshimaster96 Yoshimaster96 commented Oct 4, 2017

@rkitover What's with the delay?

@ZachBacon

This comment has been minimized.

Copy link
Contributor

@ZachBacon ZachBacon commented Oct 4, 2017

The delay is that some of us have a life. I work full time at a warehouse and rkitover has things and other projects that take his attention. We do this on our spare time. Please continue being patient, we appreciate it :)

@Yoshimaster96

This comment has been minimized.

Copy link

@Yoshimaster96 Yoshimaster96 commented Oct 4, 2017

@ZachBacon Ah okay, sorry about that. I just thought it was forgotten about entirely.

@rkitover

This comment has been minimized.

Copy link
Collaborator

@rkitover rkitover commented Oct 5, 2017

@Yoshimaster96 we'll need to be able to reproduce the bug in order to do something about it, right now I don't know how to trigger it.

@Yoshimaster96

This comment has been minimized.

Copy link

@Yoshimaster96 Yoshimaster96 commented Oct 5, 2017

@rkitover So it's never happened to you? Huh.

@ale64bit

This comment has been minimized.

Copy link

@ale64bit ale64bit commented Apr 8, 2018

I experience this to the point of rendering games unplayable.

For example, how to reproduce it playing Metroid: Zero Mission: just move towards a wall in your left, and then hold left for about 5 seconds and release. Under my setup, many times the key release doesn't seem to be registered and the character continues to run left until the left key is pressed again.

I'm on Ubuntu 18.04, Thinkpad 470, using keyboard, installed from PPA (v2.0.2).
Thanks!

@Arararararagi

This comment has been minimized.

Copy link

@Arararararagi Arararararagi commented Apr 14, 2018

This happens to me while playing Mario Kart. Pretty freaking annoying when I don't even know which key got stuck anymore.

Machine: Ideapad 300

OS: Linux 4.14.31-1-MANJARO #1 SMP PREEMPT Wed Mar 28 21:42:49 UTC 2018 x86_64 GNU/Linux

VisualBoyAdvance-M (vbam-wx) 2.0.1-1, installed from package manager (Community repository).

@huupoke12

This comment has been minimized.

Copy link

@huupoke12 huupoke12 commented May 25, 2019

Commit 3d57750 has fixed the issue with the modifier key. But the original issue is not fixed. The buttons sometimes get stuck (It can stuck even with only default directional keys) so this is not the same bug.

@denisfa

This comment has been minimized.

Copy link
Collaborator

@denisfa denisfa commented May 25, 2019

@huupoke12 Thanks for the feedback! Are you able to reproduce this bug? I can't reproduce this at the moment. I tried the game Harvest Moon - Friends Of Mineral Town, but it was not successful.

If so, would you mind providing the name of the game, OS you are running and your vbam.ini file so I can investigate what's going on?

The controller code was refactored not so long ago, so I believe this should be a keyboard-only bug.

@huupoke12

This comment has been minimized.

Copy link

@huupoke12 huupoke12 commented May 26, 2019

The games I've tried are: Mario Kart - Super Circuit, SpongeBob SquarePants - Battle for Bikini Bottom, Pokemon Leaf Green
I've also tried Harvest Moon - Friends Of Mineral Town, on the player name selection screen, the bug still happens. You can just hold right key for about 2 seconds, about 10% it will be stuck.
I'm using Arch Linux (5.1.4-arch1-1-ARCH).
vbam.zip

@nemec

This comment has been minimized.

Copy link

@nemec nemec commented May 26, 2019

I just tried the latest master and still have the same issue. Using the original (U.S.) Fire Emblem game (my rom is named 1235 - Fire Emblem (U)(Venom).gba), place the attached .sav and .sgm files into the same dir and load the game, then load the save state. Your cursor will show up on the far right of the screen. Simply hold the left arrow key until the cursor almost hits the end of the screen, then let go. Repeat left and right as needed until the cursor "sticks" in one direction. This works for me ~20% of the time in any one direction (100% after going left to right ~5 times)

Ubuntu 18.04.2 LTS

FE-saves.zip

vbam.ini

@rkitover

This comment has been minimized.

Copy link
Collaborator

@rkitover rkitover commented May 26, 2019

Does this only happen if you load a save state?

@huupoke12

This comment has been minimized.

Copy link

@huupoke12 huupoke12 commented May 26, 2019

Maybe not. In my case, I played Harvest Moon - Friends Of Mineral Town the first time to check for the bug so there won't be any save file before. And SpongeBob SquarePants - Battle for Bikini Bottom doesn't use a save file, you have to use a password.

@nemec

This comment has been minimized.

Copy link

@nemec nemec commented May 26, 2019

Not for me, it happens regardless of whether I loaded a save state or not. I just uploaded the save to provide a quick starting point in case you wanted to try to repro the issue. I'm happy to send the rom, too, if you message me on the email in my profile. There is nothing special about it, though. The saves should work with any FE7 from a GBA rom collection.

denisfa added a commit that referenced this issue May 26, 2019
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.

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.

- Discovered while looking at issue #142.
@denisfa

This comment has been minimized.

Copy link
Collaborator

@denisfa denisfa commented May 26, 2019

@huupoke12 @nemec Thank you for this feedback! I am afraid I have had a lot of luck on my games, since I failed both Harvest Moon - Friends Of Mineral Town and Fire Emblem, even with the supplied save state... There is nothing special about your config files, so this already removes some possibilities.

Your cursor will show up on the far right of the screen. Simply hold the left arrow key until the cursor almost hits the end of the screen, then let go. Repeat left and right as needed until the cursor "sticks" in one direction. This works for me ~20% of the time in any one direction (100% after going left to right ~5 times)

This is pretty straightforward, the 20% of any against the 100% from left to right is way too weird.

I noticed that the LEFT_KEY takes over the RIGHT_KEY when I accidentally pressed them both at the same time. Just putting this here so I can remember later.

@rkitover while trying to check this, I (think I) discovered an issue with the pause from the frontend. Could you see e4cb678 and confirm If this is an issue indeed?

@nemec

This comment has been minimized.

Copy link

@nemec nemec commented May 26, 2019

I noticed that the LEFT_KEY takes over the RIGHT_KEY when I accidentally pressed them both at the same time. Just putting this here so I can remember later.

I noticed that, too. In Fire Emblem this means that a stuck LEFT_KEY forces the cursor to the left side of the screen - you can move up and down, but you are unable to move right until you hit LEFT_KEY again to unstick it. And if RIGHT_KEY is stuck, your cursor will "roll" toward the right side of the screen, but pressing LEFT_KEY will override the stuck key and move your cursor left. Releasing LEFT_KEY will then cause the cursor to roll back to the right, since RIGHT_KEY is still stuck.

I recorded a screencast of both examples. At 00:07, RIGHT_KEY is already stuck. You can see me hit LEFT_KEY a few times (and only left), then let the keyboard sit. The cursor moves right without any additional input from me. At 00:15 I end up getting LEFT_KEY stuck. You can see me push RIGHT_KEY a few times at 00:18 but my cursor stays on the left wall without moving.

@denisfa

This comment has been minimized.

Copy link
Collaborator

@denisfa denisfa commented May 26, 2019

What Desktop Environment are you using? We have a theory that the DE might be related to this bug.

Just to be more clear about this, could you report if the bug still happens if you uncheck Emulation > Pause when inactive?

@BurningTurtle

This comment has been minimized.

Copy link

@BurningTurtle BurningTurtle commented May 26, 2019

Yes, it still happens.

I'm using Ubuntu 18.04 with Pokemon Emerald.

@denisfa

This comment has been minimized.

Copy link
Collaborator

@denisfa denisfa commented May 27, 2019

@huupoke12 , @nemec, @BurningTurtle Would you mind testing a possible solution for this? It should be like this:

cd ~ && mkdir src && cd src
git clone -b fix-142 https://github.com/visualboyadvance-m/visualboyadvance-m.git
cd visualboyadvance-m
./installdeps

# ./installdeps will give you build instructions, which will be similar to:

mkdir build && cd build
cmake ..
make -j`nproc`
./visualboyadvance-m

This is the branch with the possible fix. I managed to set up a VM and finally be able to run into this issue consistently. Using this branch fixed the issue for me.

denisfa referenced this issue May 27, 2019
@nemec

This comment has been minimized.

Copy link

@nemec nemec commented May 27, 2019

That's perfect, @denisfa! I built it and moved the cursor back and forth for ~3 minutes and did not see the issue once. Thank you for tracking this down!

@huupoke12

This comment has been minimized.

Copy link

@huupoke12 huupoke12 commented May 28, 2019

I have tested and didn't run to any issue with the default config. It only happens when I hold a key, then click outside of the windows (still hold the key) and release it when "Pause when inactive" is unticked.

denisfa added a commit that referenced this issue May 28, 2019
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.

- Fix #142.
denisfa added a commit that referenced this issue May 28, 2019
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.

- Fix #142.
denisfa added a commit that referenced this issue May 28, 2019
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.

- Fix #142.
@denisfa denisfa mentioned this issue May 28, 2019
@denisfa

This comment has been minimized.

Copy link
Collaborator

@denisfa denisfa commented May 28, 2019

@nemec Good to know! I believe this should be ready to land soon! Thanks for the feedback, it really helped track this down.

I have tested and didn't run to any issue with the default config. It only happens when I hold a key, then click outside of the windows (still hold the key) and release it when "Pause when inactive" is unticked.

@huupoke12 I found out about this issue while trying to run into the original bug. It should also be fixed. If you don't mind, you can test the given branch solution for this one too.

@huupoke12

This comment has been minimized.

Copy link

@huupoke12 huupoke12 commented May 29, 2019

I've tested commit 42d3577, the bug has been fixed.

@denisfa denisfa self-assigned this May 29, 2019
@denisfa denisfa added this to To Do in release v2.1.7 via automation May 29, 2019
@denisfa denisfa added the fixed label May 29, 2019
@denisfa

This comment has been minimized.

Copy link
Collaborator

@denisfa denisfa commented May 29, 2019

@huupoke12 Thank you for the testing! I will consider it fixed. It will be available for our next release 2.1.4.

@denisfa denisfa closed this May 29, 2019
release v2.1.7 automation moved this from To Do to Done May 29, 2019
rkitover added a commit that referenced this issue May 29, 2019
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
You can’t perform that action at this time.