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.
This commit is contained in:
Jyrki Vesterinen 2018-02-28 20:04:37 +02:00
parent 4668010c4b
commit 1aa9a37915

View File

@ -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;
}