From 0703030be3551b1914bec99ce6140d84db39c0c0 Mon Sep 17 00:00:00 2001
From: "alexey.lysiuk" <alexey.lysiuk@gmail.com>
Date: Fri, 29 Jun 2018 12:26:30 +0300
Subject: [PATCH] - simplified key repeat detection in SDL backend

---
 src/posix/sdl/i_input.cpp | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/src/posix/sdl/i_input.cpp b/src/posix/sdl/i_input.cpp
index 561870a4e..fe777d77a 100644
--- a/src/posix/sdl/i_input.cpp
+++ b/src/posix/sdl/i_input.cpp
@@ -64,8 +64,6 @@ EXTERN_CVAR (Bool, fullscreen)
 extern int WaitingForKey, chatmodeon;
 extern constate_e ConsoleState;
 
-static bool DownState[SDL_NUM_SCANCODES];
-
 static const SDL_Keycode DIKToKeySym[256] =
 {
 	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)
 	{
 		GUICapture = wantCapt;
-		if (wantCapt)
-		{
-			memset (DownState, 0, sizeof(DownState));
-		}
 		ResetButtonStates();
 	}
 }
@@ -441,17 +435,9 @@ void MessagePump (const SDL_Event &sev)
 				((kmod & KMOD_CTRL) ? GKM_CTRL : 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;
-				}
-				DownState[sev.key.keysym.scancode] = 1;
-			}
-			else
-			{
-				DownState[sev.key.keysym.scancode] = 0;
+				event.subtype = EV_GUI_KeyRepeat;
 			}
 
 			switch (sev.key.keysym.sym)