From 6a6465498f378fd103d2bf43aadb973ca76038e8 Mon Sep 17 00:00:00 2001 From: hokasha2016 <46494088+hokasha2016@users.noreply.github.com> Date: Thu, 2 May 2019 15:42:05 -0400 Subject: [PATCH] Fix #7878: Scroll shortcut keys ignore SHIFT/CTRL/ALT modifiers --- src/openrct2-ui/input/KeyboardShortcuts.cpp | 30 +++++++-------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/src/openrct2-ui/input/KeyboardShortcuts.cpp b/src/openrct2-ui/input/KeyboardShortcuts.cpp index 9046baa351..a77a8932dd 100644 --- a/src/openrct2-ui/input/KeyboardShortcuts.cpp +++ b/src/openrct2-ui/input/KeyboardShortcuts.cpp @@ -169,27 +169,17 @@ void KeyboardShortcuts::GetKeyboardMapScroll(const uint8_t* keysState, int32_t* if (!keysState[scancode]) continue; - if (shortcutKey & SHIFT) - { - if (!keysState[SDL_SCANCODE_LSHIFT] && !keysState[SDL_SCANCODE_RSHIFT]) - continue; - } - if (shortcutKey & CTRL) - { - if (!keysState[SDL_SCANCODE_LCTRL] && !keysState[SDL_SCANCODE_RCTRL]) - continue; - } - if (shortcutKey & ALT) - { - if (!keysState[SDL_SCANCODE_LALT] && !keysState[SDL_SCANCODE_RALT]) - continue; - } + // Check if SHIFT is either set in the shortcut key and currently, + // or not set in the shortcut key and not currently pressed (in other words: check if they match). + if ((bool)(shortcutKey & SHIFT) != (keysState[SDL_SCANCODE_LSHIFT] || keysState[SDL_SCANCODE_RSHIFT])) + continue; + if ((bool)(shortcutKey & CTRL) != (keysState[SDL_SCANCODE_LCTRL] || keysState[SDL_SCANCODE_RCTRL])) + continue; + if ((bool)(shortcutKey & ALT) != (keysState[SDL_SCANCODE_LALT] || keysState[SDL_SCANCODE_RALT])) + continue; #ifdef __MACOSX__ - if (shortcutKey & CMD) - { - if (!keysState[SDL_SCANCODE_LGUI] && !keysState[SDL_SCANCODE_RGUI]) - continue; - } + if ((bool)(shortcutKey & CMD) != (keysState[SDL_SCANCODE_LGUI] || keysState[SDL_SCANCODE_RGUI])) + continue; #endif switch (shortcutId) {