CommonHostInterface: Fix key inputs getting stuck with modifiers

This commit is contained in:
Connor McLaughlin
2021-02-28 02:45:30 +10:00
parent 091b745af6
commit a48fa4097b
5 changed files with 32 additions and 20 deletions

View File

@ -1267,11 +1267,15 @@ void CommonHostInterface::RegisterHotkey(String category, String name, String di
m_hotkeys.push_back(HotkeyInfo{std::move(category), std::move(name), std::move(display_name), std::move(handler)});
}
bool CommonHostInterface::HandleHostKeyEvent(HostKeyCode key, bool pressed)
bool CommonHostInterface::HandleHostKeyEvent(HostKeyCode code, HostKeyCode modifiers, bool pressed)
{
const auto iter = m_keyboard_input_handlers.find(key);
auto iter = m_keyboard_input_handlers.find(code | modifiers);
if (iter == m_keyboard_input_handlers.end())
return false;
{
// try without the modifier
if (modifiers == 0 || (iter = m_keyboard_input_handlers.find(code)) == m_keyboard_input_handlers.end())
return false;
}
iter->second(pressed);
return true;

View File

@ -347,7 +347,7 @@ protected:
virtual bool AddRumbleToInputMap(const std::string& binding, u32 controller_index, u32 num_motors);
void RegisterHotkey(String category, String name, String display_name, InputButtonHandler handler);
bool HandleHostKeyEvent(HostKeyCode code, bool pressed);
bool HandleHostKeyEvent(HostKeyCode code, HostKeyCode modifiers, bool pressed);
bool HandleHostMouseEvent(HostMouseButton button, bool pressed);
void UpdateInputMap(SettingsInterface& si);
void ClearInputMap();
@ -492,8 +492,8 @@ private:
u32 controller_index;
u32 num_motors;
std::array<float, MAX_MOTORS> last_strength;
ControllerRumbleCallback update_callback;
u64 last_update_time;
ControllerRumbleCallback update_callback;
};
std::vector<ControllerRumbleState> m_controller_vibration_motors;