Switch Pro Controller Host Example#
This example reads a Nintendo Switch Pro controller (NS1) plugged into the
ESP32-S3’s native USB port in host mode. espp::UsbHost opens it as a HID
device, and espp::SwitchProHost runs the USB handshake that starts it, reads
its stick calibration, lights the player 1 LED, and decodes its input reports
into espp::GamepadState, which the example logs. The triggers rumble the
controller (ZL: the left grip, ZR: the right).
How to use the example#
Hardware Required#
An ESP32-S3 (or -S2 / -P4) board whose native USB port can source VBUS to the controller (a USB-A host port, or an OTG adapter with power), and a Nintendo Switch Pro controller with a USB-C cable. On the ESP32-S3 the console runs on UART0 (the native USB port is the host), so monitor it with a UART adapter.
Build and Flash#
idf.py -p PORT flash monitor
(To exit the serial monitor, type Ctrl-].)
Example Output#
I (1234) Switch Pro Host: Starting the Switch Pro controller host example
I (2345) Switch Pro Host: Pro controller connected: 'Pro Controller'
I (2600) Switch Pro Host: Pro controller running
I (2700) Switch Pro Host: GamepadState{buttons: [east], left_x: 0, ...}