-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SDL: Some keybinds broken due to missing character lookup #14545
Comments
Shouldn’t key bindings depend on key positions and not on symbols? Otherwise switching a layout would break them (and e.g. I do that often: not all scripts are Latin) |
Ideally binding both types of keys should be possible. In the case of The thing is, minetest currently allows binding symbols, so to not change user experience, SDL should support this too, imo. |
Fixing bugs is changing user experience, too.
In theory, maybe. But in practice, that would only confuse players. Key location is simple to understand, simple to code, and always works. While characters... aren’t. There are just too many things that may go wrong with them. P.S. Default keybindings may need some rethinking too. E.g. |
A bit off-topic but I don't think it's all that simple. |
Scancode. Not keycode. That’s the whole point.
|
I can see two distinct issues here:
|
@nephele-gh reported needing to rebind sneak from the default "Shift" to "Left Shift" upon switching from 5.8 to 5.9.0-dev on macOS. Render distance is one thing, but having a core gameplay control like sneak broken by default is not good. I'll reinforce the point in my last comment. I think a clear upgrade path for existing controls is needed: something like either a layer to translate old/existing bind names to SDL ones or at least working new defaults. |
Note that SDL2 isn't (yet) enabled by default on macOS. The cause of nephele-gh's bug is probably this, which should be disabled when compiling with SDL: PR'd a fix: #14754 |
It seems that SDL fails to provide the information we need here. Like Desour, I have a German keyboard where slash is Shift + 7. SDL has a keycode named diff --git a/irr/src/CIrrDeviceSDL.cpp b/irr/src/CIrrDeviceSDL.cpp
index ecea5bac3..6f08d7fa4 100644
--- a/irr/src/CIrrDeviceSDL.cpp
+++ b/irr/src/CIrrDeviceSDL.cpp
@@ -2,6 +2,7 @@
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
+#include <iostream>
#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
#include "CIrrDeviceSDL.h"
@@ -817,6 +818,9 @@ bool CIrrDeviceSDL::run()
irrevent.KeyInput.Shift = (SDL_event.key.keysym.mod & KMOD_SHIFT) != 0;
irrevent.KeyInput.Control = (SDL_event.key.keysym.mod & KMOD_CTRL) != 0;
irrevent.KeyInput.Char = findCharToPassToIrrlicht(mp.SDLKey, key);
+ std::cerr << "got " << (SDL_event.type == SDL_KEYDOWN ? "SDL_KEYDOWN" : "SDL_KEYUP") << ". " <<
+ "SDL_event.key.keysym.sym = " << (int)SDL_event.key.keysym.sym << "; " <<
+ "Irrlicht key = " << (int)key << "; assumed char = " << irrevent.KeyInput.Char << std::endl;
postEventFromUser(irrevent);
} break;
When pressing Shift + 7, I get the following output:
1073742049 =
While searching the SDL issue tracker, I found this: libsdl-org/SDL#3559 |
With the changes to SDL3 coming from libsdl-org/SDL#3559, SDL3 makes it easy to reimplement the behavior of other Irrlicht devices in CIrrDeviceSDL. I have a version that fixes the slash issue here: grorp@48db7e5 (please note that I didn't do the SDL2 -> SDL3 migration properly) (the numpad +/- keys are still not working properly, haven't investigated) |
Numpad +/- fixed by #14780. |
So to clarify: the issues remaining are:
Anything else? |
The SDL people have done more fancy things to key input for SDL 3 btw: libsdl-org/SDL#10156 |
Not just the backtick key. Umlaut keys (e.g.
Dead keys appear to be mapped to the "Left Button" (left mouse button). |
Related: #14940 |
Looks fine on Mac OS, both in the Minetest build for Intel and ARM. I tested two keyboard layouts where "/" required normal key press and shift + key press. Works as expected in both states. |
Our macOS builds don't use SDL by default. To reproduce the issue, you have to build with |
Oh yes. In the Minetest built on Mac with |
Opening the chat with
/
is broken on my keyboard setup. I write it withshift
+7
. It's instead just interpreted as7
(= select item in horbar).The text was updated successfully, but these errors were encountered: