Use bluepad32 Library in PIO

Dear community,

for my little robot I want to use a gamepad to control it. The Bluepad32 Library is the only working Lib that works with my pad (in the Arduino IDE).

So I tried to use this library in my normal working environment → PIO.

But it seems that I’m too stupid to get it running. :exploding_head:

Somebody also asked this at the library side, but the owner isn’t familiar with PlatformIO. I also tried to follow the recommended way to download the zip file and extract it. But I don’t know how to include it in PIO or how to work with the mentioned platformio-build.py file.

Could someone give me some hints to get it working, please?

Here are my attempts in PlatformIO.ini with different lib_deps:

[env]
monitor_speed = 115200

[env:lolin32_lite]
platform = espressif32
board = lolin32_lite
framework = arduino
build_flags = 
  -DBOARD_HAS_PSRAM
lib_deps = 
  # https://gitlab.com/ricardoquesada/bluepad32/-/releases/4.2.0
  # https://gitlab.com/ricardoquesada/bluepad32.git
  # git@gitlab.com:ricardoquesada/bluepad32.git
lib_ldf_mode = chain+

The main.cpp File is reduced to (based o an Arduino IDE example):

#include <Arduino.h> 
#include <Bluepad32.h>

void setup() {
}

void loop() {
}

The key to this is to understand that the Bluepad32 “library” for the Arduino IDE and ESP32 is actually included in the alternative version of the Arduino-ESP32 core that the author provides. See documentation.

The board URL that they make you install in the Arduino IDE (https://raw.githubusercontent.com/ricardoquesada/esp32-arduino-lib-builder/master/bluepad32_files/package_esp32_bluepad32_index.json) then points to the package https://github.com/ricardoquesada/esp32-arduino-lib-builder/releases/download/4.1.0/esp32-bluepad32-4.1.0.zip which is just a packaging of Arduino-ESP32 with the Bluepad32 library included.

You need to tell PlatformIO to use that as the Arduino-ESP32 framework package instead of the regular framework-arduinoespressif32 package. The .zip file I linked to already has a package.json for inclusion into PlatformIO. Sadly however, the name field of the package was changed to framework-arduinoespressif32bluepad32, so it will be rejected as a replacement for framework-arduinoespressif32 until renamed. (Otherwise,we could have referenced the release zip directly.)

Thus, I simply renamed it back to framework-arduinoespressif32 and reuploaded it here. With that, I can then tell PlatformIO to simply use this as the Arduino core package.

[env:esp32dev]
platform = espressif32@6.10.0
board = esp32dev
framework = arduino
; reupload of https://github.com/ricardoquesada/esp32-arduino-lib-builder/releases/download/4.1.0/esp32-bluepad32-4.1.0.zip
; but with package.json's "name" field renamed back to framework-arduinoespressif32
platform_packages =
   framework-arduinoespressif32@https://github.com/maxgerhardt/pio-framework-bluepad32/archive/refs/heads/main.zip

You can see that the Controller.ino example compiles perfectly fine with this configuration then:

2 Likes

Hello maxgerhardt,

what a pleasure to get your support. You helped me indirectly so many times by reading your answers that I can’t count it…

Okay, I think I got your points: the library is provided as an Arduino-ESP32 core with Bluepad32 library. (But how can I recognize that if I ever have a similar problem?)

Then the simplest solution is to use this core, and only this core, for a project by redefining “platform_packages”.

The incompatible name field makes it impossible to link to it directly. Maybe I can ask the author to adjust the field name in the library. Perhaps there are reasons to don’t rename it….

Hope to get you right. I will try my luck later and will give you feedback then.

1 Like

it works perfectly as you descript

2 Likes