diff --git a/README.md b/README.md index 3f8b7512..9e2a71c5 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,15 @@ property: > The color to use for highlighting the modifiers. Defaults to a white color. +### `.oneshot_only` + +> A flag one can set to tell the plugin that they are using one-shot modifiers +> and layers only. This allows it to take some shortcuts, and optimize +> performance, at the cost of not highlighting any non-oneshot keys it otherwise +> would. +> +> Defaults to `false`. + ## Dependencies * [Kaleidoscope-LEDControl](https://github.com/keyboardio/Kaleidoscope-LEDControl) diff --git a/src/Kaleidoscope/LED-ActiveModColor.cpp b/src/Kaleidoscope/LED-ActiveModColor.cpp index e47d16c5..25bb39df 100644 --- a/src/Kaleidoscope/LED-ActiveModColor.cpp +++ b/src/Kaleidoscope/LED-ActiveModColor.cpp @@ -25,6 +25,7 @@ namespace kaleidoscope { cRGB ActiveModColorEffect::highlight_color = (cRGB) { 0xff, 0xff, 0xff }; +bool ActiveModColorEffect::oneshot_only; void ActiveModColorEffect::begin(void) { Kaleidoscope.useLoopHook(loopHook); @@ -34,6 +35,9 @@ void ActiveModColorEffect::loopHook(bool is_post_clear) { if (is_post_clear) return; + if (oneshot_only && !::OneShot.isActive()) + return; + for (byte r = 0; r < ROWS; r++) { for (byte c = 0; c < COLS; c++) { Key k = Layer.lookupOnActiveLayer(r, c); diff --git a/src/Kaleidoscope/LED-ActiveModColor.h b/src/Kaleidoscope/LED-ActiveModColor.h index 2d0a05b6..82a880de 100644 --- a/src/Kaleidoscope/LED-ActiveModColor.h +++ b/src/Kaleidoscope/LED-ActiveModColor.h @@ -29,6 +29,7 @@ class ActiveModColorEffect : public KaleidoscopePlugin { void begin(void) final; static cRGB highlight_color; + static bool oneshot_only; private: static void loopHook(bool is_post_clear);