From 379a2d483b46a8a13307a9c7d6420ed12867e0b0 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Wed, 22 Mar 2017 08:22:13 +0100 Subject: [PATCH] Add a `getKeyOverride` method This method uses the EEPROM only to augment the PROGMEM keymap: if EEPROM is transparent, then PROGMEM is used. As such, the keymap in EEPROM is only an overlay in this case. Signed-off-by: Gergely Nagy --- examples/EEPROM-Keymap/EEPROM-Keymap.ino | 4 ++-- src/Kaleidoscope/EEPROM-Keymap.cpp | 10 ++++++++++ src/Kaleidoscope/EEPROM-Keymap.h | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/examples/EEPROM-Keymap/EEPROM-Keymap.ino b/examples/EEPROM-Keymap/EEPROM-Keymap.ino index 30d39015..b2d8be40 100644 --- a/examples/EEPROM-Keymap/EEPROM-Keymap.ino +++ b/examples/EEPROM-Keymap/EEPROM-Keymap.ino @@ -54,9 +54,9 @@ void setup () { Focus.addHook (FOCUS_HOOK_HELP); Focus.addHook (FOCUS_HOOK_VERSION); - Layer.getKey = EEPROMKeymap.getKey; + Layer.getKey = EEPROMKeymap.getKeyOverride; - EEPROMKeymap.reserveSpace (2); + EEPROMKeymap.reserveSpace (1); EEPROMSettings.seal (); } diff --git a/src/Kaleidoscope/EEPROM-Keymap.cpp b/src/Kaleidoscope/EEPROM-Keymap.cpp index 126c0e77..2e095fff 100644 --- a/src/Kaleidoscope/EEPROM-Keymap.cpp +++ b/src/Kaleidoscope/EEPROM-Keymap.cpp @@ -53,6 +53,16 @@ namespace KaleidoscopePlugins { return key; } + Key + EEPROMKeymap::getKeyOverride (uint8_t layer, byte row, byte col) { + Key key; + + key = getKey (layer, row, col); + if (key == Key_Transparent) + key = Layer.getKeyFromPROGMEM (layer, row, col); + return key; + } + uint16_t EEPROMKeymap::base (void) { return keymapBase; diff --git a/src/Kaleidoscope/EEPROM-Keymap.h b/src/Kaleidoscope/EEPROM-Keymap.h index f9995d71..65574d23 100644 --- a/src/Kaleidoscope/EEPROM-Keymap.h +++ b/src/Kaleidoscope/EEPROM-Keymap.h @@ -32,6 +32,7 @@ namespace KaleidoscopePlugins { static uint16_t base (void); static Key getKey (uint8_t layer, byte row, byte col); + static Key getKeyOverride (uint8_t layer, byte row, byte col); static bool focusKeymap (const char *command); static bool focusKeymapTransfer (const char *command);