in_sdl.c: Workaround for broken SDL2 numlock state.

git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@1091 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
Sander van Dijk 2014-10-07 06:15:16 +00:00
parent eaa33b20b6
commit 5e73eb18a4

View file

@ -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)