rust-embedded-community / pc-keyboard

PS/2 Keyboard Decoder in Rust
Apache License 2.0
96 stars 28 forks source link

Implement USB HID scancodes ? #44

Open CHiPs44 opened 7 months ago

CHiPs44 commented 7 months ago

It's perhaps a silly question, but should this library implement USB HID scan codes, too?

Feel free to close this ASAP if I'm completely out of subject.

thejpster commented 7 months ago

No it's a great question. I have wondered this, but I personally have not needed such support so I didn't write it.

It makes sense though as it's a well defined language-agnostic standard that sits alongside ScanCode Set 1 and Set 2. One issue might be though that the modifiers come as a bitfield in USB HID rather than individual keystrokes, so you'd need an API to set them all manually before feeding in key codes. HID again only gives you "is currently down" so you need a mechanism to remember what was down last time and pop up anything that is not still down (and press anything that just went down). So it's not just as easy as copying Set 2 and changing the numbers.

CHiPs44 commented 7 months ago

Thanks!

It seems there are many libraries (even in Rust) handling USB HID devices, so inspiration or inclusion should not be too cumbersome.