SDL: Use scancodes for keybindings#14964
Conversation
7a62dab to
8fb2682
Compare
|
Very nice work y5nw! Thanks for picking this up so quickly |
Oops, I wrote some boilerplate code to allow other devices to pass scancode information but did not actually implement scancode passing/handling for devices other than SDL. Will fix. |
|
Testing needed. Note that binding to Shift+[Key] is also removed for non-SDL devices and non-SDL devices practically still use keycodes instead of scancodes. |
Would it not make sense to change the defaults when built with SDL? We don't need to worry about breaking user configs created using a |
This is defined in the existing keycode map: In the future (i.e. after fully switching to SDL), this map should ideally be refactored to drop
Yes, this is a result of
On a second thought, this would make sense. I have added this in a later commit now. That said, I have chosen to keep F1, F2, etc as keycodes as I do not see any reason to use scancodes for those (and such keys usually have a scancode anyway). (I only skimmed through the |
|
I would love to backport this one to 5.9.0, so we can have proper SDL 2 for Linux distros (and we can run Minetest nicely on the phones). If I would ask if it would be possible to keep this MR without behavior changes when using SDL 2 and drop anything which changing behavior into followup MR. Thank you for addressing it so quickly! |
The PR in itself is intended to bring a (potentially breaking) behavior change: switching from SDL keycodes to scancodes, so I don't think it would make much sense to split this PR specifically. My intention with this PR is to have this merged immediately before/after creating a hard dependency on SDL, as support for the non-SDL device is (at least) partly broken by this PR anyway and it would therefore not make sense to ship a release with a non-SDL device with breaking changes only to break things again in the release after that. The result of this intention is that the code changes are relatively (in comparison to another approach I attempted) small and simple (quite some things can be removed without much pain in a post-SDL refactor) but at the cost of partly breaking non-SDL devices. |
|
We're planning on releasing much more frequently, on a regular interval of every 2-3 months rather than 6-9 months. The idea is to release on a date rather than waiting for certain features to make it in. If this gets in soon then we can release 5.10.0 with SDL2 in October. There's also an argument to release 5.10 sooner than that if we finish all the SDL2 required changes We cannot backport this to 5.9.1 with our version scheme, it would have to be 5.10.0 |
amazing, that sounds like very good news to me! :) If the new release comes soon after the SDL2 testing and switch, that would help the effort of bringing more users to mobile Linux platforms by a lot (X11 is serious pain on mobile). Good games always help 😉 |
|
@y5nw rebase needed |
appgurueu
left a comment
There was a problem hiding this comment.
Took a look at the code (looks pretty good overall), haven't tested so far. Thanks for working on this.
This reverts commit 1b72dc3. Review: luanti-org@1b72dc3#r1989986592
Co-authored-by: SmallJoker <SmallJoker@users.noreply.github.com>
|
My review still holds. The changes look good. 👍 |



This PR makes Minetest use scancodes for keybindings.
Make Minetest use scancodes (instead of keycodes) for key bindings.
The SDL scancode is passed to
SKeyInput::SystemKeyCode. TheKeyPressclass is modified to be basically a wrapper around this.Yes - SDL.
This was discussed recently.
Related: #12507 (new default key), #14545, #14874 (allows people to continue using e.g. Shift+7 if they want to).
Documentation update: luanti-org/docs.luanti.org#211
To do
This PR is ready for review.
AC_BACKkeys not working.std::variant) for keypresses from non-keyboard input (mouse, joystick, etc.)KEY_OEM_*keys to scancodes directly. (See note below)The current approach no longer requires changing non-SDL
IrrlichtDevices.KeyPressand event handlingKeyPressIrrlichtDevices:std::hash<KeyPress>and replaceKeyListwithstd::unordered_set<KeyPress>SDL_SCANCODE_x). (Useful for Support custom key binds (with keyboard and touchscreen support) #12488) Note that this requires Luanti (not just Irrlicht) to have access to SDL headers.How to test
ü, and dead keys). Observe that the keybinding (in terms of scancodes) is the same after switching to a different layout.Notes
KeyPressis fully dependent on the Irrlicht device.IrrlichtDevicewhich is not available in unittests.