mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-03-14 06:43:27 +00:00
input: Some more console-toggle-key tuning.
Partial revert of r1024, since the lastKeyDown stuff is actually needed for SDL2 when the keyboard layout has a printable character that isn't '`' or '~' on the default console-toggle-key (the one below 'Esc'). Instead of hardcoding it though, it is now determined by a new Key_ConsoleBindable function. This makes sure that we don't write an unwanted character into the console as a side effect of opening/closing it, but it still does allow the user to type '`' and '~' in chat messages. git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@1027 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
775a688c3c
commit
3674e9387c
3 changed files with 25 additions and 5 deletions
|
@ -496,7 +496,7 @@ void IN_SendKeyEvents (void)
|
|||
SDL_Event event;
|
||||
int sym;
|
||||
#if defined(USE_SDL2)
|
||||
unsigned char *ch;
|
||||
static int lastKeyDown = 0;
|
||||
#else
|
||||
int state, modstate;
|
||||
#endif
|
||||
|
@ -527,9 +527,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.
|
||||
for (ch = (unsigned char *)event.text.text; ch[0] != 0 && ch[0] < 128; ch++)
|
||||
if (!Key_ConsoleBindable(lastKeyDown))
|
||||
{
|
||||
Char_Event (ch[0]);
|
||||
unsigned char *ch;
|
||||
for (ch = (unsigned char *)event.text.text; ch[0] != 0 && ch[0] < 128; ch++)
|
||||
Char_Event (ch[0]);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
@ -553,6 +555,11 @@ void IN_SendKeyEvents (void)
|
|||
// layout, so keybindings are based on key position, not the label
|
||||
// on the key cap.
|
||||
sym = IN_SDL2_ScancodeToQuakeKey(event.key.keysym.scancode);
|
||||
|
||||
if (event.type == SDL_KEYDOWN)
|
||||
lastKeyDown = sym;
|
||||
else
|
||||
lastKeyDown = 0;
|
||||
|
||||
Key_Event (sym, event.key.state == SDL_PRESSED);
|
||||
break;
|
||||
|
@ -783,7 +790,7 @@ void IN_SendKeyEvents (void)
|
|||
break;
|
||||
}
|
||||
Key_Event (sym, state);
|
||||
if (event.type == SDL_KEYDOWN)
|
||||
if (event.type == SDL_KEYDOWN && !Key_ConsoleBindable(sym))
|
||||
Char_Event (sym);
|
||||
break;
|
||||
#endif
|
||||
|
|
|
@ -444,7 +444,7 @@ void Char_Console (int key)
|
|||
return; // non printable
|
||||
|
||||
if (!consolekeys[key])
|
||||
return; // bindable key
|
||||
return; // bindable
|
||||
|
||||
if (keydown[K_CTRL])
|
||||
return; // control character
|
||||
|
@ -1117,3 +1117,15 @@ void Key_UpdateForDest (void)
|
|||
IN_UpdateForKeydest ();
|
||||
}
|
||||
|
||||
/*
|
||||
===================
|
||||
Key_ConsoleBindable
|
||||
===================
|
||||
*/
|
||||
qboolean Key_ConsoleBindable(int key)
|
||||
{
|
||||
if ((key_dest == key_console && !consolekeys[key]) ||
|
||||
(key_dest == key_game && con_forcedup && !consolekeys[key]))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -163,6 +163,7 @@ extern qboolean chat_team;
|
|||
void Key_Init (void);
|
||||
void Key_ClearStates (void);
|
||||
void Key_UpdateForDest (void);
|
||||
qboolean Key_ConsoleBindable (int key);
|
||||
|
||||
void Key_Event (int key, qboolean down);
|
||||
void Char_Event (int key);
|
||||
|
|
Loading…
Reference in a new issue