Skip to content

fhoedemakers/pico-pio-usb-gamepad-test

Repository files navigation

USB Gamepad Test Program for RP2040/RP2350 microcontrollers using PIO USB

This C++ project demonstrates USB gamepad support on RP2040 and RP2350-based boards using PIO USB.
It prints the pressed gamepad buttons to the serial console for easy debugging and testing.

image


Prerequisites

Note:
Program output is printed to the serial console (GPIO-0 and GPIO-1).


Building the Project

For Adafruit Metro RP2350

This is the default config. Connect the gamepad to the usb host breakout pins You need to solder the headers yopurself.

git clone https://github.com/fhoedemakers/pico-pio-usb-gamepad-test.git
cd pico-pio-usb-gamepad-test
git submodule update --init
mkdir build
cd build
cmake ..
make

IMG_8837


For Other RP2040/RP2350 Boards

Building for Raspberry Pi Pico 2 with PIO USB

Example: Building for a Raspberry Pi Pico 2 with PIO-USB enabled on an external USB connector (DP+ on GPIO 16, DP- on GPIO 17):

git clone https://github.com/fhoedemakers/pico-pio-usb-gamepad-test.git
cd pico-pio-usb-gamepad-test
git submodule update --init
mkdir build
cd build
cmake -DBOARD=pico_sdk -DPICO_BOARD=pico2 -DPIO_DP_PLUS_PIN=16 ..
make

IMG_8838

Building for the WaveShare RP2040 PiZero

Example: Building for the WaveShare RP2040 PiZero with PIO-USB enabled on USB port labeled PIO USB (DP+ on GPIO 6, DP- on GPIO 7):

git clone https://github.com/fhoedemakers/pico-pio-usb-gamepad-test.git
cd pico-pio-usb-gamepad-test
git submodule update --init
mkdir build
cd build
cmake -DBOARD=pico_sdk -DPICO_BOARD=pico -DPIO_DP_PLUS_PIN=6 ..
make

Using the Internal USB Connector (Disabling PIO USB)

For boards where you want to use the internal USB controller instead of PIO USB:

git clone https://github.com/fhoedemakers/pico-pio-usb-gamepad-test.git
cd pico-pio-usb-gamepad-test
git submodule update --init
mkdir build
cd build
# For Adafruit Metro RP2350:
cmake -DENABLE_PIO_USB=0 ..
# For Raspberry Pi Pico 2:
cmake -DBOARD=pico_sdk -DPICO_BOARD=pico2 -DENABLE_PIO_USB=0 ..
make

Tested Controllers

See hid_app.cpp for the full list of tested controllers. Confirmed working:

  • Xbox-style controllers (XINPUT)
  • Sony DualShock 4
  • Sony DualSense
  • (More in source)

Additional Notes

  • For wiring details and pin assignments, refer to the board documentation and the CMakeLists.txt options.
  • Some low speed devices like keyboards might not work with PIO usb.
  • Button labels are displayed in the serial console using a NES controller style:
    A, B, Select, Start, Left, Right, Up, Down.
    Other buttons are currently not shown.

Resources

About

A test program for usb game controllers using PIO usb RP2040/RP2350 microcontrollers.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published