summaryrefslogtreecommitdiff
path: root/keyboards
diff options
context:
space:
mode:
authorEric.a Gebhart <e.a.gebhart@gmail.com>2023-02-12 11:31:04 -0500
committerGitHub <noreply@github.com>2023-02-13 03:31:04 +1100
commitdb1eeea4788de062eccf327da5844fc3f46844f9 (patch)
treecb8537e4a0222c84d0cd653661eb94a579000036 /keyboards
parentbbf7a20b33de2d203518687cb5cd1aa85005ea27 (diff)
Add combo hook to allow per layer combo reference layers. (#16699)
Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: Sergey Vlasov <sigprof@gmail.com>
Diffstat (limited to 'keyboards')
-rw-r--r--keyboards/gboards/g/keymap_combo.h48
1 files changed, 41 insertions, 7 deletions
diff --git a/keyboards/gboards/g/keymap_combo.h b/keyboards/gboards/g/keymap_combo.h
index b92b6a4bc4..68ea44b1b4 100644
--- a/keyboards/gboards/g/keymap_combo.h
+++ b/keyboards/gboards/g/keymap_combo.h
@@ -1,4 +1,10 @@
// Keymap helpers
+// define reference layers per layer.
+#define REF_LAYER_FOR_LAYER(LAYER, REF_LAYER) \
+ case LAYER: return REF_LAYER;
+
+#define DEF_REF_LAYER(LAYER) \
+ default: return LAYER;
#define K_ENUM(name, key, ...) name,
#define K_DATA(name, key, ...) const uint16_t PROGMEM cmb_##name[] = {__VA_ARGS__, COMBO_END};
@@ -7,17 +13,22 @@
#define A_ENUM(name, string, ...) name,
#define A_DATA(name, string, ...) const uint16_t PROGMEM cmb_##name[] = {__VA_ARGS__, COMBO_END};
#define A_COMB(name, string, ...) [name] = COMBO_ACTION(cmb_##name),
-#define A_ACTI(name, string, ...) \
- case name: \
- if (pressed) SEND_STRING(string); \
+#define A_ACTI(name, string, ...) \
+ case name: \
+ if (pressed) SEND_STRING(string); \
break;
-#define A_TOGG(name, layer, ...) \
- case name: \
- if (pressed) layer_invert(layer); \
+#define A_TOGG(name, layer, ...) \
+ case name: \
+ if (pressed) layer_invert(layer); \
break;
#define BLANK(...)
+#undef COMBO_REF_LAYER
+#undef DEFAULT_REF_LAYER
+#define COMBO_REF_LAYER BLANK
+#define DEFAULT_REF_LAYER BLANK
+
// Generate data needed for combos/actions
// Create Enum
#undef COMB
@@ -66,10 +77,33 @@ void process_combo_event(uint16_t combo_index, bool pressed) {
}
// Allow user overrides per keymap
-#if __has_include("inject.h")
+#if __has_include("inject.h")
# include "inject.h"
#endif
}
#undef COMB
#undef SUBS
#undef TOGG
+
+// Allow reference layers per layer.
+#define COMB BLANK
+#define SUBS BLANK
+#define TOGG BLANK
+
+#undef DEFAULT_REF_LAYER
+#undef COMBO_REF_LAYER
+#define COMBO_REF_LAYER REF_LAYER_FOR_LAYER
+#define DEFAULT_REF_LAYER DEF_REF_LAYER
+
+uint8_t combo_ref_from_layer(uint8_t current_layer){
+ switch (current_layer){
+#include "combos.def"
+ }
+ return current_layer;
+}
+
+#undef COMB
+#undef SUBS
+#undef TOGG
+#undef COMBO_REF_LAYER
+#undef DEFAULT_REF_LAYER