mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-22 22:13:35 +02:00
fix shortcut modifier
This commit is contained in:
parent
04987eef5c
commit
2d94246174
@ -32,15 +32,22 @@ InputSourceKeyboard::InputSourceKeyboard()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string InputSourceKeyboard::getKeyNameWithModifiers(const std::string & keyName) const
|
std::string InputSourceKeyboard::getKeyNameWithModifiers(const std::string & keyName, bool keyUp)
|
||||||
{
|
{
|
||||||
std::string result;
|
std::string result;
|
||||||
|
|
||||||
if (isKeyboardCtrlDown())
|
if(!keyUp)
|
||||||
|
{
|
||||||
|
wasKeyboardCtrlDown = isKeyboardCtrlDown();
|
||||||
|
wasKeyboardAltDown = isKeyboardAltDown();
|
||||||
|
wasKeyboardShiftDown = isKeyboardShiftDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wasKeyboardCtrlDown)
|
||||||
result += "Ctrl+";
|
result += "Ctrl+";
|
||||||
if (isKeyboardAltDown())
|
if (wasKeyboardAltDown)
|
||||||
result += "Alt+";
|
result += "Alt+";
|
||||||
if (isKeyboardShiftDown())
|
if (wasKeyboardShiftDown)
|
||||||
result += "Shift+";
|
result += "Shift+";
|
||||||
result += keyName;
|
result += keyName;
|
||||||
|
|
||||||
@ -49,7 +56,7 @@ std::string InputSourceKeyboard::getKeyNameWithModifiers(const std::string & key
|
|||||||
|
|
||||||
void InputSourceKeyboard::handleEventKeyDown(const SDL_KeyboardEvent & key)
|
void InputSourceKeyboard::handleEventKeyDown(const SDL_KeyboardEvent & key)
|
||||||
{
|
{
|
||||||
std::string keyName = getKeyNameWithModifiers(SDL_GetKeyName(key.keysym.sym));
|
std::string keyName = getKeyNameWithModifiers(SDL_GetKeyName(key.keysym.sym), false);
|
||||||
logGlobal->trace("keyboard: key '%s' pressed", keyName);
|
logGlobal->trace("keyboard: key '%s' pressed", keyName);
|
||||||
assert(key.state == SDL_PRESSED);
|
assert(key.state == SDL_PRESSED);
|
||||||
|
|
||||||
@ -111,7 +118,7 @@ void InputSourceKeyboard::handleEventKeyUp(const SDL_KeyboardEvent & key)
|
|||||||
if(key.repeat != 0)
|
if(key.repeat != 0)
|
||||||
return; // ignore periodic event resends
|
return; // ignore periodic event resends
|
||||||
|
|
||||||
std::string keyName = getKeyNameWithModifiers(SDL_GetKeyName(key.keysym.sym));
|
std::string keyName = getKeyNameWithModifiers(SDL_GetKeyName(key.keysym.sym), true);
|
||||||
logGlobal->trace("keyboard: key '%s' released", keyName);
|
logGlobal->trace("keyboard: key '%s' released", keyName);
|
||||||
|
|
||||||
if (SDL_IsTextInputActive() == SDL_TRUE)
|
if (SDL_IsTextInputActive() == SDL_TRUE)
|
||||||
|
@ -15,7 +15,11 @@ struct SDL_KeyboardEvent;
|
|||||||
/// Class that handles keyboard input from SDL events
|
/// Class that handles keyboard input from SDL events
|
||||||
class InputSourceKeyboard
|
class InputSourceKeyboard
|
||||||
{
|
{
|
||||||
std::string getKeyNameWithModifiers(const std::string & keyName) const;
|
bool wasKeyboardCtrlDown;
|
||||||
|
bool wasKeyboardAltDown;
|
||||||
|
bool wasKeyboardShiftDown;
|
||||||
|
|
||||||
|
std::string getKeyNameWithModifiers(const std::string & keyName, bool keyUp);
|
||||||
public:
|
public:
|
||||||
InputSourceKeyboard();
|
InputSourceKeyboard();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user