cancel
Showing results for 
Search instead for 
Did you mean: 

Read state of caps lock from keyboard

oeliks
Senior

keyboard-pc-usb-stm32

Is it possible to read state of capslock on/off with stm?

Using HAL and cubemx HID configuration.

I can send report. But how to receive report - status?​

1 ACCEPTED SOLUTION

Accepted Solutions

> Is it possible to read state of capslock on/off with stm

No, but this is regardless of whether "with stm" or without. The USB keyboard is completely state-less - it reports which keys are currently pressed, and CAPS LOCK is not different from any other ordinary key. It's the host which has to maintain the CAPS-toggle state, if it implements that at all.

Similarly for LEDs - there is no way to read out the state of LEDs from the keyboard (it even may not implement the LEDs at all). This is even explicitly stated in the standard (HID1.11) in Appendix C:

Synchronization between LED states and CAPS LOCK , NUM L OCK , SCROLL L OCK ,

COMPOSE , and KANA events is maintained by the host and NOT the keyboard

Read the respective USB HID standard documents.

JW

View solution in original post

3 REPLIES 3

> Is it possible to read state of capslock on/off with stm

No, but this is regardless of whether "with stm" or without. The USB keyboard is completely state-less - it reports which keys are currently pressed, and CAPS LOCK is not different from any other ordinary key. It's the host which has to maintain the CAPS-toggle state, if it implements that at all.

Similarly for LEDs - there is no way to read out the state of LEDs from the keyboard (it even may not implement the LEDs at all). This is even explicitly stated in the standard (HID1.11) in Appendix C:

Synchronization between LED states and CAPS LOCK , NUM L OCK , SCROLL L OCK ,

COMPOSE , and KANA events is maintained by the host and NOT the keyboard

Read the respective USB HID standard documents.

JW

Not applicable

Actually yes. It is possible to read and write memory from the keyboard LEDs. I just tested it, see the code:

https://community.st.com/s/question/0D53W00000FNNDF/usb-host-keyboard-output-report-how-to-control-the-3-leds-numlock-caps-lock-and-scroll-lock-status

Actually yes. It is possible to read and write memory from the keyboard LEDs. I just tested it, see the code:

https://community.st.com/s/question/0D53W00000FNNDF/usb-host-keyboard-output-report-how-to-control-the-3-leds-numlock-caps-lock-and-scroll-lock-status