Merge pull request #5 from jamesnvc/print-layer

Make keymap layer hook able to print map as well
pull/365/head
Gergely Nagy 7 years ago committed by GitHub
commit b7d27a8997

@ -67,8 +67,8 @@ The plugin provides the `EEPROMKeymap` object, which has the following methods:
## Focus commands ## Focus commands
The plugin provides two `Focus` hooks: `FOCUS_HOOK_KEYMAP`, and The plugin provides three `Focus` hooks: `FOCUS_HOOK_KEYMAP`, `FOCUS_HOOK_KEYMAP_LAYER`,
`FOCUS_HOOK_KEYMAP_TRANSFER`. Together, they make the following commands and `FOCUS_HOOK_KEYMAP_TRANSFER`. Together, they make the following commands
available, respectively: available, respectively:
### `keymap.map [codes...]` ### `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 > layer, and go on as long as it has input. It will not go past the layer set
> via the `.max_layers()` method. > 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` ### `keymap.transfer LAYER`
> Transfers the `LAYER` from the built-in memory of the keyboard into `EEPROM` > Transfers the `LAYER` from the built-in memory of the keyboard into `EEPROM`

@ -115,9 +115,19 @@ bool EEPROMKeymap::focusKeymapLayer(const char *command) {
uint8_t layer = Serial.parseInt(); uint8_t layer = Serial.parseInt();
uint16_t keysPerLayer = ROWS * COLS; uint16_t keysPerLayer = ROWS * COLS;
uint16_t offset = layer * keysPerLayer; uint16_t offset = layer * keysPerLayer;
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++) { for (uint16_t k = 0; (k < keysPerLayer) && (Serial.peek() != '\n'); k++) {
updateKey(layer + k, parseKey()); updateKey(layer + k, parseKey());
} }
}
return true; return true;

Loading…
Cancel
Save