Only apply the effect, if the LED mode is active

When using AlphaSquareEffect, in the event handler hook, return early if the
currently active LED mode is not us.

Fixes #2.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
pull/365/head
Gergely Nagy 8 years ago
parent 397c08ec9f
commit d805d50d22

@ -23,6 +23,7 @@ namespace KaleidoscopePlugins {
uint16_t AlphaSquareEffect::length = 1000;
uint32_t AlphaSquareEffect::endTimeLeft, AlphaSquareEffect::endTimeRight;
Key AlphaSquareEffect::lastKeyLeft, AlphaSquareEffect::lastKeyRight;
uint8_t AlphaSquareEffect::us;
AlphaSquareEffect::AlphaSquareEffect (void) {
}
@ -30,7 +31,8 @@ namespace KaleidoscopePlugins {
void
AlphaSquareEffect::begin (void) {
Kaleidoscope.useEventHandlerHook (eventHandlerHook);
LEDMode::begin ();
Kaleidoscope.use (&LEDControl, NULL);
us = LEDControl.mode_add (this);
}
void
@ -47,6 +49,9 @@ namespace KaleidoscopePlugins {
Key
AlphaSquareEffect::eventHandlerHook (Key key, byte row, byte col, uint8_t keyState) {
if (LEDControl.get_mode () != us)
return key;
if (keyState & INJECTED)
return key;

@ -34,6 +34,7 @@ namespace KaleidoscopePlugins {
private:
static uint32_t endTimeLeft, endTimeRight;
static Key lastKeyLeft, lastKeyRight;
static uint8_t us;
static Key eventHandlerHook (Key key, uint8_t row, uint8_t col, uint8_t keyState);
};

Loading…
Cancel
Save