From 87373803ed21595a0eb1be6cc986fd92ff1e9cbc Mon Sep 17 00:00:00 2001 From: Florian Fleissner Date: Tue, 12 Nov 2019 17:56:06 +0100 Subject: [PATCH] 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 --- src/kaleidoscope/layers.h | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/kaleidoscope/layers.h b/src/kaleidoscope/layers.h index a9047127..61b08ea6 100644 --- a/src/kaleidoscope/layers.h +++ b/src/kaleidoscope/layers.h @@ -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 {