From 6675de319befedc3a7100c7d86b3f712579cf5fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Sun, 16 Jan 2022 11:52:04 +0100 Subject: [PATCH] do not copy keyboard over mouse state, refactoring --- src/engine/client/input.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/engine/client/input.cpp b/src/engine/client/input.cpp index 2749d556e..6b5e07999 100644 --- a/src/engine/client/input.cpp +++ b/src/engine/client/input.cpp @@ -223,15 +223,14 @@ int CInput::Update() // keep the counter between 1..0xFFFF, 0 means not pressed m_InputCounter = (m_InputCounter % 0xFFFF) + 1; - { - int i; - const Uint8 *pState = SDL_GetKeyboardState(&i); - if(i >= KEY_LAST) - i = KEY_LAST - 1; - mem_copy(m_aInputState, pState, i); - if(m_EditingTextLen == 0) - m_EditingTextLen = -1; - } + int NumKeyStates; + const Uint8 *pState = SDL_GetKeyboardState(&NumKeyStates); + if(NumKeyStates >= KEY_MOUSE_1) + NumKeyStates = KEY_MOUSE_1; + mem_copy(m_aInputState, pState, NumKeyStates); + mem_zero(m_aInputState + NumKeyStates, KEY_LAST - NumKeyStates); + if(m_EditingTextLen == 0) + m_EditingTextLen = -1; // these states must always be updated manually because they are not in the GetKeyState from SDL const int MouseState = SDL_GetMouseState(NULL, NULL);