Skip to main content
oeliks
Associate III
Dec 30, 2019 2:57 PM UTC
Solved

Read state of caps lock from keyboard

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?​

​

​

​

This topic has been closed for replies.
waclawek.jan
waclawek.janBest answer
Super User
Dec 30, 2019 6:02 PM UTC

> 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

3 replies

waclawek.jan
waclawek.janBest answer
Super User
Dec 30, 2019 6:02 PM UTC

> 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

Nov 20, 2021 5:04 AM UTC

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

Nov 20, 2021 5:03 AM UTC

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