- simplified key repeat detection in SDL backend

This commit is contained in:
alexey.lysiuk 2018-06-29 12:26:30 +03:00
parent 0342bf532d
commit 0703030be3

View file

@ -64,8 +64,6 @@ EXTERN_CVAR (Bool, fullscreen)
extern int WaitingForKey, chatmodeon; extern int WaitingForKey, chatmodeon;
extern constate_e ConsoleState; extern constate_e ConsoleState;
static bool DownState[SDL_NUM_SCANCODES];
static const SDL_Keycode DIKToKeySym[256] = static const SDL_Keycode DIKToKeySym[256] =
{ {
0, SDLK_ESCAPE, SDLK_1, SDLK_2, SDLK_3, SDLK_4, SDLK_5, SDLK_6, 0, SDLK_ESCAPE, SDLK_1, SDLK_2, SDLK_3, SDLK_4, SDLK_5, SDLK_6,
@ -190,10 +188,6 @@ static void I_CheckGUICapture ()
if (wantCapt != GUICapture) if (wantCapt != GUICapture)
{ {
GUICapture = wantCapt; GUICapture = wantCapt;
if (wantCapt)
{
memset (DownState, 0, sizeof(DownState));
}
ResetButtonStates(); ResetButtonStates();
} }
} }
@ -441,17 +435,9 @@ void MessagePump (const SDL_Event &sev)
((kmod & KMOD_CTRL) ? GKM_CTRL : 0) | ((kmod & KMOD_CTRL) ? GKM_CTRL : 0) |
((kmod & KMOD_ALT) ? GKM_ALT : 0); ((kmod & KMOD_ALT) ? GKM_ALT : 0);
if (event.subtype == EV_GUI_KeyDown) if (event.subtype == EV_GUI_KeyDown && sev.key.repeat)
{ {
if (DownState[sev.key.keysym.scancode]) event.subtype = EV_GUI_KeyRepeat;
{
event.subtype = EV_GUI_KeyRepeat;
}
DownState[sev.key.keysym.scancode] = 1;
}
else
{
DownState[sev.key.keysym.scancode] = 0;
} }
switch (sev.key.keysym.sym) switch (sev.key.keysym.sym)