ActiveModColor: Add a way to disable highlighting normal modifiers

Fixes #535.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/536/head
Gergely Nagy 6 years ago
parent 116f9b9e71
commit b3aaf6f235
No known key found for this signature in database
GPG Key ID: AC1E90BAC433F68F

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

@ -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)

@ -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) ||
(highlight_normal_modifiers_ && (
(k.raw >= Key_LeftControl.raw && k.raw <= Key_RightGui.raw) ||
(k.flags == (SYNTHETIC | SWITCH_TO_KEYMAP))) {
(k.flags == (SYNTHETIC | SWITCH_TO_KEYMAP))))) {
uint8_t coords = r * COLS + c;
mod_keys_[mod_key_count_++] = coords;
}

@ -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_;
};

Loading…
Cancel
Save