#usb-hid #hid #usb-device #usb #keyboard #mouse #usb-host

no-std usbd-human-interface-device

Batteries included embedded USB HID library for usb-device. Includes concrete Keyboard (boot and NKRO), Mouse, Joystick and Consumer Control implementations as well as support for building your own HID classes.

15 releases

0.5.0 Apr 13, 2024
0.4.5 Dec 29, 2023
0.4.4 Nov 17, 2023
0.4.3 Jul 14, 2023
0.2.1 Jun 12, 2022

#141 in Embedded development

Download history 17/week @ 2024-07-20 62/week @ 2024-07-27 11/week @ 2024-08-03 27/week @ 2024-08-10 6/week @ 2024-08-17 31/week @ 2024-08-24 91/week @ 2024-08-31 40/week @ 2024-09-07 25/week @ 2024-09-14 104/week @ 2024-09-21 66/week @ 2024-09-28 36/week @ 2024-10-05 10/week @ 2024-10-12 6/week @ 2024-10-19 20/week @ 2024-10-26 7/week @ 2024-11-02

51 downloads per month
Used in owotility

MIT license

175KB
4.5K SLoC

Library build Example build Security audit

crates.io docs.rs

Batteries included embedded USB HID library for usb-device. Includes Keyboard (boot and NKRO), Mouse, Joystick and Consumer Control implementations as well as support for building your own HID classes.

Tested on the RP2040, but should work on any platform supported by usb-device.

Devices created with this library should work with any USB host. Tested on Windows, Linux, MacOS and Android.

Note: Managed interfaces that support HID idle, such as NKROBootKeyboardInterface and BootKeyboardInterface, require the UsbHidClass::tick() method calling every 1ms.

Features

  • Keyboard - boot compliant keyboard, boot compliant NKRO(N-Key Roll Over) keyboard
  • Mouse - boot compliant mouse, boot compliant mouse with scroll wheel and pan
  • Joystick - two axis joystick with eight buttons
  • Consumer Control - Media control device, generic consumer control device
  • Enums for the Consumer, Desktop, Game, Keyboard, LED, Simulation and Telephony HID usage pages
  • Support for multi-interface devices
  • Support for HID idle and HID protocol changing
  • Support for both single and multi report interfaces
  • Compatible with RTIC

Examples

See examples for demonstrations of how to use this library on the RP2040 (Raspberry Pi Pico)

Road map

  • Examples and testing for other micro-controllers such as the SAM D2x family.
  • Support for host device remote wakeup

Contact

https://github.com/dlkj/usbd-human-interface-device/issues

License

Distributed under the MIT License, see LICENSE.

Contributing

Contributions are welcome via pull requests

Acknowledgements

This library was inspired by existing rust USB libraries and the following sources of USB information:

Dependencies

~4MB
~80K SLoC