Browse Source

Merge pull request #73 from petejohanson/core/keymap-file-refactor

Refactor to using .keymap files
xmkb
Pete Johanson 4 years ago committed by GitHub
parent
commit
81090d9af0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/CMakeLists.txt
  2. 0
      app/boards/arm/planck/planck_rev6.keymap
  3. 0
      app/boards/shields/clueboard_california/clueboard_california.keymap
  4. 0
      app/boards/shields/kyria/kyria.keymap
  5. 0
      app/boards/shields/lily58/lily58.keymap
  6. 13
      app/boards/shields/petejohanson_handwire/Kconfig.defconfig
  7. 5
      app/boards/shields/petejohanson_handwire/Kconfig.shield
  8. 40
      app/boards/shields/petejohanson_handwire/keymap/keymap.overlay
  9. 1
      app/boards/shields/petejohanson_handwire/petejohanson_handwire.conf
  10. 44
      app/boards/shields/petejohanson_handwire/petejohanson_handwire.overlay
  11. 13
      app/boards/shields/petejohanson_pro_micro_handwire/Kconfig.defconfig
  12. 5
      app/boards/shields/petejohanson_pro_micro_handwire/Kconfig.shield
  13. 41
      app/boards/shields/petejohanson_pro_micro_handwire/keymap/keymap.overlay
  14. 0
      app/boards/shields/petejohanson_pro_micro_handwire/petejohanson_pro_micro_handwire.conf
  15. 17
      app/boards/shields/petejohanson_pro_micro_handwire/petejohanson_pro_micro_handwire.overlay
  16. 50
      app/cmake/zmk_config.cmake

4
app/CMakeLists.txt

@ -18,10 +18,6 @@ include(cmake/zmk_config.cmake)
find_package(Zephyr REQUIRED HINTS ../zephyr) find_package(Zephyr REQUIRED HINTS ../zephyr)
project(zmk) project(zmk)
if(EXISTS ${KEYMAP_DIR}/keymap.c)
target_sources(app PRIVATE ${KEYMAP_DIR}/keymap.c)
endif()
zephyr_linker_sources(RODATA include/linker/zmk-events.ld) zephyr_linker_sources(RODATA include/linker/zmk-events.ld)
# Add your source file to the "app" target. This must come after # Add your source file to the "app" target. This must come after

0
app/boards/arm/planck/keymap/keymap.overlay → app/boards/arm/planck/planck_rev6.keymap

0
app/boards/shields/clueboard_california/keymap/keymap.overlay → app/boards/shields/clueboard_california/clueboard_california.keymap

0
app/boards/shields/kyria/keymap/keymap.overlay → app/boards/shields/kyria/kyria.keymap

0
app/boards/shields/lily58/keymap/keymap.overlay → app/boards/shields/lily58/lily58.keymap

13
app/boards/shields/petejohanson_handwire/Kconfig.defconfig

@ -1,13 +0,0 @@
if SHIELD_PETEJOHANSON_HANDWIRE
config ZMK_KEYBOARD_NAME
default "Pete's Handwire Breadboard"
config ZMK_BLE
default y
config ZMK_ACTION_MOD_TAP
default y
endif

5
app/boards/shields/petejohanson_handwire/Kconfig.shield

@ -1,5 +0,0 @@
# Copyright (c) 2019 Linaro Limited
# SPDX-License-Identifier: MIT
config SHIELD_PETEJOHANSON_HANDWIRE
def_bool $(shields_list_contains,petejohanson_handwire)

40
app/boards/shields/petejohanson_handwire/keymap/keymap.overlay

@ -1,40 +0,0 @@
#include <dt-bindings/zmk/keys.h>
#include <behaviors.dtsi>
/ {
chosen {
zmk,keymap = &keymap0;
};
keymap0: keymap {
compatible = "zmk,keymap";
label ="Default keymap";
layers = <&default &lower &raise>;
};
layers {
compatible = "zmk,layers";
default: layer_0 {
label = "DEFAULT";
bindings = <
&cp M_NEXT &mt MOD_LSFT B &trans &trans
&mo 1 &mo 2 &trans &trans>;
};
lower: layer_1 {
label = "LOWER";
bindings = <
&cp M_PLAY &cp M_NEXT &trans &trans
&trans &trans &trans &trans>;
};
raise: layer_2 {
label = "RAISE";
bindings = <
&kp C &kp D &trans &trans
&trans &kp E &trans &trans>;
};
};
};

1
app/boards/shields/petejohanson_handwire/petejohanson_handwire.conf

@ -1 +0,0 @@
CONFIG_ZMK_KSCAN_COMPOSITE_DRIVER=y

44
app/boards/shields/petejohanson_handwire/petejohanson_handwire.overlay

@ -1,44 +0,0 @@
/ {
chosen {
zmk,kscan = &kscan0;
};
kscan0: kscan_0 {
compatible = "zmk,kscan-composite";
label = "KSCAN_COMP";
rows = <2>;
columns = <4>;
left {
kscan = <&left_hand>;
};
right {
kscan = <&right_hand>;
column-offset = <2>;
};
};
left_hand: kscan_1 {
compatible = "zmk,kscan-gpio-matrix";
label = "KSCAN_LEFT";
diode-direction = "row2col";
row-gpios = <&arduino_header 8 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>,
<&arduino_header 9 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
col-gpios = <&arduino_header 10 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>,
<&arduino_header 11 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
};
right_hand: kscan_2 {
compatible = "zmk,kscan-gpio-matrix";
label = "KSCAN_RIGHT";
diode-direction = "row2col";
row-gpios = <&arduino_header 12 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>,
<&arduino_header 13 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
col-gpios = <&arduino_header 14 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>,
<&arduino_header 15 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
};
};

