mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-17 01:32:21 +02:00
Move keyboard tests to keyboard handler
This commit is contained in:
@ -186,21 +186,17 @@ void InputHandler::fetchEvents()
|
|||||||
|
|
||||||
bool InputHandler::isKeyboardCtrlDown() const
|
bool InputHandler::isKeyboardCtrlDown() const
|
||||||
{
|
{
|
||||||
#ifdef VCMI_MAC
|
return keyboardHandler->isKeyboardCtrlDown();
|
||||||
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 InputHandler::isKeyboardAltDown() const
|
bool InputHandler::isKeyboardAltDown() const
|
||||||
{
|
{
|
||||||
return SDL_GetKeyboardState(nullptr)[SDL_SCANCODE_LALT] || SDL_GetKeyboardState(nullptr)[SDL_SCANCODE_RALT];
|
return keyboardHandler->isKeyboardAltDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InputHandler::isKeyboardShiftDown() const
|
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)
|
void InputHandler::moveCursorPosition(const Point & distance)
|
||||||
|
@ -83,3 +83,22 @@ void InputSourceKeyboard::handleEventKeyUp(const SDL_KeyboardEvent & key)
|
|||||||
|
|
||||||
GH.events().dispatchShortcutReleased(shortcutsVector);
|
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];
|
||||||
|
}
|
||||||
|
@ -20,4 +20,8 @@ public:
|
|||||||
|
|
||||||
void handleEventKeyDown(const SDL_KeyboardEvent & current);
|
void handleEventKeyDown(const SDL_KeyboardEvent & current);
|
||||||
void handleEventKeyUp(const SDL_KeyboardEvent & current);
|
void handleEventKeyUp(const SDL_KeyboardEvent & current);
|
||||||
|
|
||||||
|
bool isKeyboardAltDown() const;
|
||||||
|
bool isKeyboardCtrlDown() const;
|
||||||
|
bool isKeyboardShiftDown() const;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user