summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Brassel <nick@tzarc.org>2022-07-05 08:58:35 +1000
committerGitHub <noreply@github.com>2022-07-05 08:58:35 +1000
commit0e5d67145a649480fd49a72712997feb6303a471 (patch)
treee8d4090768c2612fa77c3d508bc7af998b5d96b0
parent5cad58dfa960c9463ee5835de131b8fcb2d446e4 (diff)
Allow for `keymaps` array to be implemented in a file other than `$(KEYMAP_C)` (#17559)
-rw-r--r--builddefs/build_keyboard.mk6
-rw-r--r--quantum/keymap_introspection.c5
-rw-r--r--users/manna-harbour_miryoku/post_rules.mk2
-rw-r--r--users/manna-harbour_miryoku/rules.mk2
4 files changed, 12 insertions, 3 deletions
diff --git a/builddefs/build_keyboard.mk b/builddefs/build_keyboard.mk
index b5616a438f..fe95dcaf15 100644
--- a/builddefs/build_keyboard.mk
+++ b/builddefs/build_keyboard.mk
@@ -400,6 +400,12 @@ endif
OPT_DEFS += -DKEYMAP_C=\"$(KEYMAP_C)\"
+# If a keymap or userspace places their keymap array in another file instead, allow for it to be included
+# !!NOTE!! -- For this to work, the source file cannot be part of $(SRC), so users should not add it via `SRC += <file>`
+ifneq ($(strip $(INTROSPECTION_KEYMAP_C)),)
+OPT_DEFS += -DINTROSPECTION_KEYMAP_C=\"$(strip $(INTROSPECTION_KEYMAP_C))\"
+endif
+
# project specific files
SRC += \
$(KEYBOARD_SRC) \
diff --git a/quantum/keymap_introspection.c b/quantum/keymap_introspection.c
index 9628b41eef..7a96f802ef 100644
--- a/quantum/keymap_introspection.c
+++ b/quantum/keymap_introspection.c
@@ -4,6 +4,11 @@
// Pull the actual keymap code so that we can inspect stuff from it
#include KEYMAP_C
+// Allow for keymap or userspace rules.mk to specify an alternate location for the keymap array
+#ifdef INTROSPECTION_KEYMAP_C
+# include INTROSPECTION_KEYMAP_C
+#endif // INTROSPECTION_KEYMAP_C
+
#include "keymap_introspection.h"
#define NUM_KEYMAP_LAYERS ((uint8_t)(sizeof(keymaps) / ((MATRIX_ROWS) * (MATRIX_COLS) * sizeof(uint16_t))))
diff --git a/users/manna-harbour_miryoku/post_rules.mk b/users/manna-harbour_miryoku/post_rules.mk
index c5b4b7d28e..8fece85e66 100644
--- a/users/manna-harbour_miryoku/post_rules.mk
+++ b/users/manna-harbour_miryoku/post_rules.mk
@@ -1,8 +1,6 @@
# Copyright 2019 Manna Harbour
# https://github.com/manna-harbour/miryoku
-SRC += manna-harbour_miryoku.c # keymaps
-
# alternative layouts:
# alphas
diff --git a/users/manna-harbour_miryoku/rules.mk b/users/manna-harbour_miryoku/rules.mk
index 879c7fc43e..ea226c4a3d 100644
--- a/users/manna-harbour_miryoku/rules.mk
+++ b/users/manna-harbour_miryoku/rules.mk
@@ -5,7 +5,7 @@ MOUSEKEY_ENABLE = yes # Mouse keys
EXTRAKEY_ENABLE = yes # Audio control and System control
AUTO_SHIFT_ENABLE = yes # Auto Shift
-SRC += manna-harbour_miryoku.c # keymaps
+INTROSPECTION_KEYMAP_C = manna-harbour_miryoku.c # keymaps
include users/manna-harbour_miryoku/custom_rules.mk