Home

Awesome

360-raw-gadget

360 controller raw USB gadget. (WIP)

Initially tried this using functionfs in both python and Rust, but this only worked on *nix hosts. The reason for this is that functionfs/gadgetfs only allows for well-defined USB classes/well-formed descriptors. After the interface descriptor, windows expects a vendor-specific descriptor, which is not supported by functionfs.

Thus, we're using raw-gadget + c here.

(First project using C, so don't judge too hard)

Functionality

For now only the input endpoint is implemented, which allows for controller input to be sent to the host.

Building for Specific Hardware

This project supports a range of hardware configurations, as listed below. You can build the project for your specific device using the appropriate make target.

HardwareBuild TargetDriverDevice
Raspberry Pi Zero (default target)make20980000.usb20980000.usb (dwc2)
Raspberry Pi 4make rpi4fe980000.usbfe980000.usb (dwc2)
Raspberry Pi 5make rpi51000480000.usb1000480000.usb (dwc2)
USB Armory Mk IImake usb-armory-mk22184000.usbci_hdrc.0
Orange Pi PCmake orange-pi-pcmusb-hdrcmusb-hdrc.4.auto
Khadas VIM1make khadas-vim1c9100000.usbc9100000.usb
ThinkPad X1 Carbon Gen 6make thinkpad-x1dwc3-gadgetdwc3.1.auto
NXP i.MX8MPmake nxp-imx8mpdwc3-gadget38100000.usb
BeagleBone Blackmake beaglebone-blackmusb-hdrcmusb-hdrc.0
BeagleBone AImake beaglebone-aidwc3-gadget48380000.usb
EC3380-ABmake ec3380-abnet22800000:04:00.0
Odroid C2make odroid-c2dwc_otg_pcddwc2_a
Generic hardwaremake genericdummy_udcdummy_udc.0

(Table is taken from the raw-gadget repository)

To build for your device, use the corresponding target, for example:

make rpi4

For the Raspberry Pi Zero / Zero 2, you can use the default target:

make

Running

To run the gadget, you need to load the kernel module for raw-gadget and then run the gadget binary.

For the raw-gadget module, you can follow the instructions in the raw-gadget repo, e.g. for raspberry pi's: setup_raspberry-pi.md

After loading the module, you can run the gadget example binary:

sudo ./example

This will run the example function, which activates the A button every second.

For more input control, take a look at the partsnotincluded link in the sources section.

Static lib

If you want to use this in other projects, you can edit the makefile CFLAGS. More info the makefile.

TODO:

Sources

useful links/sources:

More sources (old):