Fixed bug 4094 - No SDL_TEXTEDITING after pressing Alt key on Raspberry Pi Linux
authorSam Lantinga <slouken@libsdl.org>
Thu, 14 Jun 2018 00:51:45 -0700
changeset 120207f3c9bffada4
parent 12019 25d299fc8443
child 12021 3239c8ad2986
Fixed bug 4094 - No SDL_TEXTEDITING after pressing Alt key on Raspberry Pi Linux

This was reproducible by running an SDL app on the console from an ssh login. In this case the terminal wasn't owned by the user running the app, so we were using the default keymap, which didn't have state transitions defined for ctrl and alt, so once we entered that state keypresses would no longer transition out of that state, nor would they generate text.

As a workaround, we'll just reset to the default shift state if that happens, which means we'll get text for keys pressed while ctrl is held down, but I don't think that's a big problem.

Note that in this case we also can't mute the keyboard, so the keypresses go to the console, which probably isn't what you want...
src/core/linux/SDL_evdev_kbd.c
     1.1 --- a/src/core/linux/SDL_evdev_kbd.c	Wed Jun 13 14:24:30 2018 -0700
     1.2 +++ b/src/core/linux/SDL_evdev_kbd.c	Thu Jun 14 00:51:45 2018 -0700
     1.3 @@ -609,7 +609,10 @@
     1.4      shift_final = (kbd->shift_state | kbd->slockstate) ^ kbd->lockstate;
     1.5      key_map = kbd->key_maps[shift_final];
     1.6      if (!key_map) {
     1.7 +        /* Unsupported shift state (e.g. ctrl = 4, alt = 8), just reset to the default state */
     1.8 +        kbd->shift_state = 0;
     1.9          kbd->slockstate = 0;
    1.10 +        kbd->lockstate = 0;
    1.11          return;
    1.12      }
    1.13