Xbox Host Example#
This example reads wired Xbox controllers plugged into the ESP32-S3’s native USB port in host mode: an Xbox 360 controller (or a third-party controller in its X-input mode) and an Xbox One / Xbox Series controller. It logs each controller’s state as it changes, and rumbles it with its triggers (left trigger: the strong motor, right trigger: the weak one).
espp::UsbHost installs the USB Host Library and espp::XboxHost registers
its client alongside it.
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 wired Xbox 360, Xbox One or Xbox Series controller. 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) Xbox Host: Starting the Xbox controller host example
I (2345) Xbox Host: GIP controller connected: 'Microsoft' 'Controller' 045e:0b12, player 1
I (2400) Xbox Host: player 1: GamepadState{buttons: [south], left_x: 0, ...}