mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-09 09:10:54 +00:00
input: Remove unneeded key_repeats array, some input grab tuning.
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@1083 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
f605137b02
commit
4b011d6285
1 changed files with 17 additions and 21 deletions
38
Quake/keys.c
38
Quake/keys.c
|
@ -43,7 +43,6 @@ keydest_t key_dest;
|
||||||
#define MAX_KEYS 256
|
#define MAX_KEYS 256
|
||||||
|
|
||||||
char *keybindings[MAX_KEYS];
|
char *keybindings[MAX_KEYS];
|
||||||
int key_repeats[MAX_KEYS]; // if > 1, it is autorepeating
|
|
||||||
qboolean consolekeys[MAX_KEYS]; // if true, can't be rebound while in console
|
qboolean consolekeys[MAX_KEYS]; // if true, can't be rebound while in console
|
||||||
qboolean menubound[MAX_KEYS]; // if true, can't be rebound while in menu
|
qboolean menubound[MAX_KEYS]; // if true, can't be rebound while in menu
|
||||||
qboolean ignoretext[MAX_KEYS]; // if true, should never cause text input
|
qboolean ignoretext[MAX_KEYS]; // if true, should never cause text input
|
||||||
|
@ -912,6 +911,8 @@ Key_BeginInputGrab
|
||||||
*/
|
*/
|
||||||
void Key_BeginInputGrab (void)
|
void Key_BeginInputGrab (void)
|
||||||
{
|
{
|
||||||
|
Key_ClearStates ();
|
||||||
|
|
||||||
key_inputgrab.active = true;
|
key_inputgrab.active = true;
|
||||||
key_inputgrab.lastkey = 0;
|
key_inputgrab.lastkey = 0;
|
||||||
key_inputgrab.lastchar = 0;
|
key_inputgrab.lastchar = 0;
|
||||||
|
@ -926,6 +927,8 @@ Key_EndInputGrab
|
||||||
*/
|
*/
|
||||||
void Key_EndInputGrab (void)
|
void Key_EndInputGrab (void)
|
||||||
{
|
{
|
||||||
|
Key_ClearStates ();
|
||||||
|
|
||||||
key_inputgrab.active = false;
|
key_inputgrab.active = false;
|
||||||
|
|
||||||
IN_UpdateInputMode ();
|
IN_UpdateInputMode ();
|
||||||
|
@ -960,15 +963,21 @@ void Key_Event (int key, qboolean down)
|
||||||
if (key < 0 || key >= MAX_KEYS)
|
if (key < 0 || key >= MAX_KEYS)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
keydown[key] = down;
|
// handle autorepeats and stray key up events
|
||||||
|
if (down)
|
||||||
if (!down)
|
|
||||||
{
|
{
|
||||||
if (key_repeats[key] == 0)
|
if (keydown[key])
|
||||||
return;
|
{
|
||||||
|
if (key_dest == key_game && !con_forcedup)
|
||||||
key_repeats[key] = 0;
|
return; // ignore autorepeats in game mode
|
||||||
|
}
|
||||||
|
else if (key >= 200 && !keybindings[key])
|
||||||
|
Con_Printf ("%s is unbound, hit F4 to set.\n", Key_KeynumToString(key));
|
||||||
}
|
}
|
||||||
|
else if (!keydown[key])
|
||||||
|
return; // ignore stray key up events
|
||||||
|
|
||||||
|
keydown[key] = down;
|
||||||
|
|
||||||
if (key_inputgrab.active)
|
if (key_inputgrab.active)
|
||||||
{
|
{
|
||||||
|
@ -976,19 +985,6 @@ void Key_Event (int key, qboolean down)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// update auto-repeat status
|
|
||||||
if (down)
|
|
||||||
{
|
|
||||||
key_repeats[key]++;
|
|
||||||
if (key_repeats[key] > 1)
|
|
||||||
{
|
|
||||||
if (key_dest == key_game && !con_forcedup)
|
|
||||||
return; // ignore autorepeats in game mode
|
|
||||||
}
|
|
||||||
else if (key >= 200 && !keybindings[key])
|
|
||||||
Con_Printf ("%s is unbound, hit F4 to set.\n", Key_KeynumToString(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
// handle escape specialy, so the user can never unbind it
|
// handle escape specialy, so the user can never unbind it
|
||||||
if (key == K_ESCAPE)
|
if (key == K_ESCAPE)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue