-
-
Notifications
You must be signed in to change notification settings - Fork 21.9k
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 underscore input not working with jp106 keyboard on Wayland platform #99633
Conversation
7f9a3cb
to
19ad91b
Compare
Hi, thank you for the PR! IIRC the physical map is supposed to be mapped to an "average" QWERTY keyboard, hence the missing value, as this keyboard seems to have an extra key if I understand correctly. Because of this, I think that an empty physical key makes sense and it indeed seems that the Wayland backend is being too strict compared to the other ones. I agree with the solution, with a small gotcha. As-is, this patch would allow for Other backends (or at least the X11 one) seem to have a more sophisticated check where they fail if and only if there's no meaning at all, namely with a void physical keycode, keycode and unicode value. I'd recommend to switch to a similar pattern: godot/platform/linuxbsd/x11/display_server_x11.cpp Lines 3651 to 3657 in d09d82d
Note that
It looks like the Qt6 API still has a level of translation when it comes to checking and whatnot, which is needed for cross-compatibility, so that would be offsetting the problem I think. You're free to discuss this with other input people on our RocketChat instance if you want though! https://chat.godotengine.org |
Yes, this definitely should be added, input should have at least some valid value.
Should be OK, anything complex will be handled by IME (
If it's stored in addition to existing values, I do have anything against it, but it probably will be almost never used. |
19ad91b
to
6d43f47
Compare
6d43f47
to
f367a6c
Compare
@Riteo @bruvzg Thank you for your reviews. I understand now that physical_keycoed represents US QWERTY keys and its intended use case. I agree that for this use case, it should represent Godot's key codes, and maintaining perfect key data would be excessive. Finally, following your feedback, I've modified it so that key input fails when keycode is Key::NONE. There still seems to be an issue where physical keycodes don't match between Wayland and X11, #99008, but I will try to work on this in another PR. |
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.
Code looks fine and a quick test on sway shows no regressions!
Thanks! |
This PR fixes an issue where the underscore key can't be typed in the jp106 Japanese input environments on the wayland platform.
Details
Godot's wayland platform correctly converts keysyms using xkb and godot's xkb_keycode_map table.
However, in jp106 environments, when retrieving the physical key, physical_key becomes Key::NONE and input fails because the scancode_map table doesn't have a value set corresponding to underscore (0x61: backslash).
Solutions
Set Key::BACKSLASH to 0x61 in scancode_map
While this solution works correctly in jp106 keymap environments, it breaks the other environments where 0x61 is assigned to different keys.
Allow Key::NONE for physical_key
This seems valid as godot's windows implementation also allows Key::NONE for physical_key.
This PR implements solution 2.
Additional Notes
Godot currently stores scancodes as its internal code, but converting to internal codes can result in loss of information when using keymapping.
In the future, it might be better to store platform native scancodes.
Looking at Qt's implementation, scancode is stored as uint32 type with platform native values.
https://doc.qt.io/qt-6/qkeyevent.html