A bluetooth gamepad "host" for the ESP32.
Based on BTStack v1.1 example "external\btstack\example\hid_host_demo.c".
I am not C++ programmer, sorry for my code ;)
- Supports all buttons
- Supports keyboard mode (Joystick 0 or 1 + all buttons)
- Supports gamepad mode (Joystick from 127 to 0, from 127 to 255 + all buttons)
Supports iCade- Values received from the joystick are smooth out (got rid of 154,155,154,155...)
- Added a physical button to reconnect to a gamepad
- top - from 127 to 0
- down - from 127 to 255
- left - from 127 to 0
- right - from 127 to 255
- Install ESP-IDF
Install the ESP32 toolchain. Use version 4.1 or newer.
- Clone repo
$ git clone git@github.com:overplex/pg9021.git
$ cd pg9021
$ git submodule update --init
- Integrate BTStack into ESP32
$ cd external/btstack/port/esp32
$ ./integrate_btstack.py
- Compile pg9021
$ cd ../../../../src
$ make -j
- Flash it
$ make flash monitor
If you see error:
L2CAP Connection failed: 0x6a
- Try erasing flash memory:
esptool.py --port /dev/ttyUSB0 erase_flash
- Then disable saving keys to flash memory in {YOUR_ESP_IDF_DIR}\components\btstack\include\btstack_config.h
#define NVM_NUM_LINK_KEYS 0
- Rebuild (in pg9021/src)
make -j
- Flash it
$ make flash monitor
pg9021 is open source, licensed under Apache 2.
However pg9021 depends on the great BTStack library. Which is free to use for open source projects. But commercial for closed-source projects. Contact them for details. They are very friendly + helpful (I’m not affiliated with them).