-
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: Use scancodes for keybindings #14964
base: master
Are you sure you want to change the base?
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took a look at the code (looks pretty good overall), haven't tested so far. Thanks for working on this.
Future steps, as proposed:
|
+1. Although I would prefer having this in a different PR. (Also: do we have code to check whether the user upgraded from a preivous version? Or would we simply check whether the user has settings based on keycodes?)
Agreed. The current numeric scancodes are a temporary/fallback solution anyway; I would personally prefer naming keys based on SDL scancodes as such names are IMO much easier to work with. (Note that SDL renamed certain scancodes from SDL2 to SDL3.)
I sort of did: the modified The main limitation here is that SDL headers are not exposed to Luanti except for Android builds, which limits our ability to use e.g. SDL scancodes directly.
Aside from keeping the PR buildable with non-SDL devices (and without SDL headers, as I mentioned above), the other piece of compat code involves keeping compatibility with keycodes. I am largely not sure whether we want to (at least) attempt to help migrate user settings to scancodescodes. Note that we currently cannot drop
I suppose I will just request a review when I finish some of the cleanup (and rebase). Another idea here is to tag (in what name?) such an SDL build to make users aware of the oncoming change. |
Co-authored-by: Lars Müller <[email protected]>
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
. TheKeyPress
class is modified to be basically a wrapper around this.Fixes Use scancodes for key binding #14940
Yes - SDL.
This was discussed recently.
Related: #8781 (not fully fixed), #12507 (new default key), #12556 (relevant code removed/refactored), #13904, #14545, #14874 (allows people to continue using e.g. Shift+7 if they want to)
To do
This PR is ready for review.
AC_BACK
keys 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
.KeyPress
and event handlingKeyPress
IrrlichtDevice
s:std::hash<KeyPress>
and replaceKeyList
withstd::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
KeyPress
is fully dependent on the Irrlicht device.IrrlichtDevice
which is not available in unittests.