-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Improve handling of Space key combinations #16645
Conversation
We really need some automated tests for international keyboard layouts, but I have no idea how we can do that. |
We could load any arbitrary HKL with BTW I've been thinking about |
Would that not require that all the keyboard layouts are already installed on the test machine?
Here's an example: On my UK keyboard, And that's not the only modifier that matters. Shift, Alt, and CapsLock can all potentially contribute to how the key is interpreted. |
If the test machine is similar to a standard desktop Windows OS, then all standard layouts should already be installed. You can find the list at const auto hkl = LoadKeyboardLayoutW(L"00000429", KLF_ACTIVATE);
PostMessageW(GetConsoleWindow(), WM_INPUTLANGCHANGEREQUEST, 0, (LPARAM)hkl);
char buffer[1024];
fgets(&buffer[0], 1024, stdin);
UnloadKeyboardLayout(hkl); FYI: If you fail to call
That's such a great example and a great test case too! I don't mind if you don't do this, but I think it would be really helpful for the future if you added this as a comment next to the |
@lhecker Sorry, I forgot to reply so you here. Thank you for the info about the keyboard layouts being preinstalled. That's very useful, and I'm quite keen to try and make some tests for the international layouts now. I can't promise I'll be able to do anything soon, but it's definitely on my TODO list. |
This fixes two issues where the `Space` key wasn't being handled correctly: * Keyboards with an `AltGr`+`Space` mapping were not generating the expected character. * Pressing a dead key followed by `Space` is supposed to generate the accent character associated with that key, but it wasn't doing so. ## References and Relevant Issues These were both regressions from the keyboard refactor in PR #16511. ## Detailed Description of the Pull Request / Additional comments The problem was that we were treating `VK_SPACE` as a "functional" key, which means it gets hardcoded VT mappings which take precedence over whatever is in the keyboard layout. This was deemed necessary to deal with the fact that many keyboards incorrectly map `Ctrl`+`Space` as a `SP` character, when it's expected to be `NUL`. I've now dropped `VK_SPACE` from the functional mapping table and allow it be handled by the default mapping algorithm for "graphic" keys. However, I've also introduced a special case check for `Ctrl`+`Space` (and other modifier variants), so we can bypass any incorrect keyboard layouts for those combinations. ## Validation Steps Performed I couldn't test with a French-BEPO keyboard layout directly, because the MS Keyboard Layout Creator wouldn't accept a `Space` key mapping that wasn't whitespace. However, if I remapped the `AltGr`+`Space` combo to `LF`, I could confirm that we are now generating that correctly. I've also tested the dead key `Space` combination on various keyboard layouts and confirmed that that is now working correctly, and checked that the `Ctrl`+`Space` combinations are still working too. Closes #16641 Closes #16642 (cherry picked from commit ec91be5) Service-Card-Id: 91738880 Service-Version: 1.20
Summary of the Pull Request
This fixes two issues where the
Space
key wasn't being handledcorrectly:
AltGr
+Space
mapping were not generating theexpected character.
Space
is supposed to generate theaccent character associated with that key, but it wasn't doing so.
References and Relevant Issues
These were both regressions from the keyboard refactor in PR #16511.
Detailed Description of the Pull Request / Additional comments
The problem was that we were treating
VK_SPACE
as a "functional" key,which means it gets hardcoded VT mappings which take precedence over
whatever is in the keyboard layout. This was deemed necessary to deal
with the fact that many keyboards incorrectly map
Ctrl
+Space
as aSP
character, when it's expected to beNUL
.I've now dropped
VK_SPACE
from the functional mapping table and allowit be handled by the default mapping algorithm for "graphic" keys.
However, I've also introduced a special case check for
Ctrl
+Space
(and other modifier variants), so we can bypass any incorrect keyboard
layouts for those combinations.
Validation Steps Performed
I couldn't test with a French-BEPO keyboard layout directly, because the
MS Keyboard Layout Creator wouldn't accept a
Space
key mapping thatwasn't whitespace. However, if I remapped the
AltGr
+Space
combo toLF
, I could confirm that we are now generating that correctly.I've also tested the dead key
Space
combination on various keyboardlayouts and confirmed that that is now working correctly, and checked
that the
Ctrl
+Space
combinations are still working too.PR Checklist