diff --git a/src/KeyboardioFirmware.cpp b/src/KeyboardioFirmware.cpp index 94dce80f..82315e37 100644 --- a/src/KeyboardioFirmware.cpp +++ b/src/KeyboardioFirmware.cpp @@ -24,12 +24,18 @@ void Keyboardio_::loop(void) { KeyboardHardware.scan_matrix(); LEDControl.update(); + + for (byte i = 0; loopHooks[i] != NULL && i < HOOK_MAX; i++) { + custom_loop_t hook = loopHooks[i]; + (*hook)(false); + } + Keyboard.sendReport(); Keyboard.releaseAll(); for (byte i = 0; loopHooks[i] != NULL && i < HOOK_MAX; i++) { custom_loop_t hook = loopHooks[i]; - (*hook)(); + (*hook)(true); } } diff --git a/src/LED-Numlock.cpp b/src/LED-Numlock.cpp index 0f6df86d..354390b7 100644 --- a/src/LED-Numlock.cpp +++ b/src/LED-Numlock.cpp @@ -40,7 +40,10 @@ LEDNumlock::update (void) { } void -LEDNumlock::loopHook (void) { +LEDNumlock::loopHook (bool postClear) { + if (!postClear) + return; + if (Layer.isOn (numpadIndex)) { if (storedLEDMode != us) { storedLEDMode = LEDControl.get_mode (); diff --git a/src/LED-Numlock.h b/src/LED-Numlock.h index 0c64aa7d..d104f0be 100644 --- a/src/LED-Numlock.h +++ b/src/LED-Numlock.h @@ -13,7 +13,7 @@ class LEDNumlock : LEDMode { virtual void setup (void) final; private: - static void loopHook (void); + static void loopHook (bool postClear); BreathState breathState; }; diff --git a/src/hooks.h b/src/hooks.h index 2499174b..464b4727 100644 --- a/src/hooks.h +++ b/src/hooks.h @@ -11,7 +11,7 @@ extern custom_handler_t eventHandlers[HOOK_MAX]; void event_handler_hook_add (custom_handler_t hook); void event_handler_hook_replace (custom_handler_t oldHook, custom_handler_t newHook); -typedef void (*custom_loop_t)(void); +typedef void (*custom_loop_t)(bool postClear); extern custom_loop_t loopHooks[HOOK_MAX]; void loop_hook_add (custom_loop_t hook);