examples/host/hid_controller/README.md
A USB host example that reads a USB game controller / gamepad (a HID device) and prints its inputs over the debug UART.
CFG_TUH_HID) and, on mount, prints the device's VID/PID.Note: events are only shown for the explicitly supported controllers above; other HID devices enumerate but their reports are not decoded.
The board must support USB host mode (provide VBUS to the connected device); some boards need an external USB-A port / host adapter.
Notable tusb_config.h settings:
#define CFG_TUH_ENABLED 1
#define CFG_TUH_HUB 0
#define CFG_TUH_DEVICE_MAX (3*CFG_TUH_HUB + 1)
#define CFG_TUH_HID (3*CFG_TUH_DEVICE_MAX)
#define CFG_TUH_HID_EP_BUFSIZE 64
CMake:
mkdir build && cd build
cmake -DBOARD=raspberry_pi_pico ..
cmake --build .
Make:
make BOARD=raspberry_pi_pico all
Plug a supported USB game controller (e.g. a Sony DualShock 4) into the board's USB host port. Move the sticks and press buttons — the changes are printed on the debug UART, and squeezing the L2/R2 triggers makes the controller rumble.