From dc1a483b538f0f62a916a84d16ec283ef6698c6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Sun, 4 Aug 2024 21:37:28 +0200 Subject: [PATCH] Make handling of F1-F24 keys binds consistent with regular binds The handling of F1-F24 keys in `CBindsSpecial` was not correct for composite binds, leading to stuck inputs if modifier keys are released first. Now, the `CBindsSpecial::OnInput` function simply delegates to `CBinds::OnInput` for F-key presses/releases so the behavior is consistent with regular binds. --- src/game/client/components/binds.cpp | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/game/client/components/binds.cpp b/src/game/client/components/binds.cpp index 5fe69b6f8..7f82aa485 100644 --- a/src/game/client/components/binds.cpp +++ b/src/game/client/components/binds.cpp @@ -11,26 +11,15 @@ static const ColorRGBA gs_BindPrintColor{1.0f, 1.0f, 0.8f, 1.0f}; bool CBinds::CBindsSpecial::OnInput(const IInput::CEvent &Event) { + if((Event.m_Flags & (IInput::FLAG_PRESS | IInput::FLAG_RELEASE)) == 0) + return false; + // only handle F and composed F binds - if(((Event.m_Key >= KEY_F1 && Event.m_Key <= KEY_F12) || (Event.m_Key >= KEY_F13 && Event.m_Key <= KEY_F24)) && (Event.m_Key != KEY_F5 || !m_pClient->m_Menus.IsActive())) + // do not handle F5 bind while menu is active + if(((Event.m_Key >= KEY_F1 && Event.m_Key <= KEY_F12) || (Event.m_Key >= KEY_F13 && Event.m_Key <= KEY_F24)) && + (Event.m_Key != KEY_F5 || !m_pClient->m_Menus.IsActive())) { - int Mask = CBinds::GetModifierMask(Input()); - - // Look for a composed bind - bool ret = false; - if(m_pBinds->m_aapKeyBindings[Mask][Event.m_Key]) - { - m_pBinds->GetConsole()->ExecuteLineStroked(Event.m_Flags & IInput::FLAG_PRESS, m_pBinds->m_aapKeyBindings[Mask][Event.m_Key]); - ret = true; - } - // Look for a non composed bind - if(!ret && m_pBinds->m_aapKeyBindings[0][Event.m_Key]) - { - m_pBinds->GetConsole()->ExecuteLineStroked(Event.m_Flags & IInput::FLAG_PRESS, m_pBinds->m_aapKeyBindings[0][Event.m_Key]); - ret = true; - } - - return ret; + return m_pBinds->OnInput(Event); } return false;