From f58aa4c2f9af80ea54f2ef578755422034891939 Mon Sep 17 00:00:00 2001 From: Robert Burnham Date: Wed, 9 Sep 2026 08:32:00 -0500 Subject: [PATCH 1/2] Add KeyBindingsChanged callin (#3081) * Add KeyBindingsChanged callin * Emit KeyBindingsChanged from keybinding commands --- cont/LuaUI/callins.lua | 1 + cont/LuaUI/widgets.lua | 7 +++ .../base/springcontent/LuaGadgets/callins.lua | 1 + .../base/springcontent/LuaGadgets/gadgets.lua | 7 +++ doc/pr-changelogs/3081.md | 2 + rts/Game/UI/KeyBindings.cpp | 47 ++++++++++++------- rts/Lua/LuaHandle.cpp | 25 ++++++++++ rts/Lua/LuaHandle.h | 1 + rts/System/EventClient.cpp | 1 + rts/System/EventClient.h | 1 + rts/System/EventHandler.cpp | 6 +++ rts/System/EventHandler.h | 1 + rts/System/Events.def | 1 + 13 files changed, 83 insertions(+), 18 deletions(-) create mode 100644 doc/pr-changelogs/3081.md diff --git a/cont/LuaUI/callins.lua b/cont/LuaUI/callins.lua index db7d4380c99..2279b135c37 100644 --- a/cont/LuaUI/callins.lua +++ b/cont/LuaUI/callins.lua @@ -23,6 +23,7 @@ CallInsList = { "MiniMapGeometryChanged", "CommandNotify", + "KeyBindingsChanged", "KeyMapChanged", "KeyPress", "KeyRelease", diff --git a/cont/LuaUI/widgets.lua b/cont/LuaUI/widgets.lua index 4808aa9a436..bbed83d538f 100644 --- a/cont/LuaUI/widgets.lua +++ b/cont/LuaUI/widgets.lua @@ -195,6 +195,7 @@ local callInLists = { 'AddConsoleLine', 'ViewResize', 'DrawScreen', + 'KeyBindingsChanged', 'KeyMapChanged', 'KeyPress', 'KeyRelease', @@ -1416,6 +1417,12 @@ end -- Keyboard call-ins -- +function widgetHandler:KeyBindingsChanged() + for _,w in ipairs(self.KeyBindingsChangedList) do + w:KeyBindingsChanged() + end +end + function widgetHandler:KeyMapChanged() for _,w in ipairs(self.KeyMapChangedList) do w:KeyMapChanged() diff --git a/cont/base/springcontent/LuaGadgets/callins.lua b/cont/base/springcontent/LuaGadgets/callins.lua index 852dbab48f3..78f51d4384c 100644 --- a/cont/base/springcontent/LuaGadgets/callins.lua +++ b/cont/base/springcontent/LuaGadgets/callins.lua @@ -192,6 +192,7 @@ CALLIN_LIST = { "GroupChanged", -- moved from LuaUI + "KeyBindingsChanged", "KeyPress", "KeyRelease", "TextInput", diff --git a/cont/base/springcontent/LuaGadgets/gadgets.lua b/cont/base/springcontent/LuaGadgets/gadgets.lua index 9c97e1bd739..e5a2045719d 100644 --- a/cont/base/springcontent/LuaGadgets/gadgets.lua +++ b/cont/base/springcontent/LuaGadgets/gadgets.lua @@ -2060,6 +2060,13 @@ end -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- +function gadgetHandler:KeyBindingsChanged() + for _,g in r_ipairs(self.KeyBindingsChangedList) do + g:KeyBindingsChanged() + end +end + + function gadgetHandler:KeyPress(key, mods, isRepeat, label, unicode, scanCode) for _,g in r_ipairs(self.KeyPressList) do if (g:KeyPress(key, mods, isRepeat, label, unicode, scanCode)) then diff --git a/doc/pr-changelogs/3081.md b/doc/pr-changelogs/3081.md new file mode 100644 index 00000000000..f16f29b9c62 --- /dev/null +++ b/doc/pr-changelogs/3081.md @@ -0,0 +1,2 @@ +### Features + * added `wupget:KeyBindingsChanged()` unsynced callin. Called whenever a valid `/bind` or similar command is called. diff --git a/rts/Game/UI/KeyBindings.cpp b/rts/Game/UI/KeyBindings.cpp index cc756cd26d5..32c55dcfb6a 100644 --- a/rts/Game/UI/KeyBindings.cpp +++ b/rts/Game/UI/KeyBindings.cpp @@ -9,6 +9,7 @@ #include "KeySet.h" #include "Sim/Units/UnitDef.h" #include "Sim/Units/UnitDefHandler.h" +#include "System/EventHandler.h" #include "System/FileSystem/FileHandler.h" #include "System/FileSystem/SimpleParser.h" #include "System/Log/ILog.h" @@ -677,19 +678,17 @@ bool CKeyBindings::UnBind(const std::string& keystr, const std::string& command) KeyMap& bindings = ks.IsKeyCode() ? codeBindings : scanBindings; const auto it = bindings.find(ks); - if (it == bindings.end()) - return false; - - ActionList& al = it->second; - const bool success = RemoveCommandFromList(al, command); + if (it != bindings.end()) { + ActionList& al = it->second; - if (al.empty()) - bindings.erase(it); + if (RemoveCommandFromList(al, command)) + buildHotkeyMap = true; - if (success) - buildHotkeyMap = true; + if (al.empty()) + bindings.erase(it); + } - return success; + return true; } @@ -709,11 +708,11 @@ bool CKeyBindings::UnBindKeyset(const std::string& keystr) const auto it = bindings.find(ks); - if (it == bindings.end()) - return false; + if (it != bindings.end()) { + bindings.erase(it); + buildHotkeyMap = true; + } - bindings.erase(it); - buildHotkeyMap = true; return true; } @@ -756,7 +755,7 @@ bool CKeyBindings::UnBindAction(const std::string& command) if (changed) buildHotkeyMap = true; - return changed; + return true; } @@ -880,6 +879,9 @@ bool CKeyBindings::ExecuteCommandInternal(const std::string& line) const std::string command = StringToLower(words[0]); + // emit even on a no-op command so clients can tell it ran; keydebug is logging-only, so skip it + bool emitEvent = true; + if (command == "keydebug") { if (words.size() == 1) { // toggle @@ -888,6 +890,7 @@ bool CKeyBindings::ExecuteCommandInternal(const std::string& line) // set debugEnabled = atoi(words[1].c_str()); } + emitEvent = false; } else if (command == "keyload") { const std::string& filename = words.size() > 1 ? words[1] : DEFAULT_FILENAME; @@ -952,15 +955,19 @@ bool CKeyBindings::ExecuteCommandInternal(const std::string& line) return false; } - return false; + return emitEvent; } bool CKeyBindings::ExecuteCommand(const std::string& line) { - const bool ret = ExecuteCommandInternal(line); + const bool emitEvent = ExecuteCommandInternal(line); MaybeBuildHotkeyMap(); - return ret; + + if (emitEvent) + eventHandler.KeyBindingsChanged(); + + return emitEvent; } @@ -1001,6 +1008,10 @@ bool CKeyBindings::Load(const std::string& filename) { const bool ret = LoadInternal(filename); MaybeBuildHotkeyMap(); + + if (ret) + eventHandler.KeyBindingsChanged(); + return ret; } diff --git a/rts/Lua/LuaHandle.cpp b/rts/Lua/LuaHandle.cpp index 9e8b12ec14d..c0baa78cf78 100644 --- a/rts/Lua/LuaHandle.cpp +++ b/rts/Lua/LuaHandle.cpp @@ -3129,6 +3129,31 @@ void CLuaHandle::Pong(uint8_t pingTag, const spring_time pktSendTime, const spri RunCallIn(L, cmdStr, 3, 0); } +/*** Called after a keybinding command runs. + * + * Called when: + * + * - A keybinding command runs, e.g. `bind k action`. This may fire even when nothing actually changed (e.g. a redundant bind), so treat it as "a binding command ran", not a guarantee that bindings differ. An operation covering multiple keybindings fires a single event at the end, e.g. `keyreload`. + * - Any operation that changes how actions are retrieved from input triggers happened, e.g. `fakemeta space`. + * + * Nothing is passed; call `Spring.GetKeyBindings` to read the current state. + * + * @function Callins:KeyBindingsChanged + */ +void CLuaHandle::KeyBindingsChanged() +{ + RECOIL_DETAILED_TRACY_ZONE; + LUA_CALL_IN_CHECK(L); + luaL_checkstack(L, 2, __func__); + + static const LuaHashString cmdStr(__func__); + + if (!cmdStr.GetGlobalFunc(L)) + return; + + RunCallIn(L, cmdStr, 0, 0); +} + /*** Called when the keymap changes * diff --git a/rts/Lua/LuaHandle.h b/rts/Lua/LuaHandle.h index a3757b7af56..40d7470daa2 100644 --- a/rts/Lua/LuaHandle.h +++ b/rts/Lua/LuaHandle.h @@ -201,6 +201,7 @@ class CLuaHandle : public CEventClient void UnsyncedHeightMapUpdate(const SRectangle& rect) override; void Update() override; + void KeyBindingsChanged() override; bool KeyMapChanged() override; bool KeyPress(int keyCode, int scanCode, bool isRepeat) override; bool KeyRelease(int keyCode, int scanCode) override; diff --git a/rts/System/EventClient.cpp b/rts/System/EventClient.cpp index de94b03c58d..849ad9d0fce 100644 --- a/rts/System/EventClient.cpp +++ b/rts/System/EventClient.cpp @@ -61,6 +61,7 @@ void CEventClient::DrawLoadScreen() {} void CEventClient::LoadProgress(const std::string& msg, const bool replace_lastline) {} // from LuaUI +void CEventClient::KeyBindingsChanged() {} bool CEventClient::KeyMapChanged() { return false; } bool CEventClient::KeyPress(int keyCode, int scanCode, bool isRepeat) { return false; } bool CEventClient::KeyRelease(int keyCode, int scanCode) { return false; } diff --git a/rts/System/EventClient.h b/rts/System/EventClient.h index 6d938cebd5a..3b2eaff019c 100644 --- a/rts/System/EventClient.h +++ b/rts/System/EventClient.h @@ -287,6 +287,7 @@ class CEventClient virtual void Update(); virtual void UnsyncedHeightMapUpdate(const SRectangle& rect); + virtual void KeyBindingsChanged(); virtual bool KeyMapChanged(); virtual bool KeyPress(int keyCode, int scanCode, bool isRepeat); virtual bool KeyRelease(int keyCode, int scanCode); diff --git a/rts/System/EventHandler.cpp b/rts/System/EventHandler.cpp index f815ae7f33e..570ab1d0bf9 100644 --- a/rts/System/EventHandler.cpp +++ b/rts/System/EventHandler.cpp @@ -811,6 +811,12 @@ bool CEventHandler::CommandNotify(const Command& cmd) return ControlReverseIterateDefTrue(listCommandNotify, &CEventClient::CommandNotify, cmd); } +void CEventHandler::KeyBindingsChanged() +{ + ZoneScoped; + ITERATE_EVENTCLIENTLIST_NA(KeyBindingsChanged); +} + bool CEventHandler::KeyMapChanged() { ZoneScoped; diff --git a/rts/System/EventHandler.h b/rts/System/EventHandler.h index 31d77790597..688fa0051fc 100644 --- a/rts/System/EventHandler.h +++ b/rts/System/EventHandler.h @@ -223,6 +223,7 @@ class CEventHandler void UnsyncedHeightMapUpdate(const SRectangle& rect); void Update(); + void KeyBindingsChanged(); bool KeyMapChanged(); bool KeyPress(int keyCode, int scanCode, bool isRepeat); bool KeyRelease(int keyCode, int scanCode); diff --git a/rts/System/Events.def b/rts/System/Events.def index e36f11dac3d..118eebd1beb 100644 --- a/rts/System/Events.def +++ b/rts/System/Events.def @@ -101,6 +101,7 @@ SETUP_EVENT(Update, MANAGED_BIT | UNSYNCED_BIT) + SETUP_EVENT(KeyBindingsChanged, MANAGED_BIT | UNSYNCED_BIT) SETUP_EVENT(KeyMapChanged, MANAGED_BIT | UNSYNCED_BIT | CONTROL_BIT) SETUP_EVENT(KeyPress, MANAGED_BIT | UNSYNCED_BIT | CONTROL_BIT) SETUP_EVENT(KeyRelease, MANAGED_BIT | UNSYNCED_BIT | CONTROL_BIT) From 694e9df7cf5068aef2cdebbf5e6587d539344001 Mon Sep 17 00:00:00 2001 From: Robert Burnham Date: Wed, 9 Sep 2026 08:58:40 -0500 Subject: [PATCH 2/2] Deprecate the KEYSYMS Lua table (#3105) * Register key names for the keys that had none * Correct the key listing in the ui-keys reference * Deprecate KEYSYMS in favour of Spring.GetKeyCode --- cont/LuaUI/Headers/keysym.h.lua | 97 ++++++++++++++++++- .../LuaHandler/Utilities/keysym.lua | 97 ++++++++++++++++++- doc/pr-changelogs/3105.md | 2 + .../content/articles/ui-keys-reference.md | 37 ++++--- rts/Game/UI/KeyCodes.cpp | 25 +++-- 5 files changed, 228 insertions(+), 30 deletions(-) create mode 100644 doc/pr-changelogs/3105.md diff --git a/cont/LuaUI/Headers/keysym.h.lua b/cont/LuaUI/Headers/keysym.h.lua index 2c2557ad28b..dba89daeb67 100644 --- a/cont/LuaUI/Headers/keysym.h.lua +++ b/cont/LuaUI/Headers/keysym.h.lua @@ -13,7 +13,7 @@ -- From SDL_keysym.h -KEYSYMS = { +local KEYSYM_VALUES = { UNKNOWN = 0, FIRST = 0, @@ -273,3 +273,98 @@ KEYSYMS = { -- Add any other keys here LAST = 323 } + + +-- KEYSYMS is deprecated in favour of Spring.GetKeyCode(name) (see issue #2611: +-- these legacy SDL1.2 values can't represent keys like F13-F20). It stays fully +-- available for now - same values, still iterable - but warns on use to nudge +-- migration. Deprecation only; no behaviour change. +local warnedKeys = {} +local warnedSites = {} + +-- first stack frame outside this shim, so the warning points at the offending +-- widget line instead of the proxy. skips C frames (no line) and the shim itself. +local function callerSite() + if not (debug and debug.getinfo) then return nil end + for lvl = 2, 8 do + local info = debug.getinfo(lvl, "Sl") + if not info then return nil end + local src = info.short_src or "" + if info.currentline and info.currentline > 0 and not src:find("keysym") then + return src .. ":" .. info.currentline + end + end + return nil +end + +-- SDL2 folded these keys into another one, so nothing produces their old value +-- and GetKeySymbol cannot find them; name the surviving key by hand +local RENAMED_KEYS = { + BREAK = "pause", + LSUPER = "meta", + RSUPER = "rmeta", +} + +local function warnKeysym(key, value) + -- default (empty) section: on release its floor is INFO, so a DEPRECATED + -- message gets through; named sections floor at WARNING and would swallow it. + if not (Spring and Spring.Log and LOG and LOG.DEPRECATED) then return end + + local name = (key ~= nil) and tostring(key) or "*" + if warnedKeys[name] then return end + warnedKeys[name] = true + + -- collapse a loop over KEYSYMS to one warning per source line, not one per key + local site = callerSite() + if site then + if warnedSites[site] then return end + warnedSites[site] = true + end + + -- GetKeySymbol is the runtime inverse of GetKeyCode: it turns the legacy value + -- back into the current key name, so the message can name the exact replacement + local replacement, unsupported + if key ~= nil and value ~= nil then + local keyName = RENAMED_KEYS[key] + if not keyName and Spring.GetKeySymbol then + keyName = Spring.GetKeySymbol(value) + if keyName and keyName:sub(1, 2) == "0x" then keyName = nil end + end + if keyName then + replacement = 'Spring.GetKeyCode("' .. keyName .. '")' + else + -- nothing names this value, so SDL2 dropped the key rather than renaming it + unsupported = true + end + end + + local msg + if key == nil then + msg = "pairs(KEYSYMS) is deprecated, use Spring.GetKeySymbol() for a reverse mapping and check https://recoilengine.org/articles/ui-keys-reference/ for a listing of available keys" + elseif unsupported then + msg = "KEYSYMS." .. name .. " is deprecated and SDL2 no longer supports this key; " + .. "move the functionality to a key Spring.GetKeyCode can resolve" + else + msg = "KEYSYMS." .. name .. " is deprecated, use " + .. (replacement or "Spring.GetKeyCode() with the key's name") .. " instead" + end + if site then + msg = msg .. " [" .. site .. "]" + end + + Spring.Log("", LOG.DEPRECATED, msg) +end + +-- proxy: warns on access/iteration, returns the original values (no drift), and +-- keeps pairs() working via __pairs (backported into this Lua from 5.2) +KEYSYMS = setmetatable({}, { + __index = function(_, key) + local value = KEYSYM_VALUES[key] + warnKeysym(key, value) + return value + end, + __pairs = function() + warnKeysym(nil, nil) + return next, KEYSYM_VALUES, nil + end, +}) diff --git a/cont/base/springcontent/LuaHandler/Utilities/keysym.lua b/cont/base/springcontent/LuaHandler/Utilities/keysym.lua index 2c2557ad28b..dba89daeb67 100644 --- a/cont/base/springcontent/LuaHandler/Utilities/keysym.lua +++ b/cont/base/springcontent/LuaHandler/Utilities/keysym.lua @@ -13,7 +13,7 @@ -- From SDL_keysym.h -KEYSYMS = { +local KEYSYM_VALUES = { UNKNOWN = 0, FIRST = 0, @@ -273,3 +273,98 @@ KEYSYMS = { -- Add any other keys here LAST = 323 } + + +-- KEYSYMS is deprecated in favour of Spring.GetKeyCode(name) (see issue #2611: +-- these legacy SDL1.2 values can't represent keys like F13-F20). It stays fully +-- available for now - same values, still iterable - but warns on use to nudge +-- migration. Deprecation only; no behaviour change. +local warnedKeys = {} +local warnedSites = {} + +-- first stack frame outside this shim, so the warning points at the offending +-- widget line instead of the proxy. skips C frames (no line) and the shim itself. +local function callerSite() + if not (debug and debug.getinfo) then return nil end + for lvl = 2, 8 do + local info = debug.getinfo(lvl, "Sl") + if not info then return nil end + local src = info.short_src or "" + if info.currentline and info.currentline > 0 and not src:find("keysym") then + return src .. ":" .. info.currentline + end + end + return nil +end + +-- SDL2 folded these keys into another one, so nothing produces their old value +-- and GetKeySymbol cannot find them; name the surviving key by hand +local RENAMED_KEYS = { + BREAK = "pause", + LSUPER = "meta", + RSUPER = "rmeta", +} + +local function warnKeysym(key, value) + -- default (empty) section: on release its floor is INFO, so a DEPRECATED + -- message gets through; named sections floor at WARNING and would swallow it. + if not (Spring and Spring.Log and LOG and LOG.DEPRECATED) then return end + + local name = (key ~= nil) and tostring(key) or "*" + if warnedKeys[name] then return end + warnedKeys[name] = true + + -- collapse a loop over KEYSYMS to one warning per source line, not one per key + local site = callerSite() + if site then + if warnedSites[site] then return end + warnedSites[site] = true + end + + -- GetKeySymbol is the runtime inverse of GetKeyCode: it turns the legacy value + -- back into the current key name, so the message can name the exact replacement + local replacement, unsupported + if key ~= nil and value ~= nil then + local keyName = RENAMED_KEYS[key] + if not keyName and Spring.GetKeySymbol then + keyName = Spring.GetKeySymbol(value) + if keyName and keyName:sub(1, 2) == "0x" then keyName = nil end + end + if keyName then + replacement = 'Spring.GetKeyCode("' .. keyName .. '")' + else + -- nothing names this value, so SDL2 dropped the key rather than renaming it + unsupported = true + end + end + + local msg + if key == nil then + msg = "pairs(KEYSYMS) is deprecated, use Spring.GetKeySymbol() for a reverse mapping and check https://recoilengine.org/articles/ui-keys-reference/ for a listing of available keys" + elseif unsupported then + msg = "KEYSYMS." .. name .. " is deprecated and SDL2 no longer supports this key; " + .. "move the functionality to a key Spring.GetKeyCode can resolve" + else + msg = "KEYSYMS." .. name .. " is deprecated, use " + .. (replacement or "Spring.GetKeyCode() with the key's name") .. " instead" + end + if site then + msg = msg .. " [" .. site .. "]" + end + + Spring.Log("", LOG.DEPRECATED, msg) +end + +-- proxy: warns on access/iteration, returns the original values (no drift), and +-- keeps pairs() working via __pairs (backported into this Lua from 5.2) +KEYSYMS = setmetatable({}, { + __index = function(_, key) + local value = KEYSYM_VALUES[key] + warnKeysym(key, value) + return value + end, + __pairs = function() + warnKeysym(nil, nil) + return next, KEYSYM_VALUES, nil + end, +}) diff --git a/doc/pr-changelogs/3105.md b/doc/pr-changelogs/3105.md new file mode 100644 index 00000000000..2eb88ca7ef7 --- /dev/null +++ b/doc/pr-changelogs/3105.md @@ -0,0 +1,2 @@ +* `Spring.GetKeyCode` now supports most of keys defined in `keysyms.lua`, except a few that SDL2 dropped. +* deprecation notice: basecontent's `LuaHandler/Utilities/keysym.lua` and the loose `LuaUI/Headers/keysym.h.lua‎` distributed with engine installs are deprecated and will be removed. For now they work unchanged, but print helpful migration suggestions when used. diff --git a/doc/site/content/articles/ui-keys-reference.md b/doc/site/content/articles/ui-keys-reference.md index 0d850a03b5b..17b1f1b24c9 100644 --- a/doc/site/content/articles/ui-keys-reference.md +++ b/doc/site/content/articles/ui-keys-reference.md @@ -128,6 +128,7 @@ see rts/Game/UI/KeyBindings.cpp | $ | 0x024 | | % | 0x025 | | & | 0x026 | +| | | 0x07C | | ' | 0x027 | | ( | 0x028 | | ) | 0x029 | @@ -163,8 +164,11 @@ see rts/Game/UI/KeyBindings.cpp | a | 0x061 | | alt | 0x134 | | b | 0x062 | +| backquote | 0x060 | | backspace | 0x008 | | c | 0x063 | +| capslock | 0x12D | +| caret | 0x05E | | clear | 0x00C | | ctrl | 0x132 | | d | 0x064 | @@ -193,32 +197,20 @@ see rts/Game/UI/KeyBindings.cpp | f9 | 0x122 | | g | 0x067 | | h | 0x068 | +| help | 0x13B | | home | 0x116 | | i | 0x069 | | insert | 0x115 | | j | 0x06A | -| joy0 | 0x12C | -| joy1 | 0x12D | -| joy2 | 0x12E | -| joy3 | 0x12F | -| joy4 | 0x130 | -| joy5 | 0x131 | -| joy6 | 0x132 | -| joy7 | 0x133 | -| joydown | 0x141 | -| joyleft | 0x142 | -| joyright | 0x143 | -| joyup | 0x140 | -| joyw | 0x193 | -| joyx | 0x190 | -| joyy | 0x191 | -| joyz | 0x192 | | k | 0x06B | | l | 0x06C | | left | 0x114 | | m | 0x06D | +| menu | 0x13F | | meta | 0x136 | +| mode | 0x139 | | n | 0x06E | +| numlock | 0x12C | | numpad* | 0x10C | | numpad+ | 0x10E | | numpad- | 0x10D | @@ -241,24 +233,31 @@ see rts/Game/UI/KeyBindings.cpp | pagedown | 0x119 | | pageup | 0x118 | | pause | 0x013 | +| power | 0x140 | +| print | 0x13C | | printscreen | 0x13C | | q | 0x071 | | r | 0x072 | +| ralt | 0x133 | +| rctrl | 0x131 | | return | 0x00D | | right | 0x113 | +| rmeta | 0x135 | +| rshift | 0x12F | | s | 0x073 | +| scrollock | 0x12E | | shift | 0x130 | | space | 0x020 | +| sysreq | 0x13D | | t | 0x074 | | tab | 0x009 | +| tilde | 0x060 | | u | 0x075 | +| undo | 0x142 | | up | 0x111 | | v | 0x076 | | w | 0x077 | | x | 0x078 | | y | 0x079 | | z | 0x07A | -| { | 0x07B | -| | | 0x07C | -| } | 0x07D | | ~ | 0x07E | diff --git a/rts/Game/UI/KeyCodes.cpp b/rts/Game/UI/KeyCodes.cpp index 6169852e453..1d0c64f1f34 100644 --- a/rts/Game/UI/KeyCodes.cpp +++ b/rts/Game/UI/KeyCodes.cpp @@ -137,28 +137,35 @@ void CKeyCodes::Reset() } // Key state modifier keys - //AddPair("numlock", SDLK_NUMLOCK); - //AddPair("capslock", SDLK_CAPSLOCK); - //AddPair("scrollock", SDLK_SCROLLOCK); + AddPair("numlock", SDLK_NUMLOCKCLEAR); + AddPair("capslock", SDLK_CAPSLOCK); + AddPair("scrollock", SDLK_SCROLLLOCK); AddPair("shift", SDLK_LSHIFT); AddPair("ctrl", SDLK_LCTRL); AddPair("alt", SDLK_LALT); AddPair("meta", SDLK_LGUI); - // these can not be used correctly anyway (without special support in other parts of Spring code...) + // the plain names above are the left-hand keys, so the right-hand ones + // need their own names to be reachable by name at all + AddPair("rshift", SDLK_RSHIFT); + AddPair("rctrl", SDLK_RCTRL); + AddPair("ralt", SDLK_RALT); + AddPair("rmeta", SDLK_RGUI); + AddPair("mode", SDLK_MODE); // "Alt Gr" key; binding it still needs support elsewhere + // these have no SDL2 equivalent //AddPair("super", SDLK_LSUPER); // Left "Windows" key - //AddPair("mode", SDLK_MODE); // "Alt Gr" key //AddPair("compose", SDLK_COMPOSE); // Multi-key compose key // Miscellaneous function keys AddPair("help", SDLK_HELP); AddPair("printscreen", SDLK_PRINTSCREEN); AddPair("print", SDLK_PRINTSCREEN); - //AddPair("sysreq", SDLK_SYSREQ); + AddPair("sysreq", SDLK_SYSREQ); + AddPair("menu", SDLK_MENU); + AddPair("power", SDLK_POWER); // Power Macintosh power key + AddPair("undo", SDLK_UNDO); // Atari keyboard has Undo + // these have no SDL2 equivalent //AddPair("break", SDLK_BREAK); - //AddPair("menu", SDLK_MENU); - //AddPair("power", SDLK_POWER); // Power Macintosh power key //AddPair("euro", SDLK_EURO); // Some european keyboards - //AddPair("undo", SDLK_UNDO); // Atari keyboard has Undo for (int i = ACTION_BUTTON_MIN; i <= NUM_BUTTONS; i++) { AddPair("mouse" + IntToString(i), CKeyCodes::GetMouseButtonSymbol(i));