This is an example application for the Raspberry Pi Pico (RP2040) that demonstrates reading an XInput controller and outputting/presenting as an XInput controller simultaneously.
I use a basic Pico board and had to solder wires from a female usb type-a connector to pins on my board to connect a controller.
Instead, you can get a board from Adafruit that already has a connector attached. https://www.adafruit.com/product/5723
This application reads a report from a physical XInput controller connected to the Pico and immediately sends a corresponding report to the host computer, effectively "passing through" the inputs from the controller to the PC. Latency should be minimal, though I have no gear to test true end to end latency. However, using a polling rate tester I can still achieve my controller's native polling rate using this device.
- TinyUSB: An open-source cross-platform USB stack.
- Pico-PIO-USB: A library that allows the Pico's PIO state machines to act as a USB host port.
- TinyUSB XInput Host Driver: A third-party driver for handling XInput devices in host mode.
- TinyUSB XInput Device Driver: My class driver for handling XInput in device mode. I developed it alongside this but eventually separated it into its own project
While this application doesn't have much practical use on its own, it serves as a foundation for more advanced projects such as an input remapper. The code may not be perfect but I wanted to learn how to do this and also have a simple template I can build from or have others use as a base. There are some popular projects that something similar (as in simultaenous host/device controller handling) such as the GP2040-CE Firmware, but it's decently sized codebase so it can be difficult for a beginner (like me) to learn from. So I hope this helps someone.