diff --git a/src/Kaleidoscope.cpp b/src/Kaleidoscope.cpp index e5c38a1e..c50d7d64 100644 --- a/src/Kaleidoscope.cpp +++ b/src/Kaleidoscope.cpp @@ -14,6 +14,7 @@ Kaleidoscope_::setup(void) { // A workaround, so that the compiler does not optimize this out... handleKeyswitchEvent(Key_NoKey, 255, 255, 0); + Layer.updateKeyCache(); } void diff --git a/src/layers.cpp b/src/layers.cpp index 73a3c341..23377a3a 100644 --- a/src/layers.cpp +++ b/src/layers.cpp @@ -80,6 +80,15 @@ Layer_::updateKeyCache(byte row, byte col) { } } +void +Layer_::updateKeyCache(void) { + for (byte row = 0; row < ROWS; row++) { + for (byte col = 0; col < COLS; col++) { + updateKeyCache(row, col); + } + } +} + uint8_t Layer_::top(void) { for (int8_t i = 31; i >= 0; i--) { if (bitRead(LayerState, i)) @@ -97,12 +106,14 @@ void Layer_::on(uint8_t layer) { bitSet(LayerState, layer); if (layer > highestLayer) highestLayer = layer; + updateKeyCache(); } void Layer_::off(uint8_t layer) { bitClear(LayerState, layer); if (layer == highestLayer) highestLayer = top(); + updateKeyCache(); } boolean Layer_::isOn(uint8_t layer) { diff --git a/src/layers.h b/src/layers.h index acc25011..0814bf6f 100644 --- a/src/layers.h +++ b/src/layers.h @@ -33,6 +33,7 @@ class Layer_ { static Key getKeyFromPROGMEM(uint8_t layer, byte row, byte col); static void updateKeyCache(byte row, byte col); + static void updateKeyCache(void); private: static uint8_t highestLayer;