Rust Library for the USB HID protocol. Based on zero-hid.
Compatible | Board | Port(s) |
---|---|---|
ESP32 | ||
Raspberry Pi Pico | ||
✅ | Raspberry Pi Zero 2w | 🎩 |
Legend: ✅ Compatible, ❌ Incompatible,
⚠️ Untested. Ports: 🎩 USB Hat, 📡 USB Port.
- Keyboard.
- Keydown.
- Keyup.
- Type string.
- Mod keys.
- Mouse.
- Move to.
- Move relative.
- Left click.
- Right click.
- Middle click.
- Scroll Wheel.
- Mass storage.
- Write file.
- Read file.
- Delete file.
- Ethernet.
- Send packet.
- Receive packet.
- Gamepad.
- Button press.
- Button release.
- Joystick move.
- Printer.
- Print text.
- Print image.
Before using this library, you need to install a virtual USB HID device on your board.
# Clone the repository
git clone https://github.com/sammwyy/usbhid.git
# Go to the installer directory
cd usbhid/hid
# Install the virtual device
chmod +x install.sh && sudo ./install.sh
⌨ Keyboard:
use usbhid::{keyboard:Keyboard, device::Device};
fn main() {
// Install your virtual device before (See documentation)
let mut device = Device::new("/dev/hidg0");
let mut keyboard = Keyboard::new(device, "us");
keyboard.type_string("Hello World!");
}
🖱 Mouse:
use usbhid::{mouse:Mouse, device::Device};
fn main() {
// Install your virtual device before (See documentation)
let mut device = Device::new("/dev/hidg1");
let mut mouse = Mouse::new(device);
mouse.move_to(100, 100);
mouse.left_click();
}
Contributions, issues and feature requests are welcome! Feel free to check issues page.
Give a ⭐️ if this project helped you! Or buy me a coffeelatte 🙌 on Ko-fi