diff --git a/src/kaleidoscope/Kaleidoscope.h b/src/kaleidoscope/Kaleidoscope.h
index 20948d42..7804d791 100644
--- a/src/kaleidoscope/Kaleidoscope.h
+++ b/src/kaleidoscope/Kaleidoscope.h
@@ -40,6 +40,14 @@ void setup();
extern HARDWARE_IMPLEMENTATION KeyboardHardware;
+#ifdef PER_KEY_DATA_STACKED
+#define KEYMAP_STACKED(...) { PER_KEY_DATA_STACKED(XXX, __VA_ARGS__) }
+#endif
+
+#ifdef PER_KEY_DATA
+#define KEYMAP(...) { PER_KEY_DATA(XXX, __VA_ARGS__) }
+#endif
+
#define ROWS (KeyboardHardware.matrix_rows)
#define COLS (KeyboardHardware.matrix_columns)
#define LED_COUNT (KeyboardHardware.led_count)
diff --git a/src/kaleidoscope/bitfields.h b/src/kaleidoscope/bitfields.h
index 22e0e4e1..338362e9 100644
--- a/src/kaleidoscope/bitfields.h
+++ b/src/kaleidoscope/bitfields.h
@@ -180,20 +180,20 @@ constexpr size_t nListEntries(Args__...) {
#define BITFIELD(VAR_NAME, ...) BITFIELD__(VAR_NAME,, __VA_ARGS__)
#define BITFIELD_PROGMEM(VAR_NAME, ...) BITFIELD__(VAR_NAME, const PROGMEM, __VA_ARGS__)
-#ifdef KEYMAP_GENERIC
+#ifdef PER_KEY_DATA
#define KEYMAP_BITFIELD(VAR_NAME, ...) \
- BITFIELD(VAR_NAME, KEYMAP_GENERIC(0 /*default for non-existent keys*/, __VA_ARGS__))
+ BITFIELD(VAR_NAME, PER_KEY_DATA(0 /*default for non-existent keys*/, __VA_ARGS__))
#define KEYMAP_BITFIELD_PROGMEM(VAR_NAME, ...) \
- BITFIELD_PROGMEM(VAR_NAME, KEYMAP_GENERIC(0 /*default for non-existent keys*/, __VA_ARGS__))
+ BITFIELD_PROGMEM(VAR_NAME, PER_KEY_DATA(0 /*default for non-existent keys*/, __VA_ARGS__))
#endif
-#ifdef KEYMAP_STACKED_GENERIC
-#define KEYMAP_BITFIELDK_STACKED(VAR_NAME, ...) \
- BITFIELD(VAR_NAME, KEYMAP_STACKED_GENERIC(0 /*default for non-existent keys*/, __VA_ARGS__))
+#ifdef PER_KEY_DATA_STACKED
+#define KEYMAP_BITFIELD_STACKED(VAR_NAME, ...) \
+ BITFIELD(VAR_NAME, PER_KEY_DATA_STACKED(0 /*default for non-existent keys*/, __VA_ARGS__))
#define KEYMAP_BITFIELD_STACKED_PROGMEM(VAR_NAME, ...) \
- BITFIELD_PROGMEM(VAR_NAME, KEYMAP_STACKED_GENERIC(0 /*default for non-existent keys*/, __VA_ARGS__))
+ BITFIELD_PROGMEM(VAR_NAME, PER_KEY_DATA_STACKED(0 /*default for non-existent keys*/, __VA_ARGS__))
#endif
} // end namespace bitfields
diff --git a/src/kaleidoscope/hardware/ez/ErgoDox.h b/src/kaleidoscope/hardware/ez/ErgoDox.h
index ec2da2bb..1b148406 100644
--- a/src/kaleidoscope/hardware/ez/ErgoDox.h
+++ b/src/kaleidoscope/hardware/ez/ErgoDox.h
@@ -93,7 +93,7 @@ class ErgoDox : public kaleidoscope::Hardware {
static void readMatrixRow(uint8_t row);
};
-#define KEYMAP_STACKED( \
+#define PER_KEY_DATA_STACKED(dflt, \
/* left hand, spatial positions */ \
r0c0, r0c1, r0c2, r0c3, r0c4, r0c5, r0c6, \
r1c0, r1c1, r1c2, r1c3, r1c4, r1c5, r1c6, \
@@ -115,23 +115,22 @@ class ErgoDox : public kaleidoscope::Hardware {
r5c12, r5c11, r5c10 ) \
\
/* matrix positions */ \
- { \
- { r0c0, r1c0, r2c0, r3c0, r4c0, XXX }, \
- { r0c1, r1c1, r2c1, r3c1, r4c1, r5c1 }, \
- { r0c2, r1c2, r2c2, r3c2, r4c2, r5c2 }, \
- { r0c3, r1c3, r2c3, r3c3, r4c3, r5c3 }, \
- { r0c4, r1c4, r2c4, r3c4, r4c4, r5c4 }, \
- { r0c5, r1c5, r2c5, r3c5, XXX, r5c5 }, \
- { r0c6, r1c6, XXX, r3c6, XXX, r5c6 }, \
\
- { r0c7, r1c7, XXX, r3c7, XXX, r5c7 }, \
- { r0c8, r1c8, r2c8, r3c8, XXX, r5c8 }, \
- { r0c9, r1c9, r2c9, r3c9, r4c9, r5c9 }, \
- { r0c10, r1c10, r2c10, r3c10, r4c10, r5c10 }, \
- { r0c11, r1c11, r2c11, r3c11, r4c11, r5c11 }, \
- { r0c12, r1c12, r2c12, r3c12, r4c12, r5c12 }, \
- { r0c13, r1c13, r2c13, r3c13, r4c13, XXX } \
- }
+ r0c0, r1c0, r2c0, r3c0, r4c0, dflt, \
+ r0c1, r1c1, r2c1, r3c1, r4c1, r5c1, \
+ r0c2, r1c2, r2c2, r3c2, r4c2, r5c2, \
+ r0c3, r1c3, r2c3, r3c3, r4c3, r5c3, \
+ r0c4, r1c4, r2c4, r3c4, r4c4, r5c4, \
+ r0c5, r1c5, r2c5, r3c5, dflt, r5c5, \
+ r0c6, r1c6, dflt, r3c6, dflt, r5c6, \
+ \
+ r0c7, r1c7, dflt, r3c7, dflt, r5c7, \
+ r0c8, r1c8, r2c8, r3c8, dflt, r5c8, \
+ r0c9, r1c9, r2c9, r3c9, r4c9, r5c9, \
+ r0c10, r1c10, r2c10, r3c10, r4c10, r5c10, \
+ r0c11, r1c11, r2c11, r3c11, r4c11, r5c11, \
+ r0c12, r1c12, r2c12, r3c12, r4c12, r5c12, \
+ r0c13, r1c13, r2c13, r3c13, r4c13, dflt
}
}
}
diff --git a/src/kaleidoscope/hardware/kbdfans/KBD4x.h b/src/kaleidoscope/hardware/kbdfans/KBD4x.h
index 439b2404..dd9d898f 100644
--- a/src/kaleidoscope/hardware/kbdfans/KBD4x.h
+++ b/src/kaleidoscope/hardware/kbdfans/KBD4x.h
@@ -48,17 +48,16 @@ class KBD4x: public kaleidoscope::hardware::ATMegaKeyboard {
void resetDevice();
};
-#define KEYMAP( \
+#define PER_KEY_DATA(dflt, \
R0C0, R0C1, R0C2, R0C3, R0C4, R0C5, R0C6, R0C7, R0C8, R0C9, R0C10, R0C11, \
R1C0, R1C1, R1C2, R1C3, R1C4, R1C5, R1C6, R1C7, R1C8, R1C9, R1C10, R1C11, \
R2C0, R2C1, R2C2, R2C3, R2C4, R2C5, R2C6, R2C7, R2C8, R2C9, R2C10, R2C11, \
- R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C7, R3C8, R3C9, R3C10, R3C11 \
- ) { \
- { R0C0, R0C1, R0C2, R0C3, R0C4, R0C5, R0C6, R0C7, R0C8, R0C9, R0C10, R0C11, }, \
- { R1C0, R1C1, R1C2, R1C3, R1C4, R1C5, R1C6, R1C7, R1C8, R1C9, R1C10, R1C11, }, \
- { R2C0, R2C1, R2C2, R2C3, R2C4, R2C5, R2C6, R2C7, R2C8, R2C9, R2C10, R2C11, }, \
- { R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C5, R3C7, R3C8, R3C9, R3C10, R3C11, } \
- }
+ R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C7, R3C8, R3C9, R3C10, R3C11 \
+ ) \
+ R0C0, R0C1, R0C2, R0C3, R0C4, R0C5, R0C6, R0C7, R0C8, R0C9, R0C10, R0C11, \
+ R1C0, R1C1, R1C2, R1C3, R1C4, R1C5, R1C6, R1C7, R1C8, R1C9, R1C10, R1C11, \
+ R2C0, R2C1, R2C2, R2C3, R2C4, R2C5, R2C6, R2C7, R2C8, R2C9, R2C10, R2C11, \
+ R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C5, R3C7, R3C8, R3C9, R3C10, R3C11
}
}
diff --git a/src/kaleidoscope/hardware/keyboardio/Model01.h b/src/kaleidoscope/hardware/keyboardio/Model01.h
index 60112673..17cfe499 100644
--- a/src/kaleidoscope/hardware/keyboardio/Model01.h
+++ b/src/kaleidoscope/hardware/keyboardio/Model01.h
@@ -100,7 +100,7 @@ class Model01 : public kaleidoscope::Hardware {
#include "kaleidoscope/hardware/key_indexes.h"
-#define KEYMAP_STACKED( \
+#define PER_KEY_DATA_STACKED(dflt, \
r0c0, r0c1, r0c2, r0c3, r0c4, r0c5, r0c6, \
r1c0, r1c1, r1c2, r1c3, r1c4, r1c5, r1c6, \
r2c0, r2c1, r2c2, r2c3, r2c4, r2c5, \
@@ -114,25 +114,22 @@ class Model01 : public kaleidoscope::Hardware {
r2c9, r3c10, r3c11, r3c12, r3c13, r3c14, r3c15, \
r3c8, r2c8, r1c8, r0c8, \
r3c9, ...) \
- { \
- {r0c0, r0c1, r0c2, r0c3, r0c4, r0c5, r0c6, r0c7, r0c8, r0c9, r0c10, r0c11, r0c12, r0c13, r0c14, r0c15}, \
- {r1c0, r1c1, r1c2, r1c3, r1c4, r1c5, r1c6, r1c7, r1c8, r1c9, r1c10, r1c11, r1c12, r1c13, r1c14, r1c15}, \
- {r2c0, r2c1, r2c2, r2c3, r2c4, r2c5, r2c6, r2c7, r2c8, r2c9, r2c10, r2c11, r2c12, r2c13, r2c14, r2c15}, \
- {r3c0, r3c1, r3c2, r3c3, r3c4, r3c5, r3c6, r3c7, r3c8, r3c9, r3c10, r3c11, r3c12, r3c13, r3c14, RESTRICT_ARGS_COUNT((r3c15), 64, KEYMAP_STACKED, ##__VA_ARGS__)}, \
- }
-
-#define KEYMAP( \
+ \
+ r0c0, r0c1, r0c2, r0c3, r0c4, r0c5, r0c6, r0c7, r0c8, r0c9, r0c10, r0c11, r0c12, r0c13, r0c14, r0c15, \
+ r1c0, r1c1, r1c2, r1c3, r1c4, r1c5, r1c6, r1c7, r1c8, r1c9, r1c10, r1c11, r1c12, r1c13, r1c14, r1c15, \
+ r2c0, r2c1, r2c2, r2c3, r2c4, r2c5, r2c6, r2c7, r2c8, r2c9, r2c10, r2c11, r2c12, r2c13, r2c14, r2c15, \
+ r3c0, r3c1, r3c2, r3c3, r3c4, r3c5, r3c6, r3c7, r3c8, r3c9, r3c10, r3c11, r3c12, r3c13, r3c14, RESTRICT_ARGS_COUNT((r3c15), 64, KEYMAP_STACKED, ##__VA_ARGS__)
+
+#define PER_KEY_DATA(dflt, \
r0c0, r0c1, r0c2, r0c3, r0c4, r0c5, r0c6, r0c9, r0c10, r0c11, r0c12, r0c13, r0c14, r0c15, \
r1c0, r1c1, r1c2, r1c3, r1c4, r1c5, r1c6, r1c9, r1c10, r1c11, r1c12, r1c13, r1c14, r1c15, \
r2c0, r2c1, r2c2, r2c3, r2c4, r2c5, r2c10, r2c11, r2c12, r2c13, r2c14, r2c15, \
r3c0, r3c1, r3c2, r3c3, r3c4, r3c5, r2c6, r2c9, r3c10, r3c11, r3c12, r3c13, r3c14, r3c15, \
r0c7, r1c7, r2c7, r3c7, r3c8, r2c8, r1c8, r0c8, \
r3c6, r3c9, ...) \
- { \
- {r0c0, r0c1, r0c2, r0c3, r0c4, r0c5, r0c6, r0c7, r0c8, r0c9, r0c10, r0c11, r0c12, r0c13, r0c14, r0c15}, \
- {r1c0, r1c1, r1c2, r1c3, r1c4, r1c5, r1c6, r1c7, r1c8, r1c9, r1c10, r1c11, r1c12, r1c13, r1c14, r1c15}, \
- {r2c0, r2c1, r2c2, r2c3, r2c4, r2c5, r2c6, r2c7, r2c8, r2c9, r2c10, r2c11, r2c12, r2c13, r2c14, r2c15}, \
- {r3c0, r3c1, r3c2, r3c3, r3c4, r3c5, r3c6, r3c7, r3c8, r3c9, r3c10, r3c11, r3c12, r3c13, r3c14, RESTRICT_ARGS_COUNT((r3c15), 64, KEYMAP, ##__VA_ARGS__)}, \
- }
+ r0c0, r0c1, r0c2, r0c3, r0c4, r0c5, r0c6, r0c7, r0c8, r0c9, r0c10, r0c11, r0c12, r0c13, r0c14, r0c15, \
+ r1c0, r1c1, r1c2, r1c3, r1c4, r1c5, r1c6, r1c7, r1c8, r1c9, r1c10, r1c11, r1c12, r1c13, r1c14, r1c15, \
+ r2c0, r2c1, r2c2, r2c3, r2c4, r2c5, r2c6, r2c7, r2c8, r2c9, r2c10, r2c11, r2c12, r2c13, r2c14, r2c15, \
+ r3c0, r3c1, r3c2, r3c3, r3c4, r3c5, r3c6, r3c7, r3c8, r3c9, r3c10, r3c11, r3c12, r3c13, r3c14, RESTRICT_ARGS_COUNT((r3c15), 64, KEYMAP, ##__VA_ARGS__)
#endif
diff --git a/src/kaleidoscope/hardware/olkb/Planck.h b/src/kaleidoscope/hardware/olkb/Planck.h
index e42eb15c..d1d38d72 100644
--- a/src/kaleidoscope/hardware/olkb/Planck.h
+++ b/src/kaleidoscope/hardware/olkb/Planck.h
@@ -43,17 +43,17 @@ class Planck: public kaleidoscope::hardware::ATMegaKeyboard {
static constexpr int8_t led_count = 0;
};
-#define KEYMAP( \
+#define PER_KEY_DATA(dflt, \
R0C0, R0C1, R0C2, R0C3, R0C4, R0C5, R0C6, R0C7, R0C8, R0C9, R0C10, R0C11, \
R1C0, R1C1, R1C2, R1C3, R1C4, R1C5, R1C6, R1C7, R1C8, R1C9, R1C10, R1C11, \
R2C0, R2C1, R2C2, R2C3, R2C4, R2C5, R2C6, R2C7, R2C8, R2C9, R2C10, R2C11, \
- R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11 \
- ) { \
- { R0C0, R0C1, R0C2, R0C3, R0C4, R0C5, R0C6, R0C7, R0C8, R0C9, R0C10, R0C11, }, \
- { R1C0, R1C1, R1C2, R1C3, R1C4, R1C5, R1C6, R1C7, R1C8, R1C9, R1C10, R1C11, }, \
- { R2C0, R2C1, R2C2, R2C3, R2C4, R2C5, R2C6, R2C7, R2C8, R2C9, R2C10, R2C11, }, \
- { R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11, } \
- }
+ R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11 \
+ ) \
+ R0C0, R0C1, R0C2, R0C3, R0C4, R0C5, R0C6, R0C7, R0C8, R0C9, R0C10, R0C11, \
+ R1C0, R1C1, R1C2, R1C3, R1C4, R1C5, R1C6, R1C7, R1C8, R1C9, R1C10, R1C11, \
+ R2C0, R2C1, R2C2, R2C3, R2C4, R2C5, R2C6, R2C7, R2C8, R2C9, R2C10, R2C11, \
+ R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11
+
}
}
diff --git a/src/kaleidoscope/hardware/softhruf/Splitography.h b/src/kaleidoscope/hardware/softhruf/Splitography.h
index 073d3c0a..3eb313c9 100644
--- a/src/kaleidoscope/hardware/softhruf/Splitography.h
+++ b/src/kaleidoscope/hardware/softhruf/Splitography.h
@@ -52,36 +52,33 @@ class Splitography: public kaleidoscope::hardware::ATMegaKeyboard {
static constexpr int8_t led_count = 0;
};
-#define KEYMAP( \
+#define PER_KEY_DATA(dflt, \
r0c0 ,r0c1 ,r0c2 ,r0c3 ,r0c4 ,r0c5 ,r0c6 ,r0c7 ,r0c8 ,r0c9 ,r0c10 ,r0c11 \
,r1c0 ,r1c1 ,r1c2 ,r1c3 ,r1c4 ,r1c5 ,r1c6 ,r1c7 ,r1c8 ,r1c9 ,r1c10 ,r1c11 \
,r2c0 ,r2c1 ,r2c2 ,r2c3 ,r2c4 ,r2c5 ,r2c6 ,r2c7 ,r2c8 ,r2c9 ,r2c10 ,r2c11 \
,r3c4 ,r3c5 ,r3c6 ,r3c7 \
) \
- { \
- { r0c0 ,r0c1 ,r0c2 ,r0c3 ,r0c4 ,r0c5 , r0c6 ,r0c7 ,r0c8 ,r0c9 ,r0c10 ,r0c11 }, \
- { r1c0 ,r1c1 ,r1c2 ,r1c3 ,r1c4 ,r1c5 , r1c6 ,r1c7 ,r1c8 ,r1c9 ,r1c10 ,r1c11 }, \
- { r2c0 ,r2c1 ,r2c2 ,r2c3 ,r2c4 ,r2c5 , r2c6 ,r2c7 ,r2c8 ,r2c9 ,r2c10 ,r2c11 }, \
- { XXX ,XXX ,XXX ,XXX ,r3c4 ,r3c5 ,r3c6 ,r3c7 ,XXX ,XXX ,XXX ,XXX } \
- }
-
-#define KEYMAP_STACKED( \
- r0c0 ,r0c1 ,r0c2 ,r0c3 ,r0c4 ,r0c5 \
- ,r1c0 ,r1c1 ,r1c2 ,r1c3 ,r1c4 ,r1c5 \
- ,r2c0 ,r2c1 ,r2c2 ,r2c3 ,r2c4 ,r2c5 \
- ,r3c4 ,r3c5 \
\
- ,r0c6 ,r0c7 ,r0c8 ,r0c9 ,r0c10 ,r0c11 \
- ,r1c6 ,r1c7 ,r1c8 ,r1c9 ,r1c10 ,r1c11 \
- ,r2c6 ,r2c7 ,r2c8 ,r2c9 ,r2c10 ,r2c11 \
- ,r3c6 ,r3c7 \
- ) \
- { \
- { r0c0 ,r0c1 ,r0c2 ,r0c3 ,r0c4 ,r0c5 , r0c6 ,r0c7 ,r0c8 ,r0c9 ,r0c10 ,r0c11 }, \
- { r1c0 ,r1c1 ,r1c2 ,r1c3 ,r1c4 ,r1c5 , r1c6 ,r1c7 ,r1c8 ,r1c9 ,r1c10 ,r1c11 }, \
- { r2c0 ,r2c1 ,r2c2 ,r2c3 ,r2c4 ,r2c5 , r2c6 ,r2c7 ,r2c8 ,r2c9 ,r2c10 ,r2c11 }, \
- { XXX ,XXX ,XXX ,XXX ,r3c4 ,r3c5 ,r3c6 ,r3c7 ,XXX ,XXX ,XXX ,XXX } \
- }
+ r0c0 ,r0c1 ,r0c2 ,r0c3 ,r0c4 ,r0c5 , r0c6 ,r0c7 ,r0c8 ,r0c9 ,r0c10 ,r0c11, \
+ r1c0 ,r1c1 ,r1c2 ,r1c3 ,r1c4 ,r1c5 , r1c6 ,r1c7 ,r1c8 ,r1c9 ,r1c10 ,r1c11, \
+ r2c0 ,r2c1 ,r2c2 ,r2c3 ,r2c4 ,r2c5 , r2c6 ,r2c7 ,r2c8 ,r2c9 ,r2c10 ,r2c11, \
+ dflt ,dflt ,dflt ,dflt ,r3c4 ,r3c5 ,r3c6 ,r3c7 ,dflt ,dflt ,dflt ,dflt
+
+#define PER_KEY_DATA_STACKED(dflt, \
+ r0c0 ,r0c1 ,r0c2 ,r0c3 ,r0c4 ,r0c5 \
+ ,r1c0 ,r1c1 ,r1c2 ,r1c3 ,r1c4 ,r1c5 \
+ ,r2c0 ,r2c1 ,r2c2 ,r2c3 ,r2c4 ,r2c5 \
+ ,r3c4 ,r3c5 \
+ \
+ ,r0c6 ,r0c7 ,r0c8 ,r0c9 ,r0c10 ,r0c11 \
+ ,r1c6 ,r1c7 ,r1c8 ,r1c9 ,r1c10 ,r1c11 \
+ ,r2c6 ,r2c7 ,r2c8 ,r2c9 ,r2c10 ,r2c11 \
+ ,r3c6 ,r3c7 \
+ ) \
+ r0c0 ,r0c1 ,r0c2 ,r0c3 ,r0c4 ,r0c5 ,r0c6 ,r0c7 ,r0c8 ,r0c9 ,r0c10 ,r0c11, \
+ r1c0 ,r1c1 ,r1c2 ,r1c3 ,r1c4 ,r1c5 ,r1c6 ,r1c7 ,r1c8 ,r1c9 ,r1c10 ,r1c11, \
+ r2c0 ,r2c1 ,r2c2 ,r2c3 ,r2c4 ,r2c5 ,r2c6 ,r2c7 ,r2c8 ,r2c9 ,r2c10 ,r2c11, \
+ dflt ,dflt ,dflt ,dflt ,r3c4 ,r3c5 ,r3c6 ,r3c7 ,dflt ,dflt ,dflt ,dflt
}
}
diff --git a/src/kaleidoscope/hardware/technomancy/Atreus.h b/src/kaleidoscope/hardware/technomancy/Atreus.h
index 00ce781b..8ecd21c7 100644
--- a/src/kaleidoscope/hardware/technomancy/Atreus.h
+++ b/src/kaleidoscope/hardware/technomancy/Atreus.h
@@ -70,20 +70,19 @@ class Atreus: public kaleidoscope::hardware::ATMegaKeyboard {
protected:
};
-#define KEYMAP( \
+#define PER_KEY_DATA(dflt, \
R0C0, R0C1, R0C2, R0C3, R0C4, R0C7, R0C8, R0C9, R0C10, R0C11, \
R1C0, R1C1, R1C2, R1C3, R1C4, R1C7, R1C8, R1C9, R1C10, R1C11, \
R2C0, R2C1, R2C2, R2C3, R2C4, R2C7, R2C8, R2C9, R2C10, R2C11, \
R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11 \
) \
- { \
- { R0C0, R0C1, R0C2, R0C3, R0C4, XXX, R0C7, R0C8, R0C9, R0C10, R0C11 }, \
- { R1C0, R1C1, R1C2, R1C3, R1C4, XXX, R1C7, R1C8, R1C9, R1C10, R1C11 }, \
- { R2C0, R2C1, R2C2, R2C3, R2C4, R3C5, R2C7, R2C8, R2C9, R2C10, R2C11 }, \
- { R3C0, R3C1, R3C2, R3C3, R3C4, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11 } \
- }
-
-#define KEYMAP_STACKED( \
+ \
+ R0C0, R0C1, R0C2, R0C3, R0C4, XXX, R0C7, R0C8, R0C9, R0C10, R0C11, \
+ R1C0, R1C1, R1C2, R1C3, R1C4, XXX, R1C7, R1C8, R1C9, R1C10, R1C11, \
+ R2C0, R2C1, R2C2, R2C3, R2C4, R3C5, R2C7, R2C8, R2C9, R2C10, R2C11, \
+ R3C0, R3C1, R3C2, R3C3, R3C4, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11
+
+#define PER_KEY_DATA_STACKED(dflt, \
R0C0, R0C1, R0C2, R0C3, R0C4, \
R1C0, R1C1, R1C2, R1C3, R1C4, \
R2C0, R2C1, R2C2, R2C3, R2C4, \
@@ -94,12 +93,10 @@ class Atreus: public kaleidoscope::hardware::ATMegaKeyboard {
R2C7, R2C8, R2C9, R2C10, R2C11, \
R3C6, R3C7, R3C8, R3C9, R3C10, R3C11 \
) \
- { \
- { R0C0, R0C1, R0C2, R0C3, R0C4, XXX, R0C7, R0C8, R0C9, R0C10, R0C11 }, \
- { R1C0, R1C1, R1C2, R1C3, R1C4, XXX, R1C7, R1C8, R1C9, R1C10, R1C11 }, \
- { R2C0, R2C1, R2C2, R2C3, R2C4, R3C5, R2C7, R2C8, R2C9, R2C10, R2C11 }, \
- { R3C0, R3C1, R3C2, R3C3, R3C4, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11 } \
- }
+ R0C0, R0C1, R0C2, R0C3, R0C4, dflt, R0C7, R0C8, R0C9, R0C10, R0C11, \
+ R1C0, R1C1, R1C2, R1C3, R1C4, dflt, R1C7, R1C8, R1C9, R1C10, R1C11, \
+ R2C0, R2C1, R2C2, R2C3, R2C4, R3C5, R2C7, R2C8, R2C9, R2C10, R2C11, \
+ R3C0, R3C1, R3C2, R3C3, R3C4, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11
}
}
}
diff --git a/src/kaleidoscope/hardware/technomancy/Atreus2.h b/src/kaleidoscope/hardware/technomancy/Atreus2.h
index cad7c6f3..524bef82 100644
--- a/src/kaleidoscope/hardware/technomancy/Atreus2.h
+++ b/src/kaleidoscope/hardware/technomancy/Atreus2.h
@@ -48,20 +48,18 @@ class Atreus2: public kaleidoscope::hardware::ATMegaKeyboard {
protected:
};
-#define KEYMAP( \
+#define PER_KEY_DATA(dflt, \
R0C0, R0C1, R0C2, R0C3, R0C4, R0C7, R0C8, R0C9, R0C10, R0C11, \
R1C0, R1C1, R1C2, R1C3, R1C4, R1C7, R1C8, R1C9, R1C10, R1C11, \
R2C0, R2C1, R2C2, R2C3, R2C4, R2C5, R2C6, R2C7, R2C8, R2C9, R2C10, R2C11, \
R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11 \
) \
- { \
- { R0C0, R0C1, R0C2, R0C3, R0C4, XXX, XXX, R0C7, R0C8, R0C9, R0C10, R0C11 }, \
- { R1C0, R1C1, R1C2, R1C3, R1C4, XXX, XXX, R1C7, R1C8, R1C9, R1C10, R1C11 }, \
- { R2C0, R2C1, R2C2, R2C3, R2C4, R2C5, R2C6, R2C7, R2C8, R2C9, R2C10, R2C11 }, \
- { R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11 } \
- }
+ R0C0, R0C1, R0C2, R0C3, R0C4, XXX, XXX, R0C7, R0C8, R0C9, R0C10, R0C11, \
+ R1C0, R1C1, R1C2, R1C3, R1C4, XXX, XXX, R1C7, R1C8, R1C9, R1C10, R1C11, \
+ R2C0, R2C1, R2C2, R2C3, R2C4, R2C5, R2C6, R2C7, R2C8, R2C9, R2C10, R2C11, \
+ R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11
-#define KEYMAP_STACKED( \
+#define PER_KEY_DATA_STACKED(dflt, \
R0C0, R0C1, R0C2, R0C3, R0C4, \
R1C0, R1C1, R1C2, R1C3, R1C4, \
R2C0, R2C1, R2C2, R2C3, R2C4, R2C5, \
@@ -72,12 +70,10 @@ class Atreus2: public kaleidoscope::hardware::ATMegaKeyboard {
R2C6, R2C7, R2C8, R2C9, R2C10, R2C11, \
R3C6, R3C7, R3C8, R3C9, R3C10, R3C11 \
) \
- { \
- { R0C0, R0C1, R0C2, R0C3, R0C4, XXX, XXX, R0C7, R0C8, R0C9, R0C10, R0C11 }, \
- { R1C0, R1C1, R1C2, R1C3, R1C4, XXX, XXX, R1C7, R1C8, R1C9, R1C10, R1C11 }, \
- { R2C0, R2C1, R2C2, R2C3, R2C4, R2C5, R2C6, R2C7, R2C8, R2C9, R2C10, R2C11 }, \
- { R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11 } \
- }
+ R0C0, R0C1, R0C2, R0C3, R0C4, XXX, XXX, R0C7, R0C8, R0C9, R0C10, R0C11, \
+ R1C0, R1C1, R1C2, R1C3, R1C4, XXX, XXX, R1C7, R1C8, R1C9, R1C10, R1C11, \
+ R2C0, R2C1, R2C2, R2C3, R2C4, R2C5, R2C6, R2C7, R2C8, R2C9, R2C10, R2C11, \
+ R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C6, R3C7, R3C8, R3C9, R3C10, R3C11
}
}
}
diff --git a/src/kaleidoscope/keymaps.h b/src/kaleidoscope/keymaps.h
new file mode 100644
index 00000000..9e49222c
--- /dev/null
+++ b/src/kaleidoscope/keymaps.h
@@ -0,0 +1,79 @@
+/* Kaleidoscope - Firmware for computer input devices
+ * Copyright (C) 2013-2018 Keyboard.io, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see .
+ */
+
+#pragma once
+
+#include "kaleidoscope/key_defs.h"
+
+extern const Key keymaps_linear[][ROWS * COLS];
+
+namespace kaleidoscope {
+
+inline
+Key keyFromKeymap(uint8_t layer, uint8_t row, uint8_t col) {
+ return pgm_read_word(&keymaps_linear[layer][row * COLS + col]);
+}
+
+namespace internal {
+
+// This class mimics a three-dimensional array as formerly used to
+// store keymap arrays in progmem. It wraps the new one dimentional
+// keymap array.
+
+class Keymaps2DInterface {
+
+ public:
+
+ class KeymapLayer {
+
+ const Key * const keymap_layer_;
+
+ public:
+
+ KeymapLayer(const Key * const keymap_layer) : keymap_layer_(keymap_layer) {}
+
+ class KeymapRow {
+
+ const Key * const keymap_row_;
+
+ public:
+ KeymapRow(const Key * const keymap_row) : keymap_row_(keymap_row) {}
+
+ const Key &operator[](uint8_t col) {
+ return keymap_row_[col];
+ }
+ };
+
+ KeymapRow operator[](uint8_t row) {
+ return KeymapRow(keymap_layer_ + row * COLS);
+ }
+ };
+
+ KeymapLayer operator[](uint8_t layer) {
+ return KeymapLayer(keymaps_linear[layer]);
+ }
+};
+
+}
+}
+
+#define _DEPRECATED_MESSAGE_2D_KEYMAP_ARRAY \
+ "Accessing the keymap array directly is deprecated. Please use the function "\
+ "keyFromKeymap() to access keys. The keymap array will be removed in future "\
+ "versions of the firmware"
+
+DEPRECATED(2D_KEYMAP_ARRAY)
+extern kaleidoscope::internal::Keymaps2DInterface keymaps;
diff --git a/src/kaleidoscope/layers.cpp b/src/kaleidoscope/layers.cpp
index e581703e..d6dfa0ce 100644
--- a/src/kaleidoscope/layers.cpp
+++ b/src/kaleidoscope/layers.cpp
@@ -21,7 +21,7 @@
// that should be enough for almost any layout.
#define MAX_LAYERS sizeof(uint32_t) * 8;
-// The total number of defined layers in the firmware sketch keymaps[]
+// The total number of defined layers in the firmware sketch keymaps_linear[]
// array. If the keymap wasn't defined using KEYMAPS(), set it to the
// highest possible number of layers.
uint8_t layer_count __attribute__((weak)) = MAX_LAYERS;
@@ -93,11 +93,7 @@ Key Layer_::eventHandler(Key mappedKey, byte row, byte col, uint8_t keyState) {
}
Key Layer_::getKeyFromPROGMEM(uint8_t layer, byte row, byte col) {
- Key key;
-
- key.raw = pgm_read_word(&(keymaps[layer][row][col]));
-
- return key;
+ return keyFromKeymap(layer, row, col);
}
void Layer_::updateLiveCompositeKeymap(byte row, byte col) {
diff --git a/src/kaleidoscope/layers.h b/src/kaleidoscope/layers.h
index 74b970b2..490b5a2b 100644
--- a/src/kaleidoscope/layers.h
+++ b/src/kaleidoscope/layers.h
@@ -18,17 +18,21 @@
#include
#include "kaleidoscope/key_defs.h"
+#include "kaleidoscope/keymaps.h"
#include KALEIDOSCOPE_HARDWARE_H
-extern const Key keymaps[][ROWS][COLS];
-
-
// 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...) \
- const Key keymaps[][ROWS][COLS] PROGMEM = { layers }; \
- uint8_t layer_count = sizeof(keymaps) / sizeof(*keymaps);
+#define KEYMAPS(layers...) __NL__ \
+ const Key keymaps_linear[][ROWS*COLS] PROGMEM = { layers }; __NL__ \
+ uint8_t layer_count __NL__ \
+ = sizeof(keymaps_linear) / sizeof(*keymaps_linear); __NL__ \
+ __NL__ \
+ /* This deprecated compatibility wrapper is removed by the linker if __NL__ \
+ it is not accessed nowhere. __NL__ \
+ */ __NL__ \
+ kaleidoscope::internal::Keymaps2DInterface keymaps;
extern uint8_t layer_count;