Add `beforeSyncingLeds()` event handler hook function

This allows plugins to override the current LED mode just before the LED sync is
done (i.e. after the mode sets the LED colors, but before those changes are
pushed to the hardware.)

Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
pull/1024/head
Michael Richters 4 years ago
parent 015b8e3140
commit 7756be1a6d
No known key found for this signature in database
GPG Key ID: 1288FD13E4EEF0C0

@ -234,6 +234,15 @@ class SignatureCheckDummy {};
_NOT_ABORTABLE, __NL__ \
(),(),(), /* non template */ __NL__ \
(), (), ##__VA_ARGS__) __NL__ \
/* Called immediately before the LEDs get updated. This is for */ __NL__ \
/* plugins that override the current LED mode. */ __NL__ \
OPERATION(beforeSyncingLeds, __NL__ \
1, __NL__ \
_CURRENT_IMPLEMENTATION, __NL__ \
_NOT_ABORTABLE, __NL__ \
(),(),(), /* non template */ __NL__ \
(), (), ##__VA_ARGS__) __NL__ \
/* DEPRECATED */ __NL__ \
/* Called before reporting our state to the host. This is the */ __NL__ \
/* last point in a cycle where a plugin can alter what gets */ __NL__ \
/* reported to the host. */ __NL__ \
@ -333,6 +342,10 @@ class SignatureCheckDummy {};
OP(onLEDModeChange, 1) __NL__ \
END(onLEDModeChange, 1) __NL__ \
__NL__ \
START(beforeSyncingLeds, 1) __NL__ \
OP(beforeSyncingLeds, 1) __NL__ \
END(beforeSyncingLeds, 1) __NL__ \
__NL__ \
START(beforeReportingState, 1, 2) __NL__ \
OP(beforeReportingState, 1) __NL__ \
OP(beforeReportingState, 2) __NL__ \

@ -124,6 +124,11 @@ void LEDControl::syncLeds(void) {
if (!enabled_)
return;
// This would be a good spot to introduce a new hook function so that a plugin
// that needs to override the color of an LED used by an LED mode can do so
// efficiently.
Hooks::beforeSyncingLeds();
Runtime.device().syncLeds();
}

Loading…
Cancel
Save