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
Fixes for macOS scancode implementation #2243
Fixes for macOS scancode implementation #2243
Conversation
I looked into the caps lock issue a while ago and I'm not sure there's a perfect solution for it based on what we get from the OS. I looked at what others do and tried some things myself and only found these options:
The only other keys I can see not working are:
What's the issue you're seeing with the shift key? As far as I can tell the scan codes are always the same whether shift is pressed or not |
The issue is that, when pressing shift, |
I think I fixed all I could fix. Remaining issues:
Regarding issues 2. and 3., fixing it would require detecting if keyboard uses ANSI or ISO layout because virtual key code 0x32 then has a different meaning. See Figure 2-10 in Macintosh Toolbox Essentials. |
iOS build failure should vanish as soon as the feature branch is rebased on 2.6.x thanks to #2263 |
fb27ad3
to
6d4daef
Compare
I just rebased |
f6a4ea1
to
ae855be
Compare
For caps lock if we're happy with it representing the lock status then we can use the method I mentioned above For the other two keys, does the virtual key code matter for scan codes, where we're representing the physical location of the key? We discussed it briefly on discord a while ago and the conclusion was that the one above tab should be Grave and the one next to left shift should be non-US backslash? |
I would not say I would be happy with that, but that's maybe better than nothing. I don't know.
As far as I understand, virtual key code is Apple's equivalent of SFML's scancode. It represents a physical location of a key. But the location of virtual key code 0x32 is above tab for ANSI keyboards and next to left shift for ISO keyboards. Digging a little further, it should be doable to detect which type of keyboard is used and map the correct scancode accordingly. This is what chromium does for example. |
I think I fixed the issue related to §/± (key above tab) and `/~ (key next to left shift). |
With the help of @ChrisThrasher, we could check the key above tab is correctly mapped to Scancode::Grave on ANSI keyboard. |
Should I implement events for caps lock using the lock status? It would get one out of every two events for that key, so it would be half broken, but maybe better than nothing? |
Yeah I'd say it's better than nothing, and also agree this is otherwise ready |
Here it is! Caps lock now generates a key pressed / released event when the corresponding modifier state changes. Rebasing should solve CI failures thanks to fa2e61b. |
6d4daef
to
31e47ed
Compare
2f39f4c
to
7ca9c73
Compare
and actually return it when appropriate.
and make the callback a static method so that buildMappings can be a private method.
That is better than translating to text because several keys can generate the same text.
plus some mapping adjustments.
This is not accurate because modifier state and key state are not the same thing for caps lock, but at least some events are generated instead of nothing.
7ca9c73
to
1706749
Compare
Thanks A MILLION TONS for this! I personally know how much time it takes to dive into stuff like that. ❤️ I'll clean up the commits a bit on the feature branch. |
Thank you @kimci86 for all you've done! I think we're all really excited to see this ship. |
Description
Here are some fixes for the scancode feature implementation for macOS. This PR is related to #1235.
This is a work is progress. I hope to make some more improvements soon but I open this draft PR already so that other contributors do not repeat the same work and can look for other improvements from there.Some issues remain to be fixed:Edit: fixed.
How to test this PR?
Running SFML-Input on macOS