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 input is broken with SDL2 on X11/libinput #54

Closed
lachs0r opened this Issue Feb 15, 2017 · 6 comments

Comments

Projects
None yet
3 participants
@lachs0r
Copy link
Collaborator

lachs0r commented Feb 15, 2017

SDL2 always repeats keys on its own, and each keypress generates a series of SDL_KEYUP/SDL_KEYDOWN events. If key repeat is enabled (e.g. via xset), it gets all key events twice, half of them with key.repeat == 0, rendering the menus unusable and badly influencing gameplay.

I’m not alone with this problem; multiple SDL2 applications appear to suffer from this. I have not tested whether this happens on Wayland as well. Given that this issue has been around for years in SDL2, it seems we’ll have to support multiple input APIs, like many other games do, and only use SDL2 as fallback where no native API is implemented.
Looks like xkbcommon is the way to go on Linux, rather than the ancient Xlib2 extension.

@laochailan

This comment has been minimized.

Copy link
Collaborator

laochailan commented Feb 15, 2017

That seems a bit drastic. Can’t we just check key.repeat and ignore key.repeat == 1? Would that break the key repeating on windows?

@lachs0r

This comment has been minimized.

Copy link
Collaborator Author

lachs0r commented Feb 15, 2017

  1. That doesn’t work. SDL always repeats keystrokes. No matter what.
  2. Yes it would break it on other platforms.
@Akaricchi

This comment has been minimized.

Copy link
Collaborator

Akaricchi commented Feb 15, 2017

@lachs0r didn't you later say that you had some input issues across the whole system on IRC? Any updates on that? FWIW, I have no problems with X11 + libinput + keyrepeat enabled via xset here, so I have no idea how to even reproduce this problem.

After a quick look at SDL evdev and keyboard code, I'm inclined to think that it's not SDL repeating keys. SDL_SendKeyboardKey doesn't appear to be called more than once per evdev event. My guess is that it receives release events for the repeated keys from evdev for some reason -- that shouldn't happen, and would definitely mess up key repeat. But I can't be sure about that since, as I said, I don't know how to reproduce it myself.

Having to support multiple input backends would seriously suck, considering that SDL is basically there so that we don't have to...

@laochailan

This comment has been minimized.

Copy link
Collaborator

laochailan commented Feb 15, 2017

I think I can reproduce this when I hold my keys in the menu long enough for key repeat, I can’t tell if it’s faster than my key repeat should be or not. Single keys definitely don’t get repeatet. I use X11/libinput too. I don’t know if that was what @lachs0r meant.

@Akaricchi

This comment has been minimized.

Copy link
Collaborator

Akaricchi commented Feb 15, 2017

@laochailan try disabling key repeat in X via xset r off. You shouldn't have any key repeat in Taisei then. With @lachs0r's problem you would.

@lachs0r

This comment has been minimized.

Copy link
Collaborator Author

lachs0r commented Feb 15, 2017

@lachs0r lachs0r closed this Feb 15, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment