简体   繁体   中英

USB-HID data initialisation

I configured the USB driver at my RPi4 as a USB-Slave device and set the USB descriptors in the RPI4 to enumarate as a ordenary USB keyboard. Therefore I wrote a Java program on the RPi4 which read-in the keyboard states from the USB driver (Scroll-Lock, Num-Lock, and so on)

This works great. I can plug in the RPi4 at any PC. If I hit the Num-Lock key at the hardware- keyboard my RPi recognizes the change at the same time and shows the same state in the Java programm as the led at the hardware keyboard.

But how the heck does initialisation work for such states? I did not find any hint at the USB documentation upto now.

  • When Num-Lock on the PC is "on" (true) and I plug in the RPi the state in my Java program stays "false". (incorrect)
  • At the moment I hit the Num-Lock key (PC change to false), my programm gets the update and shows "false", too. (correct)
  • At the moment I hit the Num-Lock key again (PC change to true), my programm gets the update and shows "true", too. (correct)

This event-triggered data flow from PC to RPI4 works as intended and is absolutely right. But how can I trigger in this USB data flow model a "manual update" for my program internal states at the startup of my Java program?

To detect the state of the numlock/capslock/scrolllock you need to read the values of the respective LED lights report that the host sends to the device soon after it is plugged in.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM