summaryrefslogtreecommitdiff
path: root/app/cmake
diff options
context:
space:
mode:
authorPete Johanson <peter@peterjohanson.com>2020-08-06 10:32:06 -0400
committerPete Johanson <peter@peterjohanson.com>2020-08-06 10:32:06 -0400
commitf83ec5ce2b04380158299c20c603c1fbb49b12d6 (patch)
tree61694b8adf3635bdd083f781eb30dc9b25da798a /app/cmake
parent9233ab60cda263b5286ffc9edef8c8cd40cc5c0e (diff)
Refactor to using .keymap files
* Still just devicetree keymaps. * Filename can now use `<board>.keymap` or `<shield>.keymap` convention, including overrides for revisions, etc.
Diffstat (limited to 'app/cmake')
-rw-r--r--app/cmake/zmk_config.cmake54
1 files changed, 25 insertions, 29 deletions
diff --git a/app/cmake/zmk_config.cmake b/app/cmake/zmk_config.cmake
index e4d2632..518c3c3 100644
--- a/app/cmake/zmk_config.cmake
+++ b/app/cmake/zmk_config.cmake
@@ -62,11 +62,9 @@ foreach(root ${BOARD_ROOT})
NAMES ${BOARD}_defconfig
PATHS ${root}/boards/*/*
NO_DEFAULT_PATH
- )
- if(BOARD_DIR)
- if (EXISTS "${BOARD_DIR}/keymap")
- list(APPEND KEYMAP_DIRS ${BOARD_DIR}/keymap)
- endif()
+ )
+ if(BOARD_DIR)
+ list(APPEND KEYMAP_DIRS ${BOARD_DIR})
endif()
if(DEFINED SHIELD)
@@ -77,37 +75,16 @@ foreach(root ${BOARD_ROOT})
)
foreach(shield_path ${shields_refs_list})
get_filename_component(SHIELD_DIR ${shield_path} NAME)
- if (EXISTS "${shield_path}/keymap")
- list(APPEND KEYMAP_DIRS ${shield_path}/keymap)
- endif()
+ list(APPEND KEYMAP_DIRS ${shield_path})
endforeach()
endif()
endforeach()
-find_path(BASE_KEYMAPS_DIR
- NAMES ${KEYMAP}/keymap.overlay
- PATHS ${KEYMAP_DIRS}
- NO_DEFAULT_PATH
-)
-
-if (BASE_KEYMAPS_DIR)
- set(KEYMAP_DIR "${BASE_KEYMAPS_DIR}/${KEYMAP}" CACHE STRING "Selected keymap directory")
- message(STATUS "Keyboard Base Keymap: ${KEYMAP_DIR}/")
- # Used to let local imports of custom keycodes work as expected
- list(APPEND DTS_ROOT ${KEYMAP_DIR})
- if (EXISTS "${KEYMAP_DIR}/include")
- include_directories("${KEYMAP_DIR}/include")
- endif()
- list(APPEND ZMK_DTC_FILES "${KEYMAP_DIR}keymap.overlay")
-endif()
-
if (ZMK_CONFIG)
if (EXISTS ${ZMK_CONFIG})
message(STATUS "ZMK Config directory: ${ZMK_CONFIG}")
list(APPEND DTS_ROOT ${ZMK_CONFIG})
- if (EXISTS "${ZMK_CONFIG}/include")
- include_directories("${ZMK_CONFIG}/include")
- endif()
+ list(PREPEND KEYMAP_DIRS "${ZMK_CONFIG}")
if (SHIELD)
message(STATUS "Board: ${BOARD}, ${BOARD_DIR}, ${SHIELD}, ${SHIELD_DIR}")
@@ -137,7 +114,7 @@ if (ZMK_CONFIG)
foreach(conf ${config_candidates})
if (EXISTS "${conf}")
- message(STATUS "ZMK Config Kconfig: ${overlay}")
+ message(STATUS "ZMK Config Kconfig: ${conf}")
set(CONF_FILE "${conf}")
break()
endif()
@@ -147,6 +124,25 @@ if (ZMK_CONFIG)
endif()
endif()
+
+if(NOT KEYMAP_FILE)
+ foreach(keymap_dir ${KEYMAP_DIRS})
+ foreach(keymap_prefix ${SHIELD} ${SHIELD_DIR} ${BOARD} ${BOARD_DIR})
+ if (EXISTS ${keymap_dir}/${keymap_prefix}.keymap)
+ set(KEYMAP_FILE "${keymap_dir}/${keymap_prefix}.keymap" CACHE STRING "Selected keymap file")
+ message(STATUS "Using keymap file: ${KEYMAP_FILE}")
+ break()
+ endif()
+ endforeach()
+ endforeach()
+endif()
+
+if (NOT KEYMAP_FILE)
+ message(FATAL_ERROR "Failed to locate keymap file!")
+endif()
+
+list(APPEND ZMK_DTC_FILES ${KEYMAP_FILE})
+
if (ZMK_DTC_FILES)
string(REPLACE ";" " " DTC_OVERLAY_FILE "${ZMK_DTC_FILES}")
endif()