mirror of
https://github.com/Ryujinx/SDL.git
synced 2026-01-17 23:09:16 +00:00
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.
|
||
|---|---|---|
| .. | ||
| android | ||
| cocoa | ||
| directfb | ||
| dummy | ||
| emscripten | ||
| haiku | ||
| mir | ||
| nacl | ||
| pandora | ||
| psp | ||
| raspberry | ||
| uikit | ||
| vivante | ||
| wayland | ||
| windows | ||
| winrt | ||
| x11 | ||
| SDL_blit.c | ||
| SDL_blit.h | ||
| SDL_blit_0.c | ||
| SDL_blit_1.c | ||
| SDL_blit_A.c | ||
| SDL_blit_auto.c | ||
| SDL_blit_auto.h | ||
| SDL_blit_copy.c | ||
| SDL_blit_copy.h | ||
| SDL_blit_N.c | ||
| SDL_blit_slow.c | ||
| SDL_blit_slow.h | ||
| SDL_bmp.c | ||
| SDL_clipboard.c | ||
| SDL_egl.c | ||
| SDL_egl_c.h | ||
| SDL_fillrect.c | ||
| SDL_pixels.c | ||
| SDL_pixels_c.h | ||
| SDL_rect.c | ||
| SDL_rect_c.h | ||
| SDL_RLEaccel.c | ||
| SDL_RLEaccel_c.h | ||
| SDL_shape.c | ||
| SDL_shape_internals.h | ||
| SDL_stretch.c | ||
| SDL_surface.c | ||
| SDL_sysvideo.h | ||
| SDL_video.c | ||
| sdlgenblit.pl | ||