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

Turbo: keep sticky toggle key lit while active #1389

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions plugins/Kaleidoscope-Turbo/src/kaleidoscope/plugin/Turbo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ EventHandlerResult Turbo::onKeyEvent(KeyEvent &event) {
if (event.key != Key_Turbo)
return EventHandlerResult::OK;

// Remember the address so we can pin its LED on each cycle when necessary
turbo_key_addr_ = event.addr;


if (active_) {
// If Turbo is active, and in "sticky" mode, we abort the event when a Turbo
Expand All @@ -94,13 +97,15 @@ EventHandlerResult Turbo::onKeyEvent(KeyEvent &event) {
// If not in "sticky" mode and a Turbo key toggles off, or if in "sticky"
// mode and a Turbo key toggles on, we deactivate Turbo.
active_ = false;
LEDControl::setCrgbAt(event.addr, CRGB(0, 0, 0));
if (flash_)
LEDControl::refreshAll();

} else if (keyToggledOn(event.state)) {
// If Turbo is inactive, turn it on when a Turbo key is pressed.
active_ = true;
start_time_ = Runtime.millisAtCycleStart() - interval_;
LEDControl::setCrgbAt(event.addr, active_color_);
}

// We assume that other plugins don't need to know about Turbo key events.
Expand Down Expand Up @@ -129,6 +134,8 @@ EventHandlerResult Turbo::afterEachCycle() {

// Send the re-populated keyboard report.
Runtime.hid().keyboard().sendReport();
} else {
LEDControl::setCrgbAt(turbo_key_addr_, active_color_);
}
}
return EventHandlerResult::OK;
Expand Down
1 change: 1 addition & 0 deletions plugins/Kaleidoscope-Turbo/src/kaleidoscope/plugin/Turbo.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class Turbo : public kaleidoscope::Plugin {
bool sticky_ = false;
bool flash_ = true;
cRGB active_color_ = CRGB(160, 0, 0);
KeyAddr turbo_key_addr_;

bool active_ = false;
uint32_t start_time_ = 0;
Expand Down
Loading