Skip to content

Commit

Permalink
allow bootkb_only toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
tlyu committed Dec 1, 2023
1 parent 5dac1e0 commit 3c9462c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ namespace kaleidoscope {
namespace plugin {

void USBQuirks::toggleKeyboardProtocol() {
uint8_t new_protocol = !Runtime.hid().keyboard().getProtocol();
uint8_t new_bootonly = !Runtime.hid().keyboard().getBootOnly();

Runtime.detachFromHost();
Runtime.hid().keyboard().setDefaultProtocol(new_protocol);
Runtime.hid().keyboard().setBootOnly(new_bootonly);
delay(1000);
Runtime.attachToHost();
}
Expand Down
12 changes: 12 additions & 0 deletions src/kaleidoscope/driver/hid/base/Keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ class NoBootKeyboard {
void setProtocol(uint8_t protocol) {}
void setDefaultProtocol(uint8_t protocol) {}

uint8_t getBootOnly() {
return 0;
}
void setBootOnly(uint8_t bootonly) {}

void sendReport() {}

void press(uint8_t code) {}
Expand Down Expand Up @@ -211,6 +216,13 @@ class Keyboard {
boot_keyboard_.setDefaultProtocol(protocol);
}

uint8_t getBootOnly() {
return boot_keyboard_.getBootOnly();
}
void setBootOnly(uint8_t bootonly) {
boot_keyboard_.setBootOnly(bootonly);
}

void onUSBReset() {
boot_keyboard_.onUSBReset();
}
Expand Down
12 changes: 12 additions & 0 deletions src/kaleidoscope/driver/hid/keyboardio/Keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
// From Kaleidoscope:
#include "kaleidoscope/driver/hid/base/Keyboard.h" // for Keyboard, KeyboardProps

#if !BOOTKB_HYBRID
#error "This version of Kaleidoscope requires KeyboardioHID with BOOTKB_HYBRID"
#error "Please update your KeyboardioHID"
#endif

namespace kaleidoscope {
namespace driver {
namespace hid {
Expand Down Expand Up @@ -57,6 +62,13 @@ class BootKeyboardWrapper {
setProtocol(protocol);
}

uint8_t getBootOnly() {
return BootKeyboard().getBootOnly();
}
void setBootOnly(uint8_t bootonly) {
BootKeyboard().setBootOnly(bootonly);
}

void sendReport() {
BootKeyboard().sendReport();
}
Expand Down

0 comments on commit 3c9462c

Please sign in to comment.