diff --git a/quakespasm/Quake/console.c b/quakespasm/Quake/console.c index d052f562..05f8e21c 100644 --- a/quakespasm/Quake/console.c +++ b/quakespasm/Quake/console.c @@ -1243,7 +1243,7 @@ void Con_NotifyBox (const char *text) Sys_Sleep (16); t2 = Sys_DoubleTime (); realtime += t2-t1; // make the cursor blink - } while (lastkey == 0 && lastchar == 0); + } while (lastkey == -1 && lastchar == -1); Key_EndInputGrab (); Con_Printf ("\n"); diff --git a/quakespasm/Quake/in_sdl.c b/quakespasm/Quake/in_sdl.c index 89986baa..7247cb29 100644 --- a/quakespasm/Quake/in_sdl.c +++ b/quakespasm/Quake/in_sdl.c @@ -625,11 +625,11 @@ void IN_SendKeyEvents (void) // SDL2: We use SDL_TEXTINPUT for typing in the console / chat. // SDL2 uses the local keyboard layout and handles modifiers // (shift for uppercase, etc.) for us. - if (!lastKeyDown || !Key_IgnoreTextInput(lastKeyDown)) + if (!Key_IgnoreTextInput(lastKeyDown)) { int i; for (i = 0; event.text.text[i]; i++) - if ((event.text.text[i] & 0x80) == 0) + if ((event.text.text[i] & ~0x7F) == 0) Char_Event (event.text.text[i]); } break; @@ -660,11 +660,10 @@ void IN_SendKeyEvents (void) key = IN_SDL_KeysymToQuakeKey(event.key.keysym.sym); #endif - // Filter out key down events for numpad keys when we expect them + // Filter key down events for numpad keys when we expect them // to also send a char event. Doing this only for key down events - // can generate some stray numpad key up events, but that's much - // less problematic than the missing key up events that could be - // caused if we'd also filter those out. + // will generate some stray key up events, but that's much less + // problematic than missing key up events. if (down && textmode && numlock && IN_IsNumpadKey(key)) key = 0; @@ -672,12 +671,10 @@ void IN_SendKeyEvents (void) lastKeyDown = down ? key : 0; #endif - if (key) - Key_Event (key, down); + Key_Event (key, down); #if !defined(USE_SDL2) - if (down && (!key || !Key_IgnoreTextInput(key)) && - (event.key.keysym.unicode & ~0x7F) == 0) + if (down && !Key_IgnoreTextInput(key) && (event.key.keysym.unicode & ~0x7F) == 0) Char_Event (event.key.keysym.unicode); #endif break; diff --git a/quakespasm/Quake/keys.c b/quakespasm/Quake/keys.c index c53b928e..70785299 100644 --- a/quakespasm/Quake/keys.c +++ b/quakespasm/Quake/keys.c @@ -904,7 +904,7 @@ static struct { qboolean active; int lastkey; int lastchar; -} key_inputgrab; +} key_inputgrab = { false, -1, -1 }; /* =================== @@ -916,8 +916,8 @@ void Key_BeginInputGrab (void) Key_ClearStates (); key_inputgrab.active = true; - key_inputgrab.lastkey = 0; - key_inputgrab.lastchar = 0; + key_inputgrab.lastkey = -1; + key_inputgrab.lastchar = -1; IN_UpdateInputMode (); } @@ -983,7 +983,8 @@ void Key_Event (int key, qboolean down) if (key_inputgrab.active) { - key_inputgrab.lastkey = key; + if (down) + key_inputgrab.lastkey = key; return; }