T-vK / ESP32-BLE-Keyboard

Bluetooth LE Keyboard library for the ESP32 (Arduino IDE compatible)
2.46k stars 410 forks source link

Use of BLE Keyboard and BLE-Gamepad in one Sketch #76

Open Laredo25 opened 3 years ago

Laredo25 commented 3 years ago

Hello, congratulations on these great libraries!

for my Controller Project i try to use Keyboard and Gamepad in one Sketch. The control, if keyboard or gamepad is needed, should take place via an input pin once after startup of the Controller.

I tried to use the attached code, but always get compilation errors: multiple definition of `BleConnectionStatus::onConnect(BLEServer*)

Any Ideas?

Best Regards Michael

include

include

BleKeyboard bleKeyboard; BleGamepad bleGamepad;

void setup() { int stateControllerMode = HIGH;

if (stateControllerMode == HIGH) {
bleGamepad.begin(); } else if (stateControllerMode == LOW) { bleKeyboard.begin(); } }

void loop() {

if(bleGamepad.isConnected()) { bleGamepad.setAxes(100, 100, 100); }

if(bleKeyboard.isConnected()) { bleKeyboard.print("Keyboard"); } }

T-vK commented 3 years ago

Unfortunately using ESP32-BLE-Keyboard and Gamepad or Mouse is not possible at the moment. But there are some workarounds using modified versions of the library that allow using keyboard+mouse, maybe you can convice the author to add support for gamepad as well or maybe you can give it a try yourself. https://github.com/T-vK/ESP32-BLE-Keyboard/issues/66