-
Notifications
You must be signed in to change notification settings - Fork 15
Add support for reading the device path for a function #23
Description
I stumbled across this crate while looking into related resources. I previously implemented something similar for creating HID gadget devices (specifically for emulating Nintendo Switch gamepads) in this repo. While looking at your examples to see if I could replace my implementation with your crate I noticed that your printer example hardcodes the device file:
usb-gadget/examples/printer.rs
Line 22 in d5823aa
| const DEV_PATH: &str = "/dev/g_printer0"; |
My code supports creating multiple HID functions per gadget, so I added code to read the device major and minor numbers out of the configfs function path under dev:
https://github.com/luser/pizero-gadget-gamepads/blob/73613817d1caf508c79a0f49ffc7ef3af990b116/src/hid_gadget.rs#L124-L134
This should be generalizable to other device types since the major and minor numbers are available there. Feel free to use my code if it would be useful!