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.
This commit is contained in:
Robert Müller 2024-08-04 21:37:28 +02:00
parent 12e5f7f1d3
commit dc1a483b53

View file

@ -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) 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 // 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()); return m_pBinds->OnInput(Event);
// 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 false; return false;