Skip to content

Commit 0affea4

Browse files
Fix KeyboardBT/BLE, JoystickBT/BLE not xmitting (#3222)
Fixes #3221 The ::begin() for the BT/BLE HID devices shadows the lower-level HID::begin() calls. This means we need to explicitly call the parent's begin to set things like the _running flag. Without it, transmission from the BT/BLE device would be stopped by the virtual parent's ::send() since _running wasn't set.
1 parent a4a8f60 commit 0affea4

File tree

7 files changed

+15
-6
lines changed

7 files changed

+15
-6
lines changed

libraries/JoystickBLE/src/JoystickBLE.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ uint8_t *desc_joystickBLE;
4343
uint16_t desc_joystickBLE_length;
4444

4545
void JoystickBLE_::begin(const char *localName, const char *hidName) {
46+
HID_Joystick::begin();
47+
4648
if (!localName) {
4749
localName = "PicoW BLE Joystick";
4850
}

libraries/JoystickBT/src/JoystickBT.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ uint8_t *desc_joystickBT;
4343
uint16_t desc_joystickBT_length;
4444

4545
void JoystickBT_::begin(const char *localName, const char *hidName) {
46+
HID_Joystick::begin();
47+
4648
if (!localName) {
4749
localName = "PicoW BT Joystick";
4850
}

libraries/KeyboardBLE/src/KeyboardBLE.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,14 @@ uint8_t *desc_keyboardBLE;
4040
uint16_t desc_keyboardBLE_length;
4141

4242
void KeyboardBLE_::begin(const char *localName, const char *hidName, const uint8_t *layout) {
43+
HID_Keyboard::begin(layout);
44+
4345
if (!localName) {
4446
localName = "PicoW BLE Keyboard";
4547
}
4648
if (!hidName) {
4749
hidName = localName;
4850
}
49-
_asciimap = layout;
5051

5152
__SetupHIDreportmap(__BLEInstallMouse, __BLEInstallKeyboard, __BLEInstallJoystick, false, &desc_keyboardBLE_length, &desc_keyboardBLE);
5253

libraries/KeyboardBT/examples/BTKeyboardPassword/BTKeyboardPassword.ino

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@ void ledCB(bool numlock, bool capslock, bool scrolllock, bool compose, bool kana
1414

1515
void setup() {
1616
Serial.begin(115200);
17-
KeyboardBT.begin("PicoW Password");
1817
pinMode(LED_BUILTIN, OUTPUT);
1918
digitalWrite(LED_BUILTIN, LOW);
2019
KeyboardBT.onLED(ledCB);
21-
KeyboardBT.begin();
20+
KeyboardBT.begin("PicoW Password");
2221
delay(5000);
2322
Serial.printf("Arduino USB Password Typer\n");
2423
Serial.printf("Press BOOTSEL to enter your super-secure(not!) password\n\n");

libraries/KeyboardBT/src/KeyboardBT.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,16 @@ static void _hidReportCB(uint16_t cid, hid_report_type_t report_type, uint16_t r
4949
}
5050

5151
void KeyboardBT_::begin(const char *localName, const char *hidName, const uint8_t *layout) {
52+
HID_Keyboard::begin(layout);
53+
5254
if (!localName) {
5355
localName = "PicoW BT Keyboard";
5456
}
5557
if (!hidName) {
5658
hidName = localName;
5759
}
58-
_asciimap = layout;
60+
61+
5962
// Required because the hid_report_type_t overlap in BTStack and TUSB
6063
auto *fcn = (void (*)(short unsigned int, hid_report_type_t_bt, short unsigned int, int, unsigned char*))_hidReportCB;
6164
hid_device_register_report_data_callback(fcn);

libraries/MouseBLE/src/MouseBLE.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ uint8_t *desc_mouseBLE;
3434
uint16_t desc_mouseBLE_length;
3535

3636
void MouseBLE_::begin(const char *localName, const char *hidName) {
37+
HID_Mouse::begin();
38+
3739
if (!localName) {
3840
localName = "PicoW BLE Mouse";
3941
}
@@ -44,7 +46,6 @@ void MouseBLE_::begin(const char *localName, const char *hidName) {
4446
__SetupHIDreportmap(__BLEInstallMouse, __BLEInstallKeyboard, __BLEInstallJoystick, _absolute, &desc_mouseBLE_length, &desc_mouseBLE);
4547

4648
PicoBluetoothBLEHID.startHID(localName, hidName, __BLEGetAppearance(), desc_mouseBLE, desc_mouseBLE_length);
47-
_running = true;
4849
}
4950

5051
void MouseBLE_::end(void) {

libraries/MouseBT/src/MouseBT.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ uint8_t *desc_mouseBT;
3434
uint16_t desc_mouseBT_length;
3535

3636
void MouseBT_::begin(const char *localName, const char *hidName) {
37+
HID_Mouse::begin();
38+
3739
if (!localName) {
3840
localName = "PicoW Mouse 00:00:00:00:00:00";
3941
}
@@ -44,7 +46,6 @@ void MouseBT_::begin(const char *localName, const char *hidName) {
4446
__SetupHIDreportmap(__BTInstallMouse, __BTInstallKeyboard, __BTInstallJoystick, _absolute, &desc_mouseBT_length, &desc_mouseBT);
4547

4648
PicoBluetoothHID.startHID(localName, hidName, __BTGetCOD(), 33, desc_mouseBT, desc_mouseBT_length);
47-
_running = true;
4849
}
4950

5051
void MouseBT_::end(void) {

0 commit comments

Comments
 (0)