Bluepad32 Documentation

repository·main·Indexed 22 days ago

https://github.com/ricardoquesada/bluepad32

A 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.

Tokens
21.9K
Snippets
52
Records
105
Agent score
76%

What's inside Bluepad32

  1. What is Bluepad32

    main
    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.
  2. What is MightyMiggy

    main

    MightyMiggy 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.
  3. Bluepad32 Features and Platform Support

    main

    Bluepad32 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
  4. Supported Bluetooth controllers and devices

    main

    Bluepad32 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.
  5. What is AirLift and how Bluepad32 works with it

    main

    AirLift 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.

  6. Use CD32 Controller Mode

    main

    MightyMiggy 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
  7. Understand Bluepad32 licensing and BTstack requirements

    main

    Bluepad32 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.
  8. Limitations of Bluepad32 on NINA-W10 boards

    main

    When 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.
  9. Identify compatible Bluetooth protocols for mice

    main

    When selecting a mouse for use with Bluepad32, consider the following protocol compatibility guidelines:

    ProtocolStatusDescriptionSearch Term
    BLEShould workBLE only (Low Energy, BT 5.0)"BLE mouse"
    BR/EDRShould workBR/EDR only (Classic, BT 3.0)"Mouse Bluetooth Windows XP"
    Dual ModeMight 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).

  10. Understand keyboard support in Bluepad32

    main

    Keyboard 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).
  11. Configure MightyMiggy Operating Modes

    main

    MightyMiggy 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:

    MappingCommandLED BlinksDescription
    Standard<kbd>Back</kbd> + <kbd>X</kbd>1D-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>4Similar 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.