Move the modifier activity check into `isModifierActive`

This way, the body of the loop in `loopHook` becomes even simpler.

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

@ -33,7 +33,7 @@ void ActiveModColorEffect::begin(void) {
loop_hook_use(loopHook); loop_hook_use(loopHook);
} }
bool ActiveModColorEffect::isModifier(Key key) { bool ActiveModColorEffect::isModifierActive(Key key) {
if (key.raw >= ranges::OSM_FIRST && key.raw <= ranges::OSM_LAST) { if (key.raw >= ranges::OSM_FIRST && key.raw <= ranges::OSM_LAST) {
uint8_t idx = key.raw - ranges::OSM_FIRST; uint8_t idx = key.raw - ranges::OSM_FIRST;
key.flags = 0; key.flags = 0;
@ -43,7 +43,7 @@ bool ActiveModColorEffect::isModifier(Key key) {
if (key.raw < Key_LeftControl.raw || key.raw > Key_RightGui.raw) if (key.raw < Key_LeftControl.raw || key.raw > Key_RightGui.raw)
return false; return false;
return true; return hid::isModifierKeyActive(key);
} }
void ActiveModColorEffect::loopHook(bool is_post_clear) { void ActiveModColorEffect::loopHook(bool is_post_clear) {
@ -54,7 +54,7 @@ void ActiveModColorEffect::loopHook(bool is_post_clear) {
for (byte c = 0; c < COLS; c++) { for (byte c = 0; c < COLS; c++) {
Key k = Layer.lookup(r, c); Key k = Layer.lookup(r, c);
if (isModifier(k) && hid::isModifierKeyActive(k)) if (isModifierActive(k))
LEDControl.setCrgbAt(r, c, highlight_color); LEDControl.setCrgbAt(r, c, highlight_color);
} }
} }

@ -31,7 +31,7 @@ class ActiveModColorEffect : public KaleidoscopePlugin {
static cRGB highlight_color; static cRGB highlight_color;
private: private:
static bool isModifier(Key key); static bool isModifierActive(Key key);
static void loopHook(bool is_post_clear); static void loopHook(bool is_post_clear);
}; };
} }

Loading…
Cancel
Save