diff --git a/client/eventsSDL/InputHandler.cpp b/client/eventsSDL/InputHandler.cpp index ea318599e..4ddadd290 100644 --- a/client/eventsSDL/InputHandler.cpp +++ b/client/eventsSDL/InputHandler.cpp @@ -186,21 +186,17 @@ void InputHandler::fetchEvents() bool InputHandler::isKeyboardCtrlDown() const { -#ifdef VCMI_MAC - return SDL_GetKeyboardState(nullptr)[SDL_SCANCODE_LGUI] || SDL_GetKeyboardState(nullptr)[SDL_SCANCODE_RGUI]; -#else - return SDL_GetKeyboardState(nullptr)[SDL_SCANCODE_LCTRL] || SDL_GetKeyboardState(nullptr)[SDL_SCANCODE_RCTRL]; -#endif + return keyboardHandler->isKeyboardCtrlDown(); } bool InputHandler::isKeyboardAltDown() const { - return SDL_GetKeyboardState(nullptr)[SDL_SCANCODE_LALT] || SDL_GetKeyboardState(nullptr)[SDL_SCANCODE_RALT]; + return keyboardHandler->isKeyboardAltDown(); } bool InputHandler::isKeyboardShiftDown() const { - return SDL_GetKeyboardState(nullptr)[SDL_SCANCODE_LSHIFT] || SDL_GetKeyboardState(nullptr)[SDL_SCANCODE_RSHIFT]; + return keyboardHandler->isKeyboardShiftDown(); } void InputHandler::moveCursorPosition(const Point & distance) diff --git a/client/eventsSDL/InputSourceKeyboard.cpp b/client/eventsSDL/InputSourceKeyboard.cpp index 699ad81a9..adce3271b 100644 --- a/client/eventsSDL/InputSourceKeyboard.cpp +++ b/client/eventsSDL/InputSourceKeyboard.cpp @@ -83,3 +83,22 @@ void InputSourceKeyboard::handleEventKeyUp(const SDL_KeyboardEvent & key) GH.events().dispatchShortcutReleased(shortcutsVector); } + +bool InputSourceKeyboard::isKeyboardCtrlDown() const +{ +#ifdef VCMI_MAC + return SDL_GetKeyboardState(nullptr)[SDL_SCANCODE_LGUI] || SDL_GetKeyboardState(nullptr)[SDL_SCANCODE_RGUI]; +#else + return SDL_GetKeyboardState(nullptr)[SDL_SCANCODE_LCTRL] || SDL_GetKeyboardState(nullptr)[SDL_SCANCODE_RCTRL]; +#endif +} + +bool InputSourceKeyboard::isKeyboardAltDown() const +{ + return SDL_GetKeyboardState(nullptr)[SDL_SCANCODE_LALT] || SDL_GetKeyboardState(nullptr)[SDL_SCANCODE_RALT]; +} + +bool InputSourceKeyboard::isKeyboardShiftDown() const +{ + return SDL_GetKeyboardState(nullptr)[SDL_SCANCODE_LSHIFT] || SDL_GetKeyboardState(nullptr)[SDL_SCANCODE_RSHIFT]; +} diff --git a/client/eventsSDL/InputSourceKeyboard.h b/client/eventsSDL/InputSourceKeyboard.h index 9e4fdb80a..775318701 100644 --- a/client/eventsSDL/InputSourceKeyboard.h +++ b/client/eventsSDL/InputSourceKeyboard.h @@ -20,4 +20,8 @@ public: void handleEventKeyDown(const SDL_KeyboardEvent & current); void handleEventKeyUp(const SDL_KeyboardEvent & current); + + bool isKeyboardAltDown() const; + bool isKeyboardCtrlDown() const; + bool isKeyboardShiftDown() const; };