aboutsummaryrefslogtreecommitdiffstats
path: root/src/Kaleidoscope-LayerHighlighter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Kaleidoscope-LayerHighlighter.cpp')
-rw-r--r--src/Kaleidoscope-LayerHighlighter.cpp75
1 files changed, 39 insertions, 36 deletions
diff --git a/src/Kaleidoscope-LayerHighlighter.cpp b/src/Kaleidoscope-LayerHighlighter.cpp
index d81c6a7..798aab6 100644
--- a/src/Kaleidoscope-LayerHighlighter.cpp
+++ b/src/Kaleidoscope-LayerHighlighter.cpp
@@ -1,50 +1,53 @@
#include "Kaleidoscope-LayerHighlighter.h"
-#include "Kaleidoscope-LEDControl.h"
+#include "kaleidoscope/KeyAddr.h" // for KeyAddr
+#include "kaleidoscope/Runtime.h" // for Runtime, Runtime_
+#include "kaleidoscope/plugin/LEDControl.h" // for LEDControl
+#include "kaleidoscope/plugin/LEDControl/LEDUtils.h" // for breathe_compute
-#include <Kaleidoscope.h>
+namespace kaleidoscope {
+ namespace plugin {
-kaleidoscope::EventHandlerResult LayerHighlighter::onSetup(void) {
- return kaleidoscope::EventHandlerResult::OK;
-}
-
-kaleidoscope::EventHandlerResult LayerHighlighter::onKeyswitchEvent(Key &mappedKey, byte row, byte col, uint8_t keyState) {
- if (mappedKey != LockLayer(layer)) {
- return kaleidoscope::EventHandlerResult::OK;
- }
-
- if (keyToggledOn(keyState)) {
- savedLEDMode = LEDControl.get_mode_index();
- } else if (keyToggledOff(keyState)) {
- LEDControl.set_mode(LEDControl.get_mode_index());
- }
+ EventHandlerResult LayerHighlighter::onSetup(void) {
+ return EventHandlerResult::OK;
+ }
- return kaleidoscope::EventHandlerResult::OK;
-}
+ EventHandlerResult LayerHighlighter::onKeyEvent(KeyEvent &event) {
+ if (event.key != LockLayer(layer)) {
+ return EventHandlerResult::OK;
+ }
-kaleidoscope::EventHandlerResult LayerHighlighter::afterEachCycle() {
- if (!Layer.isOn(layer)) {
- return kaleidoscope::EventHandlerResult::OK;
- }
+ if (keyToggledOff(event.state)) {
+ ::LEDControl.set_mode(::LEDControl.get_mode_index());
+ }
- LEDControl.set_mode(LEDControl.get_mode_index());
- for (uint8_t r = 0; r < ROWS; r++) {
- for (uint8_t c = 0; c < COLS; c++) {
- Key k = Layer.lookupOnActiveLayer(r, c);
- Key layer_key = Layer.getKey(layer, r, c);
+ return EventHandlerResult::OK;
+ }
- if (k == LockLayer(layer)) {
- cRGB lock_color = breath_compute(lockHue);
- LEDControl.setCrgbAt(r, c, lock_color);
+ EventHandlerResult LayerHighlighter::afterEachCycle() {
+ if (!Layer.isActive(layer)) {
+ return EventHandlerResult::OK;
}
- if ((k != layer_key) || (k == Key_NoKey)) {
- LEDControl.refreshAt(r, c);
- } else {
- LEDControl.setCrgbAt(r, c, color);
+ ::LEDControl.set_mode(::LEDControl.get_mode_index());
+ for (auto keyAddr : KeyAddr::all()) {
+ Key k = Layer.lookupOnActiveLayer(keyAddr);
+ Key layer_key = Layer.getKey(layer, keyAddr);
+
+ if (k == LockLayer(layer)) {
+ cRGB lock_color = breath_compute(this->lockHue);
+ ::LEDControl.setCrgbAt(keyAddr, lock_color);
+ }
+
+ if ((k != layer_key) || (k == Key_NoKey)) {
+ ::LEDControl.refreshAt(keyAddr);
+ } else {
+ ::LEDControl.setCrgbAt(keyAddr, this->color);
+ }
}
+
+ return EventHandlerResult::OK;
}
- }
- return kaleidoscope::EventHandlerResult::OK;
+ }
}