This library enables connecting BLE (Bluetooth Low Energy) gamepads to ESP32 boards. Currently, only the Xbox Wireless Controller is supported.
PlatformIO dependency
Add the following line to the lib_deps option of platformio.ini file.
tbekas/BLE-Gamepad-Client@^0.3.2
Example usage
#include <Arduino.h>
#include <BLEController.h>
void setup(void) {
}
void loop() {
}
delay(100);
}
Definition BLEController.h:9
bool begin()
Initializes a controller instance and NimBLE stack if it's not already initialized.
Definition BLEController.cpp:22
bool isConnected() const
Is controller connected to the board.
Definition BLEController.cpp:54
void readControls(BLEControlsEvent &event) const
Read the controls state from the connected controller.
Definition BLEController.cpp:104
Definition BLEControlsEvent.h:5
float leftStickX
Left stick deflection along the X-axis. Takes values between -1.0 and 1.0. No deflection should yield...
Definition BLEControlsEvent.h:26
float leftStickY
Left stick deflection along the Y-axis. Takes values between -1.0 and 1.0. No deflection should yield...
Definition BLEControlsEvent.h:34
More examples
Checkout the code examples in the examples directory.
Supported gamepads
Xbox One Wireless Controller (model 1708)
Pairing instructions are the same as for model 1914. If controller is not pairing, you probably need to update the controller's firmware to version 5.x using these instructions.
Xbox Series S/X Wireless Controller (model 1914)
Pairing instructions:
- Turn on your controller by pressing the Xbox button.
- Press and hold the controller’s pair button for 3 seconds, then release.
Acknowledgments