Prevent SDL_StartTextInput during single-letter y/n prompts

y/n prompts also support controller inputs, so we don't want to trigger an
onscreen keyboard for them.
This commit is contained in:
Chris Cowan 2023-03-13 02:48:35 -07:00
parent fa20f03de6
commit 8d03392559
3 changed files with 27 additions and 2 deletions

View File

@ -1059,7 +1059,8 @@ void IN_SendKeyEvents (void)
key = IN_SDL_KeysymToQuakeKey(event.key.keysym.sym);
#endif
Key_Event (key, down);
// also pass along the underlying keycode using the proper current layout for Y/N prompts.
Key_EventWithKeycode (key, down, event.key.keysym.sym);
#if !defined(USE_SDL2)
if (down && (event.key.keysym.unicode & ~0x7F) == 0)

View File

@ -948,6 +948,21 @@ Should NOT be called during an interrupt!
===================
*/
void Key_Event (int key, qboolean down)
{
Key_EventWithKeycode (key, down, 0);
}
/*
===================
Key_EventWithKeycode
Called by the system between frames for both key up and key down events
Should NOT be called during an interrupt!
keycode parameter should have the key's actual keycode using the current keyboard layout,
not necessarily the US-keyboard-based scancode. Pass 0 if not applicable.
===================
*/
void Key_EventWithKeycode (int key, qboolean down, int keycode)
{
char *kb;
char cmd[1024];
@ -981,7 +996,11 @@ void Key_Event (int key, qboolean down)
if (key_inputgrab.active)
{
if (down)
{
key_inputgrab.lastkey = key;
if (keycode > 0)
key_inputgrab.lastchar = keycode;
}
return;
}
@ -1135,7 +1154,11 @@ Key_TextEntry
qboolean Key_TextEntry (void)
{
if (key_inputgrab.active)
return true;
{
// This path is used for simple single-letter inputs (y/n prompts) that also
// accept controller input, so we don't want an onscreen keyboard for this case.
return false;
}
switch (key_dest)
{

View File

@ -182,6 +182,7 @@ void Key_EndInputGrab (void);
void Key_GetGrabbedInput (int *lastkey, int *lastchar);
void Key_Event (int key, qboolean down);
void Key_EventWithKeycode (int key, qboolean down, int keycode);
void Char_Event (int key);
qboolean Key_TextEntry (void);