Instead of a low-level interface where one has to set the EEPROM-stored layers and the lookup method separately, introduce a `setup` method that combines the two in a much easier to grasp interface. It takes a layer number, and an optional mode, and sets things up accordingly. With this new setup procedure comes a new way of how the plugin works: instead of being able to override the keymap in EEPROM, we extend it (or use a custom implementation, for advanced use-cases). The default layer can still be set via Focus, thus effectively overriding the keymap in PROGMEM. To better support this, a new Focus command is introduced too: `keymap.roLayers`, which returns the number of layers in PROGMEM. The `keymap.transfer` Focus command is removed, because it can be done much more reliably from the host side, building on top of `keymap.map`. The rest of the lower-level interface is still there, though undocumented, for advanced use-cases the new simplified setup does not fit. Signed-off-by: Gergely Nagy <algernon@keyboard.io>pull/365/head
parent
a066d82747
commit
83f1805d5d
@ -1,50 +0,0 @@
|
||||
/* -*- mode: c++ -*-
|
||||
* Kaleidoscope-EEPROM-Keymap -- EEPROM-based keymap support.
|
||||
* Copyright (C) 2017, 2018 Keyboard.io, Inc
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <Kaleidoscope-EEPROM-Settings.h>
|
||||
#include <Kaleidoscope-EEPROM-Keymap.h>
|
||||
#include <Kaleidoscope-FocusSerial.h>
|
||||
|
||||
namespace kaleidoscope {
|
||||
namespace eeprom {
|
||||
|
||||
EventHandlerResult FocusKeymapTransferCommand::onFocusEvent(const char *command) {
|
||||
const char *cmd = PSTR("keymap.transfer");
|
||||
|
||||
if (::Focus.handleHelp(command, cmd))
|
||||
return EventHandlerResult::OK;
|
||||
if (strcmp_P(command, cmd) != 0)
|
||||
return EventHandlerResult::OK;
|
||||
|
||||
uint8_t layer = Serial.parseInt();
|
||||
|
||||
for (uint8_t row = 0; row < ROWS; row++) {
|
||||
for (uint8_t col = 0; col < COLS; col++) {
|
||||
Key k = Layer.getKeyFromPROGMEM(layer, row, col);
|
||||
uint16_t pos = ((layer * ROWS * COLS) + (row * COLS) + col);
|
||||
|
||||
::EEPROMKeymap.updateKey(pos, k);
|
||||
}
|
||||
}
|
||||
|
||||
return EventHandlerResult::EVENT_CONSUMED;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
kaleidoscope::eeprom::FocusKeymapTransferCommand FocusKeymapTransferCommand;
|
@ -1,34 +0,0 @@
|
||||
/* -*- mode: c++ -*-
|
||||
* Kaleidoscope-EEPROM-Keymap -- EEPROM-based keymap support.
|
||||
* Copyright (C) 2017-2018 Keyboard.io, Inc
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Kaleidoscope.h>
|
||||
#include <Kaleidoscope/EEPROM-Keymap.h>
|
||||
|
||||
namespace kaleidoscope {
|
||||
namespace eeprom {
|
||||
class FocusKeymapTransferCommand : public Plugin {
|
||||
public:
|
||||
FocusKeymapTransferCommand() {}
|
||||
|
||||
EventHandlerResult onFocusEvent(const char *command);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
extern kaleidoscope::eeprom::FocusKeymapTransferCommand FocusKeymapTransferCommand;
|
Loading…
Reference in new issue