Skip to content

Add support for reading the device path for a function #23

@luser

Description

@luser

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:

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!

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions