Description
For virtual keyboards that don't send key press events for modifiers (which seems to always be the case for Linux/Wayland touch devices, at least it is with Phosh+squeekboard on the PinePhone), SDL2 should insert them if it detects them being missing. Example: if SDL2 prepares to send an SDLK_a
key down with CTRL modifier enabled but didn't previously send an SDLK_LCTRL
or SDLK_RCTRL
event, it should insert a fake one right before that SDLK_a
event. Edit: as for release, that would probably best done right after each keypress again, since multi letter key shortcuts can't usually be entered on these touch keyboards anyway.
This seems to be impossible to solve correctly at the app level due to the lacking information about which keyboard the key presses come from, I'm pretty sure with multiple keyboards this would then lead to an incorrect state in corner cases. Also, solving it at the app level kind of goes against what I'm hoping this would achieve:
I'm just hoping naive, simple SDL2 applications that have simple UI, happen to work on a phone screen, and may naively use shortcuts based on sdl key down/up tracking instead of checking the modifier flag still "just work". I ran into an application of my own running into this very same bug, so I think it's an easy detail to miss. Devs just don't really test for some types of keys on only some platforms not emitting up/down events.
Edit: I'm aware this doesn't fix anything for cases where CTRL needs to be pressed on its own, like for crouching controls or alike. But such games aren't usually playable with a touch keyboard in practice. However, something like manager games or media player apps might have their keyboard shortcuts saved by this