From 1aa9a37915764243e749a37b4b05ab19756c293d Mon Sep 17 00:00:00 2001 From: Jyrki Vesterinen Date: Wed, 28 Feb 2018 20:04:37 +0200 Subject: [PATCH] Fix input system ignoring mouse input Regression from commit ecc0dca665737bcb411fbd355edd37df8a9038b8. It turned out that the "hotkey" system is involved even when mouse clicks are processed. Therefore my code treated pressing a mouse key as a press only if there was a keyboard key release since the last mouse click. The result was that mouse input seemingly didn't work at all. Fixed by always treating mouse (and joystick) key presses as key presses regardless of whether there have been key release events in between. --- src/hotkey/command_executor.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/hotkey/command_executor.cpp b/src/hotkey/command_executor.cpp index 6d9a9345f18..f4a086d2625 100644 --- a/src/hotkey/command_executor.cpp +++ b/src/hotkey/command_executor.cpp @@ -549,13 +549,15 @@ void command_executor::execute_command(const SDL_Event& event, int index) } const hotkey_command& command = hotkey::get_hotkey_command(hk->get_command()); - bool press = (event.type == SDL_KEYDOWN || - event.type == SDL_JOYBUTTONDOWN || - event.type == SDL_MOUSEBUTTONDOWN || - event.type == SDL_TEXTINPUT) && + bool keypress = (event.type == SDL_KEYDOWN || event.type == SDL_TEXTINPUT) && !press_event_sent_; + bool press = keypress || + (event.type == SDL_JOYBUTTONDOWN || event.type == SDL_MOUSEBUTTONDOWN); if(press) { - LOG_HK << "sending press event\n"; + LOG_HK << "sending press event (keypress = " << + std::boolalpha << keypress << std::noboolalpha << ")\n"; + } + if(keypress) { press_event_sent_ = true; }