mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-13 07:21:31 +00:00
input: Some more tuning.
* in_sdl.c: Remove the over-zealous "no events for unknown keys" checks introduced in r1085. Events for unknown keys can be useful for "press any key" situations. * keys.c: In input grab mode, update the "lastkey" member only for key down events. * keys.c/console.c: Adapt input grab mode to properly support catching "any key" presses. git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@1089 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
4eee84a9fc
commit
cec23e9fa5
3 changed files with 13 additions and 15 deletions
|
@ -1243,7 +1243,7 @@ void Con_NotifyBox (const char *text)
|
||||||
Sys_Sleep (16);
|
Sys_Sleep (16);
|
||||||
t2 = Sys_DoubleTime ();
|
t2 = Sys_DoubleTime ();
|
||||||
realtime += t2-t1; // make the cursor blink
|
realtime += t2-t1; // make the cursor blink
|
||||||
} while (lastkey == 0 && lastchar == 0);
|
} while (lastkey == -1 && lastchar == -1);
|
||||||
Key_EndInputGrab ();
|
Key_EndInputGrab ();
|
||||||
|
|
||||||
Con_Printf ("\n");
|
Con_Printf ("\n");
|
||||||
|
|
|
@ -625,11 +625,11 @@ void IN_SendKeyEvents (void)
|
||||||
// SDL2: We use SDL_TEXTINPUT for typing in the console / chat.
|
// SDL2: We use SDL_TEXTINPUT for typing in the console / chat.
|
||||||
// SDL2 uses the local keyboard layout and handles modifiers
|
// SDL2 uses the local keyboard layout and handles modifiers
|
||||||
// (shift for uppercase, etc.) for us.
|
// (shift for uppercase, etc.) for us.
|
||||||
if (!lastKeyDown || !Key_IgnoreTextInput(lastKeyDown))
|
if (!Key_IgnoreTextInput(lastKeyDown))
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; event.text.text[i]; 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]);
|
Char_Event (event.text.text[i]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -660,11 +660,10 @@ void IN_SendKeyEvents (void)
|
||||||
key = IN_SDL_KeysymToQuakeKey(event.key.keysym.sym);
|
key = IN_SDL_KeysymToQuakeKey(event.key.keysym.sym);
|
||||||
#endif
|
#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
|
// 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
|
// will generate some stray key up events, but that's much less
|
||||||
// less problematic than the missing key up events that could be
|
// problematic than missing key up events.
|
||||||
// caused if we'd also filter those out.
|
|
||||||
if (down && textmode && numlock && IN_IsNumpadKey(key))
|
if (down && textmode && numlock && IN_IsNumpadKey(key))
|
||||||
key = 0;
|
key = 0;
|
||||||
|
|
||||||
|
@ -672,12 +671,10 @@ void IN_SendKeyEvents (void)
|
||||||
lastKeyDown = down ? key : 0;
|
lastKeyDown = down ? key : 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (key)
|
|
||||||
Key_Event (key, down);
|
Key_Event (key, down);
|
||||||
|
|
||||||
#if !defined(USE_SDL2)
|
#if !defined(USE_SDL2)
|
||||||
if (down && (!key || !Key_IgnoreTextInput(key)) &&
|
if (down && !Key_IgnoreTextInput(key) && (event.key.keysym.unicode & ~0x7F) == 0)
|
||||||
(event.key.keysym.unicode & ~0x7F) == 0)
|
|
||||||
Char_Event (event.key.keysym.unicode);
|
Char_Event (event.key.keysym.unicode);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -904,7 +904,7 @@ static struct {
|
||||||
qboolean active;
|
qboolean active;
|
||||||
int lastkey;
|
int lastkey;
|
||||||
int lastchar;
|
int lastchar;
|
||||||
} key_inputgrab;
|
} key_inputgrab = { false, -1, -1 };
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===================
|
===================
|
||||||
|
@ -916,8 +916,8 @@ void Key_BeginInputGrab (void)
|
||||||
Key_ClearStates ();
|
Key_ClearStates ();
|
||||||
|
|
||||||
key_inputgrab.active = true;
|
key_inputgrab.active = true;
|
||||||
key_inputgrab.lastkey = 0;
|
key_inputgrab.lastkey = -1;
|
||||||
key_inputgrab.lastchar = 0;
|
key_inputgrab.lastchar = -1;
|
||||||
|
|
||||||
IN_UpdateInputMode ();
|
IN_UpdateInputMode ();
|
||||||
}
|
}
|
||||||
|
@ -983,6 +983,7 @@ void Key_Event (int key, qboolean down)
|
||||||
|
|
||||||
if (key_inputgrab.active)
|
if (key_inputgrab.active)
|
||||||
{
|
{
|
||||||
|
if (down)
|
||||||
key_inputgrab.lastkey = key;
|
key_inputgrab.lastkey = key;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue