Git Product home page Git Product logo

bluepad32's Introduction

Bluepad32

discord

drawing

A Bluetooth controller "host" for the ESP32, ESP32-S3, ESP32-C3, Raspberry Pi Pico W and Posix (Linux, macOS).

Add Bluetooth gamepad, mouse and keyboard support to your projects easily.

In other words, it allows you to control a robot using a DualSense controller.

Where to start

Choose your target platform:

Platform Start here Further info Community projects
Arduino IDE Watch the video Doc Controller for Tello drone
Arduino using ESP-IDF toolchain Template project Doc Lego Robot (video), gbaHD Shield (a GameBoy consolizer)
Arduino + NINA coprocessor Arduino Library Doc Philips CD-i meets Bluetooth
CircuitPython + AirLift coprocessor CircuitPython Library Doc Quico console, Controlling 4 servos (video)
Pico W Pico W example Doc Pico Switch, PicoNtrol
ESP-IDF ESP32 example Doc OGX-Wireless-Lite
Posix (Linux, macOS) Posix example Doc
Unijoysticle Unijoysticle2 Doc
MightyMiggy Unijoysticle for Amiga Doc

Features

  • Supports most, if not all, modern Bluetooth gamepads, mice and keyboards (see below)
  • Supports ESP32 and Pico W
  • Supported APIs: ESP-IDF, Pico-SDK, Arduino and CircuitPython
  • Fast (very low latency)
  • Small footprint
  • Uses only one core (CPU0). The remaining one is free to use.
  • C11 based
  • Open Source (see below)
  • Easy to integrate into 3rd party projects

Supported controllers

Supported gamepads

  • Sony DualSense (PS5)
  • Sony DualShock 4 (PS4)
  • Sony DualShock 3 (PS3)
  • Nintendo Switch Pro controller
  • Nintendo Switch JoyCon
  • Nintendo Wii U controller
  • Nintendo Wii Remote + accessories
  • Xbox Wireless controller (models 1708, 1914, adaptive)
  • Android controllers
  • Steam controller
  • Stadia controller
  • PC/Window controller
  • 8BitDo controllers
  • Atari joystick
  • iCade
  • Mouse
  • Keyboards
  • And more

NOTE: Original ESP32 and Pico W support all listed controllers. ESP32-S3 and ESP32-C3 support only a subset.

See: Supported gamepads, supported mice and supported keyboards

Pre-compiled binaries

Download pre-compiled binaries for Unijoysticle, Nina, AirLift, MightyMiggy:

Creating your project

See the examples folder which includes examples for:

Arduino examples are in:

Support

License

Bluepad32 is open source, licensed under Apache 2.

However, Bluepad32 depends on the great BTstack library. Which is free to use for open source projects. But commercial for closed-source projects.

If you are developing a commercial product for:

Notice: I’m not affiliated with BTstack people. They are super friendly and willing to help.

bluepad32's People

Contributors

bbsan2k avatar greso avatar herraa1 avatar mdvorak avatar mikh3x4 avatar mneuhaus avatar onlinewithryan avatar ricardoquesada avatar ricardoquesadawork avatar selimrecep avatar sideprojectslab avatar solhuebner avatar sukkopera avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bluepad32's Issues

[Bug] Bluepad crashing when connecting `Switch Pro controller` devices

Found on Pico W platform:

