Crates.io | usbhid |
lib.rs | usbhid |
version | 0.1.0 |
source | src |
created_at | 2023-11-07 02:45:45.519694 |
updated_at | 2023-11-07 02:45:45.519694 |
description | A library for interacting with USB HID devices. |
homepage | |
repository | https://github.com/sammwyy/usbhid |
max_upload_size | |
id | 1027537 |
size | 27,222 |
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.
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