macos: Send CapsLock keyboard events
On macOS, no WindowEvent is sent when CapsLock is pressed.
Actually there is a trick: only the CapsLock state change is sent by macOS, not the state of the keyboard key. The press/release cycle is simulated to fake the presses.
Checklist
- [ ] Tested on all platforms changed
- [ ] Added an entry to
CHANGELOG.mdif knowledge of this change could be valuable to users - [ ] Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
- [ ] Created or updated an example program if it would help users understand this functionality
- [ ] Updated feature matrix, if new features were added or implemented
About how CapsLock should be exposed, I had a look at SDL implementation: it seems that it is a modifier and an event. With the fake Press/Release trick too.
I made some tests with IOKit. With this API it is possible to catch the real key state, but it requires to grants extra permissions to the application in the Preference Pane, which isn't a correct solution.
It seems that it is possible to get events from Quartz, but I don't know the limitations and if it could solve this issue.
If you're still interested in this, could you rebase or test on the latest master? We were changing the keyboard API, so that's why it was left unnoticed. Now we have a dedicated key for CapsLock and such and generally report the key downstream.
I tried to integrate my commit in the new macOS codebase, but currently it looks like a big hack even if it works. I'm still struggling to understand the update_modifiers() logic.