Merge pull request #536 from keyboardio/ActiveModColor/highlightNormalModifiers

ActiveModColor: Add a way to disable highlighting normal modifiers
pull/539/head
Jesse Vincent 6 years ago committed by GitHub
commit 02ac44d6ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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. 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 ### 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. 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.

@ -43,6 +43,14 @@ properties:
> The color to use for highlighting one-shot modifiers when they are sticky. Defaults to a red color. > 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 ## Dependencies
* [Kaleidoscope-LEDControl](LEDControl.md) * [Kaleidoscope-LEDControl](LEDControl.md)

@ -24,6 +24,7 @@ namespace plugin {
uint8_t ActiveModColorEffect::mod_keys_[MAX_MODS_PER_LAYER]; uint8_t ActiveModColorEffect::mod_keys_[MAX_MODS_PER_LAYER];
uint8_t ActiveModColorEffect::mod_key_count_; uint8_t ActiveModColorEffect::mod_key_count_;
bool ActiveModColorEffect::highlight_normal_modifiers_ = true;
cRGB ActiveModColorEffect::highlight_color = (cRGB) { cRGB ActiveModColorEffect::highlight_color = (cRGB) {
160, 160, 160 160, 160, 160
@ -42,8 +43,9 @@ EventHandlerResult ActiveModColorEffect::onLayerChange() {
Key k = Layer.lookupOnActiveLayer(r, c); Key k = Layer.lookupOnActiveLayer(r, c);
if (::OneShot.isOneShotKey(k) || if (::OneShot.isOneShotKey(k) ||
(k.raw >= Key_LeftControl.raw && k.raw <= Key_RightGui.raw) || (highlight_normal_modifiers_ && (
(k.flags == (SYNTHETIC | SWITCH_TO_KEYMAP))) { (k.raw >= Key_LeftControl.raw && k.raw <= Key_RightGui.raw) ||
(k.flags == (SYNTHETIC | SWITCH_TO_KEYMAP))))) {
uint8_t coords = r * COLS + c; uint8_t coords = r * COLS + c;
mod_keys_[mod_key_count_++] = coords; mod_keys_[mod_key_count_++] = coords;
} }

@ -31,10 +31,15 @@ class ActiveModColorEffect : public kaleidoscope::Plugin {
static cRGB highlight_color; static cRGB highlight_color;
static cRGB sticky_color; static cRGB sticky_color;
static void highlightNormalModifiers(bool value) {
highlight_normal_modifiers_ = value;
}
EventHandlerResult beforeReportingState(); EventHandlerResult beforeReportingState();
EventHandlerResult onLayerChange(); EventHandlerResult onLayerChange();
private: private:
static bool highlight_normal_modifiers_;
static uint8_t mod_keys_[MAX_MODS_PER_LAYER]; static uint8_t mod_keys_[MAX_MODS_PER_LAYER];
static uint8_t mod_key_count_; static uint8_t mod_key_count_;
}; };

Loading…
Cancel
Save