Focus: Lift out keymap.transfer

The keymap.transfer command is only useful if we have both PROGMEM & EEPROM
keymaps, which will rarely be a case, and likely only temporarily, too. As such,
lift that out of the `focusKeymap` function, into its own. This makes the
command optional, and can save us some 140 bytes of program space (even more if
documentation is enabled).

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
pull/365/head
Gergely Nagy 8 years ago
parent 035c95a207
commit 0c387ce1c3

@ -50,6 +50,7 @@ void setup () {
Focus.addHook (FOCUS_HOOK_SETTINGS);
Focus.addHook (FOCUS_HOOK_KEYMAP);
Focus.addHook (FOCUS_HOOK_KEYMAP_TRANSFER);
Focus.addHook (FOCUS_HOOK_HELP);
Focus.addHook (FOCUS_HOOK_VERSION);

@ -29,7 +29,10 @@
"-------------------------------\n" \
"Uploads a new keymap to EEPROM." \
"Starts at layer 0, row 0, column 0, " \
"and continues as long as there is data on the line.\n\n" \
"and continues as long as there is data on the line.")
#define FOCUS_HOOK_KEYMAP_TRANSFER FOCUS_HOOK(EEPROMKeymap.focusKeymapTransfer, \
"keymap.transfer layer\n" \
"---------------------\n" \
"Transfers the `layer` from PROGMEM to EEPROM.")

@ -86,7 +86,6 @@ namespace KaleidoscopePlugins {
enum {
UPLOAD,
DUMP,
TRANSFER,
} subCommand;
if (strncmp_P (command, PSTR ("keymap."), 7) != 0)
@ -96,8 +95,6 @@ namespace KaleidoscopePlugins {
subCommand = UPLOAD;
else if (strcmp_P (command + 7, PSTR ("dump")) == 0)
subCommand = DUMP;
else if (strcmp_P (command + 7, PSTR ("transfer")) == 0)
subCommand = TRANSFER;
else
return false;
@ -131,8 +128,16 @@ namespace KaleidoscopePlugins {
break;
}
case TRANSFER:
{
}
return true;
}
bool
EEPROMKeymap::focusKeymapTransfer (const char *command) {
if (strcmp_P (command, PSTR ("keymap.transfer")) != 0)
return false;
uint8_t layer = Serial.parseInt ();
for (uint8_t row = 0; row < ROWS; row++) {
@ -144,11 +149,6 @@ namespace KaleidoscopePlugins {
}
}
break;
}
}
return true;
}

@ -34,6 +34,7 @@ namespace KaleidoscopePlugins {
static Key getKey (uint8_t layer, byte row, byte col);
static bool focusKeymap (const char *command);
static bool focusKeymapTransfer (const char *command);
private:
static uint16_t keymapBase;

Loading…
Cancel
Save