13
app/boards/shields/petejohanson_pro_micro_handwire/Kconfig.defconfig

@ -1,13 +0,0 @@
if SHIELD_PETEJOHANSON_PRO_MICRO_HANDWIRE
config ZMK_KEYBOARD_NAME
default "Pete's ProMicro Compat Handwire"
config ZMK_USB
default y
config ZMK_ACTION_MOD_TAP
default y
endif

5
app/boards/shields/petejohanson_pro_micro_handwire/Kconfig.shield

@ -1,5 +0,0 @@
# Copyright (c) 2020 Pete Johanson
# SPDX-License-Identifier: MIT
config SHIELD_PETEJOHANSON_PRO_MICRO_HANDWIRE
def_bool $(shields_list_contains,petejohanson_pro_micro_handwire)

41
app/boards/shields/petejohanson_pro_micro_handwire/keymap/keymap.overlay

@ -1,41 +0,0 @@
#include <behaviors.dtsi>
#include <dt-bindings/zmk/keys.h>
/ {
chosen {
zmk,keymap = &keymap0;
};
keymap0: keymap {
compatible = "zmk,keymap";
label ="Default keymap";
layers = <&default &lower &raise>;
};
layers {
compatible = "zmk,layers";
default: layer_0 {
label = "DEFAULT";
bindings = <
&mo 1 &kp A
&mo 2 &kp C>;
};
lower: layer_1 {
label = "LOWER";
bindings = <
&trans &kp D
&trans &kp E>;
};
raise: layer_2 {
label = "RAISE";
bindings = <
&trans &kp I
&trans &kp H>;
};
};
};

0
app/boards/shields/petejohanson_pro_micro_handwire/petejohanson_pro_micro_handwire.conf

17
app/boards/shields/petejohanson_pro_micro_handwire/petejohanson_pro_micro_handwire.overlay

@ -1,17 +0,0 @@
/ {
chosen {
zmk,kscan = &kscan0;
};
kscan0: kscan {
compatible = "zmk,kscan-gpio-matrix";
label = "KSCAN";
diode-direction = "row2col";
row-gpios = <&pro_micro_d 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>,
<&pro_micro_d 7 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
col-gpios = <&pro_micro_d 8 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>,
<&pro_micro_d 9 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
};
};

50
app/cmake/zmk_config.cmake

@ -64,9 +64,7 @@ foreach(root ${BOARD_ROOT})
NO_DEFAULT_PATH NO_DEFAULT_PATH
) )
if(BOARD_DIR) if(BOARD_DIR)
if (EXISTS "${BOARD_DIR}/keymap") list(APPEND KEYMAP_DIRS ${BOARD_DIR})
list(APPEND KEYMAP_DIRS ${BOARD_DIR}/keymap)
endif()
endif() endif()
if(DEFINED SHIELD) if(DEFINED SHIELD)
@ -77,37 +75,16 @@ foreach(root ${BOARD_ROOT})
) )
foreach(shield_path ${shields_refs_list}) foreach(shield_path ${shields_refs_list})
get_filename_component(SHIELD_DIR ${shield_path} NAME) get_filename_component(SHIELD_DIR ${shield_path} NAME)
if (EXISTS "${shield_path}/keymap") list(APPEND KEYMAP_DIRS ${shield_path})
list(APPEND KEYMAP_DIRS ${shield_path}/keymap)
endif()
endforeach() endforeach()
endif() endif()
endforeach() 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 (ZMK_CONFIG)
if (EXISTS ${ZMK_CONFIG}) if (EXISTS ${ZMK_CONFIG})
message(STATUS "ZMK Config directory: ${ZMK_CONFIG}") message(STATUS "ZMK Config directory: ${ZMK_CONFIG}")
list(APPEND DTS_ROOT ${ZMK_CONFIG}) list(APPEND DTS_ROOT ${ZMK_CONFIG})
if (EXISTS "${ZMK_CONFIG}/include") list(PREPEND KEYMAP_DIRS "${ZMK_CONFIG}")
include_directories("${ZMK_CONFIG}/include")
endif()
if (SHIELD) if (SHIELD)
message(STATUS "Board: ${BOARD}, ${BOARD_DIR}, ${SHIELD}, ${SHIELD_DIR}") message(STATUS "Board: ${BOARD}, ${BOARD_DIR}, ${SHIELD}, ${SHIELD_DIR}")
@ -137,7 +114,7 @@ if (ZMK_CONFIG)
foreach(conf ${config_candidates}) foreach(conf ${config_candidates})
if (EXISTS "${conf}") if (EXISTS "${conf}")
message(STATUS "ZMK Config Kconfig: ${overlay}") message(STATUS "ZMK Config Kconfig: ${conf}")
set(CONF_FILE "${conf}") set(CONF_FILE "${conf}")
break() break()
endif() endif()
@ -147,6 +124,25 @@ if (ZMK_CONFIG)
endif() endif()
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) if (ZMK_DTC_FILES)
string(REPLACE ";" " " DTC_OVERLAY_FILE "${ZMK_DTC_FILES}") string(REPLACE ";" " " DTC_OVERLAY_FILE "${ZMK_DTC_FILES}")
endif() endif()

Loading…
Cancel
Save