SDL/src/video
Sam Lantinga 32d6dcdb47 Fixed bug 2096 - Mapping from scancode to keycode doesn't work for remapped modifier keys
Jacob Lee

If a user has a non-standard keyboard mapping -- say, their caps lock key has been mapped to Ctrl -- then SDL_GetModState() is no longer accurate: it only considers the unmapped keys. This is a regression from SDL 1.2.

I think there are two parts to this bug: first, GetModState should use keycodes, rather than scancodes, which is easy enough.

Unfortunately, on my system, SDL considers Caps Lock, even when mapped as Control, to be both SDL_SCANCODE_CAPSLOCK and SDLK_CAPSLOCK. The output from checkkeys for it is:

INFO: Key pressed :  scancode 57 = CapsLock, keycode 0x40000039 = CapsLock  modifiers: CAPS

Whereas the output for xev is:

KeyPress event, serial 41, synthetic NO, window 0x4a00001,
    root 0x9a, subw 0x0, time 40218333, (144,177), root:(1458,222),
    state 0x10, keycode 66 (keysym 0xffe3, Control_L), same_screen YES,
    XKeysymToKeycode returns keycode: 37
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

I think the problem is that X11_UpdateKeymap in SDL_x11keyboard.c only builds a mapping for keycodes associated with a Unicode character (anything where X11_KeyCodeToUcs returns a value). In the case of caps lock, SDL scancode 57 becomes x11 keycode 66, which becomes x11 keysym 65507(Control_L), which does not have a unicode value.

To fix this, I suspect that SDL needs a mapping of the rest of the x11 keysyms to their corresponding SDL key codes.
2015-05-28 12:48:20 -07:00
..
android Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
cocoa Mac: Send a window resize event when the window's backing scale factor changes. 2015-05-26 21:51:47 -03:00
directfb Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
dummy Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
emscripten Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
haiku Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
mir Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
nacl Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
pandora Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
psp Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
raspberry Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
uikit Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
vivante Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
wayland Patched to compile on C89 compilers. 2015-05-27 19:00:56 -04:00
windows Fixed Windows build 2015-05-28 08:51:59 -07:00
winrt Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
x11 Fixed bug 2096 - Mapping from scancode to keycode doesn't work for remapped modifier keys 2015-05-28 12:48:20 -07:00
SDL_blit.c Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
SDL_blit.h Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
SDL_blit_0.c Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
SDL_blit_1.c Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
SDL_blit_A.c Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
SDL_blit_auto.c Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
SDL_blit_auto.h Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
SDL_blit_copy.c Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
SDL_blit_copy.h Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
SDL_blit_N.c Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
SDL_blit_slow.c Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
SDL_blit_slow.h Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
SDL_bmp.c Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
SDL_clipboard.c Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
SDL_egl.c EGL: OpenGL ES 3.0 contexts can now be created without the EGL_KHR_create_context extension. 2015-05-26 19:34:56 -03:00
SDL_egl_c.h Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
SDL_fillrect.c Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
SDL_pixels.c Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
SDL_pixels_c.h Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
SDL_rect.c Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
SDL_rect_c.h Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
SDL_RLEaccel.c Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
SDL_RLEaccel_c.h Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
SDL_shape.c Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
SDL_shape_internals.h Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
SDL_stretch.c Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
SDL_surface.c Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
SDL_sysvideo.h Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
SDL_video.c Reset the keyboard state when launching a message box (thanks, Sean!). 2015-05-26 20:49:27 -04:00
sdlgenblit.pl Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00