From a44f3785d8bb137e6032e0b8323f1c58407d43b6 Mon Sep 17 00:00:00 2001 From: svdijk Date: Tue, 7 Oct 2014 06:15:16 +0000 Subject: [PATCH] in_sdl.c: Workaround for broken SDL2 numlock state. git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@1091 af15c1b1-3010-417e-b628-4374ebc0bcbd --- quakespasm/Quake/in_sdl.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/quakespasm/Quake/in_sdl.c b/quakespasm/Quake/in_sdl.c index a80ac8cf..8db68547 100644 --- a/quakespasm/Quake/in_sdl.c +++ b/quakespasm/Quake/in_sdl.c @@ -569,17 +569,16 @@ static inline int IN_SDL2_ScancodeToQuakeKey(SDL_Scancode scancode) } #endif -static inline qboolean IN_NumlockDown (SDL_Event event) +static inline qboolean IN_ExpectingCharEvent (SDL_Event event) { #if defined(USE_SDL2) - return ((event.key.keysym.mod & KMOD_NUM) != 0); + return (SDL_PeepEvents(&event, 1, SDL_PEEKEVENT, SDL_TEXTINPUT, SDL_TEXTINPUT) > 0); #else - // Workaround for broken numlock state with SDL 1.2. return (event.key.keysym.unicode != 0); #endif } -static inline qboolean IN_NumpadKey (int key) +static inline qboolean IN_IsNumpadKey (int key) { switch (key) { @@ -673,7 +672,7 @@ void IN_SendKeyEvents (void) // to also send a char event. Doing this only for key down events // will generate some stray key up events, but that's much less // problematic than missing key up events. - if (down && textmode && IN_NumlockDown(event) && IN_NumpadKey(key)) + if (down && textmode && IN_IsNumpadKey(key) && IN_ExpectingCharEvent(event)) key = 0; #if defined(USE_SDL2)