Using a Leonardo, I know I can send a 'Caps Lock' key to the host computer with:
Keyboard.write( KEY_CAPS_LOCK );
But do a get a response? I would like the onboard LED (pin 13) to reflect the 'Caps Lock' status.
I could track the toggle of the lock in my code but that would not help if the lock is changed by a different keyboard/HID device. (is that redundant, Human Interface Device device?)
I appreciate everyone's concern about my Caps Lock being turned on by accident. I happen to like using my Caps Lock.
My interest is knowing the status of the Caps Lock, as well as the Num Lock, the Scroll Lock and any other status information that a keyboard (or mouse) can receive.
The communications between the keyboard and compute has always be two way, however, it don't see it in the core Arduino code. Is it there and I am missing it?
My interest is knowing the status of the Caps Lock, as well as the Num Lock, the Scroll Lock and any other status information that a keyboard (or mouse) can receive.
The keyboard itself is maintaining that status. I have an external keyboard on my notebook. If I press the caps lock key on it, the corresponding LED turns on and off. If I press the caps lock on the notebook the keyboard doesn't get any information about thats. If I hit it on both keyboards, both LEDs turn on but the computer didn't activate the functionality for any of them.
So if your Leonardo is the keyboard it has to keep track of the caps lock key usage and display the status according to the tracked usage of that key.
pylon:
The keyboard itself is maintaining that status.
That's not my understanding. The LEDs in the keyboard are under the control of the host computer. It might appear that the LED control is something that happens spontaneously within the keyboard, but it isn't; the host computer is what controls whether capslock is engaged and it will be updating this in response to the capslock keypress events and sending LED commands to the keyboard via USB. It is up to the implementation of the USB slave software whether it makes those commands available to your sketch - I'm not familiar with the USB HID implementation used on the Leonardo so I don't know whether it does.
pylon:
The keyboard itself is maintaining that status. I have an external keyboard on my notebook. If I press the caps lock key on it, the corresponding LED turns on and off. If I press the caps lock on the notebook the keyboard doesn't get any information about thats. If I hit it on both keyboards, both LEDs turn on but the computer didn't activate the functionality for any of them.
So if your Leonardo is the keyboard it has to keep track of the caps lock key usage and display the status according to the tracked usage of that key.
I do not doubt what you are seeing. However, it is my understanding that if the status of the Caps Lock, Num Lock, ... changes, then the OS should inform all attached keyboards. That is true if the keyboard is a PS/2 attached keyboard or a USB HID.
This may be one of those things that is not done as well as it should be.
jumpjack:
It looks like message #7 from this thread solves this issue... although I don't know how to implement it in my system...
That contains a 'diff' file used to patch the source files. Reply #11 in the thread has the pre-patched version of the two files. They are from 2014 so they may not match the latest sources. I'd compare them to the latest and make sure all of the latest bug fixes and features are included.