libnx
libnx copied to clipboard
Emulating HID with usbds
I want to emulate a HID device using usbds.
The key requirements are:
- Add the HID descriptor to the configuration descriptor. (Done. ✔)
- Implement the GetDescriptor request to return the HID report descriptor.
- Handle SetIdle and other class-specific request.
I’m unable to find how to handle standard control requests(EP0). Could anyone provide guidance or examples on achieving this? Thanks!
https://github.com/switchbrew/libnx/blob/master/nx/include/switch/services/usbds.h#L137-L140
Thanks, but I still don’t really get how to call the interface. Here’s what I’m thinking:
usbDsInterface_CtrlOutPostBufferAsync ==>
waiterForEvent(interface ->CtrlOutCompletionEvent) ==>
usbDsInterface_GetCtrlOutReportData ==>
usbDsParseReportData
If I call it this way, can I get the requests during the enumeration process? Then use the CtrlIn API to reply (like Get Descriptor HID Report – I need to reply with the content of the HID Report Descriptor)?