Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible with usb keyboard demo from esp library #196

Open
PeterHindes opened this issue Nov 10, 2022 · 3 comments · Fixed by espressif/arduino-esp32#7463
Open

Incompatible with usb keyboard demo from esp library #196

PeterHindes opened this issue Nov 10, 2022 · 3 comments · Fixed by espressif/arduino-esp32#7463

Comments

@PeterHindes
Copy link

The following imports conflict with eachother. This is an issue as I would like to use usb and bluetooth keyboards in the same program.

// Bluetooth Libraries
#include <BleKeyboard.h>

// USB Libraries
#include "USB.h"
#include "USBHIDKeyboard.h"

The full program looks somewhat like this

// Bluetooth Libraries
#include <BleKeyboard.h>
BleKeyboard bleKeyboard;

// USB Libraries
#include "USB.h"
#include "USBHIDKeyboard.h"
USBHIDKeyboard Keyboard;

// Button On Board Feather
const int buttonPin = 0;
int buttonState = 0;  // variable for reading the pushbutton status

String msg = "Hello Gamer";

void setup() {
  Serial.begin(115200);
  delay(1000);
  
  Serial.println("Starting BLE work!");
  bleKeyboard.begin();
  
  Keyboard.begin();
  USB.begin();

  pinMode(buttonPin, INPUT_PULLUP);
}

void loop() {
  bleKeyboard.setBatteryLevel(98);
  buttonState = digitalRead(buttonPin);
  // Serial.println("checking button");
  // Serial.println(buttonState == LOW);
  if (buttonState == LOW){
    if(bleKeyboard.isConnected()) {
      Serial.println("Using Bluetooth");
      bleKeyboard.print(msg);
    } 
    else {
      Serial.println("Using USB");
      Keyboard.print(msg);
    }
    delay(500);
  }
  delay(10);
}
@PeterHindes
Copy link
Author

This seems to be related to two overlapping variables KeyReport and HID_SUBCLASS_NONE.
HID_SUBCLASS_NONE is part of the esp library, it can just be removed from there. as for KeyReport it can be renamed KeyReportBLE in this repo and will avoid conflicts with the stock usb keyboard implementation from espresif.

@PeterHindes
Copy link
Author

I have opened a pr with espresif for the collision in their repo espressif/arduino-esp32#7463

@PeterHindes
Copy link
Author

PeterHindes commented Nov 11, 2022

Now I have a pr for this repo to fix the naming conflicts present here.
#197

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant