Bluepad32 Documentation
repository·main·Indexed 22 days ago
https://github.com/ricardoquesada/bluepad32A Bluetooth controller 'host' for ESP32, Raspberry Pi Pico W, and Posix systems. It enables support for modern Bluetooth gamepads (including PS5, PS4, Xbox, and Nintendo Switch), mice, and keyboards in embedded or desktop projects. Supports various toolchains including Arduino IDE, ESP-IDF, and Pico SDK, with specific integration guides for ESP32-S3/C3/C6/H2 and Pico 2 W.
What's inside Bluepad32
- Bluepad32 is a library that functions as a Bluetooth host for HID (Human Interface Device) peripherals. It allows microcontrollers to connect to and control modern Bluetooth gamepads, mice, and keyboards. A common use case is controlling a robot using a standard game controller like a Sony DualSense.
What is MightyMiggy
mainMightyMiggy is a version of Bluepad32 specifically designed for the Commodore Amiga line of computers. It allows you to control a joystick and a mouse using a single controller, or two joysticks using two controllers. It supports 2 buttons in joystick mode and 7 buttons in CD32 mode.
Hardware Requirements:
- While it can run on an unmodified Unijoysticle2 board (Rev F), it is recommended to use an alternative version of the board that plugs directly into an Amiga 500 or 1200 to access all features.
- It is backwards compatible with Atari-style joystick interfaces (VIC-20, C64, etc.) via extension cables.
- WARNING: DO NOT use on MSX computers due to different electrical interfaces.
Understand Bluepad32 mouse support limitations
mainMouse support in Bluepad32 is currently a BETA feature. Users should expect bugs and are encouraged to file a bug if they encounter issues.
While any Bluetooth mouse (BLE or BR/EDR) should theoretically work, practical compatibility varies depending on the protocol used.
Bluepad32 Features and Platform Support
mainBluepad32 is designed for low-latency, small-footprint applications on microcontrollers.
Key Features:
- Low latency and small footprint.
- Runs on a single core (CPU0).
- C11 based and Open Source.
Supported Hardware Platforms:
- ESP32 family
- Pico W family
Supported APIs/Frameworks:
- ESP-IDF
- Pico-SDK
- Arduino
- CircuitPython
Supported Bluetooth controllers and devices
mainBluepad32 provides support for a wide range of Bluetooth HID devices, including:
- Gamepads: Sony DualSense (PS5), DualShock 4 (PS4), DualShock 3 (PS3), Nintendo Switch Pro, Nintendo Switch JoyCon, Nintendo Wii U, Nintendo Wii Remote, Xbox Wireless (models 1708, 1914, adaptive), Android controllers, Steam controller, Stadia controller, PC/Windows controllers, 8BitDo, and Atari joysticks.
- Input Devices: Mice and Keyboards.
- Other: iCade and more.
Hardware Compatibility Note:
- Full Support: Original ESP32, Pico W, and Pico 2 W support all listed controllers.
- Partial Support: ESP32-S3, ESP32-C3, ESP32-C6, and ESP32-H2 only support a subset of these controllers.
What is AirLift and how Bluepad32 works with it
mainAirLift is an ESP32-based co-processor module used to provide WiFi or BLE connectivity to a main processor. It is commonly found in Adafruit boards like MatrixPortal M4, PyPortal, PyBadge, and Metro M4/M7 Express.
To enable gamepad support on these boards, the original Adafruit NINA firmware must be replaced with Bluepad32 firmware. Bluepad32 is designed to be 'compatible-enough' with the original firmware by using the same SPI interface, GPIOs, and the same communication protocol, though it only implements the specific messages required for gamepad functionality.
Use CD32 Controller Mode
mainMightyMiggy automatically switches to CD32 mode when a game supports CD32 joypads. This mode supports 7 buttons.
Default Button Mapping:
<kbd>X</kbd>: Red<kbd>A</kbd>: Blue<kbd>B</kbd>: Yellow<kbd>Y</kbd>: Green<kbd>Shoulder Left</kbd>/<kbd>Trigger Left</kbd>: L<kbd>Shoulder Right</kbd>/<kbd>Trigger Right</kbd>: R<kbd>Home</kbd>: Home/Pause
Button Rotation: Pressing
<kbd>Back</kbd>rotates the 4 main buttons to the following configuration:<kbd>A</kbd>: Red<kbd>B</kbd>: Blue<kbd>Y</kbd>: Yellow<kbd>X</kbd>: Green
Understand Bluepad32 licensing and BTstack requirements
mainBluepad32 is licensed under Apache 2.0.
Important Dependency Note: Bluepad32 depends on the BTstack library. While BTstack is free for open-source projects, it requires a commercial license for closed-source/commercial projects.
- ESP32 users: If developing a commercial product, you must contact the BTstack team directly.
- Pico W users: You are covered by the Raspberry Pi License.
Limitations of Bluepad32 on NINA-W10 boards
mainWhen using Bluepad32 on NINA-W10 modules (as a co-processor), be aware of the following limitations:
- Supported: BLE controllers (gamepads) are supported.
- Not Supported: WiFi API and BLE API (you cannot use the NINA module as a BLE peripheral/client, only as a host for controllers).
- Not Supported: Bluepad32 logs cannot be seen via the main processor.
- Not Supported: Bluepad32 console is not supported.
- Functionality: Only Bluepad32-specific features are implemented; original WiFi/BLE functionality is unavailable while Bluepad32 is running.
Identify compatible Bluetooth protocols for mice
mainWhen selecting a mouse for use with Bluepad32, consider the following protocol compatibility guidelines:
Protocol Status Description Search Term BLE Should work BLE only (Low Energy, BT 5.0) "BLE mouse" BR/EDR Should work BR/EDR only (Classic, BT 3.0) "Mouse Bluetooth Windows XP" Dual Mode Might work* Supports both BLE and BR/EDR "Tri-Mode BT 3.0, BT 5.0, 2.4Gz" *Note: Dual-mode devices may encounter issues (see Issue #18 or Issue BK3632).
Understand keyboard support in Bluepad32
mainKeyboard support is currently a BETA feature in Bluepad32. While many keyboards are supported, users should expect bugs. If you encounter issues, it is recommended to file a bug.
In theory, any Bluetooth keyboard should work. Support is categorized by protocol:
- BLE (Bluetooth Low Energy / BT 5.0): Should work. Most modern keyboards are BLE only. Note that BLE support is considered beta as of Bluepad32 v4.1.
- BR/EDR (Bluetooth Classic / BT 3.0): Should work. These are older non-BLE keyboards.
- Dual Mode (Supports both BLE and BR/EDR): Might work, but may encounter issues (see Issue #18).
Configure MightyMiggy Operating Modes
mainMightyMiggy supports multiple operating modes depending on the game requirements. The first controller connected controls the joystick in Port 2 and the mouse in Port 1. A second controller controls the joystick in Port 1.
Two-Button Joystick Mode
This is the default mode. You can switch between built-in button mappings by pressing
<kbd>Back</kbd>in combination with other buttons. The player LED blinks to indicate the active mapping:Mapping Command LED Blinks Description Standard <kbd>Back</kbd> + <kbd>X</kbd>1 D-Pad and Left Analog work as directions. <kbd>X</kbd>is Button 1,<kbd>A</kbd>is Button 2.Racing 1 <kbd>Back</kbd> + <kbd>Y</kbd>2 <kbd>X</kbd>and<kbd>A</kbd>map to Up/Down (Accel/Brake). Left Analog steers.Racing 2 <kbd>Back</kbd> + <kbd>B</kbd>3 <kbd>Trigger Right</kbd>/<kbd>Shoulder Right</kbd>is Accel,<kbd>Trigger Left</kbd>/<kbd>Shoulder Left</kbd>is Brake.Platform <kbd>Back</kbd> + <kbd>A</kbd>4 Similar to Standard, but <kbd>A</kbd>replicates<kbd>Up</kbd>for easier jumping.<kbd>Button 2</kbd>moves to<kbd>Y</kbd>.Mouse Mode
In all modes, the
<kbd>Right Analog</kbd>stick on the first controller emulates mouse movement. The left and right mouse buttons are mapped to<kbd>Left Thumb</kbd>and<kbd>Right Thumb</kbd>respectively.