mirror of
https://github.com/Ryujinx/SDL.git
synced 2024-12-29 11:45:41 +00:00
195b8bd8ee
Adam M. The keysym.mod field does not reflect the state of the modified keys when processing key down events for the modifier keys themselves. The documentation says that it returns the current key modifiers, but they are not current for key down events involving modifier keys. I interpret "current" to mean "equal to SDL_GetModState() at the instant the event is processed/enqueued". For example, if you depress the Shift key you get a key down event with .mod == 0. However, .mod should not be 0 because a shift key is down. If you then release the Shift key, you get a key up event with .mod == 0. Neither event reports the modifier key. If you press Shift and then A, .mod is incorrect (== 0) when Shift is pressed, but is correct later when A is pressed (== KMOD_LSHIFT). You might say this behavior is deliberate, i.e. keysym.mod is the value /before/ the event, not the current value as documented, but that explanation is incorrect because only key down events behave that way. Key up events correctly give the current value, not the value before the event. Not only is it inconsistent with itself, I think it makes keyboard processing harder. The problem is near line 740 in SDL_keyboard.c: if (SDL_KEYDOWN == type) { modstate = keyboard->modstate; // SHOULD THIS BE MOVED DOWN? switch (keycode) { case SDLK_NUMLOCKCLEAR: keyboard->modstate ^= KMOD_NUM; break; case SDLK_CAPSLOCK: keyboard->modstate ^= KMOD_CAPS; break; default: keyboard->modstate |= modifier; break; } } else { keyboard->modstate &= ~modifier; modstate = keyboard->modstate; } In the key down path, modstate (and thus keysym.mod) ends up being the modifier state /before/ the event, but in the key up path modstate ends up being the modifier state /after/ the event. Personally I think the "modstate = keyboard->modstate" line should just be moved after the entire if/else statement, so that keysym.mod always reflects the current state. |
||
---|---|---|
.. | ||
blank_cursor.h | ||
default_cursor.h | ||
scancodes_darwin.h | ||
scancodes_linux.h | ||
scancodes_windows.h | ||
scancodes_xfree86.h | ||
SDL_clipboardevents.c | ||
SDL_clipboardevents_c.h | ||
SDL_dropevents.c | ||
SDL_dropevents_c.h | ||
SDL_events.c | ||
SDL_events_c.h | ||
SDL_gesture.c | ||
SDL_gesture_c.h | ||
SDL_keyboard.c | ||
SDL_keyboard_c.h | ||
SDL_mouse.c | ||
SDL_mouse_c.h | ||
SDL_quit.c | ||
SDL_sysevents.h | ||
SDL_touch.c | ||
SDL_touch_c.h | ||
SDL_windowevents.c | ||
SDL_windowevents_c.h |