Refactor KEYMAPS(...) macro

This refactors the KEYMAPS(...) macro and factors out
a header and footer portion that are now define as individual
macros START_KEYMAPS and END_KEYMAPS. The original
KEYMAPS(...) macro now relies on the newly defined macros.

The newly introduced macros enable keymap definitions that
allow for macro definitions between the start and end part
which is not possible inside the KEYMAPS(...) macro invocation.

Signed-off-by: Florian Fleissner <florian.fleissner@inpartik.de>
pull/916/head
Florian Fleissner 5 years ago committed by Jesse Vincent
parent be91a03719
commit 87373803ed
No known key found for this signature in database
GPG Key ID: CC228463465E40BC

@ -24,17 +24,25 @@
#include "kaleidoscope_internal/sketch_exploration/sketch_exploration.h"
#include "kaleidoscope_internal/shortname.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 KEYMAPS(layers...) __NL__ \
constexpr Key keymaps_linear[][kaleidoscope_internal::device.matrix_rows * kaleidoscope_internal::device.matrix_columns] PROGMEM = { layers }; __NL__ \
uint8_t layer_count __NL__ \
= sizeof(keymaps_linear) / sizeof(*keymaps_linear); __NL__ \
#define START_KEYMAPS __NL__ \
constexpr Key keymaps_linear[][kaleidoscope_internal::device.matrix_rows * kaleidoscope_internal::device.matrix_columns] PROGMEM = {
#define END_KEYMAPS __NL__ \
}; __NL__ \
uint8_t layer_count __NL__ \
= sizeof(keymaps_linear) / sizeof(*keymaps_linear); __NL__ \
__NL__ \
_INIT_SKETCH_EXPLORATION __NL__ \
_INIT_HID_GETSHORTNAME
// 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 KEYMAPS(layers...) __NL__ \
START_KEYMAPS __NL__ \
layers __NL__ \
END_KEYMAPS
extern uint8_t layer_count;
namespace kaleidoscope {

Loading…
Cancel
Save