Skip to content
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

Report accurate state of * lock keys #23

Open
boppreh opened this issue Nov 15, 2016 · 6 comments
Open

Report accurate state of * lock keys #23

boppreh opened this issue Nov 15, 2016 · 6 comments

Comments

@boppreh
Copy link
Owner

boppreh commented Nov 15, 2016

Caps lock, num lock, scroll lock are all toggle modifiers, so if their state is unexpected at the start of the program it'll never be fixed. There should be a way to poll their actual status.

This may be expanded to include other modifiers, so the library starts more ready.

This may require update the functions that handle modifier keys, to take into account 'toggle' keys too.

@glitchassassin
Copy link
Collaborator

glitchassassin commented May 13, 2019

Taking a poke at this tonight to see what it will take. The Windows piece looks easy.

On OSX, caps lock is the only relevant "lock" as num/scroll don't actually have corresponding keyboard states.

The xset command does identify num lock state, e.g. with xset q | grep LED, at least on OSX and I believe on Linux as well. But I'll play around with the keyboardleds sample and try to poll the device itself instead to see if that will work reliably.

edit: xset is installed with XQuartz and isn't part of the standard OSX distribution, so this is not a viable solution on non-Linux platforms.

@glitchassassin
Copy link
Collaborator

Incidentally, investigating this, I've discovered that the current code for OSX doesn't actually toggle the capslock state - it just functions like a shift modifier. A quirk of the API, there's probably another way to actually toggle the state for the device.

@glitchassassin
Copy link
Collaborator

Aha. Carbon.GetCurrentKeyModifiers() will do the trick on OSX.

@glitchassassin
Copy link
Collaborator

Opened PR #263 to track this work. I have Windows and OSX drafted, and I'm spinning up a Linux VM to test the snippets I've found for Linux.

@glitchassassin
Copy link
Collaborator

I was not able to get the keyboardleds sample working consistently in non-TTY terminals (e.g., Gnome Terminal). Instead, I opted to call xset and parse the reported LED Flags. This should work at least for any X-based Linux GUI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants