From 1432015235eb721bc3d88672e8060fc2d45c73d0 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Wed, 5 Apr 2017 10:36:57 +0200 Subject: [PATCH] Focus: Merge keymap.dump and keymap.upload into keymap.map Fixes #2. Signed-off-by: Gergely Nagy --- src/Kaleidoscope/EEPROM-Keymap-Focus.h | 5 +-- src/Kaleidoscope/EEPROM-Keymap.cpp | 51 ++++++++------------------ 2 files changed, 16 insertions(+), 40 deletions(-) diff --git a/src/Kaleidoscope/EEPROM-Keymap-Focus.h b/src/Kaleidoscope/EEPROM-Keymap-Focus.h index 1b6b224d..eac8f2fa 100644 --- a/src/Kaleidoscope/EEPROM-Keymap-Focus.h +++ b/src/Kaleidoscope/EEPROM-Keymap-Focus.h @@ -21,10 +21,7 @@ #include #include -#define FOCUS_HOOK_KEYMAP FOCUS_HOOK(EEPROMKeymap.focusKeymap, \ - "keymap.dump\n" \ - "keymap.upload") - +#define FOCUS_HOOK_KEYMAP FOCUS_HOOK(EEPROMKeymap.focusKeymap, "keymap.map") #define FOCUS_HOOK_KEYMAP_TRANSFER FOCUS_HOOK(EEPROMKeymap.focusKeymapTransfer, \ "keymap.transfer layer") diff --git a/src/Kaleidoscope/EEPROM-Keymap.cpp b/src/Kaleidoscope/EEPROM-Keymap.cpp index 01e98507..9a4f0aa9 100644 --- a/src/Kaleidoscope/EEPROM-Keymap.cpp +++ b/src/Kaleidoscope/EEPROM-Keymap.cpp @@ -93,48 +93,27 @@ namespace KaleidoscopePlugins { bool EEPROMKeymap::focusKeymap (const char *command) { - enum { - UPLOAD, - DUMP, - } subCommand; - - if (strncmp_P (command, PSTR ("keymap."), 7) != 0) - return false; - - if (strcmp_P (command + 7, PSTR ("upload")) == 0) - subCommand = UPLOAD; - else if (strcmp_P (command + 7, PSTR ("dump")) == 0) - subCommand = DUMP; - else + if (strcmp_P (command, PSTR ("keymap.map")) != 0) return false; - switch (subCommand) { - case UPLOAD: - { - uint16_t i = 0; - while ((Serial.peek () != '\n') && (i < ROWS * COLS * maxLayers)) { - updateKey (i, parseKey ()); - i++; - } - break; - } - - case DUMP: - { - for (uint8_t layer = 0; layer < maxLayers; layer++) { - for (uint8_t row = 0; row < ROWS; row++) { - for (uint8_t col = 0; col < COLS; col++) { - Key k = getKey (layer, row, col); + if (Serial.peek () == '\n') { + for (uint8_t layer = 0; layer < maxLayers; layer++) { + for (uint8_t row = 0; row < ROWS; row++) { + for (uint8_t col = 0; col < COLS; col++) { + Key k = getKey (layer, row, col); - printKey (k); - ::Focus.printSpace (); - } + printKey (k); + ::Focus.printSpace (); } } - Serial.println (); - break; } - + Serial.println (); + } else { + uint16_t i = 0; + while ((Serial.peek () != '\n') && (i < ROWS * COLS * maxLayers)) { + updateKey (i, parseKey ()); + i++; + } } return true;