mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
Mark all keys as "up" when the refresher is restarted
This is a less intrusive variant of the old Key_ClearState() function. When the refresher is restarted or the menu is left, this function is called to mark all keys as "up". That works around some corner cases where a key is still marked "down" and thus the first stroke is detected as a repetition.
This commit is contained in:
parent
08f78ec3b5
commit
9bda84299c
4 changed files with 20 additions and 0 deletions
|
@ -39,6 +39,7 @@
|
|||
#include <errno.h>
|
||||
|
||||
#include "../../client/header/client.h"
|
||||
#include "../../client/header/keyboard.h"
|
||||
|
||||
typedef struct vidmode_s
|
||||
{
|
||||
|
@ -173,6 +174,9 @@ VID_LoadRefresh(void)
|
|||
return false;
|
||||
}
|
||||
|
||||
/* Ensure that all key states are cleared */
|
||||
Key_MarkAllUp();
|
||||
|
||||
Com_Printf("------------------------------------\n\n");
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1088,3 +1088,16 @@ Key_Event(int key, qboolean down, qboolean special)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Marks all keys as "up"
|
||||
*/
|
||||
void
|
||||
Key_MarkAllUp(void)
|
||||
{
|
||||
int key;
|
||||
|
||||
for (key = 0; key < K_LAST; key++)
|
||||
{
|
||||
key_repeats[key] = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -292,6 +292,7 @@ void Key_Event(int key, qboolean down, qboolean special);
|
|||
void Key_Init(void);
|
||||
void Key_WriteBindings(FILE *f);
|
||||
void Key_SetBinding(int keynum, char *binding);
|
||||
void Key_MarkAllUp(void);
|
||||
int Key_GetKey(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include <ctype.h>
|
||||
#include "../header/client.h"
|
||||
#include "../header/keyboard.h"
|
||||
#include "header/qmenu.h"
|
||||
|
||||
static int m_main_cursor;
|
||||
|
@ -95,6 +96,7 @@ M_ForceMenuOff(void)
|
|||
m_keyfunc = NULL;
|
||||
cls.key_dest = key_game;
|
||||
m_menudepth = 0;
|
||||
Key_MarkAllUp();
|
||||
Cvar_Set("paused", "0");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue