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

unconditionally send boot report #1360

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,8 @@ namespace kaleidoscope {
namespace plugin {

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

Runtime.detachFromHost();
Runtime.hid().keyboard().setDefaultProtocol(new_protocol);
delay(1000);
Runtime.attachToHost();
// Do nothing, because the old behavior might cause HID-aware hosts to
// receive no input, now that we mark the Boot Keyboard report as padding
}

} // namespace plugin
Expand Down
30 changes: 12 additions & 18 deletions src/kaleidoscope/driver/hid/base/Keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,15 @@ class Keyboard {
}

void sendReport() __attribute__((noinline)) {
if (boot_keyboard_.getProtocol() == HID_BOOT_PROTOCOL) {
boot_keyboard_.sendReport();
return;
boot_keyboard_.sendReport();
if (boot_keyboard_.getProtocol() != HID_BOOT_PROTOCOL) {
nkro_keyboard_.sendReport();
consumer_control_.sendReport();
}
nkro_keyboard_.sendReport();
consumer_control_.sendReport();
}
void releaseAllKeys() __attribute__((noinline)) {
if (boot_keyboard_.getProtocol() == HID_BOOT_PROTOCOL) {
boot_keyboard_.releaseAll();
} else {
boot_keyboard_.releaseAll();
if (boot_keyboard_.getProtocol() != HID_BOOT_PROTOCOL) {
nkro_keyboard_.releaseAll();
consumer_control_.releaseAll();
}
Expand Down Expand Up @@ -204,21 +202,17 @@ class Keyboard {
// pressRawKey takes a Key object and calles KeyboardioHID's ".press" method
// with its keycode. It does no processing of any flags or modifiers on the key
void pressRawKey(Key pressed_key) {
if (boot_keyboard_.getProtocol() == HID_BOOT_PROTOCOL) {
boot_keyboard_.press(pressed_key.getKeyCode());
return;
boot_keyboard_.press(pressed_key.getKeyCode());
if (boot_keyboard_.getProtocol() != HID_BOOT_PROTOCOL) {
nkro_keyboard_.press(pressed_key.getKeyCode());
}

nkro_keyboard_.press(pressed_key.getKeyCode());
}

void releaseRawKey(Key released_key) {
if (boot_keyboard_.getProtocol() == HID_BOOT_PROTOCOL) {
boot_keyboard_.release(released_key.getKeyCode());
return;
boot_keyboard_.release(released_key.getKeyCode());
if (boot_keyboard_.getProtocol() != HID_BOOT_PROTOCOL) {
nkro_keyboard_.release(released_key.getKeyCode());
}

nkro_keyboard_.release(released_key.getKeyCode());
}

void releaseKey(Key released_key) {
Expand Down
5 changes: 5 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_AS_PADDING
#error "This version of Kaleidoscope requires KeyboardioHID with BOOTKB_AS_PADDING"
#error "Please update your KeyboardioHID"
#endif

namespace kaleidoscope {
namespace driver {
namespace hid {
Expand Down
Loading