Browse Source

[1.5] Hotkeys: Support more keybindings (#7650)

* Hotkeys: Support more keybindings (#6719)

* Extend F keys with F13-F24 range
* Add more possible keybindings
* Removed hardcoded keys that are used elsewhere
* Put PAUSE back where it was before
* Remove hardcoded logic for PAUSE key
* Hotkeys: Support more keybindings

This patch adds more keybindings, so we can map multiple keys.

It also adds a possibility to bind an alternate key to pause game
(currently mapped to P and Pause key by default).
pull/7677/head
Gleb Mazovetskiy 1 year ago committed by GitHub
parent
commit
78409cc5a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 10
      Source/diablo.cpp
  2. 31
      Source/options.cpp
  3. 4
      Translations/devilutionx.pot
  4. 4
      Translations/es.po
  5. 6
      Translations/it.po
  6. 4
      Translations/ja.po
  7. 6
      Translations/pl.po
  8. 6
      Translations/uk.po
  9. 6
      Translations/zh_CN.po

10
Source/diablo.cpp

@ -475,10 +475,6 @@ void PressKey(SDL_Keycode vkey, uint16_t modState)
if (vkey == SDLK_UNKNOWN)
return;
if (vkey == SDLK_PAUSE) {
diablo_pause_game();
return;
}
if (gmenu_presskeys(vkey) || control_presskeys(vkey)) {
return;
}
@ -1791,6 +1787,12 @@ void InitKeymapActions()
N_("Pauses the game."),
'P',
diablo_pause_game);
sgOptions.Keymapper.AddAction(
"Pause Game (Alternate)",
N_("Pause Game (Alternate)"),
N_("Pauses the game."),
SDLK_PAUSE,
diablo_pause_game);
sgOptions.Keymapper.AddAction(
"DecreaseGamma",
N_("Decrease Gamma"),

31
Source/options.cpp

@ -1304,7 +1304,7 @@ std::vector<OptionEntryBase *> LanguageOptions::GetEntries()
KeymapperOptions::KeymapperOptions()
: OptionCategoryBase("Keymapping", N_("Keymapping"), N_("Keymapping Settings"))
{
// Insert all supported keys: a-z, 0-9 and F1-F12.
// Insert all supported keys: a-z, 0-9 and F1-F24.
keyIDToKeyName.reserve(('Z' - 'A' + 1) + ('9' - '0' + 1) + 12);
for (char c = 'A'; c <= 'Z'; ++c) {
keyIDToKeyName.emplace(c, std::string(1, c));
@ -1315,12 +1315,18 @@ KeymapperOptions::KeymapperOptions()
for (int i = 0; i < 12; ++i) {
keyIDToKeyName.emplace(SDLK_F1 + i, StrCat("F", i + 1));
}
for (int i = 0; i < 12; ++i) {
keyIDToKeyName.emplace(SDLK_F13 + i, StrCat("F", i + 13));
}
keyIDToKeyName.emplace(SDLK_LALT, "LALT");
keyIDToKeyName.emplace(SDLK_RALT, "RALT");
keyIDToKeyName.emplace(SDLK_SPACE, "SPACE");
keyIDToKeyName.emplace(SDLK_RCTRL, "RCONTROL");
keyIDToKeyName.emplace(SDLK_LCTRL, "LCONTROL");
keyIDToKeyName.emplace(SDLK_PRINTSCREEN, "PRINT");
keyIDToKeyName.emplace(SDLK_PAUSE, "PAUSE");
keyIDToKeyName.emplace(SDLK_TAB, "TAB");
@ -1328,6 +1334,29 @@ KeymapperOptions::KeymapperOptions()
keyIDToKeyName.emplace(SDL_BUTTON_X1 | KeymapperMouseButtonMask, "X1MOUSE");
keyIDToKeyName.emplace(SDL_BUTTON_X2 | KeymapperMouseButtonMask, "X2MOUSE");
keyIDToKeyName.emplace(SDLK_BACKQUOTE, "`");
keyIDToKeyName.emplace(SDLK_LEFTBRACKET, "[");
keyIDToKeyName.emplace(SDLK_RIGHTBRACKET, "]");
keyIDToKeyName.emplace(SDLK_BACKSLASH, "\\");
keyIDToKeyName.emplace(SDLK_SEMICOLON, ";");
keyIDToKeyName.emplace(SDLK_QUOTE, "'");
keyIDToKeyName.emplace(SDLK_COMMA, ",");
keyIDToKeyName.emplace(SDLK_PERIOD, ".");
keyIDToKeyName.emplace(SDLK_SLASH, "/");
keyIDToKeyName.emplace(SDLK_BACKSPACE, "BACKSPACE");
keyIDToKeyName.emplace(SDLK_CAPSLOCK, "CAPSLOCK");
keyIDToKeyName.emplace(SDLK_SCROLLLOCK, "SCROLLLOCK");
keyIDToKeyName.emplace(SDLK_INSERT, "INSERT");
keyIDToKeyName.emplace(SDLK_DELETE, "DELETE");
keyIDToKeyName.emplace(SDLK_HOME, "HOME");
keyIDToKeyName.emplace(SDLK_END, "END");
keyIDToKeyName.emplace(SDLK_KP_DIVIDE, "KEYPAD /");
keyIDToKeyName.emplace(SDLK_KP_MULTIPLY, "KEYPAD *");
keyIDToKeyName.emplace(SDLK_KP_ENTER, "KEYPAD ENTER");
keyIDToKeyName.emplace(SDLK_KP_PERIOD, "KEYPAD DECIMAL");
keyNameToKeyID.reserve(keyIDToKeyName.size());
for (const auto &kv : keyIDToKeyName) {
keyNameToKeyID.emplace(kv.second, kv.first);

4
Translations/devilutionx.pot

@ -1525,6 +1525,10 @@ msgstr ""
msgid "Pause Game"
msgstr ""
#: Source/diablo.cpp:1792
msgid "Pause Game (Alternate)"
msgstr ""
#: Source/diablo.cpp:1897 Source/diablo.cpp:1903 Source/diablo.cpp:2388
msgid "Pauses the game."
msgstr ""

4
Translations/es.po

@ -1492,6 +1492,10 @@ msgstr "Pausar Juego"
msgid "Pauses the game."
msgstr "Pausar el juego."
#: Source/diablo.cpp:1792
msgid "Pause Game (Alternate)"
msgstr "Pausar juego (alternativo)"
#: Source/diablo.cpp:1771 Source/diablo.cpp:2241
msgid "Decrease Gamma"
msgstr "Disminuir Gamma"

6
Translations/it.po

@ -1577,7 +1577,11 @@ msgstr "Sospendi Partita"
msgid "Pauses the game."
msgstr "Sospende la partita."
#: Source/diablo.cpp:1796 Source/diablo.cpp:2264
#: Source/diablo.cpp:1792
msgid "Pause Game (Alternate)"
msgstr "Sospendi Partita (Alternativo)"
#: Source/diablo.cpp:1781 Source/diablo.cpp:2249
msgid "Decrease Gamma"
msgstr "Diminuisci Gamma"

4
Translations/ja.po

@ -1530,6 +1530,10 @@ msgstr "ゲーム一時停止"
msgid "Pauses the game."
msgstr "ゲーム一時停止ます。"
#: Source/diablo.cpp:1792
msgid "Pause Game (Alternate)"
msgstr "ゲーム一時停止"
#: Source/diablo.cpp:1782 Source/diablo.cpp:2250
msgid "Decrease Gamma"
msgstr "ガンマ下げる"

6
Translations/pl.po

@ -371,7 +371,7 @@ msgstr "Klient-Serwer (TCP)"
#: Source/DiabloUI/selconn.cpp:15
#, fuzzy
msgid "Offline"
msgid "Offline"
msgstr "Loopback"
#: Source/DiabloUI/selconn.cpp:54 Source/DiabloUI/selgame.cpp:604
@ -1379,6 +1379,10 @@ msgstr "Wstrzymaj grę"
msgid "Pauses the game."
msgstr "Wstrzymuje grę."
#: Source/diablo.cpp:1792
msgid "Pause Game (Alternate)"
msgstr "Wstrzymaj grę (alternatywnie)"
#: Source/diablo.cpp:1616
msgid "Decrease Gamma"
msgstr "Zmniejsz jasność"

6
Translations/uk.po

@ -1566,7 +1566,11 @@ msgstr "Зупинити Гру"
msgid "Pauses the game."
msgstr "Ставить гру на паузу."
#: Source/diablo.cpp:1796 Source/diablo.cpp:2264
#: Source/diablo.cpp:1792
msgid "Pause Game (Alternate)"
msgstr "Зупинити гру (Альтернатива)"
#: Source/diablo.cpp:1782 Source/diablo.cpp:2250
msgid "Decrease Gamma"
msgstr "Зменшити Гамму"

6
Translations/zh_CN.po

@ -369,7 +369,7 @@ msgstr "客户-服务器(TCP)"
#: Source/DiabloUI/selconn.cpp:15
#, fuzzy
msgid "Offline"
msgid "Offline"
msgstr "回环"
#: Source/DiabloUI/selconn.cpp:54 Source/DiabloUI/selgame.cpp:604
@ -1352,6 +1352,10 @@ msgstr "暂停游戏"
msgid "Pauses the game."
msgstr "暂停当前游戏。"
#: Source/diablo.cpp:1792
msgid "Pause Game (Alternate)"
msgstr "暂停游戏(备用)"
#: Source/diablo.cpp:1618
msgid "Decrease Gamma"
msgstr "减少伽马"

Loading…
Cancel
Save