Bluepad32 crashes when a connecting controller identified as a switch calls process_reply_spi_flash_read function. I suspect it's the following lines:

    switch_instance_t* ins = get_switch_instance(d);
    switch (ins->state) {

Reverting to an old version of code where mem_len was used:

    switch (mem_len) {

Solves the issue.

I suspect ins or ins->state might be NULL and causes a segfault.

Feel free to request logs or further info if needed.

[Bug]: Not reporting Y-axis data on ESP32 C3 from Xbox One Controller

What happened?

I'm using an ESP 32 C3 with an Xbox One Controller, I've loaded up the example code from the Arduino IDE and it connects right up and reports all the button presses and the X-axis of both joysticks however it always reports 0 for the Y-axis of both joysticks no matter what.

Bluepad32 Version

3.8.3

Bluepad32 version custom

Example: Using Git develop branch commit hash #xxxxxxx

Bluepad32 Platform

Arduino IDE

Platform version

E.g: Arduino IDE 2.1.0, or ESP-IDF v4.4.4, or CircuitPython 8.0.0, etc.

Controller

issues

ESP32 chip

ESP32

ESP32 board

ESP32-C3 Super mini ex: https://www.aliexpress.us/item/3256805781327184.html?spm=a2g0o.order_list.order_list_main.29.b2811802zmLh3P&gatewayAdapt=glo2usa

OS

Windows

Relevant log output

No response

Relevant sketch

The default example sketch.

DS4 setRumble

Using Bluepad example : Controller and changing setRumble values

I don't see differences when changing rumble force value, it seems this value may be hardcoded somewhere ? Changing rumble duration works well.

Bluepad32 version
esp32_bluepad 3.10.2

Bluepad32 Platform
Arduino IDE 2.2.1

void processGamepad(ControllerPtr ctl) {
    if (ctl->x()) {
        // Duration: 255 is ~2 seconds
        // force: intensity
        // Some gamepads like DS3, DS4, DualSense, Switch, Xbox One S support
        // rumble.
        // It is possible to set it by calling:
        static int rblForce = 0;
        rblForce+=10;
        if(rblForce > 200)
          rblForce = 0;
        ctl->setRumble(rblForce /* force */, 0xc0 /* duration */);
    }

Add BTStack examples for Arduino IDE

Please provide examples on the use of BTStack for communicating with the ESP32.

Additional context
The conversation began trying to compile OTA examples to implement OTA firmware uploads whilst using Bluepad32. The gist describing these issues can be found here for reference.

It would be fantastic if the examples could include OTA examples however that may be a stretch so including BTStack usage examples which would allow a developer to implement their own OTA implantation would also be great.

Gamepad connect but not working.

When I run esp32 bluepad32 and connect gamepad, it connect but not work. My gamepad is this model https://www.dhresource.com/0x0s/f2-albu-g4-M01-12-60-rBVaEVet7y-AClz3AAEwSGBzEK0004.jpg/kosda-bluetooth-wireless-game-controller.jpg

�[0;32mI (276) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE�[0m
�[0;32mI (376) phy: phy_version: 4180, cb3948e, Sep 12 2019, 16:39:13, 0, 0�[0m
BTstack up and running on 08:3A:F2:AA:47:12.
Stored link keys:
8E:37:82:81:63:25 - type 4, key: .
--> Scanning for new devices...
--> HCI_EVENT_COMMAND_COMPLETE: opcode = 0x200b - status=0
Device found: 8E:37:82:81:63:25 with COD: 0x002540, pageScan 1, clock offset 0x14c0, rssi -33 dBm
STATE_DEVICE_DISCOVERED
--> GAP_EVENT_INQUIRY_COMPLETE
--> Scanning for new devices...
Device found: 8E:37:82:81:63:25 with COD: 0x002540, pageScan 1, clock offset 0x14c0, rssi -33 dBm
--> GAP_EVENT_INQUIRY_COMPLETE
--> Scanning for new devices...
--> HCI_EVENT_CONNECTION_COMPLETE
--> HCI_EVENT_LINK_KEY_REQUEST:
--> HCI_EVENT_COMMAND_COMPLETE: opcode = 0x040b - status=0
--> HCI_EVENT_AUTHENTICATION_COMPLETE_EVENT: status=0, handle=0x0081
--> HCI_EVENT_COMMAND_COMPLETE: opcode = 0x1408 - status=0
L2CAP_EVENT_CHANNEL_OPENED (channel=0x0041)
PSM: 0x0011, local CID=0x0041, remote CID=0x0040, handle=0x0081, incoming=0, local MTU=128, remote MTU=72
HID Control opened, cid 0x41
STATE_L2CAP_CONTROL_CONNECTED
L2CAP_EVENT_CHANNEL_OPENED (channel=0x0042)
PSM: 0x0013, local CID=0x0042, remote CID=0x0041, handle=0x0081, incoming=0, local MTU=128, remote MTU=72
HID Interrupt opened, cid 0x42
STATE_L2CAP_INTERRUPT_CONNECTED
Starting SDP query for HID descriptor for: 8E:37:82:81:63:25
Device without HID descriptor or Product/Vendor ID yet.
Waiting for SDP answer. Ignoring report.
STATE_SDP_HID_DESCRIPTOR_FETCHED
Starting SDP query for product/vendor ID
Vendor ID: 0x1949 - Product ID: 0x0402
Device detected as Android: 0x25
STATE_SDP_HID_VENDOR_FETCHED
unijoysticle: device 8E:37:82:81:63:25 has new gamepad seat: 2
Another SDP query in progress. Disconnect gamepad and try again.
8E:37:82:81:63:25, handle=129, ctrl_cid=0x0041, intr_cid=0x0042, cod=0x00002540, vid=0x1949, pid=0x0402, flags=0x00003902, ctrl_type=0x25, name='', (del:0)

[Bug]: Division by Zero when Connecting JoyCon

What happened?

While using the template https://gitlab.com/ricardoquesada/esp-idf-arduino-bluepad32-template and trying to connect a right JoyCon an unhandled Dvision by Zero Exception forces the ESP32 to restart.

See log output.

Bluepad32 Version

3.8.3

Bluepad32 version custom

Example: Using Git develop branch commit hash #xxxxxxx

Bluepad32 Platform

Arduino ESP-IDF

Platform version

ESP-IDF v4.4.5

Controller

Right Joycon

ESP32 chip

ESP32

ESP32 board

ESP32-S3-WROOM1 DevKit from Lolin. This is the store URL: https://example.com

OS

Windows

Relevant log output

--- WARNING: GDB cannot open serial ports accessed as COMx
--- Using \\.\COM17 instead...
--- idf_monitor on \\.\COM17 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ets Jul 29 2019 12:21:46

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:6660
load:0x40078000,len:15060
load:0x40080400,len:3824
0x40080400: _init at ??:?

entry 0x4008069c
I (27) boot: ESP-IDF -128-NOTFOUND 2nd stage bootloader
I (27) boot: compile time 13:03:48
I (27) boot: Multicore bootloader
I (31) boot: chip revision: v3.1
I (35) boot.esp32: SPI Speed      : 40MHz
I (40) boot.esp32: SPI Mode       : DIO
I (44) boot.esp32: SPI Flash Size : 4MB
I (49) boot: Enabling RNG early entropy source...
I (54) boot: Partition Table:
I (58) boot: ## Label            Usage          Type ST Offset   Length
I (65) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (72) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (80) boot:  2 factory          factory app      00 00 00010000 00100000
I (87) boot:  3 coredump         Unknown data     01 03 00110000 00010000
I (95) boot: End of partition table
I (99) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=1e604h (124420) map
I (153) esp_image: segment 1: paddr=0002e62c vaddr=3ffbdb60 size=019ech (  6636) load
I (155) esp_image: segment 2: paddr=00030020 vaddr=400d0020 size=6f860h (456800) map
I (324) esp_image: segment 3: paddr=0009f888 vaddr=3ffbf54c size=03c14h ( 15380) load
I (330) esp_image: segment 4: paddr=000a34a4 vaddr=40080000 size=1902ch (102444) load
I (385) boot: Loaded app from partition at offset 0x10000
I (385) boot: Disabling RNG early entropy source...
I (396) cpu_start: Multicore app
I (397) cpu_start: Pro cpu up.
I (397) cpu_start: Starting app cpu, entry point is 0x400813e0
0x400813e0: call_start_cpu1 at C:/Espressif/frameworks/esp-idf-v4.4/components/esp_system/port/cpu_start.c:151

I (0) cpu_start: App cpu up.
I (417) cpu_start: Pro cpu start user code
I (417) cpu_start: cpu freq: 160000000
I (417) cpu_start: Application information:
I (421) cpu_start: Project name:     app-template
I (427) cpu_start: App version:      1
I (431) cpu_start: Compile time:     Sep  6 2023 15:49:03
I (437) cpu_start: ELF file SHA256:  3204b908d80d3976...
I (443) cpu_start: ESP-IDF:          -128-NOTFOUND
I (449) cpu_start: Min chip rev:     v0.0
I (453) cpu_start: Max chip rev:     v3.99
I (458) cpu_start: Chip rev:         v3.1
I (463) heap_init: Initializing. RAM available for dynamic allocation:
I (470) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
I (476) heap_init: At 3FFB6388 len 00001C78 (7 KiB): DRAM
I (482) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM
I (488) heap_init: At 3FFD29E0 len 0000D620 (53 KiB): DRAM
I (495) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (501) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (507) heap_init: At 4009902C len 00006FD4 (27 KiB): IRAM
I (515) spi_flash: detected chip: generic
I (518) spi_flash: flash io: dio
I (523) esp_core_dump_flash: Init core dump to flash
I (528) esp_core_dump_flash: Found partition 'coredump' @ 110000 65536 bytes
I (555) esp_core_dump_flash: Core dump data checksum is correct
I (555) esp_core_dump_flash: Found core dump 16292 bytes in flash @ 0x110000
luepad32 (C) 2016-2023 Ricardo Quesada and contributors.
Version: v3.8.3
BTStack: Copyright (C) 2017 BlueKitchen GmbH.
Platform: Arduino
Max connected gamepads: 4
BR/EDR support: enabled
BLE support: enabled
Device ID SDP service record size: 64
Gap security level: 2
Periodic Inquiry: max=5, min=4, len=3
I (648) BTDM_INIT: BT controller compile version [7c67f29]
I (655) system_api: Base MAC address is not set
I (659) system_api: read default base MAC address from EFUSE
I (666) BTDM_INIT: Bluetooth MAC: b0:a7:32:27:7b:1a
I (674) phy_init: phy_version 4670,719f9f6,Feb 18 2021,17:07:07
Bluetooth Allowlist: Disabled
I (1256) console: Command history disabled

Type 'help' to get the list of commands.
Use UP/DOWN arrows to navigate through command history.
Press TAB when typing command name to auto-complete.
BTstack up and running at B0:A7:32:27:7B:1A
HCI not ready, cannot send packet, will again try later. Current state idx=1
BR/EDR scan -> 1
BLE scan -> 1
Firmware: Bluepad32 for Arduino v3.8.3
BD Addr: B0:A7:32:27:7B:1A
Deleting stored BR/EDR link keys:
.
Deleting stored BLE link keys:
.
bp32> Device found: 70:F0:88:DD:41:A4 with COD: 0x002508, pageScan 1, clock offset 0x6c52, rssi 190 dBm, name 'Joy-Con (R)'
Creating device: 70:F0:88:DD:41:A4 (idx=0)
uni_bt_process_fsm, bd addr:70:F0:88:DD:41:A4,  state: 4, incoming:0
Device detected as Nintendo Switch Pro controller: 0x28
uni_bt_process_fsm: Guess controller from name
uni_bt_process_fsm: Starting L2CAP connection
Device found: 70:F0:88:DD:41:A4 with COD: 0x002508, pageScan 1, clock offset 0x6c52, rssi 196 dBm, name 'Joy-Con (R)'
Device already added, waiting (current state=0x09)...
uni_bt_process_fsm, bd addr:70:F0:88:DD:41:A4,  state: 9, incoming:0
--> HCI_EVENT_CONNECTION_COMPLETE
SM_EVENT_PAIRING_STARTED
Identity resolving failed for 70:F0:88:DD:41:A4

--> HCI_EVENT_LINK_KEY_REQUEST:
Device found: 70:F0:88:DD:41:A4 with COD: 0x002508, pageScan 1, clock offset 0x6c52, rssi 190 dBm, name 'Joy-Con (R)'
Device already added, waiting (current state=0x09)...
uni_bt_process_fsm, bd addr:70:F0:88:DD:41:A4,  state: 9, incoming:0
Device found: 70:F0:88:DD:41:A4 with COD: 0x002508, pageScan 1, clock offset 0x6c52, rssi 190 dBm, name 'Joy-Con (R)'
Device already added, waiting (current state=0x09)...
uni_bt_process_fsm, bd addr:70:F0:88:DD:41:A4,  state: 9, incoming:0
SSP User Confirmation Request with numeric value '142039'
SSP User Confirmation Auto accept
--> HCI_EVENT_AUTHENTICATION_COMPLETE_EVENT: status=0, handle=0x0081
L2CAP_EVENT_CHANNEL_OPENED (channel=0x0041)
PSM: 0x0011, local CID=0x0041, remote CID=0x0040, handle=0x0081, incoming=0, local MTU=1691, remote MTU=800, addr=70:F0:88:DD:41:A4
HID Control opened, cid 0x41
uni_bt_process_fsm, bd addr:70:F0:88:DD:41:A4,  state: 10, incoming:0
uni_bt_process_fsm: Create L2CAP interrupt connection
L2CAP_EVENT_CHANNEL_OPENED (channel=0x0042)
PSM: 0x0013, local CID=0x0042, remote CID=0x0041, handle=0x0081, incoming=0, local MTU=1691, remote MTU=800, addr=70:F0:88:DD:41:A4
HID Interrupt opened, cid 0x42
Device 70:F0:88:DD:41:A4 is connected
uni_bt_process_fsm, bd addr:70:F0:88:DD:41:A4,  state: 12, incoming:0
uni_bt_process_fsm: Device is ready
Switch: setup timer timeout, failed state: 0x02
Switch: IMU report enabled
Switch: Firmware version: 3.145. Controller type=2
Switch: IMU calibration info: accel.offset=-6341,0,0, accel.scale=-6656,0,-6341, gyro.offset=0,0,0, gyro.scale=13371,13371,13371
Guru Meditation Error: Core  0 panic'ed (IntegerDivideByZero). Exception was unhandled.

Core  0 register dump:
PC      : 0x400dd919  PS      : 0x00060730  A0      : 0x800d9c50  A1      : 0x3ffbbb00
0x400dd919: parse_imu at C:/Users/kevin/OneDrive/Source/Espidf/BobbyBluetoothCtrl/components/bluepad32/uni_hid_parser_switch.c:715
 (inlined by) parse_report_30 at C:/Users/kevin/OneDrive/Source/Espidf/BobbyBluetoothCtrl/components/bluepad32/uni_hid_parser_switch.c:771
 (inlined by) uni_hid_parser_switch_parse_input_report at C:/Users/kevin/OneDrive/Source/Espidf/BobbyBluetoothCtrl/components/bluepad32/uni_hid_parser_switch.c:396

A2      : 0x00000000  A3      : 0x00000000  A4      : 0x00000000  A5      : 0x0000343b
A6      : 0x3ffc5250  A7      : 0x00000001  A8      : 0x3ffc5264  A9      : 0x00000000
A10     : 0x00000000  A11     : 0x00000000  A12     : 0x00000000  A13     : 0x00000000
A14     : 0x3ffbbb24  A15     : 0x00000000  SAR     : 0x0000000e  EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000  LBEG    : 0x4000c46c  LEND    : 0x4000c477  LCOUNT  : 0x00000000
0x4000c46c: memset in ROM

0x4000c477: memset in ROM



Backtrace: 0x400dd916:0x3ffbbb00 0x400d9c4d:0x3ffbbb90 0x400dfd8d:0x3ffbbc20 0x400d8051:0x3ffbbc40 0x400f4669:0x3ffbbc60 0x400f02b2:0x3ffbbce0 0x400f5976:0x3ffbbda0 0x400f8ac6:0x3ffbbdd0 0x400ead8f:0x3ffbbe00 0x400df4ab:0x3ffbbe20 0x400d8f1d:0x3ffbbe40 0x400d7c5f:0x3ffbbe60 0x4013dc77:0x3ffbbe80
0x400dd916: parse_imu at C:/Users/kevin/OneDrive/Source/Espidf/BobbyBluetoothCtrl/components/bluepad32/uni_hid_parser_switch.c:715
 (inlined by) parse_report_30 at C:/Users/kevin/OneDrive/Source/Espidf/BobbyBluetoothCtrl/components/bluepad32/uni_hid_parser_switch.c:771
 (inlined by) uni_hid_parser_switch_parse_input_report at C:/Users/kevin/OneDrive/Source/Espidf/BobbyBluetoothCtrl/components/bluepad32/uni_hid_parser_switch.c:396

0x400d9c4d: uni_hid_parse_input_report at C:/Users/kevin/OneDrive/Source/Espidf/BobbyBluetoothCtrl/components/bluepad32/uni_hid_parser.c:41

0x400dfd8d: uni_bt_bredr_on_l2cap_data_packet at C:/Users/kevin/OneDrive/Source/Espidf/BobbyBluetoothCtrl/components/bluepad32/uni_bt_bredr.c:535

0x400d8051: uni_bt_packet_handler at C:/Users/kevin/OneDrive/Source/Espidf/BobbyBluetoothCtrl/components/bluepad32/uni_bt.c:363

0x400f4669: l2cap_dispatch_to_channel at C:/Users/kevin/OneDrive/Source/Espidf/BobbyBluetoothCtrl/components/btstack/src/l2cap.c:1120
 (inlined by) l2cap_acl_classic_handler_for_channel at C:/Users/kevin/OneDrive/Source/Espidf/BobbyBluetoothCtrl/components/btstack/src/l2cap.c:4617
 (inlined by) l2cap_acl_classic_handler at C:/Users/kevin/OneDrive/Source/Espidf/BobbyBluetoothCtrl/components/btstack/src/l2cap.c:4674
 (inlined by) l2cap_acl_handler at C:/Users/kevin/OneDrive/Source/Espidf/BobbyBluetoothCtrl/components/btstack/src/l2cap.c:4753
 (inlined by) l2cap_acl_handler at C:/Users/kevin/OneDrive/Source/Espidf/BobbyBluetoothCtrl/components/btstack/src/l2cap.c:4741

0x400f02b2: hci_emit_acl_packet at C:/Users/kevin/OneDrive/Source/Espidf/BobbyBluetoothCtrl/components/btstack/src/hci.c:7568
 (inlined by) acl_handler at C:/Users/kevin/OneDrive/Source/Espidf/BobbyBluetoothCtrl/components/btstack/src/hci.c:1246
 (inlined by) packet_handler at C:/Users/kevin/OneDrive/Source/Espidf/BobbyBluetoothCtrl/components/btstack/src/hci.c:4493

0x400f5976: transport_deliver_packets at C:/Users/kevin/OneDrive/Source/Espidf/BobbyBluetoothCtrl/components/btstack/btstack_port_esp32.c:191

0x400f8ac6: btstack_run_loop_freertos_execute at C:/Users/kevin/OneDrive/Source/Espidf/BobbyBluetoothCtrl/components/btstack/platform/freertos/btstack_run_loop_freertos.c:172

0x400ead8f: btstack_run_loop_execute at C:/Users/kevin/OneDrive/Source/Espidf/BobbyBluetoothCtrl/components/btstack/src/btstack_run_loop.c:310

0x400df4ab: uni_main at C:/Users/kevin/OneDrive/Source/Espidf/BobbyBluetoothCtrl/components/bluepad32/uni_main.c:53

0x400d8f1d: uni_esp32_main at C:/Users/kevin/OneDrive/Source/Espidf/BobbyBluetoothCtrl/components/bluepad32/uni_esp32.c:64

0x400d7c5f: app_main at C:/Users/kevin/OneDrive/Source/Espidf/BobbyBluetoothCtrl/components/bluepad32/uni_platform_arduino.c:442

0x4013dc77: main_task at C:/Espressif/frameworks/esp-idf-v4.4/components/freertos/port/port_common.c:141





ELF file SHA256: 3204b908d80d3976

I (11762) esp_core_dump_flash: Save core dump to flash...
I (11768) esp_core_dump_flash: Erase flash 16384 bytes @ 0x110000
I (11840) esp_core_dump_flash: Write end offset 0x3f64, check sum length 4
I (11841) esp_core_dump_flash: Core dump has been saved to flash.
Rebooting...
ets Jul 29 2019 12:21:46

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:6660
load:0x40078000,len:15060
load:0x40080400,len:3824
0x40080400: _init at ??:?

entry 0x4008069c
I (27) boot: ESP-IDF -128-NOTFOUND 2nd stage bootloader
I (27) boot: compile time 13:03:48
I (27) boot: Multicore bootloader
I (31) boot: chip revision: v3.1
I (35) boot.esp32: SPI Speed      : 40MHz
I (40) boot.esp32: SPI Mode       : DIO
I (44) boot.esp32: SPI Flash Size : 4MB
I (49) boot: Enabling RNG early entropy source...
I (54) boot: Partition Table:
I (58) boot: ## Label            Usage          Type ST Offset   Length
I (65) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (72) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (80) boot:  2 factory          factory app      00 00 00010000 00100000
I (87) boot:  3 coredump         Unknown data     01 03 00110000 00010000
I (95) boot: End of partition table
I (99) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=1e604h (124420) map
I (152) esp_image: segment 1: paddr=0002e62c vaddr=3ffbdb60 size=019ech (  6636) load
I (155) esp_image: segment 2: paddr=00030020 vaddr=400d0020 size=6f860h (456800) map
I (323) esp_image: segment 3: paddr=0009f888 vaddr=3ffbf54c size=03c14h ( 15380) load
I (330) esp_image: segment 4: paddr=000a34a4 vaddr=40080000 size=1902ch (102444) load
I (385) boot: Loaded app from partition at offset 0x10000
I (385) boot: Disabling RNG early entropy source...
I (396) cpu_start: Multicore app
I (396) cpu_start: Pro cpu up.
I (397) cpu_start: Starting app cpu, entry point is 0x400813e0
0x400813e0: call_start_cpu1 at C:/Espressif/frameworks/esp-idf-v4.4/components/esp_system/port/cpu_start.c:151

I (388) cpu_start: App cpu up.
I (417) cpu_start: Pro cpu start user code
I (417) cpu_start: cpu freq: 160000000
I (417) cpu_start: Application information:
I (421) cpu_start: Project name:     app-template
I (427) cpu_start: App version:      1
I (431) cpu_start: Compile time:     Sep  6 2023 15:49:03
I (437) cpu_start: ELF file SHA256:  3204b908d80d3976...
I (443) cpu_start: ESP-IDF:          -128-NOTFOUND
I (449) cpu_start: Min chip rev:     v0.0
I (453) cpu_start: Max chip rev:     v3.99 
I (458) cpu_start: Chip rev:         v3.1
I (463) heap_init: Initializing. RAM available for dynamic allocation:
I (470) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
I (476) heap_init: At 3FFB6388 len 00001C78 (7 KiB): DRAM
I (482) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM
I (488) heap_init: At 3FFD29E0 len 0000D620 (53 KiB): DRAM
I (495) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (501) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (507) heap_init: At 4009902C len 00006FD4 (27 KiB): IRAM
I (515) spi_flash: detected chip: generic
I (518) spi_flash: flash io: dio
I (523) esp_core_dump_flash: Init core dump to flash
I (528) esp_core_dump_flash: Found partition 'coredump' @ 110000 65536 bytes
I (555) esp_core_dump_flash: Core dump data checksum is correct
I (555) esp_core_dump_flash: Found core dump 16228 bytes in flash @ 0x110000
luepad32 (C) 2016-2023 Ricardo Quesada and contributors.
Version: v3.8.3
BTStack: Copyright (C) 2017 BlueKitchen GmbH.
Platform: Arduino
Max connected gamepads: 4
BR/EDR support: enabled
BLE support: enabled
Device ID SDP service record size: 64
Gap security level: 2
Periodic Inquiry: max=5, min=4, len=3
I (652) BTDM_INIT: BT controller compile version [7c67f29]
I (659) system_api: Base MAC address is not set
I (663) system_api: read default base MAC address from EFUSE
I (669) BTDM_INIT: Bluetooth MAC: b0:a7:32:27:7b:1a
I (677) phy_init: phy_version 4670,719f9f6,Feb 18 2021,17:07:07
Bluetooth Allowlist: Disabled
I (1262) console: Command history disabled

Type 'help' to get the list of commands.
Use UP/DOWN arrows to navigate through command history.
Press TAB when typing command name to auto-complete.
BTstack up and running at B0:A7:32:27:7B:1A
HCI not ready, cannot send packet, will again try later. Current state idx=1
BR/EDR scan -> 1
BLE scan -> 1
Firmware: Bluepad32 for Arduino v3.8.3
BD Addr: B0:A7:32:27:7B:1A
Deleting stored BR/EDR link keys:
70:F0:88:DD:41:A4 - type 4, key: 0B 15 CE 1F 67 32 79 96 02 29 31 DA C1 73 59 12
.
Deleting stored BLE link keys:
.
bp32> --> HCI_EVENT_CONNECTION_REQUEST: link_type = 1 <--
Creating device: 70:F0:88:DD:41:A4 (idx=0)
on_hci_connection_request from: address = 70:F0:88:DD:41:A4, cod=0x0508
--> HCI_EVENT_ROLE_CHANGE
--> HCI_EVENT_CONNECTION_COMPLETE
SM_EVENT_PAIRING_STARTED
Identity resolving failed for 70:F0:88:DD:41:A4

--> HCI_EVENT_LINK_KEY_REQUEST:
Device cannot connect in time, deleting:
        btaddr: 70:F0:88:DD:41:A4
        bt: handle=128 (ACL), ctrl_cid=0x0000, intr_cid=0x0000, cod=0x00000508, flags=0x00000100, incoming=1
        model: vid=0x0000, pid=0x0000, model='Unknown', name=''
        battery: 0 / 255, type=unknown
Disconnecting device: 70:F0:88:DD:41:A4
connection 70:F0:88:DD:41:A4 already in state 0, ignoring
Deleting device: 70:F0:88:DD:41:A4
--> HCI_EVENT_DISCONNECTION_COMPLETE

Relevant sketch

No specific sketch. Just the raw example code for arduino-idf

issue with another library

Hello,

thank you for your work on this library. I have a problem with Fastaccelstepper (https://github.com/gin66/FastAccelStepper) library in conjunction with this on an esp32 wroom32. I understand that it might be not your business to explain why it's not working, but maybe you can help me in the right direction. As soon I initialize the stepper library the esp reboots endlessly with this messages:

E (451211) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (451211) task_wdt:  - IDLE (CPU 0)
E (451211) task_wdt: Tasks currently running:
E (451211) task_wdt: CPU 0: StepperTask
E (451211) task_wdt: CPU 1: IDLE
E (451211) task_wdt: Print CPU 0 (current core) backtrace


Backtrace:0x40102A12:0x3FFBE7500x40082EBD:0x3FFBE770 0x40085BED:0x3FFDC210 0x40093915:0x3FFDC230 0x400D8356:0x3FFDC250 0x400946A5:0x3FFDC270 
0x40102a12: task_wdt_isr at /Users/xxx/esp/esp-idf/components/esp_system/task_wdt.c:183 (discriminator 3)

0x40082ebd: _xt_lowint1 at /Users/xxx/esp/esp-idf/components/freertos/port/xtensa/xtensa_vectors.S:1111

0x40085bed: esp_crosscore_int_send_yield at /Users/xxx/esp/esp-idf/components/esp_system/crosscore_int.c:144

0x40093915: vTaskDelay at /Users/xxx/esp/esp-idf/components/freertos/tasks.c:1596

0x400d8356: StepperTask(void*) at /Users/xxx/esp/pan-tilt-head/build/../components/fast_accel_stepper/src/FastAccelStepper.cpp:69 (discriminator 1)

0x400946a5: vPortTaskWrapper at /Users/xxx/esp/esp-idf/components/freertos/port/xtensa/port.c:131


E (451211) task_wdt: Print CPU 1 backtrace


Backtrace:0x40085B81:0x3FFBED500x40082EBD:0x3FFBED70 0x4000BFED:0x3FFD2800 0x40094956:0x3FFD2810 0x40102CD7:0x3FFD2830 0x40102CE3:0x3FFD2860 0x400D3A5D:0x3FFD2880 0x40092C11:0x3FFD28A0 0x400946A5:0x3FFD28C0 
0x40085b81: esp_crosscore_isr at /Users/xxx/esp/esp-idf/components/esp_system/crosscore_int.c:92

0x40082ebd: _xt_lowint1 at /Users/xxx/esp/esp-idf/components/freertos/port/xtensa/xtensa_vectors.S:1111

0x40094956: vPortClearInterruptMaskFromISR at /Users/xxx/esp/esp-idf/components/freertos/port/xtensa/include/freertos/portmacro.h:571
 (inlined by) vPortExitCritical at /Users/xxx/esp/esp-idf/components/freertos/port/xtensa/port.c:319

0x40102cd7: esp_task_wdt_reset at /Users/xxx/esp/esp-idf/components/esp_system/task_wdt.c:330

0x40102ce3: idle_hook_cb at /Users/xxx/esp/esp-idf/components/esp_system/task_wdt.c:80

0x400d3a5d: esp_vApplicationIdleHook at /Users/xxx/esp/esp-idf/components/esp_system/freertos_hooks.c:51 (discriminator 1)

0x40092c11: prvIdleTask at /Users/xxx/esp/esp-idf/components/freertos/tasks.c:3974 (discriminator 1)

0x400946a5: vPortTaskWrapper at /Users/xxx/esp/esp-idf/components/freertos/port/xtensa/port.c:131

I installed your library according to the instructions for esp-idf 4.2 and arduino core... Without the stepper library its working fine. I undestand that it has something to be with cpu cores on the esp, but i'm still learning.

Thank you very much.

Conflict with SerialBluetooth.h?

Hello. Great work, this is amazing! I am trying to add the use of SerialBluetooth to my sketch but it won't work. I'm new to this but after hours of looking, my best guess is that it might be because Bluedroid mode is needed?

My end goal is to be able to connect my controller with Bluepad32 but also be able to connect to an Android phone to use something like the MIT App Inventor.

THANK YOU!
Blake

[Bug]: uni_bt_allowlist.h not found

What happened?

I am running the simple default example controller file within the Arduino environment.
Using the allowlist - enabling and setting a single address.

On validating the include at the top of the page errors, as below. It perhaps has been moved, renamed, or intentions for other way of handling this. But thought it best to flag it.
Dropping back to 3.10.2 - validates fine.

#include <uni_bt_allowlist.h>

......\Controller\Controller.ino:2:10: fatal error: uni_bt_allowlist.h: No such file or directory
#include <uni_bt_allowlist.h>
^~~~~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1

Compilation error: uni_bt_allowlist.h: No such file or directory

Bluepad32 Version

latest from develop branch

Bluepad32 version custom

BP32 V 3.10.2 works
BP32 V 4.0 Beta 0 fails

Bluepad32 Platform

Arduino IDE

Platform version

Win11, Arduino IDE 2.3.0, .INO file

Controller

No Controller issues.

ESP32 chip

ESP32

ESP32 board

ESP32 Development Board TYPE-C/MICRO USB CP2102 WiFi+Bluetooth Dual Core ESP32-DevKitC-32 ESP-WROOM-32 Expansion Board 38PINS
URL: https://www.aliexpress.com/item/1005006176546785.html

OS

Windows

Relevant log output

Win11

Relevant sketch

#include <Bluepad32.h>
#include <uni_bt_allowlist.h>

ControllerPtr myControllers[BP32_MAX_GAMEPADS];

// This callback gets called any time a new gamepad is connected.
// Up to 4 gamepads can be connected at the same time.
void onConnectedController(ControllerPtr ctl) {
    bool foundEmptySlot = false;
    for (int i = 0; i < BP32_MAX_GAMEPADS; i++) {
        if (myControllers[i] == nullptr) {
            Serial.printf("CALLBACK: Controller is connected, index=%d\n", i);
            // Additionally, you can get certain gamepad properties like:
            // Model, VID, PID, BTAddr, flags, etc.
            ControllerProperties properties = ctl->getProperties();
            Serial.printf("Controller model: %s, VID=0x%04x, PID=0x%04x\n", ctl->getModelName().c_str(), properties.vendor_id,
                           properties.product_id);
            Serial.printf("Cont BD Addr: %2X:%2X:%2X:%2X:%2X:%2X\n", properties.btaddr[0], properties.btaddr[1], properties.btaddr[2], 
                           properties.btaddr[3], properties.btaddr[4], properties.btaddr[5]);
            myControllers[i] = ctl;
            foundEmptySlot = true;
            break;
        }
    }
    if (!foundEmptySlot) {
        Serial.println("CALLBACK: Controller connected, but could not found empty slot");
    }
}

void onDisconnectedController(ControllerPtr ctl) {
    bool foundController = false;

    for (int i = 0; i < BP32_MAX_GAMEPADS; i++) {
        if (myControllers[i] == ctl) {
            Serial.printf("CALLBACK: Controller disconnected from index=%d\n", i);
            myControllers[i] = nullptr;
            foundController = true;
            break;
        }
    }

    if (!foundController) {
        Serial.println("CALLBACK: Controller disconnected, but not found in myControllers");
    }
}

void dumpGamepad(ControllerPtr ctl) {
    Serial.printf(
        "idx=%d, dpad: 0x%02x, buttons: 0x%04x, axis L: %4d, %4d, axis R: %4d, %4d, brake: %4d, throttle: %4d, "
        "misc: 0x%02x, gyro x:%6d y:%6d z:%6d, accel x:%6d y:%6d z:%6d\n",
        ctl->index(),        // Controller Index
        ctl->dpad(),         // DPAD
        ctl->buttons(),      // bitmask of pressed buttons
        ctl->axisX(),        // (-511 - 512) left X Axis
        ctl->axisY(),        // (-511 - 512) left Y axis
        ctl->axisRX(),       // (-511 - 512) right X axis
        ctl->axisRY(),       // (-511 - 512) right Y axis
        ctl->brake(),        // (0 - 1023): brake button
        ctl->throttle(),     // (0 - 1023): throttle (AKA gas) button
        ctl->miscButtons(),  // bitmak of pressed "misc" buttons
        ctl->gyroX(),        // Gyro X
        ctl->gyroY(),        // Gyro Y
        ctl->gyroZ(),        // Gyro Z
        ctl->accelX(),       // Accelerometer X
        ctl->accelY(),       // Accelerometer Y
        ctl->accelZ()        // Accelerometer Z
    );
}

void dumpMouse(ControllerPtr ctl) {
    Serial.printf("idx=%d, buttons: 0x%04x, scrollWheel=0x%04x, delta X: %4d, delta Y: %4d\n",
                   ctl->index(),        // Controller Index
                   ctl->buttons(),      // bitmask of pressed buttons
                   ctl->scrollWheel(),  // Scroll Wheel
                   ctl->deltaX(),       // (-511 - 512) left X Axis
                   ctl->deltaY()        // (-511 - 512) left Y axis
    );
}

void dumpKeyboard(ControllerPtr ctl) {
    // TODO: Print pressed keys
    Serial.printf("idx=%d\n", ctl->index());
}

void dumpBalanceBoard(ControllerPtr ctl) {
    Serial.printf("idx=%d,  TL=%u, TR=%u, BL=%u, BR=%u, temperature=%d\n",
                   ctl->index(),        // Controller Index
                   ctl->topLeft(),      // top-left scale
                   ctl->topRight(),     // top-right scale
                   ctl->bottomLeft(),   // bottom-left scale
                   ctl->bottomRight(),  // bottom-right scale
                   ctl->temperature()   // temperature: used to adjust the scale value's precision
    );
}

void processGamepad(ControllerPtr ctl) {
    // There are different ways to query whether a button is pressed.
    // By query each button individually:
    //  a(), b(), x(), y(), l1(), etc...
    if (ctl->a()) {
        static int colorIdx = 0;
        // Some gamepads like DS4 and DualSense support changing the color LED.
        // It is possible to change it by calling:
        switch (colorIdx % 3) {
            case 0:
                // Red
                ctl->setColorLED(255, 0, 0);
                break;
            case 1:
                // Green
                ctl->setColorLED(0, 255, 0);
                break;
            case 2:
                // Blue
                ctl->setColorLED(0, 0, 255);
                break;
        }
        colorIdx++;
    }

    if (ctl->b()) {
        // Turn on the 4 LED. Each bit represents one LED.
        static int led = 0;
        led++;
        // Some gamepads like the DS3, DualSense, Nintendo Wii, Nintendo Switch
        // support changing the "Player LEDs": those 4 LEDs that usually indicate
        // the "gamepad seat".
        // It is possible to change them by calling:
        ctl->setPlayerLEDs(led & 0x0f);
    }

    if (ctl->x()) {
        // Duration: 255 is ~2 seconds
        // force: intensity
        // Some gamepads like DS3, DS4, DualSense, Switch, Xbox One S support
        // rumble.
        // It is possible to set it by calling:
        ctl->setRumble(0xc0 /* force */, 0xc0 /* duration */);
    }

    // Another way to query controller data is by getting the buttons() function.
    // See how the different "dump*" functions dump the Controller info.
    dumpGamepad(ctl);
}

void processMouse(ControllerPtr ctl) {
    // This is just an example.
    if (ctl->scrollWheel() > 0) {
        // Do Something
    } else if (ctl->scrollWheel() < 0) {
        // Do something else
    }

    // See "dumpMouse" for possible things to query.
    dumpMouse(ctl);
}

void processKeyboard(ControllerPtr ctl) {
    // This is just an example.
    if (ctl->isKeyPressed(Keyboard_A)) {
        // Do Something
        Serial.println("Key 'A' pressed");
    }

    // Don't do "else" here.
    // Multiple keys can be pressed at the same time.
    if (ctl->isKeyPressed(Keyboard_LeftShift)) {
        // Do something else
        Serial.println("Key 'LEFT SHIFT' pressed");
    }

    // Don't do "else" here.
    // Multiple keys can be pressed at the same time.
    if (ctl->isKeyPressed(Keyboard_LeftArrow)) {
        // Do something else
        Serial.println("Key 'Left Arrow' pressed");
    }

    // See "dumpKeyboard" for possible things to query.
    dumpKeyboard(ctl);
}

void processBalanceBoard(ControllerPtr ctl) {
    // This is just an example.
    if (ctl->topLeft() > 10000) {
        // Do Something
    }

    // See "dumpBalanceBoard" for possible things to query.
    dumpBalanceBoard(ctl);
}

// Arduino setup function. Runs in CPU 1
void setup() {
    Serial.begin(115200);
    Serial.printf("Firmware: %s\n", BP32.firmwareVersion());
    const uint8_t* addr = BP32.localBdAddress();
    Serial.printf("BD Addr: %2X:%2X:%2X:%2X:%2X:%2X\n", addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);

    // Setup the Bluepad32 callbacks
    BP32.setup(&onConnectedController, &onDisconnectedController);

    // "forgetBluetoothKeys()" should be called when the user performs
    // a "device factory reset", or similar.
    // Calling "forgetBluetoothKeys" in setup() just as an example.
    // Forgetting Bluetooth keys prevents "paired" gamepads to reconnect.
    // But might also fix some connection / re-connection issues.
    //BP32.forgetBluetoothKeys();

    // Enables mouse / touchpad support for gamepads that support them.
    // When enabled controllers like DualSense and DualShock4 generate two connected devices:
    // - First one: the gamepad
    // - Second one, which is a "vritual device", is a mouse
    // By default it is disabled.
    //BP32.enableVirtualDevice(false);

    // NE Added
    // Turn on Allowlist for selected MAC codes only.
    bd_addr_t my_controller = {0x98, 0xB6, 0xE9, 0x83, 0xF8, 0xF9};
    uni_bt_allowlist_add_addr(my_controller); // 98:B6:E9:83:F8:F9
    
    uni_bt_allowlist_set_enabled(true);

    if (uni_bt_allowlist_is_enabled()) {
      Serial.printf("True \n");
    } else {
      Serial.printf("False \n");
    }
}

// Arduino loop function. Runs in CPU 1
void loop() {
    // This call fetches all the gamepad info from the NINA (ESP32) module.
    // Just call this function in your main loop.
    // The gamepads pointer (the ones received in the callbacks) gets updated
    // automatically.
    BP32.update();

    // It is safe to always do this before using the gamepad API.
    // This guarantees that the gamepad is valid and connected.
    for (int i = 0; i < BP32_MAX_GAMEPADS; i++) {
        ControllerPtr myController = myControllers[i];

        if (myController && myController->isConnected()) {
            if (myController->isGamepad()) {
                processGamepad(myController);
            } else if (myController->isMouse()) {
                processMouse(myController);
            } else if (myController->isKeyboard()) {
                processKeyboard(myController);
            } else if (myController->isBalanceBoard()) {
                processBalanceBoard(myController);
            } else {
                Serial.printf("Data not available yet\n");
                continue;
            }
            // See ArduinoController.h for all the available functions.
        }
    }
    // The main loop must have some kind of "yield to lower priority task" event.
    // Otherwise the watchdog will get triggered.
    // If your main loop doesn't have one, just add a simple `vTaskDelay(1)`.
    // Detailed info here:
    // https://stackoverflow.com/questions/66278271/task-watchdog-got-triggered-the-tasks-did-not-reset-the-watchdog-in-time

    // vTaskDelay(1);
    delay(150);
}

PS Move Controller connects, but returns 0 for all values and doesn't process correctly [Bug]:

What happened?

A bug happened! Using Bluepad32 1.3.0 + NINA 3.7.0 fw on Arduino RP2040Connect, a previously known good configuration. PS4 Move controller connects but returns 0s (sometimes a really big number but 99% of the time it's 0s) on all fields with the default controller class. Also, processGamepad may not be running correctly as hardcoded output values for leds or rumble do nothing.

Bluepad32 Version

3.7.0

Bluepad32 version custom

Example: Using Git develop branch commit hash #xxxxxxx

Bluepad32 Platform

Arduino + NINA

Platform version

Arduino IDE 2.1.0

Controller

PsMove

ESP32 chip

ESP32

ESP32 board

Unsure

OS

Windows

Relevant log output

No response

Relevant sketch

No response

[Feature Request] Configurable buttons mappings via Bluetooth

It would be great if there was a way to connect with the Arduino via web bluetooth and issue commands to create custom button mappings.

This would allow consumers of this library to build web apps that allow users of their projects to create custom button mappings.

BlueRetro solve the configuration problem this way. You put the board into configuration mode. This means controllers cannot be connected but you can then connect a web app they provide via web bluetooth. Within this app you can then create mappings.

For this request i don't think we need the web app, just the means to connect to the Arduino.

I'm a nodejs dev so if/when this feature request is implemented i can build a Node based API that can run in node and the browser to communicate with Bluepad if that is helpful.

[Bug]: Mouse incorrectly reported as a Xbox One gamepad

What happened?

I've tried using a mouse that I've bough earlier Plexgear BT-200 which is available from here:
https://www.kjell.com/se/produkter/dator/datormus/tradlosa-moss/plexgear-tradlos-mellanstor-bluetooth-mus-p61714?gad_source=1&gclid=CjwKCAjwvrOpBhBdEiwAR58-3DdtIKX7hBMnB9uZcKrVltgNIA8F5HQsAuByna4v4W-_Zop7G4uOaxoCXgsQAvD_BwE

When attaching it is reported as a Xbox One controller.

Bluepad32 Version

Other

Bluepad32 version custom

3.9.0

Bluepad32 Platform

Arduino ESP-IDF

Platform version

ESP-IDF v4.4.5

Controller

Bluetooth mouse Plexgear BT-200

ESP32 chip

ESP32

ESP32 board

ESP32-WROOM similar to Unijoysticle

OS

Windows

Relevant log output

bp32> BTstack up and running at 08:3A:8D:1A:39:42
HCI not ready, cannot send packet, will again try later. Current state idx=1
Bluetooth BR/EDR keys:
Bluetooth LE keys:
.
BR/EDR scan -> 1
BLE scan -> 1
Firmware: Bluepad32 for Arduino v3.9.0
BD Addr:  8:3A:8D:1A:39:42
Deleting stored BR/EDR link keys:
.
Deleting stored BLE link keys:
.
Device found: DC:2C:26:BF:0A:2A with COD: 0x002580, pageScan 1, clock offset 0x16a3, rssi 226 dBm
Creating device: DC:2C:26:BF:0A:2A (idx=0)
uni_bt_process_fsm, bd addr:DC:2C:26:BF:0A:2A,  state: 1, incoming:0
uni_bt_process_fsm: requesting name
--> HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE
Name: 'Plexgear BT-200'
uni_bt_process_fsm, bd addr:DC:2C:26:BF:0A:2A,  state: 4, incoming:0
uni_bt_process_fsm: Starting L2CAP connection
--> HCI_EVENT_CONNECTION_COMPLETE
SM_EVENT_PAIRING_STARTED
Identity resolving failed for DC:2C:26:BF:0A:2A

--> HCI_EVENT_LINK_KEY_REQUEST:
SSP User Confirmation Request with numeric value '857133'
SSP User Confirmation Auto accept
Device found: DC:2C:26:BF:0A:2A with COD: 0x002580, pageScan 1, clock offset 0x16a9, rssi 226 dBm
Device already added, waiting (current state=0x09)...
uni_bt_process_fsm, bd addr:DC:2C:26:BF:0A:2A,  state: 9, incoming:0
--> HCI_EVENT_AUTHENTICATION_COMPLETE_EVENT: status=0, handle=0x0081
L2CAP_EVENT_CHANNEL_OPENED (channel=0x0041)
PSM: 0x0011, local CID=0x0041, remote CID=0x0042, handle=0x0081, incoming=0, local MTU=1691, remote MTU=48, addr=DC:2C:26:BF:0A:2A
HID Control opened, cid 0x41
uni_bt_process_fsm, bd addr:DC:2C:26:BF:0A:2A,  state: 10, incoming:0
uni_bt_process_fsm: Create L2CAP interrupt connection
L2CAP_EVENT_CHANNEL_OPENED (channel=0x0042)
PSM: 0x0013, local CID=0x0042, remote CID=0x0043, handle=0x0081, incoming=0, local MTU=1691, remote MTU=48, addr=DC:2C:26:BF:0A:2A
HID Interrupt opened, cid 0x42
Device DC:2C:26:BF:0A:2A is connected
uni_bt_process_fsm, bd addr:DC:2C:26:BF:0A:2A,  state: 12, incoming:0
uni_bt_process_fsm: starting SDP query
-----------> sdp_query_start()
Starting SDP VID/PID query for DC:2C:26:BF:0A:2A
Vendor ID: 0x00a0 - Product ID: 0x4503
Device (vendor_id=0x00a0, product_id=0x4503) not found in DB.
Device detected as Mouse: 0x320
uni_bt_process_fsm, bd addr:DC:2C:26:BF:0A:2A,  state: 6, incoming:0
uni_bt_process_fsm: querying HID descriptor
Starting SDP HID-descriptor query for DC:2C:26:BF:0A:2A
SDP HID Descriptor (64):
05 01 09 02 A1 01 85 02 09 01 A1 00 05 09 19 01 29 05 15 00 25 01 75 01 95 05 81 02 75 03 95 01 81 01 05 01 09 30 09 31 15 81 25 7F 75 08 95 02 81 06 09 38 15 81 25 7F 75 08 95 01 81 06 C0 C0
<----------- sdp_query_end()
uni_bt_process_fsm, bd addr:DC:2C:26:BF:0A:2A,  state: 8, incoming:0
uni_bt_process_fsm: Device is ready
mouse: vid=0x00a0, pid=0x4503, name='Plexgear BT-200' uses scale:1.000000
Device setup (DC:2C:26:BF:0A:2A) is complete
connected in total: 0x01 (flag)
controller connected: 0
CALLBACK: Gamepad is connected, index=0
Gamepad model: XBox One, VID=0x00a0, PID=0x4503
idx=0, dpad: 0x00, buttons: 0x0000, axis L:    0,    0, axis R:    0,    0, brake:    0, throttle:    0, misc: 0x00, gyro x:     0 y:     0 z:     0, accel x:     0 y:     0 z:     0

Relevant sketch

No response

The ESP32 WROOM32 development board is getting hot.

After compiling the code in Arduino IDE, the ESP32 starts to heat up significantly. With prolonged use of the board, the power circuit on the ESP32 burns out, specifically the +3.3 and GND tracks short circuit

Moving PS5 controller away from ESP32 cause unhandled Exception

Hello sir, I'm not sure where should I post this issue, I also posted this issue at :
https://github.com/ricardoquesada/bluepad32-arduino/issues
If it creates a duplicate, I will delete that post.

I connected a PS5 controller to ESP32, it is working fine unless I walk away with the PS5 controller from the ESP32. The issue starts to happen when the PS5 controller 6 meters away from the ESP32.

What happened:
I'm using 'Controller' from example. Upload Controller to ESP32.
image

Pair PS5 controller with ESP32
Take PS5 controller about 6 memters away from ESP32, turn myself around make sure my body is between the PS5 controller and the ESP32's direction. Keep walking untill abount 10 meters away from ESP32, the PS5 controller turned off itself.

Below error happened in ESP32

FEX 0 0
FEX 0 0
FEX 7 0
ASSERT_PARAM(0 7), in ld_acl.c at line 1772
Guru Meditation Error: Core 0 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x4008fed4: 00f01d00 00004136 f01d0000
Core 0 register dump:
PC : 0x4008fedb PS : 0x00060f34 A0 : 0x8008573e A1 : 0x3ffc1f50
A2 : 0x00000000 A3 : 0x00000000 A4 : 0x00000007 A5 : 0x3ff9cd42
A6 : 0x000006ec A7 : 0xfffffffb A8 : 0x8000814b A9 : 0x3ffc1ec0
A10 : 0x00000000 A11 : 0x3ffc1ee4 A12 : 0x3ffc1e8f A13 : 0x00000032
A14 : 0x00000000 A15 : 0x3ffc1e95 SAR : 0x00000004 EXCCAUSE: 0x00000000
EXCVADDR: 0x00000000 LBEG : 0x40090f09 LEND : 0x40090f19 LCOUNT : 0xfffffffe

Backtrace: 0x4008fed8:0x3ffc1f50 0x4008573b:0x3ffc1f70 0x400327cb:0x3ffc1f90 0x40087bb5:0x3ffc1fd0 0x40087e89:0x3ffc1ff0 0x4008bde6:0x3ffc2020 0x4008c8af:0x3ffc2040 0x400850be:0x3ffc2060 0x400853dd:0x3ffc2080 0x400853bf:0x00000000 |<-CORRUPTED

ELF file SHA256: 60dedc08e98be6b0

Rebooting...

[Bug]: Xbox controllers using FW 5.x don't support rumble

What happened?

Rumble works in Xbox controllers when they are using firmware 3.x and 4.x
But not when using FW 5.x.

This is because v5.x is using BLE, and the the new way to rumble was not implemented

Bluepad32 Version

latest from develop branch

Bluepad32 version custom

Example: Using Git develop branch commit hash #xxxxxxx

Bluepad32 Platform

Other

Platform version

All

Controller

Xbox Wireless controller

ESP32 chip

ESP32

ESP32 board

ESP32-S3-WROOM1 DevKit from Lolin. This is the store URL: https://example.com

OS

None

Relevant log output

No response

Relevant sketch

No response

[Bug]: gyro x not working with Dualshock 4 (not the original one)

What happened?

Hi,

I get this result with Dualshock 4 (not the original one), the gyro X is not at 0 with no moves :

BTstack up and running at 7C:...
Firmware: Bluepad32 for Arduino v3.7.3
BD Addr: 7C:9E:BD:4B:14:C2
CALLBACK: Gamepad is connected, index=0
Gamepad model: DualShock 4, VID=0x054c, PID=0x05c4
idx=0, dpad: 0x00, buttons: 0x0000, axis L:    0,    0, axis R:    0,    0, brake:    0, throttle:    0, misc: 0x00, gyro x:     0 y:     0 z:     0, accel x:     0 y:     0 z:     0
idx=0, dpad: 0x00, buttons: 0x0000, axis L:    0,    0, axis R:    0,    0, brake:    0, throttle:    0, misc: 0x00, gyro x:     0 y:     0 z:     0, accel x:     0 y:     0 z:     0
idx=0, dpad: 0x00, buttons: 0x0000, axis L:    0,    0, axis R:    0,    0, brake:    0, throttle:    0, misc: 0x00, gyro x:     0 y:     0 z:     0, accel x:     0 y:     0 z:     0
idx=0, dpad: 0x00, buttons: 0x0000, axis L:    0,    0, axis R:    0,    0, brake:    0, throttle:    0, misc: 0x00, gyro x:     0 y:     0 z:     0, accel x:     0 y:     0 z:     0
idx=0, dpad: 0x00, buttons: 0x0000, axis L:    0,    0, axis R:    0,    0, brake:    0, throttle:    0, misc: 0x00, gyro x:     0 y:     0 z:     0, accel x:     0 y:     0 z:     0
idx=0, dpad: 0x00, buttons: 0x0000, axis L:    4,    4, axis R:    4,    4, brake:    0, throttle:    0, misc: 0x00, gyro x:     0 y:     0 z:     0, accel x:     0 y:     0 z:     0
idx=0, dpad: 0x00, buttons: 0x0000, axis L:    4,    4, axis R:    4,    4, brake:    0, throttle:    0, misc: 0x00, gyro x:     0 y:     0 z:     0, accel x:     0 y:     0 z:     0
idx=0, dpad: 0x00, buttons: 0x0000, axis L:    4,    4, axis R:    4,    4, brake:    0, throttle:    0, misc: 0x00, gyro x: -8000 y:     0 z:     0, accel x:  -192 y:  7553 z:  1897
idx=0, dpad: 0x00, buttons: 0x0000, axis L:    4,    4, axis R:    4,    4, brake:    0, throttle:    0, misc: 0x00, gyro x: -8000 y:     0 z:     0, accel x:  -192 y:  7553 z:  1897
idx=0, dpad: 0x00, buttons: 0x0000, axis L:    4,    4, axis R:    4,    4, brake:    0, throttle:    0, misc: 0x00, gyro x: -5568 y:     0 z:     0, accel x:  -210 y:  7549 z:  1868
idx=0, dpad: 0x00, buttons: 0x0000, axis L:    4,    4, axis R:    4,    4, brake:    0, throttle:    0, misc: 0x00, gyro x: -5568 y:     0 z:     0, accel x:  -210 y:  7549 z:  1868
idx=0, dpad: 0x00, buttons: 0x0000, axis L:    4,    4, axis R:    4,    4, brake:    0, throttle:    0, misc: 0x00, gyro x: -6208 y:     0 z:     0, accel x:  -190 y:  7545 z:  1879
idx=0, dpad: 0x00, buttons: 0x0000, axis L:    4,    4, axis R:    4,    4, brake:    0, throttle:    0, misc: 0x00, gyro x: -6208 y:     0 z:     0, accel x:  -190 y:  7545 z:  1879

Bluepad32 Version

3.7.2 (latest stable)

Bluepad32 version custom

Example: Using Git develop branch commit hash #xxxxxxx

Bluepad32 Platform

None

Platform version

E.g: Arduino IDE 2.1.0, or ESP-IDF v4.4.4, or CircuitPython 8.0.0, etc.

ESP32 chip

ESP32

ESP32 board

ESP32-S3-WROOM1 DevKit from Lolin. This is the store URL: https://example.com

OS

None

Relevant log output

No response

Relevant sketch

No response

[Bug]: DS4 Gyro and Accel

What happened?

I am playing with Bluepad and this is working really well even with a DS4 clone that I was not able to pair with another library. Thank you very much for your work !

Using your arduino Controller example it looks like Gyro and Accel datas are reversed because the printed Accel is stable and depending on the orientation of the controller and Gyro datas change a lot with rapid movements. I tried with both controllers : clone (Data frog CFKJ-P02-DEC-16) and official (CUH-ZCT1).

Bluepad32 Version

Other

Bluepad32 version custom

Not sure about my version but in Arduino board manager : esp32_bluepad 3.10.2

Bluepad32 Platform

Arduino IDE

Platform version

Arduino IDE 2.2.1

Controller

  • clone (Data frog CFKJ-P02-DEC-16)
  • official (CUH-ZCT1)

ESP32 chip

ESP32

ESP32 board

ESP32 DevKit WROOM32

OS

Windows

Relevant log output

Controller placed on the table then caught and finally put back down :

gyro x:     0 y:     0 z:     0, accel x:  -223 y:  8300 z:  1393
gyro x:     0 y:     0 z:     0, accel x:  -240 y:  8301 z:  1393
gyro x:     0 y:     0 z:     0, accel x:  -220 y:  8257 z:  1439
gyro x:     0 y:     0 z:     0, accel x:  -205 y:  8269 z:  1399
gyro x:     0 y:     0 z:     0, accel x:  -197 y:  8288 z:  1432
gyro x:     0 y:     0 z:     0, accel x:  -193 y:  8295 z:  1415
gyro x:     0 y:     0 z:     0, accel x:  -211 y:  8279 z:  1431
gyro x:     0 y:     0 z:     0, accel x:  -183 y:  8307 z:  1399
gyro x:     0 y:     0 z:     0, accel x:  -251 y:  8285 z:  1401
gyro x:     0 y:     0 z:     0, accel x:  -183 y:  8271 z:  1445
gyro x:     0 y:     0 z:     0, accel x:  -222 y:  8245 z:  1462
gyro x: 66626 y:     0 z: 92354, accel x:   524 y:  9338 z:  1299
gyro x: 78146 y: 11456 z: 72194, accel x:  3031 y:  6743 z:  -449
gyro x:-42689 y:-19328 z:-84034, accel x:  2085 y:  7572 z: -1374
gyro x:-245191 y:-38017 z:-59137, accel x:  -419 y:  7459 z:  1207
gyro x:     0 y:     0 z: -7424, accel x:  -279 y:  8412 z:  1053
gyro x:     0 y:     0 z:     0, accel x:  -120 y:  8274 z:  1442
gyro x:     0 y:     0 z:     0, accel x:  -147 y:  8305 z:  1436
gyro x:     0 y:     0 z:     0, accel x:  -119 y:  8309 z:  1439
gyro x:     0 y:     0 z:     0, accel x:  -146 y:  8320 z:  1425
gyro x:     0 y:     0 z:     0, accel x:  -140 y:  8281 z:  1407
gyro x:     0 y:     0 z:     0, accel x:  -151 y:  8277 z:  1425
gyro x:     0 y:     0 z:     0, accel x:  -174 y:  8326 z:  1392

Relevant sketch

Bluepad example : Controller

Xbox system button no longer works

Firstly sorry to report another issue, seems like I'm spamming you recently with changes!

However the following code snippet reports false for a XBOX one s controller even when the Xbox button is pressed. I have a PS4 controller which works fine when the PS button is pressed.

myGamepad->miscSystem();

This is on a Arduino nano 33 IOT.

Arduino library: v1.1.2
Nina firmware: Bluepad32 for NINA v3.5-beta1

How to disconnect controller?

Is there a built-in method in this library that I can use to disconnect a connected controller after pressing any button on the controller , if not, can you suggest a way to achieve this.

DS4 setColorLED

Using Bluepad example : Controller and changing setColorLed values

I don't see differences between values from 90 to 255, maybe it's a percentage and the value should be 0 to 100? The example uses 255 by default which leads me to believe that there is a scaling error?

Bluepad32 version
esp32_bluepad 3.10.2

Bluepad32 Platform
Arduino IDE 2.2.1

void processGamepad(ControllerPtr ctl) {
    // There are different ways to query whether a button is pressed.
    // By query each button individually:
    //  a(), b(), x(), y(), l1(), etc...
    if (ctl->a()) {
        static int colorIdx = 0;
        ctl->setColorLED(colorIdx, 0, 0);
        colorIdx+=10;
        if(colorIdx > 200)
          colorIdx = 0;

[Bug]: `uni_hid_device_get_idx_for_instance()` reports index 0 for all devices

What happened?

Running example program, inside static void my_platform_on_controller_data(uni_hid_device_t* d, uni_controller_t* ctl) I've set a variable to get the index of each connected gamepad, all report to zero.

static void my_platform_on_controller_data(uni_hid_device_t* d, uni_controller_t* ctl) {
    int id = uni_hid_device_get_idx_for_instance(d);
    logi("id %d ", idx);
    ...

Bluepad32 Version

Latest

Bluepad32 version custom

Develop branch

Bluepad32 Platform

Other

Platform version

Pico W

Controller

Joycons, Xbox Series controller

ESP32 chip

None, Raspberry Pi pico W

OS

Linux

Relevant log output

(0x20006644) dpad=0x00, x= -54, y=  79, rx=   0, ry=   0, brake=   0, throttle=   0, buttons=0x0000, misc=0x00, gyro= 176000, -39000, 120000 accel=    535,  -3105,  -2859, batte5
id: 0
(0x20006644) dpad=0x00, x= -54, y=  78, rx=   0, ry=   0, brake=   0, throttle=   0, buttons=0x0000, misc=0x00, gyro=-417000,-112000, -48000 accel=    611,  -3131,  -2622, batte5
id: 0
(0x200039bc) dpad=0x02, x= -15, y= -23, rx=  -4, ry=   7, brake=   0, throttle=   0, buttons=0x0000, misc=0x00, gyro=      0,      0,      0 accel=      0,      0,      0, batte0
id: 0
(0x200039bc) dpad=0x00, x= -15, y= -23, rx=  -4, ry=   7, brake=   0, throttle=   0, buttons=0x0000, misc=0x00, gyro=      0,      0,      0 accel=      0,      0,      0, batte0
id: 0

Relevant sketch

  • Use example for pico w platform on latest commit of develop branch.
  • Change code of static void my_platform_on_controller_data(uni_hid_device_t* d, uni_controller_t* ctl), add the following two lines at the beginning:
static void my_platform_on_controller_data(uni_hid_device_t* d, uni_controller_t* ctl) {
    int id = uni_hid_device_get_idx_for_instance(d);
    logi("id %d ", idx);
    ...
  • Compile and flash program, output should only net id of value 0.

Uno R4

The R4 isn't included on the list of available boards, will it work with the adding new platform manual under docs?

quick connection to one gamepad

I made 8 cars for the kids that were controlled by gamepads; when they turn on the controls at the same time, it gets confusing. it becomes unclear which gamepad controls the car.

I would like to indicate in the firmware which gamepad the controller should work with. so that the controller does not search for all gamepads, but connects only to its own.

Now we have to turn on the machines one by one. It is difficult to explain to young children that they cannot turn on the machine and need to wait.

got a it_wdt_reset if call uni_gamepad_dump function

hi there!

I got a it_wdt_reset if call uni_gamepad_dump function .It usually appears in a few minutes.I tryed to set Interrupt watchdog timeout bigger but is no efect.even if turn off Interrupt watchdog.

and is hard to conect to xboxone controller some times.

.............................................
(0xb0cfc7f) dpad=0x00, x=-6, y=-4, rx=-15, ry=10, brake=0, accel=0, buttons=0x00000000, misc=0x00
(0xb0cfc7f) dpad=0x00, x=-6, y=-4, rx=-15, ry=5, brake=0, accel=0, buttons=0x00000000, misc=0x00
(0xb0cfc7f) dpad=0x00, x=-6, y=-4, rx=-15, ry=2, brake=0, accel=0, buttons=0x00000000, misc=0x00
(0xb0cfc7f) dpad=0x00, x=-6, y=-4, rx=-15, ry=0, brake=0, accel=0, buttons=0x00000000, misc=0x00
ASSERT_PARAM(2097152 0), in rwbt.c at line 381
Guru Meditation Error: Core 0 panic'ed (Interrupt wdt timeout on CPU0).

Core 0 register dump:
PC : 0x400877e3 PS : 0x00060034 A0 : 0x8008dc40 A1 : 0x3ffbea80
0x400877e3: r_assert_param at ??:?

A2 : 0x00000001 A3 : 0x00000000 A4 : 0x60008048 A5 : 0x00000000
A6 : 0x00000004 A7 : 0x3ffbdbb4 A8 : 0x800877e0 A9 : 0x3ffbea60
A10 : 0x00000000 A11 : 0x0000002f A12 : 0x00000014 A13 : 0xffffffff
A14 : 0x00000000 A15 : 0xfffffffc SAR : 0x00000004 EXCCAUSE: 0x00000005
EXCVADDR: 0x00000000 LBEG : 0x40087718 LEND : 0x4008771f LCOUNT : 0x00000000
0x40087718: r_assert_param at ??:?

0x4008771f: r_assert_param at ??:?

Core 0 was running in ISR context:
EPC1 : 0x400d3aef EPC2 : 0x00000000 EPC3 : 0x00000000 EPC4 : 0x400877e3
0x400d3aef: uart_hal_write_txfifo at D:/Desktop/esp-idf/components/hal/uart_hal_iram.c:35

0x400877e3: r_assert_param at ??:?

Backtrace:0x400877e0:0x3ffbea80 0x4008dc3d:0x3ffbeaa0 0x4008e05b:0x3ffbeac0 0x400829ad:0x3ffbeae0 0x4011c4b3:0x3ffd1720 0x400d98b7:0x3ffd1740 0x40091235:0x3ffd1760 0x4009341d:0x3ffd1780
0x400877e0: r_assert_param at ??:?

0x4008dc3d: r_rwbt_isr at ??:?

0x4008e05b: r_rwbtdm_isr_wrapper at intc.c:?

0x400829ad: _xt_lowint1 at D:/Desktop/esp-idf/components/freertos/port/xtensa/xtensa_vectors.S:1105

0x4011c4b3: cpu_ll_waiti at d:\desktop\esp-idf\bluepad32\src\build/../../../components/hal/esp32/include/hal/cpu_ll.h:183
(inlined by) esp_pm_impl_waiti at D:/Desktop/esp-idf/components/esp_pm/pm_impl.c:827

0x400d98b7: esp_vApplicationIdleHook at D:/Desktop/esp-idf/components/esp_common/src/freertos_hooks.c:63

0x40091235: prvIdleTask at D:/Desktop/esp-idf/components/freertos/tasks.c:3839 (discriminator 1)

0x4009341d: vPortTaskWrapper at D:/Desktop/esp-idf/components/freertos/port/xtensa/port.c:168

Core 1 register dump:
PC : 0x4011c4b6 PS : 0x00060a34 A0 : 0x800d98ba A1 : 0x3ffd2180
0x4011c4b6: esp_pm_impl_waiti at D:/Desktop/esp-idf/components/esp_pm/pm_impl.c:829

A2 : 0x00000000 A3 : 0x00000000 A4 : 0x00000001 A5 : 0x80000001
A6 : 0x00000003 A7 : 0x00060023 A8 : 0x800f3ada A9 : 0x3ffd2150
A10 : 0x00000000 A11 : 0x00060c23 A12 : 0x00060c20 A13 : 0x00060c23
A14 : 0x00000001 A15 : 0x00000000 SAR : 0x0000001e EXCCAUSE: 0x00000005
EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000

Backtrace:0x4011c4b3:0x3ffd2180 0x400d98b7:0x3ffd21a0 0x40091235:0x3ffd21c0 0x4009341d:0x3ffd21e0
0x4011c4b3: cpu_ll_waiti at d:\desktop\esp-idf\bluepad32\src\build/../../../components/hal/esp32/include/hal/cpu_ll.h:183
(inlined by) esp_pm_impl_waiti at D:/Desktop/esp-idf/components/esp_pm/pm_impl.c:827

0x400d98b7: esp_vApplicationIdleHook at D:/Desktop/esp-idf/components/esp_common/src/freertos_hooks.c:63

0x40091235: prvIdleTask at D:/Desktop/esp-idf/components/freertos/tasks.c:3839 (discriminator 1)

0x4009341d: vPortTaskWrapper at D:/Desktop/esp-idf/components/freertos/port/xtensa/port.c:168

ELF file SHA256: fae0159e96f8dc68

I (19409) esp_core_dump_flash: Save core dump to flash...
I (19416) esp_core_dump_flash: Erase flash 16384 bytes @ 0x110000
I (19643) esp_core_dump_flash: Write end offset 0x3124, check sum length 4
I (19643) esp_core_dump_flash: Core dump has been saved to flash.
Rebooting...
ets Jun 8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:6948
load:0x40078000,len:14308
load:0x40080400,len:3708
0x40080400: _init at ??:?

entry 0x40080680
I (27) boot: ESP-IDF v4.3.1 2nd stage bootloader
I (27) boot: compile time 20:42:13
I (27) boot: chip revision: 1
I (30) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (37) boot.esp32: SPI Speed : 40MHz
I (42) boot.esp32: SPI Mode : DIO
I (46) boot.esp32: SPI Flash Size : 4MB
I (51) boot: Enabling RNG early entropy source...
I (56) boot: Partition Table:
I (60) boot: ## Label Usage Type ST Offset Length
I (67) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (74) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (82) boot: 2 factory factory app 00 00 00010000 00100000
I (89) boot: 3 coredump Unknown data 01 03 00110000 00010000
I (97) boot: End of partition table
I (101) boot_comm: chip revision: 1, min. application chip revision: 0
I (108) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=15708h ( 87816) map
I (149) esp_image: segment 1: paddr=00025730 vaddr=3ffbdb60 size=05170h ( 20848) load
I (157) esp_image: segment 2: paddr=0002a8a8 vaddr=40080000 size=05770h ( 22384) load
I (166) esp_image: segment 3: paddr=00030020 vaddr=400d0020 size=4d39ch (316316) map
I (281) esp_image: segment 4: paddr=0007d3c4 vaddr=40085770 size=10c48h ( 68680) load
I (309) esp_image: segment 5: paddr=0008e014 vaddr=50000000 size=00010h ( 16) load
I (321) boot: Loaded app from partition at offset 0x10000
I (321) boot: Disabling RNG early entropy source...
I (333) cpu_start: Pro cpu up.
I (333) cpu_start: Starting app cpu, entry point is 0x400811ac
0x400811ac: call_start_cpu1 at D:/Desktop/esp-idf/components/esp_system/port/cpu_start.c:141

I (320) cpu_start: App cpu up.
I (349) cpu_start: Pro cpu start user code
I (349) cpu_start: cpu freq: 160000000
I (349) cpu_start: Application information:
I (354) cpu_start: Project name: bluepad32-app
I (359) cpu_start: App version: 3.0.0
I (364) cpu_start: Compile time: Mar 16 2022 02:36:29
I (370) cpu_start: ELF file SHA256: fae0159e96f8dc68...
I (376) cpu_start: ESP-IDF: v4.3.1
I (381) heap_init: Initializing. RAM available for dynamic allocation:
I (388) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
I (394) heap_init: At 3FFB7CD8 len 00000328 (0 KiB): DRAM
I (400) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM
I (407) heap_init: At 3FFD06C8 len 0000F938 (62 KiB): DRAM
I (413) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (419) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (426) heap_init: At 400963B8 len 00009C48 (39 KiB): IRAM
I (434) esp_core_dump_flash: Init core dump to flash
I (438) esp_core_dump_flash: Found partition 'coredump' @ 110000 65536 bytes
I (458) esp_core_dump_flash: Core dump data checksum is correct
I (458) esp_core_dump_flash: Found core dump 12580 bytes in flash @ 0x110000
luepad32 (C) 2016-2022 Ricardo Quesada and contributors.
Version: v3.0.0
BTStack: Copyright (C) 2017 BlueKitchen GmbH.
I (507) gpio: GPIO[2]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (507) gpio: GPIO[4]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (517) gpio: GPIO[13]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (527) gpio: GPIO[14]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (537) gpio: GPIO[16]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (547) gpio: GPIO[17]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (557) gpio: GPIO[18]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (567) gpio: GPIO[19]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (577) gpio: GPIO[21]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (587) gpio: GPIO[22]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (597) gpio: GPIO[23]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (607) gpio: GPIO[25]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (617) gpio: GPIO[26]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (617) gpio: GPIO[27]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (627) gpio: GPIO[32]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (637) gpio: GPIO[33]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
pc_debug: init()
Platform: PC Debug
Gap security level: 2
Periodic Inquiry: max=5, min=4, len=3
I (657) BTDM_INIT: BT controller compile version [bfbbe1e]
I (667) system_api: Base MAC address is not set
I (667) system_api: read default base MAC address from EFUSE
I (677) phy_init: phy_version 4670,719f9f6,Feb 18 2021,17:07:07
BTstack up and running at E8:68:E7:23:56:82
HCI not ready, cannot send packet, will again try later. Current state idx=1
HCI not ready, cannot send packet, will again try later. Current state idx=2
BTstack up and running on E8:68:E7:23:56:82.
pc_debug: get_property(): 0
Stored link keys:
3F C2 9B 99 7D 28 26 62 1B 4C 81 F9 43 86 04 5E
5C:BA:37:FF:6E:6B - type 4, key: .
pc_debug: on_init_complete()
--> HCI_EVENT_CONNECTION_REQUEST: link_type = 1 <--
on_hci_connection_request from: address = 5C:BA:37:FF:6E:6B, cod=0x0508
--> HCI_EVENT_ROLE_CHANGE
--> HCI_EVENT_CONNECTION_COMPLETE
--> HCI_EVENT_LINK_KEY_REQUEST:
--> HCI_EVENT_LINK_KEY_REQUEST:
--> L2CAP_EVENT_INCOMING_CONNECTION
L2CAP_EVENT_INCOMING_CONNECTION (psm=0x0011, local_cid=0x0041, remote_cid=0x0040, handle=0x0080, channel=0x0041, addr=5C:BA:37:FF:6E:6B
--> HCI_EVENT_AUTHENTICATION_COMPLETE_EVENT: status=0, handle=0x0080
--> HCI_EVENT_LINK_KEY_REQUEST:
--> HCI_EVENT_AUTHENTICATION_COMPLETE_EVENT: status=0, handle=0x0080
L2CAP_EVENT_CHANNEL_OPENED (channel=0x0041)
PSM: 0x0011, local CID=0x0041, remote CID=0x0040, handle=0x0080, incoming=1, local MTU=1691, remote MTU=1480, addr=5C:BA:37:FF:6E:6B
HID Control opened, cid 0x41
uni_bluetooth_process_fsm, bd addr:5C:BA:37:FF:6E:6B, state: 10, incoming:1
--> L2CAP_EVENT_INCOMING_CONNECTION
L2CAP_EVENT_INCOMING_CONNECTION (psm=0x0013, local_cid=0x0042, remote_cid=0x0041, handle=0x0080, channel=0x0042, addr=5C:BA:37:FF:6E:6B
L2CAP_EVENT_CHANNEL_OPENED (channel=0x0042)
PSM: 0x0013, local CID=0x0042, remote CID=0x0041, handle=0x0080, incoming=1, local MTU=1691, remote MTU=1480, addr=5C:BA:37:FF:6E:6B
HID Interrupt opened, cid 0x42
pc_debug: device connected: 0x3ffc42ac
uni_bluetooth_process_fsm, bd addr:5C:BA:37:FF:6E:6B, state: 12, incoming:1
uni_bluetooth_process_fsm: requesting name
--> HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE
Name: 'Xbox Wireless Controller'
uni_bluetooth_process_fsm, bd addr:5C:BA:37:FF:6E:6B, state: 4, incoming:1
uni_bluetooth_process_fsm: starting SDP query
-----------> sdp_query_start()
Starting SDP VID/PID query for 5C:BA:37:FF:6E:6B
Vendor ID: 0x045e - Product ID: 0x02fd
Device detected as Xbox One: 0x20
uni_bluetooth_process_fsm, bd addr:5C:BA:37:FF:6E:6B, state: 6, incoming:1
uni_bluetooth_process_fsm: querying HID descriptor
Starting SDP HID-descriptor query for 5C:BA:37:FF:6E:6B
SDP HID Descriptor (334):
05 01 09 05 A1 01 85 01 09 01 A1 00 09 30 09 31 15 00 27 FF FF 00 00 95 02 75 10 81 02 C0 09 01 A1 00 09 32 09 35 15 00 27 FF FF 00 00 95 02 75 10 81 02 C0 05 02 09 C5 15 00 26 FF 03 95 01 75 0A 81 02 15 00 25 00 75 06 95 01 81 03 05 02 09 C4 15 00 26 FF 03 95 01 75 0A 81 02 15 00 25 00 75 06 95 01 81 03 05 01 09 39 15 01 25 08 35 00 46 3B 01 66 14 00 75 04 95 01 81 42 75 04 95 01 15 00 25 00 35 00 45 00 65 00 81 03 05 09 19 01 29 0F 15 00 25 01 75 01 95 0F 81 02 15 00 25 00 75 01 95 01 81 03 05 0C 0A 24 02 15 00 25 01 95 01 75 01 81 02 15 00 25 00 75 07 95 01 81 03 05 0C 09 01 85 02 A1 01 05 0C 0A 23 02 15 00 25 01 95 01 75 01 81 02 15 00 25 00 75 07 95 01 81 03 C0 05 0F 09 21 85 03 A1 02 09 97 15 00 25 01 75 04 95 01 91 02 15 00 25 00 75 04 95 01 91 03 09 70 15 00 25 64 75 08 95 04 91 02 09 50 66 01 10 55 0E 15 00 26 FF 00 75 08 95 01 91 02 09 A7 15 00 26 FF 00 75 08 95 01 91 02 65 00 55 00 09 7C 15 00 26 FF 00 75 08 95 01 91 02 C0 05 06 09 20 85 04 15 00 26 FF 00 75 08 95 01 81 02 C0
Xbox One: Unsupported page: 0x0002, usage: 0x00c5, value=0x0
Xbox One: Unsupported page: 0x0002, usage: 0x00c4, value=0x0
Xbox One: Unsupported page: 0x0009, usage: 0x000b, value=0x0
Xbox One: Unsupported page: 0x0009, usage: 0x000c, value=0x0
Xbox One: Unsupported page: 0x0009, usage: 0x000d, value=0x0
Xbox One: Unsupported page: 0x0009, usage: 0x000e, value=0x0
Xbox one: Firmware 4.8 detected
<----------- sdp_query_end()
uni_bluetooth_process_fsm, bd addr:5C:BA:37:FF:6E:6B, state: 8, incoming:1
Xbox one: Assuming it is firmware 4.8
Device setup (5C:BA:37:FF:6E:6B) is complete
pc_debug: device ready: 0x3ffc42ac
(0xb0cfc7f) dpad=0x00, x=-5, y=-5, rx=-14, ry=0, brake=0, accel=0, buttons=0x00000000, misc=0x00
(0xb0cfc7f) dpad=0x00, x=-5, y=-5, rx=-14, ry=0, brake=0, accel=0, buttons=0x00000000, misc=0x00

[Bug]: Stadia Controller error: 'NINA_GPIO0' was not declared in this scope

What happened?

Would not compile.

Bluepad32 Version

3.10.3

Bluepad32 version custom

PACKAGES:

  • framework-arduinoespressif32 @ 3.20011.230801 (2.0.11)
  • tool-esptoolpy @ 1.40501.0 (4.5.1)
  • toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5

Dependency Graph
|-- Bluepad32 @ 1.3.1

Bluepad32 Platform

Other

Platform version

Processing PlatformIO
using dfrobot_firebeetle2_esp32e (platform: espressif32; board: dfrobot_firebeetle2_esp32e; framework: arduino)

Controller

issues

ESP32 chip

ESP32

ESP32 board

We used: FireBeetle 2 ESP32-E IoT Microcontroller (Supports Wi-Fi & Bluetooth)

OS

macOS

Relevant log output

Compiling .pio/build/dfrobot_firebeetle2_esp32e/lib3f3/Bluepad32/utility/spi_drv.cpp.o
src/main.cpp: In function 'void setup()':
src/main.cpp:50:15: error: 'onConnectedController' was not declared in this scope
   BP32.setup(&onConnectedController, &onDisconnectedController);
               ^~~~~~~~~~~~~~~~~~~~~
src/main.cpp:50:39: error: 'onDisconnectedController' was not declared in this scope
   BP32.setup(&onConnectedController, &onDisconnectedController);
                                       ^~~~~~~~~~~~~~~~~~~~~~~~
Compiling .pio/build/dfrobot_firebeetle2_esp32e/FrameworkArduino/Esp.cpp.o
Compiling .pio/build/dfrobot_firebeetle2_esp32e/FrameworkArduino/FirmwareMSC.cpp.o
Compiling .pio/build/dfrobot_firebeetle2_esp32e/FrameworkArduino/FunctionalInterrupt.cpp.o
Compiling .pio/build/dfrobot_firebeetle2_esp32e/FrameworkArduino/HWCDC.cpp.o
Compiling .pio/build/dfrobot_firebeetle2_esp32e/FrameworkArduino/HardwareSerial.cpp.o
Compiling .pio/build/dfrobot_firebeetle2_esp32e/FrameworkArduino/IPAddress.cpp.o
Compiling .pio/build/dfrobot_firebeetle2_esp32e/FrameworkArduino/IPv6Address.cpp.o
Compiling .pio/build/dfrobot_firebeetle2_esp32e/FrameworkArduino/MD5Builder.cpp.o
*** [.pio/build/dfrobot_firebeetle2_esp32e/src/main.cpp.o] Error 1
.pio/libdeps/dfrobot_firebeetle2_esp32e/Bluepad32/src/utility/spi_drv.cpp: In static member function 'static void SpiDrv::begin()':
.pio/libdeps/dfrobot_firebeetle2_esp32e/Bluepad32/src/utility/spi_drv.cpp:91:20: error: 'PINS_COUNT' was not declared in this scope
   if (SLAVERESET > PINS_COUNT) {
                    ^~~~~~~~~~
.pio/libdeps/dfrobot_firebeetle2_esp32e/Bluepad32/src/utility/spi_drv.cpp:91:20: note: suggested alternative: 'ICOUNT'
   if (SLAVERESET > PINS_COUNT) {
                    ^~~~~~~~~~
                    ICOUNT
.pio/libdeps/dfrobot_firebeetle2_esp32e/Bluepad32/src/utility/spi_drv.cpp:100:11: error: 'NINA_GPIO0' was not declared in this scope
   pinMode(NINA_GPIO0, OUTPUT);
           ^~~~~~~~~~
.pio/libdeps/dfrobot_firebeetle2_esp32e/Bluepad32/src/utility/spi_drv.cpp:100:11: note: suggested alternative: 'NINA_GPIOIRQ'
   pinMode(NINA_GPIO0, OUTPUT);
           ^~~~~~~~~~
           NINA_GPIOIRQ
.pio/libdeps/dfrobot_firebeetle2_esp32e/Bluepad32/src/utility/spi_drv.cpp: In static member function 'static int SpiDrv::available()':
.pio/libdeps/dfrobot_firebeetle2_esp32e/Bluepad32/src/utility/spi_drv.cpp:66:22: error: 'NINA_GPIO0' was not declared in this scope
 #define NINA_GPIOIRQ NINA_GPIO0
                      ^~~~~~~~~~
.pio/libdeps/dfrobot_firebeetle2_esp32e/Bluepad32/src/utility/spi_drv.cpp:539:47: note: in expansion of macro 'NINA_GPIOIRQ'
 int SpiDrv::available() { return (digitalRead(NINA_GPIOIRQ) != LOW); }
                                               ^~~~~~~~~~~~
.pio/libdeps/dfrobot_firebeetle2_esp32e/Bluepad32/src/utility/spi_drv.cpp:66:22: note: suggested alternative: 'NINA_GPIOIRQ'
 #define NINA_GPIOIRQ NINA_GPIO0
                      ^~~~~~~~~~
.pio/libdeps/dfrobot_firebeetle2_esp32e/Bluepad32/src/utility/spi_drv.cpp:539:47: note: in expansion of macro 'NINA_GPIOIRQ'
 int SpiDrv::available() { return (digitalRead(NINA_GPIOIRQ) != LOW); }
                                               ^~~~~~~~~~~~
*** [.pio/build/dfrobot_firebeetle2_esp32e/lib3f3/Bluepad32/utility/spi_drv.cpp.o] Error 1

Relevant sketch

#include <Arduino.h>

// Copyright 2021 - 2023, Ricardo Quesada
// SPDX-License-Identifier: Apache 2.0 or LGPL-2.1-or-later

/*
 * This example shows how to use the Controller API.
 *
 * Supported on boards with NINA W10x. In particular, these boards:
 *  - Arduino MKR WiFi 1010,
 *  - UNO WiFi Rev.2,
 *  - Nano RP2040 Connect,
 *  - Nano 33 IoT,
 *  - Arduino MKR Vidor 4000
 */
#include <Bluepad32.h>

ControllerPtr myControllers[BP32_MAX_CONTROLLERS];

// Arduino setup function. Runs in CPU 1
void setup() {
  // Initialize serial
  Serial.begin(9600);
  while (!Serial) {
    // Wait for serial port to connect.
    // You don't have to do this in your game. This is only for debugging
    // purposes, so that you can see the output in the serial console.
    ;
  }

  String fv = BP32.firmwareVersion();
  Serial.print("Firmware version installed: ");
  Serial.println(fv);

  // To get the BD Address (MAC address) call:
  const uint8_t* addr = BP32.localBdAddress();
  Serial.print("BD Address: ");
  for (int i = 0; i < 6; i++) {
    Serial.print(addr[i], HEX);
    if (i < 5)
      Serial.print(":");
    else
      Serial.println();
  }

  // BP32.pinMode(27, OUTPUT);
  // BP32.digitalWrite(27, 0);

  // This call is mandatory. It sets up Bluepad32 and creates the callbacks.
  BP32.setup(&onConnectedController, &onDisconnectedController);

  // "forgetBluetoothKeys()" should be called when the user performs
  // a "device factory reset", or similar.
  // Calling "forgetBluetoothKeys" in setup() just as an example.
  // Forgetting Bluetooth keys prevents "paired" gamepads to reconnect.
  // But it might also fix some connection / re-connection issues.
  BP32.forgetBluetoothKeys();
}

// This callback gets called any time a new gamepad is connected.
// Up to 4 gamepads can be connected at the same time.
void onConnectedController(ControllerPtr ctl) {
  bool foundEmptySlot = false;
  for (int i = 0; i < BP32_MAX_GAMEPADS; i++) {
    if (myControllers[i] == nullptr) {
      Serial.print("CALLBACK: Controller is connected, index=");
      Serial.println(i);
      myControllers[i] = ctl;
      foundEmptySlot = true;

      // Optional, once the gamepad is connected, request further info about the
      // gamepad.
      ControllerProperties properties = ctl->getProperties();
      char buf[80];
      sprintf(buf,
              "BTAddr: %02x:%02x:%02x:%02x:%02x:%02x, VID/PID: %04x:%04x, "
              "flags: 0x%02x",
              properties.btaddr[0], properties.btaddr[1], properties.btaddr[2],
              properties.btaddr[3], properties.btaddr[4], properties.btaddr[5],
              properties.vendor_id, properties.product_id, properties.flags);
      Serial.println(buf);
      break;
    }
  }
  if (!foundEmptySlot) {
    Serial.println(
        "CALLBACK: Controller connected, but could not found empty slot");
  }
}

void onDisconnectedController(ControllerPtr ctl) {
  bool foundGamepad = false;

  for (int i = 0; i < BP32_MAX_GAMEPADS; i++) {
    if (myControllers[i] == ctl) {
      Serial.print("CALLBACK: Controller is disconnected from index=");
      Serial.println(i);
      myControllers[i] = nullptr;
      foundGamepad = true;
      break;
    }
  }

  if (!foundGamepad) {
    Serial.println(
        "CALLBACK: Controller disconnected, but not found in myControllers");
  }
}

void processGamepad(ControllerPtr gamepad) {
  // There are different ways to query whether a button is pressed.
  // By query each button individually:
  //  a(), b(), x(), y(), l1(), etc...

  if (gamepad->a()) {
    static int colorIdx = 0;
    // Some gamepads like DS4 and DualSense support changing the color LED.
    // It is possible to change it by calling:
    switch (colorIdx % 3) {
      case 0:
        // Red
        gamepad->setColorLED(255, 0, 0);
        break;
      case 1:
        // Green
        gamepad->setColorLED(0, 255, 0);
        break;
      case 2:
        // Blue
        gamepad->setColorLED(0, 0, 255);
        break;
    }
    colorIdx++;
  }

  if (gamepad->b()) {
    // Turn on the 4 LED. Each bit represents one LED.
    static int led = 0;
    led++;
    // Some gamepads like the DS3, DualSense, Nintendo Wii, Nintendo Switch
    // support changing the "Player LEDs": those 4 LEDs that usually indicate
    // the "gamepad seat".
    // It is possible to change them by calling:
    gamepad->setPlayerLEDs(led & 0x0f);
  }

  if (gamepad->x()) {
    // Duration: 255 is ~2 seconds
    // force: intensity
    // Some gamepads like DS3, DS4, DualSense, Switch, Xbox One S support
    // rumble.
    // It is possible to set it by calling:
    gamepad->setRumble(0xc0 /* force */, 0xc0 /* duration */);
  }

  // Another way to query the buttons, is by calling buttons(), or
  // miscButtons() which return a bitmask.
  // Some gamepads also have DPAD, axis and more.
  char buf[256];
  snprintf(buf, sizeof(buf) - 1,
           "idx=%d, dpad: 0x%02x, buttons: 0x%04x, "
           "axis L: %4li, %4li, axis R: %4li, %4li, "
           "brake: %4ld, throttle: %4li, misc: 0x%02x, "
           "gyro x:%6d y:%6d z:%6d, accel x:%6d y:%6d z:%6d, "
           "battery: %d",
           gamepad->index(),        // Gamepad Index
           gamepad->dpad(),         // DPad
           gamepad->buttons(),      // bitmask of pressed buttons
           gamepad->axisX(),        // (-511 - 512) left X Axis
           gamepad->axisY(),        // (-511 - 512) left Y axis
           gamepad->axisRX(),       // (-511 - 512) right X axis
           gamepad->axisRY(),       // (-511 - 512) right Y axis
           gamepad->brake(),        // (0 - 1023): brake button
           gamepad->throttle(),     // (0 - 1023): throttle (AKA gas) button
           gamepad->miscButtons(),  // bitmask of pressed "misc" buttons
           gamepad->gyroX(),        // Gyro X
           gamepad->gyroY(),        // Gyro Y
           gamepad->gyroZ(),        // Gyro Z
           gamepad->accelX(),       // Accelerometer X
           gamepad->accelY(),       // Accelerometer Y
           gamepad->accelZ(),       // Accelerometer Z
           gamepad->battery()       // 0=Unknown, 1=empty, 255=full
  );
  Serial.println(buf);

  // You can query the axis and other properties as well. See
  // Controller.h For all the available functions.
}

void processMouse(ControllerPtr mouse) {
  char buf[160];
  sprintf(buf,
          "idx=%d, deltaX:%4li, deltaY:%4li, buttons: 0x%04x, misc: 0x%02x, "
          "scrollWheel: %d, battery=%d",
          mouse->index(),        // Controller Index
          mouse->deltaX(),       // Mouse delta X
          mouse->deltaY(),       // Mouse delta Y
          mouse->buttons(),      // bitmask of pressed buttons
          mouse->miscButtons(),  // bitmask of pressed "misc" buttons
          mouse->scrollWheel(),  // Direction: 1=up, -1=down, 0=no movement
          mouse->battery()       // 0=Unk, 1=Empty, 255=full
  );
  Serial.println(buf);
}

void processBalanceBoard(ControllerPtr balance) {
  char buf[160];
  sprintf(buf,
          "idx=%d, tl:%4i, tr:%4i, bl: %4i, br: %4i, temperature=%d, "
          "battery=%d",
          balance->index(),  // Controller Index
          balance->topLeft(), balance->topRight(), balance->bottomLeft(),
          balance->bottomRight(), balance->temperature(),
          balance->battery()  // 0=Unk, 1=Empty, 255=full
  );
  Serial.println(buf);
}

// Arduino loop function. Runs in CPU 1
void loop() {
  // This call fetches all the controller info from the NINA (ESP32) module.
  // Call this function in your main loop.
  // The controllers' pointer (the ones received in the callbacks) gets updated
  // automatically.
  BP32.update();

  // It is safe to always do this before using the controller API.
  // This guarantees that the controller is valid and connected.
  for (int i = 0; i < BP32_MAX_CONTROLLERS; i++) {
    ControllerPtr myController = myControllers[i];

    if (myController && myController->isConnected()) {
      if (myController->isGamepad())
        processGamepad(myController);
      else if (myController->isMouse())
        processMouse(myController);
      else if (myController->isBalanceBoard())
        processBalanceBoard(myController);
    }
  }
  delay(150);
}

[Feature Request] Add enableNewBluetoothConnections to Arduino + Nina Lib

Hi

Firstly fantastic library, im using it in my PSP Bluetooth controller project.

However noticed that in one of the components in the Bluepad32 project there is the ability to disable new connections with the method enableNewBluetoothConnections. Here:

void enableNewBluetoothConnections(bool enabled);

However as I'm using an Arduino nano 33 IOT i used this library based on your readme https://gitlab.com/ricardoquesada/bluepad32-arduino

Which doesn't seem to have the same functionality option.

Either i'm missing something (most likely) or i would like to request the feature added.

Thanks again!

[Bug]: thumbR button not working

What happened?

A bug happened! thumbR button not working
working:

            if (myGamepad->l2()) {
                myGamepad->setRumble(0xc0 /* force */, 0xc0 /* duration */);
            }
       not working:
            if (myGamepad->thumbR()) {
                myGamepad->setRumble(0xc0 /* force */, 0xc0 /* duration */);
            }

Bluepad32 Version

3.7.2 (latest stable)

Bluepad32 version custom

Example: Using Git develop branch commit hash #xxxxxxx

Bluepad32 Platform

Arduino ESP-IDF

Platform version

ESP-IDF v4.4.4

ESP32 chip

ESP32

ESP32 board

ESP32 WROOM DevKit

OS

Windows

Relevant log output

No response

Relevant sketch

No response

[Feature Request] Programmatic controller disconnect.

Edited the scope of the issue. The original feature request is in the spoiler at the bottom.

My Consolized PSP has the ability to turn the PSP off via a button, not just disconnecting a controller. It would be great in the situation where the user clicks the button to shut down the console i can also instruct the controller to turn off.

I cannot disable the Bluetooth and let the controller shut itself down after a timeout because i need to listen to new connections to turn the console back on.

I'm using the Arduino nano 33 IOT.

Thanks!

I understand its its allot of work maintaining this project so if you can't implement any of my requests i understand :)

Original Feature Request

Sorry to be spamming you with feature requests all of a sudden! However i have two more requests if they are at all possible.

I can split these out into two separate requests if you prefer.

1:) LED Brightness
My consolized PSP project allows for various controller button mappings to better suite the game being played. For controllers that have LED's (I'm testing on a PS4 pad) i use the LED to indicate the active mapping. Other controllers i use the player number (Wii etc)

Is it possible to control the brightness of the LED? I assume if it is it will depend on individual controller support. Iv'e read that the PS4 can have its LED brightness altered via the PS4 console itself but not sure if this is Sony bespoke stuff or can be done in a generic way.

  1. Programmatic controller disconnect
    My Consolized PSP has the ability to turn the PSP off via a button, not just disconnecting a controller. It would be great in the situation where the user clicks the button to shut down the console i can also instruct the controller to turn off.

I cannot disable the Bluetooth and let the controller shut itself down after a timeout because i need to listen to new connections to turn the console back on.

I'm using the Arduino nano 33 IOT.

Thanks!

I understand its its allot of work maintaining this project so if you can't implement any of my requests i understand :)

[Feature Request] Battery level/low battery status

Iv'e used this project to build a consolized PSP and its fantastic (your library that is, the consolized PSP is so-so).

Whilst testing it out playing Spyro half way through a long glide the batteries in my controller died without indication. The controller itself had no low battery indicator. Obviously Spyro died and i was sad.

Would it be possible to query the controller to get a battery level indication, either an overal percentage level or if not a low battery status?

This would allow me to display a low battery warning on my consolizer and prevent Spyro from future suffering.

Thanks!

Unable to connect to esp32 in AP mode

What happened?

Today I noticed that using the bluepad32 library boards, the wifi in Access Point mode does not allow connection to any device. With the same code, compiling using standard esp32 boards, there are no problems. Has anyone else encountered the same issue? The controller however connects without problems and works. The board also connects in Station mode.

Bluepad32 Version

3.10.3

Bluepad32 version custom

Example: Using Git develop branch commit hash #xxxxxxx

Bluepad32 Platform

Arduino IDE

Platform version

Arduino IDE 1.8.4

Controller

DS4 AceGamer

ESP32 chip

ESP32

ESP32 board

ESP32-Wroom 32

OS

Windows

Relevant log output

No response

Relevant sketch

No response

Trying out Pico W support in develop

Hello,

I'm trying out the new Pico W support in the develop branch.
I setup my project following the provided example as closely as possible. Without touching core 1, bluepad32 seems to start and print stuff to the console. Nice.

I have a few questions about the current state of things. I'm using pico-sdk master, as a point of reference.

I need to use core 1 for other tasks. Right now, the program seems to crash during cyw43_arch_init, if I initialize core 1 beforehand using multicore_launch_core1 as soon as the program starts. If I try to start core 1 afterwards, then it crashes there. Do you know how this could be related, though? I really need to use the second core.

Moreover, can I use USB stdio after starting the main loop? From what I gather bluepad32 is supposed to have its own console, but I've read somewhere it does not work as of now.

Finally, if I need a periodic task to check incoming commands from core 1, and react, can I register a timer like this?

// global:    
btstack_timer_source_t main_timer;

int main() {

    [...]

    // Initialize BP32
    uni_init(0, NULL);

    // add application process in run loop as a timer
    memset(&main_timer, 0x00, sizeof(btstack_timer_source_t));

    // setup my own callback
    main_timer.process = &core0_btstack_timer;
    btstack_run_loop_set_timer(&main_timer, CORE0_MAIN_TIMER_INTERVAL);
    btstack_run_loop_add_timer(&main_timer);

    // now run
    btstack_run_loop_execute();

    return 0;
}

// timer will call set_timer and add_timer again at the end of handler func

I've done that but the timer does not seem to run.

I also ran the SPP streamer from pico-examples to ensure my board is working as it should, it seemed ok.
In case the example is not expected to be working for now, for sure I can wait everything becoming stable.

Thank you so much for this amazing project.

How to know which button is being pressed?

I am using a gamepad designed by an unknown manufacturer.

I'm a bit confused about how to set it up in the program to know which button is being

pressed.

I'm currently using IDF 4.4. After successfully connecting,

I can only see information in the serial port when I press the back, start, or menu keys.

There is no information when I press any other keys. The contents of the serial port output

are as follows.

XQ ANPGKY9GQT4WSN}_X}6A

esp-idf using Rust (esp-rs) | Generate FFI Bindings

I'm trying to use this library for an embedded project in Rust with ESP-IDF (esp-rs), but I'm stuck on how to generate the necessary FFI bindings to use it.

I need guidance or documentation on generating FFI bindings for Rust and integrating them with ESP-IDF, allowing me to use this library in my project.

Additional context
Integrating this library into my Rust-based ESP-IDF project is crucial, and any help with FFI bindings would be greatly appreciated.

[Bug]: Pairing/Connection issues at startup

What happened?

Please see my Blue-64 project to reproduce the issue https://github.com/sideprojectslab/blue-64 (re-enable console output). Reproducing this issue can be done on a bare ESP32 wroom or wrover devkit without need for any additional components.

More often than not, once the board boots, the controller does not pair or does not connect. The console output shows that the bluepad32 core is stuck in a loop.

Controllers used:

  • 8BitDo SN30 Pro Bluetooth Gamepad
  • Xbox Wireless Controller 1708

Bluepad32 Version

3.8.3

Bluepad32 version custom

Example: Using Git develop branch commit hash 85100a4

Bluepad32 Platform

Other

Platform version

Blue-64

Controller

  • 8BitDo SN30 Pro Bluetooth Gamepad
  • Xbox Wireless Controller 1078

ESP32 chip

ESP32

ESP32 board

ESP32-wroom-32E (ESP32_DevKitc_V4)

OS

Windows

Relevant log output

No response

Relevant sketch

No response

Possible to set Disconnect Timeout or get Last Bluetooth Update Time?

Is your feature request related to a problem? Please describe.
I have 3 controllers, xbox one, stadia, and 8bitdo SN30pro+.

The issue I am trying to avoid is if the controller goes out of range or shuts off the last joystick values will be preserved until the bluetooth stack disconnects, I have seen this take a long time.

On the xbox one controller it takes 0.6s from when I power off the controller(last value change when I am moving the joystick in circles) until bluepad32 disconnects the controller. This is not bad, only an out of control robot/thing for 600ms
On the stadia controller it takes ~4 seconds from power off until blluepad32 disconnects, this is borderline bad.
On the 8bitdo SN30pro+ it takes ~18 seconds from power off until bluepad32 disconnects, this is bad.

Describe the solution you'd like
A method or field that showed if new controller data has been received since last calling of BP32.update().
Or a snapshot of CPU millis() each time the controller data is received.

Describe alternatives you've considered
I have thought about adding some kind of "are all the inputs identical for too long" but that doesn't work if you are just driving straight for a long time.

Additional context
I'm going to start digging into the code, but I figured I'd ask here first since maybe I'm missing something

Add Bluepad32 to Board Manager

Hello!
After adding the URL under Preferences - Additional Board Managers URLs, I get an error when I press install on the esp32_bluepad32 manager in the Boards Manager window.

Failed to install platform: 'esp32-bluepad32:esp32:3.10.2'.
Error: 9 FAILED_PRECONDITION: Platform 'esp32-bluepad32:[email protected]' not found: getting tool dependencies for platform esp32-bluepad32:[email protected]: tool version v0.12.0-esp32-20230419 not found

2024-01-25 09_18_21-sketch_jan25a _ Arduino IDE 2 2 1

Missing Defines

I downloaded the library from the Arduino library manager and the example throws error when i want to verify the sketch

C:\Users\the_g\Documents\Arduino\libraries\Bluepad32\src\utility\spi_drv.cpp: In static member function 'static void SpiDrv::begin()':
C:\Users\the_g\Documents\Arduino\libraries\Bluepad32\src\utility\spi_drv.cpp:91:20: error: 'PINS_COUNT' was not declared in this scope
   if (SLAVERESET > PINS_COUNT) {
                    ^~~~~~~~~~
C:\Users\the_g\Documents\Arduino\libraries\Bluepad32\src\utility\spi_drv.cpp:91:20: note: suggested alternative: 'ICOUNT'
   if (SLAVERESET > PINS_COUNT) {
                    ^~~~~~~~~~
                    ICOUNT
C:\Users\the_g\Documents\Arduino\libraries\Bluepad32\src\utility\spi_drv.cpp:100:11: error: 'NINA_GPIO0' was not declared in this scope
   pinMode(NINA_GPIO0, OUTPUT);
           ^~~~~~~~~~
C:\Users\the_g\Documents\Arduino\libraries\Bluepad32\src\utility\spi_drv.cpp:100:11: note: suggested alternative: 'NINA_GPIOIRQ'
   pinMode(NINA_GPIO0, OUTPUT);
           ^~~~~~~~~~
           NINA_GPIOIRQ
C:\Users\the_g\Documents\Arduino\libraries\Bluepad32\src\utility\spi_drv.cpp: In static member function 'static int SpiDrv::available()':
C:\Users\the_g\Documents\Arduino\libraries\Bluepad32\src\utility\spi_drv.cpp:66:22: error: 'NINA_GPIO0' was not declared in this scope
 #define NINA_GPIOIRQ NINA_GPIO0
                      ^~~~~~~~~~
C:\Users\the_g\Documents\Arduino\libraries\Bluepad32\src\utility\spi_drv.cpp:539:47: note: in expansion of macro 'NINA_GPIOIRQ'
 int SpiDrv::available() { return (digitalRead(NINA_GPIOIRQ) != LOW); }
                                               ^~~~~~~~~~~~
C:\Users\the_g\Documents\Arduino\libraries\Bluepad32\src\utility\spi_drv.cpp:66:22: note: suggested alternative: 'NINA_GPIOIRQ'
 #define NINA_GPIOIRQ NINA_GPIO0
                      ^~~~~~~~~~
C:\Users\the_g\Documents\Arduino\libraries\Bluepad32\src\utility\spi_drv.cpp:539:47: note: in expansion of macro 'NINA_GPIOIRQ'
 int SpiDrv::available() { return (digitalRead(NINA_GPIOIRQ) != LOW); }
                                               ^~~~~~~~~~~~
exit status 1
Fehler beim Kompilieren für das Board WEMOS LOLIN32 Lite.

BLE Controller for the ESP32S3

Hi There:

I'm trying to get a wireless gaming controller to work with the ESP32S3 via Bluepad32. It's turning out to be a PITA. The units listed with BLE support are either out of production or are very expensive (a handful of XBox models). I'm wondering if anyone can recommend a model that will work with the S3 that is readily available (e.g., on Amazon). I'm looking for a basic controller, so a lack of fancy features an issue. Thanks for any assistance.

Support for "TikTok Ring Remote Controller"

I have THIS bluetooth remote controller with 5 buttons that I would like connect with bluepad32.

I was able to connect it fast, but output is same (idx=0) for all keys. Can support for this controller be added?

Firmware: Bluepad32 for Arduino v4.0-beta1
BD Addr: AC: B:FB:25:9F:7E
CALLBACK: Controller is connected, index=0
Controller model: Keyboard, VID=0x05ac, PID=0x022c
idx=0
idx=0
idx=0
idx=0

[Feature Request] analogWrite for RGB LED

First of all, awesome library.

Now to my request:
Board MKR1010 with Bluepad32 for NINA v3.5.1

Is it possible to add analogWrite to the Bluepad32 class? Or is that a limitation in fw?

Best regards.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.