chegewara / EspTinyUSB

ESP32S2 native USB library. Implemented few common classes, like MIDI, CDC, HID or DFU (update).
MIT License
475 stars 70 forks source link

Help request - adding specific USB descriptors #16

Open jimnarey opened 3 years ago

jimnarey commented 3 years ago

Hi,

Thank you for the library!

I've got it up and running well and have run some of the examples. I'd like to use it as the basis for an adaptor to use other controllers on an original Xbox but can't work out how to apply a specific set of descriptors to the format/structure used by the library.

The descriptors can be found here but there don't seem to be completely analogous sets of descriptors across the projects.

Can you offer any guidance? I was wondering if the right approach is to subclass HIDgamepad or HIDusb to return these fixed descriptors, rather than generating them as seems (I think?) to take place in ESPTinyUSB::begin(...)?

Any help would be much appreciated! As is probably obvious, I'm still relatively new to C++.

Thanks.

chegewara commented 3 years ago

Hi, sorry for late response, but i dont have a good answer right now, also i dont have much time to study it.

I would suggest to get gamepad class and study how it is init in begin(), it should be enough to replace this line with your descriptor: https://github.com/chegewara/EspTinyUSB/blob/master/src/classes/hid/hidgamepad.cpp#L13

Recently in tinyusb examples has been expanded with Xbox and PS4 descriptors https://github.com/hathach/tinyusb/pull/638