Closed vimpostor closed 3 years ago
I have the same remap, and this is kind of by design since we don't respect the keyboard layout in order to have the same binds working with qwerty, qwertz, azerty, dvorak or whatever keyboard layout someone is using. I remember we switched to this behavior with SDL2, maybe there could be an option to disable it.
Yes it would be great, if the user can at least have an option (does not necessarily need to be exposed in GUI) to get keymappings that do respect the keyboard layout.
I tried this:
diff --git a/src/engine/client/input.cpp b/src/engine/client/input.cpp
index a0a829340..e2249f0c7 100644
--- a/src/engine/client/input.cpp
+++ b/src/engine/client/input.cpp
@@ -404,12 +404,12 @@ int CInput::Update()
// Sum if you want to ignore multiple modifiers.
if(!(Event.key.keysym.mod & g_Config.m_InpIgnoredModifiers))
{
- Scancode = Event.key.keysym.scancode;
+ Scancode = Event.key.keysym.sym;
}
break;
case SDL_KEYUP:
Action = IInput::FLAG_RELEASE;
- Scancode = Event.key.keysym.scancode;
+ Scancode = Event.key.keysym.sym;
break;
// handle mouse buttons
But the problem is that the keycodes are quite different from the scancodes, so the hardcoded KEY_ESCAPE etc don't fit then.
You can try if https://github.com/ddnet/ddnet/pull/4251 fixes this
What key do I need to set to what value in the config for testing that?
inp_translated_keys 1
In case anyone else is wondering, config file was in ~/.teeworlds/settings_ddnet.cfg
.
I can confirm that it is working, and I can finally use Caps Lock as ESC! Thanks so much, this is the only thing that has been holding me back from switching from Teeworlds to ddnet.
On Linux (X11), I have remapped my Caps Lock to ESC with
setxkbmap us -option caps:escape -variant de_se_fi
. In the original Teeworlds and in pretty much every game I know, they respect this setting and pressing Caps Lock activates ESC.However, ddnet somehow does not detect the ESC when I press Caps Lock. Since I don't have a real ESC key on my keyboard, I am unable to enter the Pause menu. Probably ddnet is checking the keyboard a layer below than what most other applications do and checks the keyboard codes from the keyboard directly. It would be good, if ddnet could handle keyboard events like Teeworlds and thus allow such weird remappings.