From 049a057b5edf9f4d09f632869a2d0a17f1fe37ed Mon Sep 17 00:00:00 2001 From: David Glasser Date: Tue, 17 Oct 2017 02:01:42 -0700 Subject: [PATCH] Show sticky keys in a different color Depends on https://github.com/keyboardio/Kaleidoscope-OneShot/pull/18 --- README.md | 4 ++++ src/Kaleidoscope/LED-ActiveModColor.cpp | 6 +++++- src/Kaleidoscope/LED-ActiveModColor.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3f8b7512..a0706e5c 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,10 @@ property: > The color to use for highlighting the modifiers. Defaults to a white color. +### `.sticky_color` + +> The color to use for highlighting one-shot modifiers when they are sticky. Defaults to a red color. + ## Dependencies * [Kaleidoscope-LEDControl](https://github.com/keyboardio/Kaleidoscope-LEDControl) diff --git a/src/Kaleidoscope/LED-ActiveModColor.cpp b/src/Kaleidoscope/LED-ActiveModColor.cpp index f615979e..a0054fcb 100644 --- a/src/Kaleidoscope/LED-ActiveModColor.cpp +++ b/src/Kaleidoscope/LED-ActiveModColor.cpp @@ -26,6 +26,8 @@ cRGB ActiveModColorEffect::highlight_color = (cRGB) { 0xff, 0xff, 0xff }; +cRGB ActiveModColorEffect::sticky_color = CRGB(0xff, 0x00, 0x00); + void ActiveModColorEffect::begin(void) { Kaleidoscope.useLoopHook(loopHook); } @@ -39,7 +41,9 @@ void ActiveModColorEffect::loopHook(bool is_post_clear) { Key k = Layer.lookupOnActiveLayer(r, c); if (::OneShot.isOneShotKey(k)) { - if (::OneShot.isActive(k)) + if (::OneShot.isSticky(k)) + ::LEDControl.setCrgbAt(r, c, sticky_color); + else if (::OneShot.isActive(k)) ::LEDControl.setCrgbAt(r, c, highlight_color); else ::LEDControl.refreshAt(r, c); diff --git a/src/Kaleidoscope/LED-ActiveModColor.h b/src/Kaleidoscope/LED-ActiveModColor.h index 2d0a05b6..569dd135 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 cRGB sticky_color; private: static void loopHook(bool is_post_clear);