Only run our "toggle numlock mode" once upon toggle of the layer

Signed-off-by: Jesse Vincent <jesse@keyboard.io>
pull/365/head
Jesse Vincent 6 years ago
parent 79996b7216
commit 8fb50b2415

@ -21,7 +21,7 @@
byte NumPad_::numpad_lock_key_row = 255, NumPad_::numpad_lock_key_col = 255; byte NumPad_::numpad_lock_key_row = 255, NumPad_::numpad_lock_key_col = 255;
uint8_t NumPad_::numPadLayer; uint8_t NumPad_::numPadLayer;
bool NumPad_::cleanupDone = true; bool NumPad_::cleanupDone = false;
bool NumPad_::originalNumLockState = false; bool NumPad_::originalNumLockState = false;
cRGB NumPad_::color = CRGB(160, 0, 0); cRGB NumPad_::color = CRGB(160, 0, 0);
uint8_t NumPad_::lock_hue = 170; uint8_t NumPad_::lock_hue = 170;
@ -52,8 +52,8 @@ void NumPad_::cleanupNumlockState() {
syncNumlockState(false); syncNumlockState(false);
numLockLEDState = false; numLockLEDState = false;
} }
cleanupDone = true;
originalNumLockState = numLockLEDState; originalNumLockState = numLockLEDState;
cleanupDone = true;
} }
} }
@ -90,10 +90,11 @@ void NumPad_::setKeyboardLEDColors(void) {
kaleidoscope::EventHandlerResult NumPad_::afterEachCycle() { kaleidoscope::EventHandlerResult NumPad_::afterEachCycle() {
if (!Layer.isOn(numPadLayer)) { if (!Layer.isOn(numPadLayer)) {
cleanupNumlockState(); cleanupNumlockState();
} else { } else if (cleanupDone) {
cleanupDone = false; // If it's the first time we're in this loop after toggling the Numpad mode on
syncNumlockState(true); syncNumlockState(true);
setKeyboardLEDColors(); setKeyboardLEDColors();
cleanupDone = false;
} }
return kaleidoscope::EventHandlerResult::OK; return kaleidoscope::EventHandlerResult::OK;

Loading…
Cancel
Save