Added better comments to CREATE_KEYMAP() & LayerCount declarations

Also improved comment in Layer.on() conditional
pull/244/head
Michael Richters 7 years ago
parent 36b461a99a
commit 0fb2abf6bc

@ -8,7 +8,9 @@ Key Layer_::liveCompositeKeymap[ROWS][COLS];
uint8_t Layer_::activeLayers[ROWS][COLS]; uint8_t Layer_::activeLayers[ROWS][COLS];
Key(*Layer_::getKey)(uint8_t layer, byte row, byte col) = Layer.getKeyFromPROGMEM; Key(*Layer_::getKey)(uint8_t layer, byte row, byte col) = Layer.getKeyFromPROGMEM;
// The total number of defined layers in the firmware sketch keymaps[] array // The total number of defined layers in the firmware sketch keymaps[]
// array. If the keymap wasn't defined using CREATE_KEYMAP() in the
// sketch file, LayerCount gets the default value of zero.
uint8_t LayerCount __attribute__((weak)) = 0; uint8_t LayerCount __attribute__((weak)) = 0;
static void handleKeymapKeyswitchEvent(Key keymapEntry, uint8_t keyState) { static void handleKeymapKeyswitchEvent(Key keymapEntry, uint8_t keyState) {
@ -128,7 +130,8 @@ void Layer_::move(uint8_t layer) {
} }
void Layer_::on(uint8_t layer) { void Layer_::on(uint8_t layer) {
// If we're trying to turn on a layer that doesn't exist; abort // If we're trying to turn on a layer that doesn't exist, abort (but
// if the keymap wasn't defined using CREATE_KEYMAP(), proceed anyway
if (LayerCount != 0 && layer >= LayerCount) if (LayerCount != 0 && layer >= LayerCount)
return; return;

@ -4,6 +4,9 @@
#include "key_defs.h" #include "key_defs.h"
#include KALEIDOSCOPE_HARDWARE_H #include KALEIDOSCOPE_HARDWARE_H
// Macro for defining the keymap. This should be used in the sketch
// file (*.ino) to define the keymap[] array that holds the user's
// layers. It also computes the number of layers in that keymap.
#define CREATE_KEYMAP(layers...) \ #define CREATE_KEYMAP(layers...) \
const Key keymaps[][ROWS][COLS] PROGMEM = { layers }; \ const Key keymaps[][ROWS][COLS] PROGMEM = { layers }; \
uint8_t LayerCount = sizeof(keymaps) / sizeof(*keymaps); uint8_t LayerCount = sizeof(keymaps) / sizeof(*keymaps);

Loading…
Cancel
Save