-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Fix non-latin layout scancodes on Linux, adds access to physical scancodes. #18020
Fix non-latin layout scancodes on Linux, adds access to physical scancodes. #18020
Conversation
6fe1e85
to
af13bc6
Compare
I would like to know why remapping was changed for OSX only, did we not have remapping in other platforms? The idea of the scancodes is that they are keyboard dependent, there is no use case IMO for physical (qwerty) keycodes. |
All platforms have remapping, macOS was only one limited to some hardcoded mappings, #17827 changes mapping from hardcoded to generated for current OS keyboard layout. Edit: Summary for remapping on different platforms Windows: Linux/X11: masOS: |
Don't know, for common game keys like WASD I would care only about physical location not letters on the keys. Most GUI frameworks I have used and libs like SDL and glfw provide both scancode for physical location and keycode for layout remapped key. |
037191a
to
2c9413f
Compare
Letting you map to the physical keys is a(n old) dream come true! This branch is a bit buggy when adding a remapped key or changing existing key mappings (as of I always have things mapped to dvorak keys while developing a game and change them out later once I add configuration. This makes it particularly complicated when sharing prototypes with people before this point, as I have to remap everything just for them, and then back. |
2c9413f
to
2959519
Compare
Whats the status of this? |
Let me explain why this should not be merged.
Physical scancode (which is pretty much the US keyboard code) is undesired, as it's non standard. |
The suggested feature to get something like this working, would be to add a function to OS:
that translates an IBM scancode to godot latin key, and a backwards one. This way, common Input functions can still be used like:
or something similar, a better name needs to be found. |
It is standard. X11 and macOS keypress events provide ONLY physical key codes. Windows events have both physical and remapped key codes. |
This has currently build errors after rebase, but they are just two lines which aren't used anymore it seems. I think this is really nice and should be merged after it is fixed. I don't think all of these are problems of this PR, but it'd be nice if they would be fixed.
Here is a img of different physical layouts to show what might be missing on other layouts. |
All keyboards have a way to input latin characters, but not all keys on every keyboard have base latin char associated with it (see Personally I don't think remapped scan-codes have any use at all, menu shortcuts and other staff implying reference to the specific word should be bound to unicode character instead of scan-code. Everything else should use physical scan-codes, but UI should display character representation for current layout (for this we'll probably need to process OS keyboard layout change event, like
Some scan codes are definitely missing. On macOS media keys doesn't trigger any keypress event at all and I have unknown I prefer to wait until we all get to a consensus before fixing anything, otherwise this work'll be in vain. |
To clarify a bit, I am using Linux Mint MATE and I am using a U.S. QWERTY keyboard, but want to support multiple layouts. I am testing by switching the layout in software. I tend to use Dvorak, so I test with that. It reports the key correctly, but the keys all seem to be tied to a certain keyboard layout when they shouldn't be. In response to Juan: "Physical scancode (which is pretty much the US keyboard code)" This is a little program I made to test this and it is how I came to my conclusions: https://github.com/agameraaron/simple-input-observer/releases/tag/v0.1 |
Just tested to compile this on the current master branch after a rebase, and this diff needs to be applied: diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index 4016009cf..ca0b1490c 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -473,9 +473,6 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even
last_wait_for_key = Ref<InputEvent>();
press_a_key->popup_centered(Size2(250, 80) * EDSCALE);
press_a_key->grab_focus();
-
- device_special_value_label->hide();
- device_special_value->hide();
} break;
case INPUT_MOUSE_BUTTON: {
|
@bruvzg Commit 29595192 doesn't seem to depend on the other two, and would likely be simple to review by itself, so it might be worth splitting in its own PR? As for the other two, I'm very much in favour of giving a way to access a kind of physical scancodes. I just tried the PR and it works great to bind e.g. Some more discussion might be needed regarding how to name and expose the feature, and @reduz still needs to be convinced fully (but he's not too far from it ;)), which is why I suggest to split the 3rd commit for now. |
Moving to 3.2 milestone, we're very close to beta for 3.1 and there is still discussion and design changes needed for this PR. |
What we discussed is that we should do something similar as this PR, including the Qwerty scancode (we should call it "us" or "hardware", or "physical" keycode, some people have no idea what qwerty is or how it looks like, also what @Yukitty mentions is not really doable due to modifiers and deadkeys). The idea is that the following should be supported:
Again, apologies for leaving this on StandBy, we did not properly document what we discussed in 2019 so this was lost, we tried to change this in 2020 and now we have a detailed doc for this. |
That's bad idea, keyboard layout is not constant, especially if someone uses non-latin layout, they will probably have at least two layouts "Local" and "English" quickly switchable, and it probably will be switched if app have any text input involved and break input mappings that were loaded with different layout. |
@bruvzg ah, I did not know that and did not come up in the discussion, clearly a product of our ignorance when we discussed it, i guess it then makes full sense to add support for it in InputMap. If this is the case, what would be remaining in this PR for it to be merged? The only suggestion we had remaining is renaming qwerty to physical. |
and given we are breaking compat in 4.x, maybe renaming scancode to keycode, if there is agreement for this (we can use the script converter from 3 to 4 to automatically rename this too?) |
ce48f6a
to
0caab5f
Compare
0caab5f
to
1c1beee
Compare
Thanks for the updates and consideration. I'm glad you're on top of this. 👍 |
|
Add `physical_keycode` (keyboard layout independent keycodes) to InputEventKey and InputMap. Fix non-latin keyboard layout keycodes on Linux/X11 (fallback to physical keycodes).
1c1beee
to
1af06d3
Compare
Thanks a lot! |
[Linux/X11] Fix non-latin keyboard layout scan-codes. (see #17827 comments).
Fallback to physical keycode if layout remapping fails.
Fixes #8039
[Linux/X11, macOS, Windows, UWP]
scancode
renamed tokeycode
, addedphysical_keycode
toInputEventKey
.Layout independent keycode, which represent the physical location on keyboard. (e.g. keys in highlighted locations will produce event with
keycode
=Q, MINUS, K, C
on DVORAK-L layout, andphysical_keycode
=W, A, S, D
on any keyboard layout.)