BLE-Gamepad-Client
This library enables connecting BLE (Bluetooth Low Energy) gamepads to ESP32 boards. Supported gamepads include the Xbox Wireless Controller and the Steam Controller.
Arduino Library
- Open Arduino Library Manager: Tools -> Manage Libraries.
- Search for
BLE-Gamepad-Clientand install it.
PlatformIO dependency
Add the following line to the lib_deps option of platformio.ini file.
tbekas/BLE-Gamepad-Client@^0.11.0
Example usage
#include <Arduino.h>
#include <BLEGamepadClient.h>
XboxController controller;
void setup(void) {
Serial.begin(115200);
controller.begin();
}
void loop() {
if (controller.isConnected()) {
XboxControlsState s;
controller.read(&s);
Serial.printf("lx: %.2f, ly: %.2f, rx: %.2f, ry: %.2f\n",
s.leftStickX, s.leftStickY, s.rightStickX, s.rightStickY);
} else {
Serial.println("controller not connected");
}
delay(100);
}