Skip to content

Commit

Permalink
Fix input system ignoring mouse input
Browse files Browse the repository at this point in the history
Regression from commit ecc0dca.

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.
  • Loading branch information
jyrkive committed Feb 28, 2018
1 parent 4668010 commit 1aa9a37
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/hotkey/command_executor.cpp
Expand Up @@ -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;
}

Expand Down

0 comments on commit 1aa9a37

Please sign in to comment.