6 releases

0.0.7 Dec 8, 2023
0.0.6 Apr 26, 2023
0.0.5 Jun 30, 2020
0.0.4 Apr 22, 2020

#166 in Unix APIs

Download history 937/week @ 2024-07-21 838/week @ 2024-07-28 801/week @ 2024-08-04 653/week @ 2024-08-11 648/week @ 2024-08-18 877/week @ 2024-08-25 1817/week @ 2024-09-01 921/week @ 2024-09-08 665/week @ 2024-09-15 707/week @ 2024-09-22 1404/week @ 2024-09-29 852/week @ 2024-10-06 817/week @ 2024-10-13 588/week @ 2024-10-20 560/week @ 2024-10-27 523/week @ 2024-11-03

2,603 downloads per month
Used in 3 crates

MIT/Apache

25KB
569 lines

uhid-virt

uhid-virt provides a safe wrapper around uhid-sys

Forked from uhid-fs, so what changed? Removal of ArrayVec dependency, and attempts to write in to borrows slices rather than creating and cloning new vectors everywhere. Where possible it tries to be an almost drop-in replacement for tokio_linux_uhid.

What is UHID?

UHID lets you write userspace drivers for HID devices in Linux. No need for a kernel module, just run your program and you can register an HID device.

There are a lot of things you can do with this, to name a few:

  • Forwarding or emulating keypresses through control daemon
  • Emulate a mouse/keyboard for shortcuts/macros/task automation (independent of X11/Wayland/system console)
  • Add support for HID devices that are only supported on Windows / other platforms
  • Write drivers for a new HID device (i.e. DIY Arduino water touchpad)

Kernel Docs Description

UHID allows user-space to implement HID transport drivers. Please see hid-transport.html for an introduction into HID transport drivers. This document relies heavily on the definitions declared there.

With UHID, a user-space transport driver can create kernel hid-devices for each device connected to the user-space controlled bus. The UHID API defines the I/O events provided from the kernel to user-space and vice versa.

See the Kernel UHID doc page for a full explanation of the mechanics.

Examples

See the example folder. Sending a newline will make the mouse move to the right.

See flukejones/rog-core and sameer/gearvr-controller-uhid for a real-world use cases.

Dependencies

~0.3–2.6MB
~53K SLoC