hathach / tinyusb

An open source cross-platform USB stack for embedded system
https://www.tinyusb.org
MIT License
4.93k stars 1.03k forks source link

Add hook to allow for external host class drivers #2685

Closed harbaum closed 3 months ago

harbaum commented 3 months ago

Related area

Allow developers to provide custom class drivers

Hardware specification

all

Is your feature request related to a problem?

I'd like to add xbox controller support to the tuh. The xbox controllers are vendor specific and the vendor class driver seems broken: https://github.com/hathach/tinyusb/issues/2684

Describe the solution you'd like

Allowing to add custom class drivers to usbh_class_drivers[] in usbh.c would allow custom class drivers without the need to change/add anything to tinyusb. A simple solution may to allow the user to statically add an entry to this list via some #define in tusb_config.h

There's some discussion about this at https://github.com/hathach/tinyusb/discussions/1929. But that approach would IMHO only work if the device would report as a hid class device which the xbox controllers don't.

There seem to be variants of tinyusb that implement something like this as this code snipped suggests: https://github.com/RT-Thread-Studio/sdk-bsp-ra8d1-vision-board/blob/master/projects/usb/vision_board_tinyusb_xpad/board/tinyusb/host_register.c

I have checked existing issues, dicussion and documentation

Ryzee119 commented 3 months ago

You've been able to hook in your own USB host drivers since https://github.com/hathach/tinyusb/pull/2222

I made this a while ago but I try keep it up to date you https://github.com/Ryzee119/tusb_xinput

harbaum commented 3 months ago

Excellent. Your driver works as advertised ... thanks a lot ...