mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2024-11-10 07:21:58 +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://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@1027 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
a5e4a93cf0
commit
bd58d1c1b8
3 changed files with 25 additions and 5 deletions
|
@ -496,7 +496,7 @@ void IN_SendKeyEvents (void)
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
int sym;
|
int sym;
|
||||||
#if defined(USE_SDL2)
|
#if defined(USE_SDL2)
|
||||||
unsigned char *ch;
|
static int lastKeyDown = 0;
|
||||||
#else
|
#else
|
||||||
int state, modstate;
|
int state, modstate;
|
||||||
#endif
|
#endif
|
||||||
|
@ -527,8 +527,10 @@ 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.
|
||||||
for (ch = (unsigned char *)event.text.text; ch[0] != 0 && ch[0] < 128; ch++)
|
if (!Key_ConsoleBindable(lastKeyDown))
|
||||||
{
|
{
|
||||||
|
unsigned char *ch;
|
||||||
|
for (ch = (unsigned char *)event.text.text; ch[0] != 0 && ch[0] < 128; ch++)
|
||||||
Char_Event (ch[0]);
|
Char_Event (ch[0]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -554,6 +556,11 @@ void IN_SendKeyEvents (void)
|
||||||
// on the key cap.
|
// on the key cap.
|
||||||
sym = IN_SDL2_ScancodeToQuakeKey(event.key.keysym.scancode);
|
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);
|
Key_Event (sym, event.key.state == SDL_PRESSED);
|
||||||
break;
|
break;
|
||||||
#else
|
#else
|
||||||
|
@ -783,7 +790,7 @@ void IN_SendKeyEvents (void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Key_Event (sym, state);
|
Key_Event (sym, state);
|
||||||
if (event.type == SDL_KEYDOWN)
|
if (event.type == SDL_KEYDOWN && !Key_ConsoleBindable(sym))
|
||||||
Char_Event (sym);
|
Char_Event (sym);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
14
Quake/keys.c
14
Quake/keys.c
|
@ -444,7 +444,7 @@ void Char_Console (int key)
|
||||||
return; // non printable
|
return; // non printable
|
||||||
|
|
||||||
if (!consolekeys[key])
|
if (!consolekeys[key])
|
||||||
return; // bindable key
|
return; // bindable
|
||||||
|
|
||||||
if (keydown[K_CTRL])
|
if (keydown[K_CTRL])
|
||||||
return; // control character
|
return; // control character
|
||||||
|
@ -1117,3 +1117,15 @@ void Key_UpdateForDest (void)
|
||||||
IN_UpdateForKeydest ();
|
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_Init (void);
|
||||||
void Key_ClearStates (void);
|
void Key_ClearStates (void);
|
||||||
void Key_UpdateForDest (void);
|
void Key_UpdateForDest (void);
|
||||||
|
qboolean Key_ConsoleBindable (int key);
|
||||||
|
|
||||||
void Key_Event (int key, qboolean down);
|
void Key_Event (int key, qboolean down);
|
||||||
void Char_Event (int key);
|
void Char_Event (int key);
|
||||||
|
|
Loading…
Reference in a new issue