mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
Added option to configure key modifiers (Alt, Shift, Ctrl). Fixes lobby
hotkey activation.
This commit is contained in:
parent
4949b98ed3
commit
ffc207888b
@ -32,9 +32,24 @@ InputSourceKeyboard::InputSourceKeyboard()
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string InputSourceKeyboard::getKeyNameWithModifiers(const std::string & keyName) const
|
||||
{
|
||||
std::string result;
|
||||
|
||||
if (isKeyboardCtrlDown())
|
||||
result += "Ctrl+";
|
||||
if (isKeyboardAltDown())
|
||||
result += "Alt+";
|
||||
if (isKeyboardShiftDown())
|
||||
result += "Shift+";
|
||||
result += keyName;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void InputSourceKeyboard::handleEventKeyDown(const SDL_KeyboardEvent & key)
|
||||
{
|
||||
std::string keyName = SDL_GetKeyName(key.keysym.sym);
|
||||
std::string keyName = getKeyNameWithModifiers(SDL_GetKeyName(key.keysym.sym));
|
||||
logGlobal->trace("keyboard: key '%s' pressed", keyName);
|
||||
assert(key.state == SDL_PRESSED);
|
||||
|
||||
|
@ -15,6 +15,7 @@ struct SDL_KeyboardEvent;
|
||||
/// Class that handles keyboard input from SDL events
|
||||
class InputSourceKeyboard
|
||||
{
|
||||
std::string getKeyNameWithModifiers(const std::string & keyName) const;
|
||||
public:
|
||||
InputSourceKeyboard();
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
// For players (Linux): create file ~/.config/vcmi/shortcutsConfig.json (or ~/.var/app/eu.vcmi.VCMI/config for Flatpak) to modify this set
|
||||
//
|
||||
// When creating your own config, you can remove all hotkeys that you have not changed and game will read them from this file
|
||||
// It is possible to add modifiers to keys: Ctrl, Shift, or Alt. For example, "Ctrl+Tab" hotkey will only activate if Ctrl is pressed
|
||||
{
|
||||
"keyboard" : {
|
||||
"globalAccept": [ "Return", "Keypad Enter"],
|
||||
@ -112,6 +113,10 @@
|
||||
"battleTacticsEnd": [ "Return", "Keypad Enter"],
|
||||
"battleToggleHeroesStats": [],
|
||||
"battleSelectAction": "S",
|
||||
"lobbyActivateInterface": "Ctrl+Tab",
|
||||
"spectateTrackHero": "F5",
|
||||
"spectateSkipBattle": "F7",
|
||||
"spectateSkipBattleResult": "F8",
|
||||
"townOpenTavern": "T",
|
||||
"townSwapArmies": "Space",
|
||||
"recruitmentMax": "End",
|
||||
|
Loading…
Reference in New Issue
Block a user