From b3aaf6f2357acf5e68ffe820cd63609437e9d8a7 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sun, 20 Jan 2019 09:06:40 +0100 Subject: [PATCH] ActiveModColor: Add a way to disable highlighting normal modifiers Fixes #535. Signed-off-by: Gergely Nagy --- NEWS.md | 4 ++++ doc/plugin/LED-ActiveModColor.md | 8 ++++++++ src/kaleidoscope/plugin/LED-ActiveModColor.cpp | 6 ++++-- src/kaleidoscope/plugin/LED-ActiveModColor.h | 5 +++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index dd1ebc42..3690ec91 100644 --- a/NEWS.md +++ b/NEWS.md @@ -79,6 +79,10 @@ The [Cycle](doc/plugin/Cycle.md) plugin has much better support for cycling thro There are situations where one would like to disable sending a report after each and every step of a macro, and rather have direct control over when reports are sent. The new `WITH_EXPLICIT_REPORT`, `WITH_IMPLICIT_REPORT` and `SEND_REPORT` steps help with that. Please see the [Macros](doc/plugin/Macros.md) documentation for more information. +### LED-ActiveModColor can be asked to not highlight normal modifiers + +The plugin was intended to work with OneShot primarily, and that's where it is most useful. To make it less surprising, and more suitable to include it in default-like firmware, we made it possible to ask it not to highlight normal modifiers. Please see the [LED-ActiveModColor](doc/plugin/LED-ActiveModColor.md) documentation for more information. + ### Events now trigger on layer changes Changing layers now triggers the `onLayerChange` event - but only if there was real change (thus, calling `Layer.on(SOME_LAYER)` multiple times in a row will only trigger one event). This event was introduced to help plugins that depend on layer state schedule their work better. diff --git a/doc/plugin/LED-ActiveModColor.md b/doc/plugin/LED-ActiveModColor.md index 46e1000f..e3cbe3e9 100644 --- a/doc/plugin/LED-ActiveModColor.md +++ b/doc/plugin/LED-ActiveModColor.md @@ -43,6 +43,14 @@ properties: > The color to use for highlighting one-shot modifiers when they are sticky. Defaults to a red color. +## Plugin methods + +The `ActiveModColorEffect` object provides the following methods: + +### `.highlightNormalModifiers(bool)` + +> Can be used to enable or disable the highlighting of normal modifiers. Defaults to true. + ## Dependencies * [Kaleidoscope-LEDControl](LEDControl.md) diff --git a/src/kaleidoscope/plugin/LED-ActiveModColor.cpp b/src/kaleidoscope/plugin/LED-ActiveModColor.cpp index 9f8b5e1b..2b29ee31 100644 --- a/src/kaleidoscope/plugin/LED-ActiveModColor.cpp +++ b/src/kaleidoscope/plugin/LED-ActiveModColor.cpp @@ -24,6 +24,7 @@ namespace plugin { uint8_t ActiveModColorEffect::mod_keys_[MAX_MODS_PER_LAYER]; uint8_t ActiveModColorEffect::mod_key_count_; +bool ActiveModColorEffect::highlight_normal_modifiers_ = true; cRGB ActiveModColorEffect::highlight_color = (cRGB) { 0xff, 0xff, 0xff @@ -42,8 +43,9 @@ EventHandlerResult ActiveModColorEffect::onLayerChange() { Key k = Layer.lookupOnActiveLayer(r, c); if (::OneShot.isOneShotKey(k) || - (k.raw >= Key_LeftControl.raw && k.raw <= Key_RightGui.raw) || - (k.flags == (SYNTHETIC | SWITCH_TO_KEYMAP))) { + (highlight_normal_modifiers_ && ( + (k.raw >= Key_LeftControl.raw && k.raw <= Key_RightGui.raw) || + (k.flags == (SYNTHETIC | SWITCH_TO_KEYMAP))))) { uint8_t coords = r * COLS + c; mod_keys_[mod_key_count_++] = coords; } diff --git a/src/kaleidoscope/plugin/LED-ActiveModColor.h b/src/kaleidoscope/plugin/LED-ActiveModColor.h index ab2b94f5..1ea1d729 100644 --- a/src/kaleidoscope/plugin/LED-ActiveModColor.h +++ b/src/kaleidoscope/plugin/LED-ActiveModColor.h @@ -31,10 +31,15 @@ class ActiveModColorEffect : public kaleidoscope::Plugin { static cRGB highlight_color; static cRGB sticky_color; + static void highlightNormalModifiers(bool value) { + highlight_normal_modifiers_ = value; + } + EventHandlerResult beforeReportingState(); EventHandlerResult onLayerChange(); private: + static bool highlight_normal_modifiers_; static uint8_t mod_keys_[MAX_MODS_PER_LAYER]; static uint8_t mod_key_count_; };