From 6dcc6a9277ae5a30c32c98f6dc85d2738f274f79 Mon Sep 17 00:00:00 2001 From: "James N. V. Cash" Date: Thu, 26 Oct 2017 08:16:48 -0400 Subject: [PATCH 1/2] Teach plugin to print out the contents of a given layer --- src/Kaleidoscope/EEPROM-Keymap.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Kaleidoscope/EEPROM-Keymap.cpp b/src/Kaleidoscope/EEPROM-Keymap.cpp index af6d5507..7d83e792 100644 --- a/src/Kaleidoscope/EEPROM-Keymap.cpp +++ b/src/Kaleidoscope/EEPROM-Keymap.cpp @@ -115,8 +115,18 @@ bool EEPROMKeymap::focusKeymapLayer(const char *command) { uint8_t layer = Serial.parseInt(); uint16_t keysPerLayer = ROWS * COLS; uint16_t offset = layer * keysPerLayer; - for (uint16_t k = 0; (k < keysPerLayer) && (Serial.peek() != '\n'); k++) { - updateKey(layer + k, parseKey()); + if (Serial.peek() == '\n') { + for (uint8_t row = 0; row < ROWS; row++) { + for (uint8_t col = 0; col < COLS; col++) { + Key k = Layer.getKey(layer, row, col); + printKey(k); + ::Focus.printSpace(); + } + } + } else { + for (uint16_t k = 0; (k < keysPerLayer) && (Serial.peek() != '\n'); k++) { + updateKey(layer + k, parseKey()); + } } return true; From e4cf2e4c755be8f667a381b07b8d9e7528cf1142 Mon Sep 17 00:00:00 2001 From: "James N. V. Cash" Date: Thu, 26 Oct 2017 08:21:01 -0400 Subject: [PATCH 2/2] Add documentation about new hook to readme --- README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8ab29ee4..3afc9628 100644 --- a/README.md +++ b/README.md @@ -67,8 +67,8 @@ The plugin provides the `EEPROMKeymap` object, which has the following methods: ## Focus commands -The plugin provides two `Focus` hooks: `FOCUS_HOOK_KEYMAP`, and -`FOCUS_HOOK_KEYMAP_TRANSFER`. Together, they make the following commands +The plugin provides three `Focus` hooks: `FOCUS_HOOK_KEYMAP`, `FOCUS_HOOK_KEYMAP_LAYER`, +and `FOCUS_HOOK_KEYMAP_TRANSFER`. Together, they make the following commands available, respectively: ### `keymap.map [codes...]` @@ -81,6 +81,13 @@ available, respectively: > layer, and go on as long as it has input. It will not go past the layer set > via the `.max_layers()` method. +### `keymap.layer LAYER [codes...]` + +> Without codes, prints the keymap for the given layer (zero-indexed). +> Prints each key as its raw 16-bit keycode. + +> With codes, stores them as the keymap for the given layer. + ### `keymap.transfer LAYER` > Transfers the `LAYER` from the built-in memory of the keyboard into `EEPROM`