Add support for highlighting layer keys too

Fixes #2, thanks @ToyKeeper!

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
pull/389/head
Gergely Nagy 7 years ago
parent de3d793b40
commit 8becec569e

@ -46,6 +46,23 @@ bool ActiveModColorEffect::isModifierActive(Key key) {
return hid::isModifierKeyActive(key);
}
bool ActiveModColorEffect::isLayerKeyActive(Key key) {
uint8_t layer = 255;
if (key.raw >= ranges::OSL_FIRST && key.raw <= ranges::OSL_LAST) {
layer = key.raw - ranges::OSL_FIRST;
} else if (key.flags & (SYNTHETIC | SWITCH_TO_KEYMAP)) {
layer = key.keyCode;
if (layer >= MOMENTARY_OFFSET)
layer -= MOMENTARY_OFFSET;
}
if (layer == 255)
return false;
return Layer.isOn(layer);
}
void ActiveModColorEffect::loopHook(bool is_post_clear) {
if (is_post_clear)
return;
@ -54,7 +71,7 @@ void ActiveModColorEffect::loopHook(bool is_post_clear) {
for (byte c = 0; c < COLS; c++) {
Key k = Layer.lookup(r, c);
if (isModifierActive(k))
if (isModifierActive(k) || isLayerKeyActive(k))
LEDControl.setCrgbAt(r, c, highlight_color);
}
}

@ -32,6 +32,7 @@ class ActiveModColorEffect : public KaleidoscopePlugin {
private:
static bool isModifierActive(Key key);
static bool isLayerKeyActive(Key key);
static void loopHook(bool is_post_clear);
};
}

Loading…
Cancel
Save