From 6927abee6ef0c604fae1c8544fc933a56be14e77 Mon Sep 17 00:00:00 2001 From: Okke Formsma Date: Sat, 26 Dec 2020 14:49:33 +0100 Subject: [PATCH 01/59] chore(tests): remove useless &cp test --- app/tests/keypress/behavior_keymap.dtsi | 3 ++- app/tests/keypress/cp-press-release/events.patterns | 1 - app/tests/keypress/cp-press-release/keycode_events.snapshot | 2 -- app/tests/keypress/cp-press-release/native_posix.keymap | 5 ----- app/tests/keypress/kp-press-release/native_posix.keymap | 5 ++++- 5 files changed, 6 insertions(+), 10 deletions(-) delete mode 100644 app/tests/keypress/cp-press-release/events.patterns delete mode 100644 app/tests/keypress/cp-press-release/keycode_events.snapshot delete mode 100644 app/tests/keypress/cp-press-release/native_posix.keymap diff --git a/app/tests/keypress/behavior_keymap.dtsi b/app/tests/keypress/behavior_keymap.dtsi index 216e760a..64851a84 100644 --- a/app/tests/keypress/behavior_keymap.dtsi +++ b/app/tests/keypress/behavior_keymap.dtsi @@ -10,7 +10,8 @@ default_layer { bindings = < &kp B &none - &kp C_NEXT &none>; + &none &none + >; }; }; }; diff --git a/app/tests/keypress/cp-press-release/events.patterns b/app/tests/keypress/cp-press-release/events.patterns deleted file mode 100644 index 833100f6..00000000 --- a/app/tests/keypress/cp-press-release/events.patterns +++ /dev/null @@ -1 +0,0 @@ -s/.*hid_listener_keycode_//p \ No newline at end of file diff --git a/app/tests/keypress/cp-press-release/keycode_events.snapshot b/app/tests/keypress/cp-press-release/keycode_events.snapshot deleted file mode 100644 index 95d24a49..00000000 --- a/app/tests/keypress/cp-press-release/keycode_events.snapshot +++ /dev/null @@ -1,2 +0,0 @@ -pressed: usage_page 0x0c keycode 0xb5 mods 0x00 -pressed: usage_page 0x0c keycode 0xb5 mods 0x00 diff --git a/app/tests/keypress/cp-press-release/native_posix.keymap b/app/tests/keypress/cp-press-release/native_posix.keymap deleted file mode 100644 index bf93af7d..00000000 --- a/app/tests/keypress/cp-press-release/native_posix.keymap +++ /dev/null @@ -1,5 +0,0 @@ -#include "../behavior_keymap.dtsi" - -&kscan { - events = ; -}; \ No newline at end of file diff --git a/app/tests/keypress/kp-press-release/native_posix.keymap b/app/tests/keypress/kp-press-release/native_posix.keymap index 279b084d..0ddb7ab6 100644 --- a/app/tests/keypress/kp-press-release/native_posix.keymap +++ b/app/tests/keypress/kp-press-release/native_posix.keymap @@ -1,5 +1,8 @@ #include "../behavior_keymap.dtsi" &kscan { - events = ; + events = < + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_RELEASE(0,0,10) + >; }; \ No newline at end of file From 842aa5a842e117b7b00e49258ca0bde44dc0c789 Mon Sep 17 00:00:00 2001 From: innovaker <66737976+innovaker@users.noreply.github.com> Date: Tue, 22 Dec 2020 15:56:00 +0000 Subject: [PATCH 02/59] refactor: replace filename hyphens with underscores Aligns *.h and *.c to underscore naming convention. These were kept (with warnings) for backwards compatibility with external boards/shields: - kscan-mock.h - matrix-transform.h They should be removed in the future. PR: #523 --- app/boards/arm/dz60rgb/dz60rgb_rev1.dts | 2 +- app/boards/native_posix.overlay | 2 +- .../shields/boardsource3x4/boardsource3x4.overlay | 2 +- app/boards/shields/corne/corne.dtsi | 2 +- app/boards/shields/cradio/cradio.dtsi | 2 +- app/boards/shields/crbn/crbn.overlay | 2 +- app/boards/shields/iris/iris.dtsi | 2 +- app/boards/shields/jian/jian.dtsi | 2 +- app/boards/shields/jorne/jorne.dtsi | 2 +- app/boards/shields/kyria/kyria.dtsi | 2 +- app/boards/shields/lily58/lily58.dtsi | 2 +- app/boards/shields/m60/m60.overlay | 2 +- app/boards/shields/microdox/microdox.dtsi | 2 +- app/boards/shields/nibble/nibble.overlay | 2 +- app/boards/shields/qaz/qaz.overlay | 2 +- app/boards/shields/quefrency/quefrency.dtsi | 2 +- app/boards/shields/reviung41/reviung41.overlay | 2 +- app/boards/shields/romac/romac.overlay | 2 +- app/boards/shields/romac_plus/romac_plus.dtsi | 2 +- .../shields/settings_reset/settings_reset.overlay | 2 +- app/boards/shields/sofle/sofle.dtsi | 2 +- app/boards/shields/splitreus62/splitreus62.dtsi | 2 +- app/boards/shields/tg4x/tg4x.overlay | 2 +- app/boards/shields/tidbit/tidbit.dtsi | 2 +- app/drivers/kscan/kscan_mock.c | 2 +- app/include/dt-bindings/zmk/kscan-mock.h | 9 ++------- app/include/dt-bindings/zmk/kscan_mock.h | 14 ++++++++++++++ app/include/dt-bindings/zmk/matrix-transform.h | 5 ++--- app/include/dt-bindings/zmk/matrix_transform.h | 10 ++++++++++ .../zmk/{event-manager.h => event_manager.h} | 0 ...ty-state-changed.h => activity_state_changed.h} | 2 +- ...ery-state-changed.h => battery_state_changed.h} | 2 +- ...file-changed.h => ble_active_profile_changed.h} | 2 +- ...ode-state-changed.h => keycode_state_changed.h} | 2 +- ...layer-state-changed.h => layer_state_changed.h} | 2 +- ...s-state-changed.h => modifiers_state_changed.h} | 2 +- ...on-state-changed.h => position_state_changed.h} | 2 +- .../zmk/events/{sensor-event.h => sensor_event.h} | 2 +- ...nn-state-changed.h => usb_conn_state_changed.h} | 2 +- app/src/activity.c | 8 ++++---- app/src/battery.c | 4 ++-- app/src/behaviors/behavior_hold_tap.c | 8 ++++---- app/src/behaviors/behavior_key_press.c | 4 ++-- .../behaviors/behavior_sensor_rotate_key_press.c | 4 ++-- app/src/behaviors/behavior_sticky_key.c | 8 ++++---- app/src/ble.c | 4 ++-- app/src/display/main.c | 4 ++-- app/src/display/widgets/battery_status.c | 6 +++--- app/src/display/widgets/output_status.c | 6 +++--- app/src/endpoints.c | 6 +++--- app/src/event_manager.c | 2 +- app/src/events/activity_state_changed.c | 2 +- app/src/events/battery_state_changed.c | 2 +- app/src/events/ble_active_profile_changed.c | 2 +- app/src/events/keycode_state_changed.c | 2 +- app/src/events/layer_state_changed.c | 2 +- app/src/events/modifiers_state_changed.c | 2 +- app/src/events/position_state_changed.c | 2 +- app/src/events/sensor_event.c | 2 +- app/src/events/usb_conn_state_changed.c | 2 +- app/src/hid_listener.c | 6 +++--- app/src/keymap.c | 8 ++++---- app/src/kscan.c | 4 ++-- app/src/matrix_transform.c | 2 +- app/src/sensors.c | 4 ++-- app/src/split/bluetooth/central.c | 4 ++-- app/src/split_listener.c | 4 ++-- app/src/usb.c | 4 ++-- .../hold-tap/balanced/1-dn-up/native_posix.keymap | 2 +- .../balanced/2-dn-timer-up/native_posix.keymap | 2 +- .../3a-moddn-dn-modup-up/native_posix.keymap | 2 +- .../3b-moddn-dn-modup-timer-up/native_posix.keymap | 2 +- .../3c-kcdn-dn-kcup-up/native_posix.keymap | 2 +- .../3d-kcdn-dn-kcup-timer-up/native_posix.keymap | 2 +- .../4a-dn-htdn-timer-htup-up/native_posix.keymap | 2 +- .../4a-dn-kcdn-timer-kcup-up/native_posix.keymap | 2 +- .../4b-dn-kcdn-kcup-timer-up/native_posix.keymap | 2 +- .../4c-dn-kcdn-kcup-up/native_posix.keymap | 2 +- .../4d-dn-kcdn-timer-up-kcup/native_posix.keymap | 2 +- app/tests/hold-tap/balanced/behavior_keymap.dtsi | 2 +- .../balanced/many-nested/native_posix.keymap | 2 +- .../hold-preferred/1-dn-up/native_posix.keymap | 2 +- .../2-dn-timer-up/native_posix.keymap | 2 +- .../3a-moddn-dn-modup-up/native_posix.keymap | 2 +- .../3b-moddn-dn-modup-timer-up/native_posix.keymap | 2 +- .../3c-kcdn-dn-kcup-up/native_posix.keymap | 2 +- .../3d-kcdn-dn-kcup-timer-up/native_posix.keymap | 2 +- .../4a-dn-htdn-timer-htup-up/native_posix.keymap | 2 +- .../4a-dn-kcdn-timer-kcup-up/native_posix.keymap | 2 +- .../4b-dn-kcdn-kcup-timer-up/native_posix.keymap | 2 +- .../4c-dn-kcdn-kcup-up/native_posix.keymap | 2 +- .../4d-dn-kcdn-timer-up-kcup/native_posix.keymap | 2 +- .../hold-tap/hold-preferred/behavior_keymap.dtsi | 2 +- .../tap-preferred/1-dn-up/native_posix.keymap | 2 +- .../2-dn-timer-up/native_posix.keymap | 2 +- .../3a-moddn-dn-modup-up/native_posix.keymap | 2 +- .../3b-moddn-dn-modup-timer-up/native_posix.keymap | 2 +- .../3c-kcdn-dn-kcup-up/native_posix.keymap | 2 +- .../3d-kcdn-dn-kcup-timer-up/native_posix.keymap | 2 +- .../4a-dn-htdn-timer-htup-up/native_posix.keymap | 2 +- .../4a-dn-kcdn-timer-kcup-up/native_posix.keymap | 2 +- .../4b-dn-kcdn-kcup-timer-up/native_posix.keymap | 2 +- .../4c-dn-kcdn-kcup-up/native_posix.keymap | 2 +- .../4d-dn-kcdn-timer-up-kcup/native_posix.keymap | 2 +- .../hold-tap/tap-preferred/behavior_keymap.dtsi | 2 +- app/tests/keypress/behavior_keymap.dtsi | 2 +- .../native_posix.keymap | 2 +- .../kp-lctl-dn-lctl-up/native_posix.keymap | 2 +- .../native_posix.keymap | 2 +- .../native_posix.keymap | 2 +- .../native_posix.keymap | 2 +- .../native_posix.keymap | 2 +- .../native_posix.keymap | 2 +- .../native_posix.keymap | 2 +- .../momentary-layer/1-normal/native_posix.keymap | 2 +- .../2-early-key-release/native_posix.keymap | 2 +- .../momentary-layer/3-covered/native_posix.keymap | 2 +- .../momentary-layer/4-nested/native_posix.keymap | 2 +- .../5-nested-early-key-release/native_posix.keymap | 2 +- app/tests/momentary-layer/behavior_keymap.dtsi | 2 +- app/tests/none/behavior_keymap.dtsi | 2 +- app/tests/none/layered/native_posix.keymap | 2 +- app/tests/none/normal/native_posix.keymap | 2 +- .../sticky-keys/1-os-dn-up/native_posix.keymap | 2 +- .../2-os-dn-up-kcdn-kcup/native_posix.keymap | 2 +- .../3a-os-dn-kcdn-kcup-up/native_posix.keymap | 2 +- .../3b-os-dn-kcdn-up-kcup/native_posix.keymap | 2 +- .../4-os-dn-up-kcdn-timer-kcup/native_posix.keymap | 2 +- .../5-os-kcdn-dn-kcup-up/native_posix.keymap | 2 +- .../native_posix.keymap | 2 +- .../8-lsk-osk-combination/native_posix.keymap | 2 +- .../9-sk-dn-up-dn-up/native_posix.keymap | 2 +- app/tests/sticky-keys/behavior_keymap.dtsi | 2 +- app/tests/toggle-layer/behavior_keymap.dtsi | 2 +- .../early-key-release/native_posix.keymap | 2 +- app/tests/toggle-layer/normal/native_posix.keymap | 2 +- app/tests/transparent/behavior_keymap.dtsi | 2 +- app/tests/transparent/layered/native_posix.keymap | 2 +- app/tests/transparent/normal/native_posix.keymap | 2 +- docs/docs/development/new-shield.md | 6 +++--- 140 files changed, 195 insertions(+), 177 deletions(-) create mode 100644 app/include/dt-bindings/zmk/kscan_mock.h create mode 100644 app/include/dt-bindings/zmk/matrix_transform.h rename app/include/zmk/{event-manager.h => event_manager.h} (100%) rename app/include/zmk/events/{activity-state-changed.h => activity_state_changed.h} (94%) rename app/include/zmk/events/{battery-state-changed.h => battery_state_changed.h} (90%) rename app/include/zmk/events/{ble-active-profile-changed.h => ble_active_profile_changed.h} (91%) rename app/include/zmk/events/{keycode-state-changed.h => keycode_state_changed.h} (97%) rename app/include/zmk/events/{layer-state-changed.h => layer_state_changed.h} (94%) rename app/include/zmk/events/{modifiers-state-changed.h => modifiers_state_changed.h} (95%) rename app/include/zmk/events/{position-state-changed.h => position_state_changed.h} (90%) rename app/include/zmk/events/{sensor-event.h => sensor_event.h} (91%) rename app/include/zmk/events/{usb-conn-state-changed.h => usb_conn_state_changed.h} (91%) diff --git a/app/boards/arm/dz60rgb/dz60rgb_rev1.dts b/app/boards/arm/dz60rgb/dz60rgb_rev1.dts index 85c4ca56..1e2755d8 100644 --- a/app/boards/arm/dz60rgb/dz60rgb_rev1.dts +++ b/app/boards/arm/dz60rgb/dz60rgb_rev1.dts @@ -7,7 +7,7 @@ /dts-v1/; #include -#include +#include / { model = "DZ60RGB, Rev 1"; diff --git a/app/boards/native_posix.overlay b/app/boards/native_posix.overlay index bbb23b65..2c1ed79d 100644 --- a/app/boards/native_posix.overlay +++ b/app/boards/native_posix.overlay @@ -1,6 +1,6 @@ #include #include -#include +#include / { chosen { diff --git a/app/boards/shields/boardsource3x4/boardsource3x4.overlay b/app/boards/shields/boardsource3x4/boardsource3x4.overlay index ad517940..0b8f8498 100644 --- a/app/boards/shields/boardsource3x4/boardsource3x4.overlay +++ b/app/boards/shields/boardsource3x4/boardsource3x4.overlay @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT */ -#include +#include / { chosen { diff --git a/app/boards/shields/corne/corne.dtsi b/app/boards/shields/corne/corne.dtsi index 4360aea7..bb37d67a 100644 --- a/app/boards/shields/corne/corne.dtsi +++ b/app/boards/shields/corne/corne.dtsi @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT */ -#include +#include / { chosen { diff --git a/app/boards/shields/cradio/cradio.dtsi b/app/boards/shields/cradio/cradio.dtsi index 43f90493..a99a8e58 100644 --- a/app/boards/shields/cradio/cradio.dtsi +++ b/app/boards/shields/cradio/cradio.dtsi @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT */ - #include + #include / { chosen { diff --git a/app/boards/shields/crbn/crbn.overlay b/app/boards/shields/crbn/crbn.overlay index 137e685e..0f7cd45b 100644 --- a/app/boards/shields/crbn/crbn.overlay +++ b/app/boards/shields/crbn/crbn.overlay @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT */ -#include +#include / { chosen { diff --git a/app/boards/shields/iris/iris.dtsi b/app/boards/shields/iris/iris.dtsi index 9ea1dd68..eb065736 100644 --- a/app/boards/shields/iris/iris.dtsi +++ b/app/boards/shields/iris/iris.dtsi @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT */ -#include +#include / { chosen { diff --git a/app/boards/shields/jian/jian.dtsi b/app/boards/shields/jian/jian.dtsi index 331624ea..88bac831 100644 --- a/app/boards/shields/jian/jian.dtsi +++ b/app/boards/shields/jian/jian.dtsi @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT */ -#include +#include / { chosen { diff --git a/app/boards/shields/jorne/jorne.dtsi b/app/boards/shields/jorne/jorne.dtsi index 7e6cfd8b..67ea9d1c 100644 --- a/app/boards/shields/jorne/jorne.dtsi +++ b/app/boards/shields/jorne/jorne.dtsi @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT */ -#include +#include / { chosen { diff --git a/app/boards/shields/kyria/kyria.dtsi b/app/boards/shields/kyria/kyria.dtsi index bbead846..c0bec79b 100644 --- a/app/boards/shields/kyria/kyria.dtsi +++ b/app/boards/shields/kyria/kyria.dtsi @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT */ -#include +#include / { chosen { diff --git a/app/boards/shields/lily58/lily58.dtsi b/app/boards/shields/lily58/lily58.dtsi index eb69fa75..db54cf4d 100644 --- a/app/boards/shields/lily58/lily58.dtsi +++ b/app/boards/shields/lily58/lily58.dtsi @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT */ -#include +#include / { chosen { diff --git a/app/boards/shields/m60/m60.overlay b/app/boards/shields/m60/m60.overlay index 0824f1c6..18d06511 100644 --- a/app/boards/shields/m60/m60.overlay +++ b/app/boards/shields/m60/m60.overlay @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT */ -#include +#include / { chosen { diff --git a/app/boards/shields/microdox/microdox.dtsi b/app/boards/shields/microdox/microdox.dtsi index 55c67dd3..ee2114d7 100644 --- a/app/boards/shields/microdox/microdox.dtsi +++ b/app/boards/shields/microdox/microdox.dtsi @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT */ -#include +#include / { chosen { diff --git a/app/boards/shields/nibble/nibble.overlay b/app/boards/shields/nibble/nibble.overlay index 7975c3cd..fd1b2f61 100644 --- a/app/boards/shields/nibble/nibble.overlay +++ b/app/boards/shields/nibble/nibble.overlay @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT */ -#include +#include / { chosen { diff --git a/app/boards/shields/qaz/qaz.overlay b/app/boards/shields/qaz/qaz.overlay index 4e733707..205f7c26 100644 --- a/app/boards/shields/qaz/qaz.overlay +++ b/app/boards/shields/qaz/qaz.overlay @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT */ -#include +#include / { chosen { diff --git a/app/boards/shields/quefrency/quefrency.dtsi b/app/boards/shields/quefrency/quefrency.dtsi index 5f1e9086..411d3658 100644 --- a/app/boards/shields/quefrency/quefrency.dtsi +++ b/app/boards/shields/quefrency/quefrency.dtsi @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT */ -#include +#include / { chosen { diff --git a/app/boards/shields/reviung41/reviung41.overlay b/app/boards/shields/reviung41/reviung41.overlay index 06270ca1..5336853b 100644 --- a/app/boards/shields/reviung41/reviung41.overlay +++ b/app/boards/shields/reviung41/reviung41.overlay @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT */ -#include +#include / { chosen { diff --git a/app/boards/shields/romac/romac.overlay b/app/boards/shields/romac/romac.overlay index f6b0f726..e0880d3f 100644 --- a/app/boards/shields/romac/romac.overlay +++ b/app/boards/shields/romac/romac.overlay @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT */ -#include +#include / { chosen { diff --git a/app/boards/shields/romac_plus/romac_plus.dtsi b/app/boards/shields/romac_plus/romac_plus.dtsi index 9b148ca0..48f73412 100644 --- a/app/boards/shields/romac_plus/romac_plus.dtsi +++ b/app/boards/shields/romac_plus/romac_plus.dtsi @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT */ -#include +#include / { chosen { diff --git a/app/boards/shields/settings_reset/settings_reset.overlay b/app/boards/shields/settings_reset/settings_reset.overlay index a2b5799b..7a6629f8 100644 --- a/app/boards/shields/settings_reset/settings_reset.overlay +++ b/app/boards/shields/settings_reset/settings_reset.overlay @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT */ -#include +#include / { chosen { diff --git a/app/boards/shields/sofle/sofle.dtsi b/app/boards/shields/sofle/sofle.dtsi index b4edb5f6..9c55fc3c 100644 --- a/app/boards/shields/sofle/sofle.dtsi +++ b/app/boards/shields/sofle/sofle.dtsi @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT */ -#include +#include / { chosen { diff --git a/app/boards/shields/splitreus62/splitreus62.dtsi b/app/boards/shields/splitreus62/splitreus62.dtsi index c2bfbc40..d88d06cb 100644 --- a/app/boards/shields/splitreus62/splitreus62.dtsi +++ b/app/boards/shields/splitreus62/splitreus62.dtsi @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT */ -#include +#include / { chosen { diff --git a/app/boards/shields/tg4x/tg4x.overlay b/app/boards/shields/tg4x/tg4x.overlay index 10ce524a..4b9d4f5b 100644 --- a/app/boards/shields/tg4x/tg4x.overlay +++ b/app/boards/shields/tg4x/tg4x.overlay @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT */ -#include +#include / { chosen { diff --git a/app/boards/shields/tidbit/tidbit.dtsi b/app/boards/shields/tidbit/tidbit.dtsi index 7a2b3de0..004de310 100644 --- a/app/boards/shields/tidbit/tidbit.dtsi +++ b/app/boards/shields/tidbit/tidbit.dtsi @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT */ -#include +#include / { kscan0: kscan { diff --git a/app/drivers/kscan/kscan_mock.c b/app/drivers/kscan/kscan_mock.c index 8b40ab44..fc0c9c5f 100644 --- a/app/drivers/kscan/kscan_mock.c +++ b/app/drivers/kscan/kscan_mock.c @@ -13,7 +13,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); -#include +#include struct kscan_mock_data { kscan_callback_t callback; diff --git a/app/include/dt-bindings/zmk/kscan-mock.h b/app/include/dt-bindings/zmk/kscan-mock.h index eff218b2..4ed666c6 100644 --- a/app/include/dt-bindings/zmk/kscan-mock.h +++ b/app/include/dt-bindings/zmk/kscan-mock.h @@ -4,11 +4,6 @@ * SPDX-License-Identifier: MIT */ -#pragma once +#warning "kscan-mock.h has been deprecated and superseded by kscan_mock.h" -#define ZMK_MOCK_IS_PRESS(v) ((v & (0x01 << 31)) != 0) -#define ZMK_MOCK_PRESS(row, col, msec) (row + (col << 8) + (msec << 16) + (0x01 << 31)) -#define ZMK_MOCK_RELEASE(row, col, msec) (row + (col << 8) + (msec << 16)) -#define ZMK_MOCK_ROW(v) (v & 0xFF) -#define ZMK_MOCK_COL(v) ((v >> 8) & 0xFF) -#define ZMK_MOCK_MSEC(v) ((v & ~(0x01 << 31)) >> 16) +#include "kscan_mock.h" \ No newline at end of file diff --git a/app/include/dt-bindings/zmk/kscan_mock.h b/app/include/dt-bindings/zmk/kscan_mock.h new file mode 100644 index 00000000..eff218b2 --- /dev/null +++ b/app/include/dt-bindings/zmk/kscan_mock.h @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#pragma once + +#define ZMK_MOCK_IS_PRESS(v) ((v & (0x01 << 31)) != 0) +#define ZMK_MOCK_PRESS(row, col, msec) (row + (col << 8) + (msec << 16) + (0x01 << 31)) +#define ZMK_MOCK_RELEASE(row, col, msec) (row + (col << 8) + (msec << 16)) +#define ZMK_MOCK_ROW(v) (v & 0xFF) +#define ZMK_MOCK_COL(v) ((v >> 8) & 0xFF) +#define ZMK_MOCK_MSEC(v) ((v & ~(0x01 << 31)) >> 16) diff --git a/app/include/dt-bindings/zmk/matrix-transform.h b/app/include/dt-bindings/zmk/matrix-transform.h index 2989cb60..223b1429 100644 --- a/app/include/dt-bindings/zmk/matrix-transform.h +++ b/app/include/dt-bindings/zmk/matrix-transform.h @@ -4,7 +4,6 @@ * SPDX-License-Identifier: MIT */ -#define KT_ROW(item) (item >> 8) -#define KT_COL(item) (item & 0xFF) +#warning "matrix-transform.h has been deprecated and superseded by matrix_transform.h" -#define RC(row, col) (((row) << 8) + (col)) \ No newline at end of file +#include "matrix_transform.h" \ No newline at end of file diff --git a/app/include/dt-bindings/zmk/matrix_transform.h b/app/include/dt-bindings/zmk/matrix_transform.h new file mode 100644 index 00000000..2989cb60 --- /dev/null +++ b/app/include/dt-bindings/zmk/matrix_transform.h @@ -0,0 +1,10 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#define KT_ROW(item) (item >> 8) +#define KT_COL(item) (item & 0xFF) + +#define RC(row, col) (((row) << 8) + (col)) \ No newline at end of file diff --git a/app/include/zmk/event-manager.h b/app/include/zmk/event_manager.h similarity index 100% rename from app/include/zmk/event-manager.h rename to app/include/zmk/event_manager.h diff --git a/app/include/zmk/events/activity-state-changed.h b/app/include/zmk/events/activity_state_changed.h similarity index 94% rename from app/include/zmk/events/activity-state-changed.h rename to app/include/zmk/events/activity_state_changed.h index cd4c618c..511fbad6 100644 --- a/app/include/zmk/events/activity-state-changed.h +++ b/app/include/zmk/events/activity_state_changed.h @@ -7,7 +7,7 @@ #pragma once #include -#include +#include #include struct activity_state_changed { diff --git a/app/include/zmk/events/battery-state-changed.h b/app/include/zmk/events/battery_state_changed.h similarity index 90% rename from app/include/zmk/events/battery-state-changed.h rename to app/include/zmk/events/battery_state_changed.h index a983820b..47e44ba1 100644 --- a/app/include/zmk/events/battery-state-changed.h +++ b/app/include/zmk/events/battery_state_changed.h @@ -7,7 +7,7 @@ #pragma once #include -#include +#include struct battery_state_changed { struct zmk_event_header header; diff --git a/app/include/zmk/events/ble-active-profile-changed.h b/app/include/zmk/events/ble_active_profile_changed.h similarity index 91% rename from app/include/zmk/events/ble-active-profile-changed.h rename to app/include/zmk/events/ble_active_profile_changed.h index 4491dfc5..fa161266 100644 --- a/app/include/zmk/events/ble-active-profile-changed.h +++ b/app/include/zmk/events/ble_active_profile_changed.h @@ -7,7 +7,7 @@ #pragma once #include -#include +#include #include #include diff --git a/app/include/zmk/events/keycode-state-changed.h b/app/include/zmk/events/keycode_state_changed.h similarity index 97% rename from app/include/zmk/events/keycode-state-changed.h rename to app/include/zmk/events/keycode_state_changed.h index 7dc87e21..28282b6b 100644 --- a/app/include/zmk/events/keycode-state-changed.h +++ b/app/include/zmk/events/keycode_state_changed.h @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include struct keycode_state_changed { diff --git a/app/include/zmk/events/layer-state-changed.h b/app/include/zmk/events/layer_state_changed.h similarity index 94% rename from app/include/zmk/events/layer-state-changed.h rename to app/include/zmk/events/layer_state_changed.h index 352c6025..cf240025 100644 --- a/app/include/zmk/events/layer-state-changed.h +++ b/app/include/zmk/events/layer_state_changed.h @@ -7,7 +7,7 @@ #pragma once #include -#include +#include struct layer_state_changed { struct zmk_event_header header; diff --git a/app/include/zmk/events/modifiers-state-changed.h b/app/include/zmk/events/modifiers_state_changed.h similarity index 95% rename from app/include/zmk/events/modifiers-state-changed.h rename to app/include/zmk/events/modifiers_state_changed.h index d2e02f82..c4daede0 100644 --- a/app/include/zmk/events/modifiers-state-changed.h +++ b/app/include/zmk/events/modifiers_state_changed.h @@ -8,7 +8,7 @@ #include #include -#include +#include struct modifiers_state_changed { struct zmk_event_header header; diff --git a/app/include/zmk/events/position-state-changed.h b/app/include/zmk/events/position_state_changed.h similarity index 90% rename from app/include/zmk/events/position-state-changed.h rename to app/include/zmk/events/position_state_changed.h index 7058276e..0f1ac1b2 100644 --- a/app/include/zmk/events/position-state-changed.h +++ b/app/include/zmk/events/position_state_changed.h @@ -7,7 +7,7 @@ #pragma once #include -#include +#include struct position_state_changed { struct zmk_event_header header; diff --git a/app/include/zmk/events/sensor-event.h b/app/include/zmk/events/sensor_event.h similarity index 91% rename from app/include/zmk/events/sensor-event.h rename to app/include/zmk/events/sensor_event.h index 0bd3ccf0..14fb2d3d 100644 --- a/app/include/zmk/events/sensor-event.h +++ b/app/include/zmk/events/sensor_event.h @@ -7,7 +7,7 @@ #pragma once #include -#include +#include #include struct sensor_event { diff --git a/app/include/zmk/events/usb-conn-state-changed.h b/app/include/zmk/events/usb_conn_state_changed.h similarity index 91% rename from app/include/zmk/events/usb-conn-state-changed.h rename to app/include/zmk/events/usb_conn_state_changed.h index d6cc6985..b38fb9fe 100644 --- a/app/include/zmk/events/usb-conn-state-changed.h +++ b/app/include/zmk/events/usb_conn_state_changed.h @@ -9,7 +9,7 @@ #include #include -#include +#include #include struct usb_conn_state_changed { diff --git a/app/src/activity.c b/app/src/activity.c index c441fa92..8fe912a3 100644 --- a/app/src/activity.c +++ b/app/src/activity.c @@ -12,10 +12,10 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); -#include -#include -#include -#include +#include +#include +#include +#include #include diff --git a/app/src/battery.c b/app/src/battery.c index 7a09ad7a..917af9cf 100644 --- a/app/src/battery.c +++ b/app/src/battery.c @@ -14,8 +14,8 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); -#include -#include +#include +#include const struct device *battery; diff --git a/app/src/behaviors/behavior_hold_tap.c b/app/src/behaviors/behavior_hold_tap.c index 556273ec..d3039605 100644 --- a/app/src/behaviors/behavior_hold_tap.c +++ b/app/src/behaviors/behavior_hold_tap.c @@ -14,10 +14,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); diff --git a/app/src/behaviors/behavior_key_press.c b/app/src/behaviors/behavior_key_press.c index aa19ca96..df0828ac 100644 --- a/app/src/behaviors/behavior_key_press.c +++ b/app/src/behaviors/behavior_key_press.c @@ -10,8 +10,8 @@ #include #include -#include -#include +#include +#include #include LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); diff --git a/app/src/behaviors/behavior_sensor_rotate_key_press.c b/app/src/behaviors/behavior_sensor_rotate_key_press.c index a0e0accc..1e659a15 100644 --- a/app/src/behaviors/behavior_sensor_rotate_key_press.c +++ b/app/src/behaviors/behavior_sensor_rotate_key_press.c @@ -11,8 +11,8 @@ #include #include -#include -#include +#include +#include LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); diff --git a/app/src/behaviors/behavior_sticky_key.c b/app/src/behaviors/behavior_sticky_key.c index 4695c7ab..643ae48b 100644 --- a/app/src/behaviors/behavior_sticky_key.c +++ b/app/src/behaviors/behavior_sticky_key.c @@ -13,10 +13,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); diff --git a/app/src/ble.c b/app/src/ble.c index 9cfef4b8..4d422877 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -32,8 +32,8 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include #include #include -#include -#include +#include +#include static struct bt_conn *auth_passkey_entry_conn; static uint8_t passkey_entries[6] = {0, 0, 0, 0, 0, 0}; diff --git a/app/src/display/main.c b/app/src/display/main.c index ea1e21ab..0bef6567 100644 --- a/app/src/display/main.c +++ b/app/src/display/main.c @@ -14,8 +14,8 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include #include -#include -#include +#include +#include #include #define ZMK_DISPLAY_NAME CONFIG_LVGL_DISPLAY_DEV_NAME diff --git a/app/src/display/widgets/battery_status.c b/app/src/display/widgets/battery_status.c index b412da2b..346c5193 100644 --- a/app/src/display/widgets/battery_status.c +++ b/app/src/display/widgets/battery_status.c @@ -11,9 +11,9 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include #include -#include -#include -#include +#include +#include +#include static sys_slist_t widgets = SYS_SLIST_STATIC_INIT(&widgets); static lv_style_t label_style; diff --git a/app/src/display/widgets/output_status.c b/app/src/display/widgets/output_status.c index 143c7781..9a725113 100644 --- a/app/src/display/widgets/output_status.c +++ b/app/src/display/widgets/output_status.c @@ -10,9 +10,9 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/app/src/endpoints.c b/app/src/endpoints.c index b126f335..9f32f197 100644 --- a/app/src/endpoints.c +++ b/app/src/endpoints.c @@ -13,9 +13,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); diff --git a/app/src/event_manager.c b/app/src/event_manager.c index 8c454e9e..872f5c86 100644 --- a/app/src/event_manager.c +++ b/app/src/event_manager.c @@ -9,7 +9,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); -#include +#include extern struct zmk_event_type *__event_type_start[]; extern struct zmk_event_type *__event_type_end[]; diff --git a/app/src/events/activity_state_changed.c b/app/src/events/activity_state_changed.c index 47aefea1..001e6a1a 100644 --- a/app/src/events/activity_state_changed.c +++ b/app/src/events/activity_state_changed.c @@ -5,6 +5,6 @@ */ #include -#include +#include ZMK_EVENT_IMPL(activity_state_changed); \ No newline at end of file diff --git a/app/src/events/battery_state_changed.c b/app/src/events/battery_state_changed.c index 4b937e34..ed6147a0 100644 --- a/app/src/events/battery_state_changed.c +++ b/app/src/events/battery_state_changed.c @@ -5,6 +5,6 @@ */ #include -#include +#include ZMK_EVENT_IMPL(battery_state_changed); \ No newline at end of file diff --git a/app/src/events/ble_active_profile_changed.c b/app/src/events/ble_active_profile_changed.c index 06988e23..e2d172fd 100644 --- a/app/src/events/ble_active_profile_changed.c +++ b/app/src/events/ble_active_profile_changed.c @@ -5,6 +5,6 @@ */ #include -#include +#include ZMK_EVENT_IMPL(ble_active_profile_changed); \ No newline at end of file diff --git a/app/src/events/keycode_state_changed.c b/app/src/events/keycode_state_changed.c index 9a1984a3..d46126be 100644 --- a/app/src/events/keycode_state_changed.c +++ b/app/src/events/keycode_state_changed.c @@ -5,6 +5,6 @@ */ #include -#include +#include ZMK_EVENT_IMPL(keycode_state_changed); diff --git a/app/src/events/layer_state_changed.c b/app/src/events/layer_state_changed.c index e4567115..e7f8039c 100644 --- a/app/src/events/layer_state_changed.c +++ b/app/src/events/layer_state_changed.c @@ -5,6 +5,6 @@ */ #include -#include +#include ZMK_EVENT_IMPL(layer_state_changed); \ No newline at end of file diff --git a/app/src/events/modifiers_state_changed.c b/app/src/events/modifiers_state_changed.c index 8becd02f..4143796e 100644 --- a/app/src/events/modifiers_state_changed.c +++ b/app/src/events/modifiers_state_changed.c @@ -5,6 +5,6 @@ */ #include -#include +#include ZMK_EVENT_IMPL(modifiers_state_changed); \ No newline at end of file diff --git a/app/src/events/position_state_changed.c b/app/src/events/position_state_changed.c index f8f1a268..b80314b9 100644 --- a/app/src/events/position_state_changed.c +++ b/app/src/events/position_state_changed.c @@ -5,6 +5,6 @@ */ #include -#include +#include ZMK_EVENT_IMPL(position_state_changed); \ No newline at end of file diff --git a/app/src/events/sensor_event.c b/app/src/events/sensor_event.c index c6b80cd6..6811e7dd 100644 --- a/app/src/events/sensor_event.c +++ b/app/src/events/sensor_event.c @@ -5,6 +5,6 @@ */ #include -#include +#include ZMK_EVENT_IMPL(sensor_event); \ No newline at end of file diff --git a/app/src/events/usb_conn_state_changed.c b/app/src/events/usb_conn_state_changed.c index d845f6d7..c299da7a 100644 --- a/app/src/events/usb_conn_state_changed.c +++ b/app/src/events/usb_conn_state_changed.c @@ -5,6 +5,6 @@ */ #include -#include +#include ZMK_EVENT_IMPL(usb_conn_state_changed); \ No newline at end of file diff --git a/app/src/hid_listener.c b/app/src/hid_listener.c index 534831cc..cf8835a2 100644 --- a/app/src/hid_listener.c +++ b/app/src/hid_listener.c @@ -9,9 +9,9 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/app/src/keymap.c b/app/src/keymap.c index cab6d474..cafe2ffe 100644 --- a/app/src/keymap.c +++ b/app/src/keymap.c @@ -14,10 +14,10 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include #include -#include -#include -#include -#include +#include +#include +#include +#include static zmk_keymap_layers_state _zmk_keymap_layer_state = 0; static uint8_t _zmk_keymap_layer_default = 0; diff --git a/app/src/kscan.c b/app/src/kscan.c index c22d71b4..6b84490a 100644 --- a/app/src/kscan.c +++ b/app/src/kscan.c @@ -12,8 +12,8 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include -#include -#include +#include +#include #define ZMK_KSCAN_EVENT_STATE_PRESSED 0 #define ZMK_KSCAN_EVENT_STATE_RELEASED 1 diff --git a/app/src/matrix_transform.c b/app/src/matrix_transform.c index 33be93d3..8f54f312 100644 --- a/app/src/matrix_transform.c +++ b/app/src/matrix_transform.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include #ifdef ZMK_KEYMAP_TRANSFORM_NODE diff --git a/app/src/sensors.c b/app/src/sensors.c index 5b4f683b..5e9ef150 100644 --- a/app/src/sensors.c +++ b/app/src/sensors.c @@ -13,8 +13,8 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include -#include -#include +#include +#include #if ZMK_KEYMAP_HAS_SENSORS diff --git a/app/src/split/bluetooth/central.c b/app/src/split/bluetooth/central.c index c41894f2..5ad83ad2 100644 --- a/app/src/split/bluetooth/central.c +++ b/app/src/split/bluetooth/central.c @@ -19,8 +19,8 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include #include -#include -#include +#include +#include #include static int start_scan(void); diff --git a/app/src/split_listener.c b/app/src/split_listener.c index b2adfb2e..153ed99d 100644 --- a/app/src/split_listener.c +++ b/app/src/split_listener.c @@ -14,8 +14,8 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); -#include -#include +#include +#include #include #include diff --git a/app/src/usb.c b/app/src/usb.c index 2b3de782..7900acef 100644 --- a/app/src/usb.c +++ b/app/src/usb.c @@ -12,8 +12,8 @@ #include #include -#include -#include +#include +#include LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); diff --git a/app/tests/hold-tap/balanced/1-dn-up/native_posix.keymap b/app/tests/hold-tap/balanced/1-dn-up/native_posix.keymap index 10336ef3..040cdd3e 100644 --- a/app/tests/hold-tap/balanced/1-dn-up/native_posix.keymap +++ b/app/tests/hold-tap/balanced/1-dn-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/balanced/2-dn-timer-up/native_posix.keymap b/app/tests/hold-tap/balanced/2-dn-timer-up/native_posix.keymap index aa93b862..11d033f4 100644 --- a/app/tests/hold-tap/balanced/2-dn-timer-up/native_posix.keymap +++ b/app/tests/hold-tap/balanced/2-dn-timer-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/balanced/3a-moddn-dn-modup-up/native_posix.keymap b/app/tests/hold-tap/balanced/3a-moddn-dn-modup-up/native_posix.keymap index 6f08689b..abb31b4b 100644 --- a/app/tests/hold-tap/balanced/3a-moddn-dn-modup-up/native_posix.keymap +++ b/app/tests/hold-tap/balanced/3a-moddn-dn-modup-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/balanced/3b-moddn-dn-modup-timer-up/native_posix.keymap b/app/tests/hold-tap/balanced/3b-moddn-dn-modup-timer-up/native_posix.keymap index 392d328b..38575e9a 100644 --- a/app/tests/hold-tap/balanced/3b-moddn-dn-modup-timer-up/native_posix.keymap +++ b/app/tests/hold-tap/balanced/3b-moddn-dn-modup-timer-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/balanced/3c-kcdn-dn-kcup-up/native_posix.keymap b/app/tests/hold-tap/balanced/3c-kcdn-dn-kcup-up/native_posix.keymap index 77306cd0..21baa447 100644 --- a/app/tests/hold-tap/balanced/3c-kcdn-dn-kcup-up/native_posix.keymap +++ b/app/tests/hold-tap/balanced/3c-kcdn-dn-kcup-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/balanced/3d-kcdn-dn-kcup-timer-up/native_posix.keymap b/app/tests/hold-tap/balanced/3d-kcdn-dn-kcup-timer-up/native_posix.keymap index 14413311..cd7ff384 100644 --- a/app/tests/hold-tap/balanced/3d-kcdn-dn-kcup-timer-up/native_posix.keymap +++ b/app/tests/hold-tap/balanced/3d-kcdn-dn-kcup-timer-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/balanced/4a-dn-htdn-timer-htup-up/native_posix.keymap b/app/tests/hold-tap/balanced/4a-dn-htdn-timer-htup-up/native_posix.keymap index c10c6d64..b84aa626 100644 --- a/app/tests/hold-tap/balanced/4a-dn-htdn-timer-htup-up/native_posix.keymap +++ b/app/tests/hold-tap/balanced/4a-dn-htdn-timer-htup-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/balanced/4a-dn-kcdn-timer-kcup-up/native_posix.keymap b/app/tests/hold-tap/balanced/4a-dn-kcdn-timer-kcup-up/native_posix.keymap index ce163f53..bdfaf9d3 100644 --- a/app/tests/hold-tap/balanced/4a-dn-kcdn-timer-kcup-up/native_posix.keymap +++ b/app/tests/hold-tap/balanced/4a-dn-kcdn-timer-kcup-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/balanced/4b-dn-kcdn-kcup-timer-up/native_posix.keymap b/app/tests/hold-tap/balanced/4b-dn-kcdn-kcup-timer-up/native_posix.keymap index 7abda41a..c0fd1bd1 100644 --- a/app/tests/hold-tap/balanced/4b-dn-kcdn-kcup-timer-up/native_posix.keymap +++ b/app/tests/hold-tap/balanced/4b-dn-kcdn-kcup-timer-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/balanced/4c-dn-kcdn-kcup-up/native_posix.keymap b/app/tests/hold-tap/balanced/4c-dn-kcdn-kcup-up/native_posix.keymap index ce030af3..69c19676 100644 --- a/app/tests/hold-tap/balanced/4c-dn-kcdn-kcup-up/native_posix.keymap +++ b/app/tests/hold-tap/balanced/4c-dn-kcdn-kcup-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/balanced/4d-dn-kcdn-timer-up-kcup/native_posix.keymap b/app/tests/hold-tap/balanced/4d-dn-kcdn-timer-up-kcup/native_posix.keymap index 54676600..301ef0ac 100644 --- a/app/tests/hold-tap/balanced/4d-dn-kcdn-timer-up-kcup/native_posix.keymap +++ b/app/tests/hold-tap/balanced/4d-dn-kcdn-timer-up-kcup/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/balanced/behavior_keymap.dtsi b/app/tests/hold-tap/balanced/behavior_keymap.dtsi index 7d18bb6e..34a4d458 100644 --- a/app/tests/hold-tap/balanced/behavior_keymap.dtsi +++ b/app/tests/hold-tap/balanced/behavior_keymap.dtsi @@ -1,6 +1,6 @@ #include #include -#include +#include / { behaviors { diff --git a/app/tests/hold-tap/balanced/many-nested/native_posix.keymap b/app/tests/hold-tap/balanced/many-nested/native_posix.keymap index f51ffb56..7941e4d3 100644 --- a/app/tests/hold-tap/balanced/many-nested/native_posix.keymap +++ b/app/tests/hold-tap/balanced/many-nested/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include / { behaviors { diff --git a/app/tests/hold-tap/hold-preferred/1-dn-up/native_posix.keymap b/app/tests/hold-tap/hold-preferred/1-dn-up/native_posix.keymap index 10336ef3..040cdd3e 100644 --- a/app/tests/hold-tap/hold-preferred/1-dn-up/native_posix.keymap +++ b/app/tests/hold-tap/hold-preferred/1-dn-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/hold-preferred/2-dn-timer-up/native_posix.keymap b/app/tests/hold-tap/hold-preferred/2-dn-timer-up/native_posix.keymap index aa93b862..11d033f4 100644 --- a/app/tests/hold-tap/hold-preferred/2-dn-timer-up/native_posix.keymap +++ b/app/tests/hold-tap/hold-preferred/2-dn-timer-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/hold-preferred/3a-moddn-dn-modup-up/native_posix.keymap b/app/tests/hold-tap/hold-preferred/3a-moddn-dn-modup-up/native_posix.keymap index 6f08689b..abb31b4b 100644 --- a/app/tests/hold-tap/hold-preferred/3a-moddn-dn-modup-up/native_posix.keymap +++ b/app/tests/hold-tap/hold-preferred/3a-moddn-dn-modup-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/hold-preferred/3b-moddn-dn-modup-timer-up/native_posix.keymap b/app/tests/hold-tap/hold-preferred/3b-moddn-dn-modup-timer-up/native_posix.keymap index 392d328b..38575e9a 100644 --- a/app/tests/hold-tap/hold-preferred/3b-moddn-dn-modup-timer-up/native_posix.keymap +++ b/app/tests/hold-tap/hold-preferred/3b-moddn-dn-modup-timer-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/hold-preferred/3c-kcdn-dn-kcup-up/native_posix.keymap b/app/tests/hold-tap/hold-preferred/3c-kcdn-dn-kcup-up/native_posix.keymap index 77306cd0..21baa447 100644 --- a/app/tests/hold-tap/hold-preferred/3c-kcdn-dn-kcup-up/native_posix.keymap +++ b/app/tests/hold-tap/hold-preferred/3c-kcdn-dn-kcup-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/hold-preferred/3d-kcdn-dn-kcup-timer-up/native_posix.keymap b/app/tests/hold-tap/hold-preferred/3d-kcdn-dn-kcup-timer-up/native_posix.keymap index 14413311..cd7ff384 100644 --- a/app/tests/hold-tap/hold-preferred/3d-kcdn-dn-kcup-timer-up/native_posix.keymap +++ b/app/tests/hold-tap/hold-preferred/3d-kcdn-dn-kcup-timer-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/hold-preferred/4a-dn-htdn-timer-htup-up/native_posix.keymap b/app/tests/hold-tap/hold-preferred/4a-dn-htdn-timer-htup-up/native_posix.keymap index c10c6d64..b84aa626 100644 --- a/app/tests/hold-tap/hold-preferred/4a-dn-htdn-timer-htup-up/native_posix.keymap +++ b/app/tests/hold-tap/hold-preferred/4a-dn-htdn-timer-htup-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/hold-preferred/4a-dn-kcdn-timer-kcup-up/native_posix.keymap b/app/tests/hold-tap/hold-preferred/4a-dn-kcdn-timer-kcup-up/native_posix.keymap index ce163f53..bdfaf9d3 100644 --- a/app/tests/hold-tap/hold-preferred/4a-dn-kcdn-timer-kcup-up/native_posix.keymap +++ b/app/tests/hold-tap/hold-preferred/4a-dn-kcdn-timer-kcup-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/hold-preferred/4b-dn-kcdn-kcup-timer-up/native_posix.keymap b/app/tests/hold-tap/hold-preferred/4b-dn-kcdn-kcup-timer-up/native_posix.keymap index 7abda41a..c0fd1bd1 100644 --- a/app/tests/hold-tap/hold-preferred/4b-dn-kcdn-kcup-timer-up/native_posix.keymap +++ b/app/tests/hold-tap/hold-preferred/4b-dn-kcdn-kcup-timer-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/hold-preferred/4c-dn-kcdn-kcup-up/native_posix.keymap b/app/tests/hold-tap/hold-preferred/4c-dn-kcdn-kcup-up/native_posix.keymap index ce030af3..69c19676 100644 --- a/app/tests/hold-tap/hold-preferred/4c-dn-kcdn-kcup-up/native_posix.keymap +++ b/app/tests/hold-tap/hold-preferred/4c-dn-kcdn-kcup-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/hold-preferred/4d-dn-kcdn-timer-up-kcup/native_posix.keymap b/app/tests/hold-tap/hold-preferred/4d-dn-kcdn-timer-up-kcup/native_posix.keymap index 54676600..301ef0ac 100644 --- a/app/tests/hold-tap/hold-preferred/4d-dn-kcdn-timer-up-kcup/native_posix.keymap +++ b/app/tests/hold-tap/hold-preferred/4d-dn-kcdn-timer-up-kcup/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/hold-preferred/behavior_keymap.dtsi b/app/tests/hold-tap/hold-preferred/behavior_keymap.dtsi index 64847a57..e6143195 100644 --- a/app/tests/hold-tap/hold-preferred/behavior_keymap.dtsi +++ b/app/tests/hold-tap/hold-preferred/behavior_keymap.dtsi @@ -1,6 +1,6 @@ #include #include -#include +#include diff --git a/app/tests/hold-tap/tap-preferred/1-dn-up/native_posix.keymap b/app/tests/hold-tap/tap-preferred/1-dn-up/native_posix.keymap index 10336ef3..040cdd3e 100644 --- a/app/tests/hold-tap/tap-preferred/1-dn-up/native_posix.keymap +++ b/app/tests/hold-tap/tap-preferred/1-dn-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/tap-preferred/2-dn-timer-up/native_posix.keymap b/app/tests/hold-tap/tap-preferred/2-dn-timer-up/native_posix.keymap index aa93b862..11d033f4 100644 --- a/app/tests/hold-tap/tap-preferred/2-dn-timer-up/native_posix.keymap +++ b/app/tests/hold-tap/tap-preferred/2-dn-timer-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/tap-preferred/3a-moddn-dn-modup-up/native_posix.keymap b/app/tests/hold-tap/tap-preferred/3a-moddn-dn-modup-up/native_posix.keymap index 6f08689b..abb31b4b 100644 --- a/app/tests/hold-tap/tap-preferred/3a-moddn-dn-modup-up/native_posix.keymap +++ b/app/tests/hold-tap/tap-preferred/3a-moddn-dn-modup-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/tap-preferred/3b-moddn-dn-modup-timer-up/native_posix.keymap b/app/tests/hold-tap/tap-preferred/3b-moddn-dn-modup-timer-up/native_posix.keymap index 392d328b..38575e9a 100644 --- a/app/tests/hold-tap/tap-preferred/3b-moddn-dn-modup-timer-up/native_posix.keymap +++ b/app/tests/hold-tap/tap-preferred/3b-moddn-dn-modup-timer-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/tap-preferred/3c-kcdn-dn-kcup-up/native_posix.keymap b/app/tests/hold-tap/tap-preferred/3c-kcdn-dn-kcup-up/native_posix.keymap index 77306cd0..21baa447 100644 --- a/app/tests/hold-tap/tap-preferred/3c-kcdn-dn-kcup-up/native_posix.keymap +++ b/app/tests/hold-tap/tap-preferred/3c-kcdn-dn-kcup-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/tap-preferred/3d-kcdn-dn-kcup-timer-up/native_posix.keymap b/app/tests/hold-tap/tap-preferred/3d-kcdn-dn-kcup-timer-up/native_posix.keymap index 14413311..cd7ff384 100644 --- a/app/tests/hold-tap/tap-preferred/3d-kcdn-dn-kcup-timer-up/native_posix.keymap +++ b/app/tests/hold-tap/tap-preferred/3d-kcdn-dn-kcup-timer-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/tap-preferred/4a-dn-htdn-timer-htup-up/native_posix.keymap b/app/tests/hold-tap/tap-preferred/4a-dn-htdn-timer-htup-up/native_posix.keymap index c10c6d64..b84aa626 100644 --- a/app/tests/hold-tap/tap-preferred/4a-dn-htdn-timer-htup-up/native_posix.keymap +++ b/app/tests/hold-tap/tap-preferred/4a-dn-htdn-timer-htup-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/tap-preferred/4a-dn-kcdn-timer-kcup-up/native_posix.keymap b/app/tests/hold-tap/tap-preferred/4a-dn-kcdn-timer-kcup-up/native_posix.keymap index ce163f53..bdfaf9d3 100644 --- a/app/tests/hold-tap/tap-preferred/4a-dn-kcdn-timer-kcup-up/native_posix.keymap +++ b/app/tests/hold-tap/tap-preferred/4a-dn-kcdn-timer-kcup-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/tap-preferred/4b-dn-kcdn-kcup-timer-up/native_posix.keymap b/app/tests/hold-tap/tap-preferred/4b-dn-kcdn-kcup-timer-up/native_posix.keymap index 7abda41a..c0fd1bd1 100644 --- a/app/tests/hold-tap/tap-preferred/4b-dn-kcdn-kcup-timer-up/native_posix.keymap +++ b/app/tests/hold-tap/tap-preferred/4b-dn-kcdn-kcup-timer-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/tap-preferred/4c-dn-kcdn-kcup-up/native_posix.keymap b/app/tests/hold-tap/tap-preferred/4c-dn-kcdn-kcup-up/native_posix.keymap index ce030af3..69c19676 100644 --- a/app/tests/hold-tap/tap-preferred/4c-dn-kcdn-kcup-up/native_posix.keymap +++ b/app/tests/hold-tap/tap-preferred/4c-dn-kcdn-kcup-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/tap-preferred/4d-dn-kcdn-timer-up-kcup/native_posix.keymap b/app/tests/hold-tap/tap-preferred/4d-dn-kcdn-timer-up-kcup/native_posix.keymap index 54676600..301ef0ac 100644 --- a/app/tests/hold-tap/tap-preferred/4d-dn-kcdn-timer-up-kcup/native_posix.keymap +++ b/app/tests/hold-tap/tap-preferred/4d-dn-kcdn-timer-up-kcup/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/hold-tap/tap-preferred/behavior_keymap.dtsi b/app/tests/hold-tap/tap-preferred/behavior_keymap.dtsi index 6e91466d..e6d33c0b 100644 --- a/app/tests/hold-tap/tap-preferred/behavior_keymap.dtsi +++ b/app/tests/hold-tap/tap-preferred/behavior_keymap.dtsi @@ -1,6 +1,6 @@ #include #include -#include +#include / { behaviors { diff --git a/app/tests/keypress/behavior_keymap.dtsi b/app/tests/keypress/behavior_keymap.dtsi index 64851a84..f0c5d0c2 100644 --- a/app/tests/keypress/behavior_keymap.dtsi +++ b/app/tests/keypress/behavior_keymap.dtsi @@ -1,6 +1,6 @@ #include #include -#include +#include / { keymap { diff --git a/app/tests/modifiers/explicit/kp-lctl-dn-lctl-dn-lctl-up-lctl-up/native_posix.keymap b/app/tests/modifiers/explicit/kp-lctl-dn-lctl-dn-lctl-up-lctl-up/native_posix.keymap index 1f3502d6..26af5657 100644 --- a/app/tests/modifiers/explicit/kp-lctl-dn-lctl-dn-lctl-up-lctl-up/native_posix.keymap +++ b/app/tests/modifiers/explicit/kp-lctl-dn-lctl-dn-lctl-up-lctl-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include &kscan { diff --git a/app/tests/modifiers/explicit/kp-lctl-dn-lctl-up/native_posix.keymap b/app/tests/modifiers/explicit/kp-lctl-dn-lctl-up/native_posix.keymap index 9c7d7c83..9df2c152 100644 --- a/app/tests/modifiers/explicit/kp-lctl-dn-lctl-up/native_posix.keymap +++ b/app/tests/modifiers/explicit/kp-lctl-dn-lctl-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include &kscan { diff --git a/app/tests/modifiers/explicit/kp-lctl-dn-lsft-dn-lctl-up-lsft-up/native_posix.keymap b/app/tests/modifiers/explicit/kp-lctl-dn-lsft-dn-lctl-up-lsft-up/native_posix.keymap index 34bb522b..5f9375fb 100644 --- a/app/tests/modifiers/explicit/kp-lctl-dn-lsft-dn-lctl-up-lsft-up/native_posix.keymap +++ b/app/tests/modifiers/explicit/kp-lctl-dn-lsft-dn-lctl-up-lsft-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include &kscan { diff --git a/app/tests/modifiers/explicit/kp-lctl-dn-lsft-dn-lsft-up-lctl-up/native_posix.keymap b/app/tests/modifiers/explicit/kp-lctl-dn-lsft-dn-lsft-up-lctl-up/native_posix.keymap index 68e4de73..1b175d44 100644 --- a/app/tests/modifiers/explicit/kp-lctl-dn-lsft-dn-lsft-up-lctl-up/native_posix.keymap +++ b/app/tests/modifiers/explicit/kp-lctl-dn-lsft-dn-lsft-up-lctl-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include &kscan { diff --git a/app/tests/modifiers/implicit/kp-mod1-dn-mod2-dn-mod1-up-mod2-up/native_posix.keymap b/app/tests/modifiers/implicit/kp-mod1-dn-mod2-dn-mod1-up-mod2-up/native_posix.keymap index 73fa7cc8..0e9a2d6a 100644 --- a/app/tests/modifiers/implicit/kp-mod1-dn-mod2-dn-mod1-up-mod2-up/native_posix.keymap +++ b/app/tests/modifiers/implicit/kp-mod1-dn-mod2-dn-mod1-up-mod2-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include &kscan { diff --git a/app/tests/modifiers/implicit/kp-mod1-dn-mod2-dn-mod2-up-mod1-up/native_posix.keymap b/app/tests/modifiers/implicit/kp-mod1-dn-mod2-dn-mod2-up-mod1-up/native_posix.keymap index 109d60e5..10d0dbf8 100644 --- a/app/tests/modifiers/implicit/kp-mod1-dn-mod2-dn-mod2-up-mod1-up/native_posix.keymap +++ b/app/tests/modifiers/implicit/kp-mod1-dn-mod2-dn-mod2-up-mod1-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include &kscan { diff --git a/app/tests/modifiers/mixed/kp-lctl-dn-mod-dn-lctl-up-mod-up/native_posix.keymap b/app/tests/modifiers/mixed/kp-lctl-dn-mod-dn-lctl-up-mod-up/native_posix.keymap index 09816d94..3d6494dd 100644 --- a/app/tests/modifiers/mixed/kp-lctl-dn-mod-dn-lctl-up-mod-up/native_posix.keymap +++ b/app/tests/modifiers/mixed/kp-lctl-dn-mod-dn-lctl-up-mod-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include &kscan { diff --git a/app/tests/modifiers/mixed/kp-lctl-dn-mod-dn-mod-up-lctl-up/native_posix.keymap b/app/tests/modifiers/mixed/kp-lctl-dn-mod-dn-mod-up-lctl-up/native_posix.keymap index 1de00a0e..d5f372f1 100644 --- a/app/tests/modifiers/mixed/kp-lctl-dn-mod-dn-mod-up-lctl-up/native_posix.keymap +++ b/app/tests/modifiers/mixed/kp-lctl-dn-mod-dn-mod-up-lctl-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include &kscan { diff --git a/app/tests/momentary-layer/1-normal/native_posix.keymap b/app/tests/momentary-layer/1-normal/native_posix.keymap index 2fc24d2b..b5249f7b 100644 --- a/app/tests/momentary-layer/1-normal/native_posix.keymap +++ b/app/tests/momentary-layer/1-normal/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" / { diff --git a/app/tests/momentary-layer/2-early-key-release/native_posix.keymap b/app/tests/momentary-layer/2-early-key-release/native_posix.keymap index 9ffa5f6e..96e4e8d9 100644 --- a/app/tests/momentary-layer/2-early-key-release/native_posix.keymap +++ b/app/tests/momentary-layer/2-early-key-release/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" / { diff --git a/app/tests/momentary-layer/3-covered/native_posix.keymap b/app/tests/momentary-layer/3-covered/native_posix.keymap index 2484d8b8..2dde6d88 100644 --- a/app/tests/momentary-layer/3-covered/native_posix.keymap +++ b/app/tests/momentary-layer/3-covered/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include /* this test verifies that the correct key is released when a layer is enabled "on top" diff --git a/app/tests/momentary-layer/4-nested/native_posix.keymap b/app/tests/momentary-layer/4-nested/native_posix.keymap index 0eb77d20..fd376d00 100644 --- a/app/tests/momentary-layer/4-nested/native_posix.keymap +++ b/app/tests/momentary-layer/4-nested/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include / { keymap { diff --git a/app/tests/momentary-layer/5-nested-early-key-release/native_posix.keymap b/app/tests/momentary-layer/5-nested-early-key-release/native_posix.keymap index a67035bf..c467aea3 100644 --- a/app/tests/momentary-layer/5-nested-early-key-release/native_posix.keymap +++ b/app/tests/momentary-layer/5-nested-early-key-release/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include / { keymap { diff --git a/app/tests/momentary-layer/behavior_keymap.dtsi b/app/tests/momentary-layer/behavior_keymap.dtsi index a5b6c12b..40bc31ec 100644 --- a/app/tests/momentary-layer/behavior_keymap.dtsi +++ b/app/tests/momentary-layer/behavior_keymap.dtsi @@ -1,6 +1,6 @@ #include #include -#include +#include / { keymap { diff --git a/app/tests/none/behavior_keymap.dtsi b/app/tests/none/behavior_keymap.dtsi index 0a4f7cb7..40d863c1 100644 --- a/app/tests/none/behavior_keymap.dtsi +++ b/app/tests/none/behavior_keymap.dtsi @@ -1,6 +1,6 @@ #include #include -#include +#include / { keymap { diff --git a/app/tests/none/layered/native_posix.keymap b/app/tests/none/layered/native_posix.keymap index 59ea4811..597ca2db 100644 --- a/app/tests/none/layered/native_posix.keymap +++ b/app/tests/none/layered/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/none/normal/native_posix.keymap b/app/tests/none/normal/native_posix.keymap index 94d7539c..cbeb61dc 100644 --- a/app/tests/none/normal/native_posix.keymap +++ b/app/tests/none/normal/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/sticky-keys/1-os-dn-up/native_posix.keymap b/app/tests/sticky-keys/1-os-dn-up/native_posix.keymap index dd2e6ea5..d0f26b2f 100644 --- a/app/tests/sticky-keys/1-os-dn-up/native_posix.keymap +++ b/app/tests/sticky-keys/1-os-dn-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/sticky-keys/2-os-dn-up-kcdn-kcup/native_posix.keymap b/app/tests/sticky-keys/2-os-dn-up-kcdn-kcup/native_posix.keymap index c96eb9f9..2d078ba5 100644 --- a/app/tests/sticky-keys/2-os-dn-up-kcdn-kcup/native_posix.keymap +++ b/app/tests/sticky-keys/2-os-dn-up-kcdn-kcup/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/sticky-keys/3a-os-dn-kcdn-kcup-up/native_posix.keymap b/app/tests/sticky-keys/3a-os-dn-kcdn-kcup-up/native_posix.keymap index 3c33908f..438880d5 100644 --- a/app/tests/sticky-keys/3a-os-dn-kcdn-kcup-up/native_posix.keymap +++ b/app/tests/sticky-keys/3a-os-dn-kcdn-kcup-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/sticky-keys/3b-os-dn-kcdn-up-kcup/native_posix.keymap b/app/tests/sticky-keys/3b-os-dn-kcdn-up-kcup/native_posix.keymap index e9290a31..067f2379 100644 --- a/app/tests/sticky-keys/3b-os-dn-kcdn-up-kcup/native_posix.keymap +++ b/app/tests/sticky-keys/3b-os-dn-kcdn-up-kcup/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/sticky-keys/4-os-dn-up-kcdn-timer-kcup/native_posix.keymap b/app/tests/sticky-keys/4-os-dn-up-kcdn-timer-kcup/native_posix.keymap index 84daad69..d58641bd 100644 --- a/app/tests/sticky-keys/4-os-dn-up-kcdn-timer-kcup/native_posix.keymap +++ b/app/tests/sticky-keys/4-os-dn-up-kcdn-timer-kcup/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/sticky-keys/5-os-kcdn-dn-kcup-up/native_posix.keymap b/app/tests/sticky-keys/5-os-kcdn-dn-kcup-up/native_posix.keymap index 71a0a1bb..aac6725e 100644 --- a/app/tests/sticky-keys/5-os-kcdn-dn-kcup-up/native_posix.keymap +++ b/app/tests/sticky-keys/5-os-kcdn-dn-kcup-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/sticky-keys/7-os-dn-up-kc1dn-kc2dn-kc1up-kc2up/native_posix.keymap b/app/tests/sticky-keys/7-os-dn-up-kc1dn-kc2dn-kc1up-kc2up/native_posix.keymap index 7a9901bf..66bb72d8 100644 --- a/app/tests/sticky-keys/7-os-dn-up-kc1dn-kc2dn-kc1up-kc2up/native_posix.keymap +++ b/app/tests/sticky-keys/7-os-dn-up-kc1dn-kc2dn-kc1up-kc2up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/sticky-keys/8-lsk-osk-combination/native_posix.keymap b/app/tests/sticky-keys/8-lsk-osk-combination/native_posix.keymap index 45cef501..beedd44e 100644 --- a/app/tests/sticky-keys/8-lsk-osk-combination/native_posix.keymap +++ b/app/tests/sticky-keys/8-lsk-osk-combination/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include / { keymap { diff --git a/app/tests/sticky-keys/9-sk-dn-up-dn-up/native_posix.keymap b/app/tests/sticky-keys/9-sk-dn-up-dn-up/native_posix.keymap index 2fcc3ff6..d4c30fbf 100644 --- a/app/tests/sticky-keys/9-sk-dn-up-dn-up/native_posix.keymap +++ b/app/tests/sticky-keys/9-sk-dn-up-dn-up/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include / { keymap { diff --git a/app/tests/sticky-keys/behavior_keymap.dtsi b/app/tests/sticky-keys/behavior_keymap.dtsi index ae463966..f1277009 100644 --- a/app/tests/sticky-keys/behavior_keymap.dtsi +++ b/app/tests/sticky-keys/behavior_keymap.dtsi @@ -1,6 +1,6 @@ #include #include -#include +#include / { keymap { diff --git a/app/tests/toggle-layer/behavior_keymap.dtsi b/app/tests/toggle-layer/behavior_keymap.dtsi index 2523d867..b9c0d4a4 100644 --- a/app/tests/toggle-layer/behavior_keymap.dtsi +++ b/app/tests/toggle-layer/behavior_keymap.dtsi @@ -1,6 +1,6 @@ #include #include -#include +#include / { keymap { diff --git a/app/tests/toggle-layer/early-key-release/native_posix.keymap b/app/tests/toggle-layer/early-key-release/native_posix.keymap index 6b2b8f20..6c293390 100644 --- a/app/tests/toggle-layer/early-key-release/native_posix.keymap +++ b/app/tests/toggle-layer/early-key-release/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/toggle-layer/normal/native_posix.keymap b/app/tests/toggle-layer/normal/native_posix.keymap index 202c105c..9df9d649 100644 --- a/app/tests/toggle-layer/normal/native_posix.keymap +++ b/app/tests/toggle-layer/normal/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/transparent/behavior_keymap.dtsi b/app/tests/transparent/behavior_keymap.dtsi index d6c5e27f..2a7e783a 100644 --- a/app/tests/transparent/behavior_keymap.dtsi +++ b/app/tests/transparent/behavior_keymap.dtsi @@ -1,6 +1,6 @@ #include #include -#include +#include / { keymap { diff --git a/app/tests/transparent/layered/native_posix.keymap b/app/tests/transparent/layered/native_posix.keymap index 59ea4811..597ca2db 100644 --- a/app/tests/transparent/layered/native_posix.keymap +++ b/app/tests/transparent/layered/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/app/tests/transparent/normal/native_posix.keymap b/app/tests/transparent/normal/native_posix.keymap index 94d7539c..cbeb61dc 100644 --- a/app/tests/transparent/normal/native_posix.keymap +++ b/app/tests/transparent/normal/native_posix.keymap @@ -1,6 +1,6 @@ #include #include -#include +#include #include "../behavior_keymap.dtsi" &kscan { diff --git a/docs/docs/development/new-shield.md b/docs/docs/development/new-shield.md index 306f1b3f..18f8b420 100644 --- a/docs/docs/development/new-shield.md +++ b/docs/docs/development/new-shield.md @@ -163,7 +163,7 @@ It is preferred to define only the `col-gpios` or `row-gpios` in the common shie For `col2row` directed boards like the iris, the shared .dtsi file may look like this: ``` -#include +#include / { chosen { @@ -315,7 +315,7 @@ Whenever that default key position mapping is insufficient, the `.o Here is an example for the [nice60](https://github.com/Nicell/nice60), which uses an efficient 8x8 GPIO matrix, and uses a transform: ``` -#include +#include / { chosen { @@ -344,7 +344,7 @@ RC(7,0) RC(7,1) RC(7,2) RC(7,3) RC(7 Some important things to note: -- The `#include ` is critical. The `RC` macro is used to generate the internal storage in the matrix transform, and is actually replaced by a C preprocessor before the final devicetree is compiled into ZMK. +- The `#include ` is critical. The `RC` macro is used to generate the internal storage in the matrix transform, and is actually replaced by a C preprocessor before the final devicetree is compiled into ZMK. - `RC(row, column)` is placed sequentially to define what row and column values that position corresponds to. - If you have a keyboard with options for `2u` keys in certain positions, or break away portions, it is a good idea to set the chosen `zmk,matrix_transform` to the default arrangement, and include _other_ possible matrix transform nodes in the devicetree that users can select in their user config by overriding the chosen node. From 4db5b169bff1f3de5353324baef5724be4f9a6a5 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Sat, 12 Dec 2020 23:13:49 -0500 Subject: [PATCH 03/59] refactor(splits): Ability to override split role. * Move central/peripheral setting to Kconfig.defconfig files to allow left/right .conf files to override central/peripheral role for splits. --- app/CMakeLists.txt | 12 ++++++--- app/Kconfig | 15 ++--------- app/boards/shields/corne/Kconfig.defconfig | 7 +++--- app/boards/shields/corne/corne_left.conf | 2 -- app/boards/shields/corne/corne_right.conf | 2 -- app/boards/shields/cradio/Kconfig.defconfig | 10 ++++++++ app/boards/shields/cradio/cradio_left.conf | 3 --- app/boards/shields/cradio/cradio_right.conf | 2 -- app/boards/shields/iris/Kconfig.defconfig | 10 ++++++++ app/boards/shields/iris/iris_left.conf | 2 -- app/boards/shields/iris/iris_right.conf | 2 -- app/boards/shields/jian/Kconfig.defconfig | 4 ++- app/boards/shields/jian/jian_left.conf | 2 -- app/boards/shields/jian/jian_right.conf | 2 -- app/boards/shields/jorne/Kconfig.defconfig | 3 +++ app/boards/shields/jorne/jorne_left.conf | 2 -- app/boards/shields/jorne/jorne_right.conf | 2 -- app/boards/shields/kyria/Kconfig.defconfig | 3 +++ app/boards/shields/kyria/kyria_left.conf | 2 -- app/boards/shields/kyria/kyria_right.conf | 2 -- app/boards/shields/lily58/Kconfig.defconfig | 7 ++++++ app/boards/shields/lily58/lily58_left.conf | 3 --- app/boards/shields/lily58/lily58_right.conf | 3 +-- app/boards/shields/microdox/Kconfig.defconfig | 3 +++ .../shields/microdox/microdox_left.conf | 2 -- .../shields/microdox/microdox_right.conf | 2 -- .../shields/quefrency/Kconfig.defconfig | 10 ++++++++ .../shields/quefrency/quefrency_left.conf | 2 -- .../shields/quefrency/quefrency_right.conf | 2 -- app/boards/shields/sofle/Kconfig.defconfig | 7 ++++++ app/boards/shields/sofle/sofle_left.conf | 3 --- app/boards/shields/sofle/sofle_right.conf | 3 --- .../shields/splitreus62/Kconfig.defconfig | 6 +++++ .../shields/splitreus62/splitreus62_left.conf | 2 -- .../splitreus62/splitreus62_right.conf | 2 -- app/src/ble.c | 25 +++++++++++-------- 36 files changed, 92 insertions(+), 79 deletions(-) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 5174576b..9e0612de 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -39,7 +39,7 @@ target_sources(app PRIVATE src/events/sensor_event.c) target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/events/ble_active_profile_changed.c) target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/events/battery_state_changed.c) target_sources_ifdef(CONFIG_USB app PRIVATE src/events/usb_conn_state_changed.c) -if (NOT CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) +if ((NOT CONFIG_ZMK_SPLIT) OR CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) target_sources(app PRIVATE src/behaviors/behavior_key_press.c) target_sources(app PRIVATE src/behaviors/behavior_reset.c) target_sources(app PRIVATE src/behaviors/behavior_hold_tap.c) @@ -57,9 +57,13 @@ target_sources_ifdef(CONFIG_ZMK_RGB_UNDERGLOW app PRIVATE src/behaviors/behavior target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/behaviors/behavior_bt.c) target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/ble.c) target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/battery.c) -target_sources_ifdef(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL app PRIVATE src/split_listener.c) -target_sources_ifdef(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL app PRIVATE src/split/bluetooth/service.c) -target_sources_ifdef(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL app PRIVATE src/split/bluetooth/central.c) +if (CONFIG_ZMK_SPLIT_BLE AND (NOT CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL)) + target_sources(app PRIVATE src/split_listener.c) + target_sources(app PRIVATE src/split/bluetooth/service.c) +endif() +if (CONFIG_ZMK_SPLIT_BLE AND CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) + target_sources(app PRIVATE src/split/bluetooth/central.c) +endif() target_sources_ifdef(CONFIG_USB app PRIVATE src/usb.c) target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/hog.c) target_sources_ifdef(CONFIG_ZMK_RGB_UNDERGLOW app PRIVATE src/rgb_underglow.c) diff --git a/app/Kconfig b/app/Kconfig index ec043bfe..acb288cb 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -83,7 +83,6 @@ menu "Split Support" config ZMK_SPLIT bool "Split keyboard support" - default n if ZMK_SPLIT @@ -95,19 +94,12 @@ config ZMK_SPLIT_BLE if ZMK_SPLIT_BLE -choice ZMK_SPLIT_BLE_ROLE - bool "BLE Role For Split Communication" - default ZMK_SPLIT_BLE_ROLE_CENTRAL - config ZMK_SPLIT_BLE_ROLE_CENTRAL bool "Central" select BT_CENTRAL select BT_GATT_CLIENT -config ZMK_SPLIT_BLE_ROLE_PERIPHERAL - bool "Peripheral" - -if ZMK_SPLIT_BLE_ROLE_PERIPHERAL +if !ZMK_SPLIT_BLE_ROLE_CENTRAL config ZMK_USB default n @@ -121,12 +113,9 @@ config BT_MAX_CONN config BT_GAP_AUTO_UPDATE_CONN_PARAMS default n -#ZMK_SPLIT_BLE_ROLE_PERIPHERAL +#!ZMK_SPLIT_BLE_ROLE_CENTRAL endif -#ZMK_SPLIT_BLE_ROLE -endchoice - #ZMK_SPLIT_BLE endif diff --git a/app/boards/shields/corne/Kconfig.defconfig b/app/boards/shields/corne/Kconfig.defconfig index 0355c776..9e33e089 100644 --- a/app/boards/shields/corne/Kconfig.defconfig +++ b/app/boards/shields/corne/Kconfig.defconfig @@ -1,12 +1,13 @@ - if SHIELD_CORNE_LEFT config ZMK_KEYBOARD_NAME - default "Corne Left" + default "Corne" + +config ZMK_SPLIT_BLE_ROLE_CENTRAL + default y endif - if SHIELD_CORNE_RIGHT config ZMK_KEYBOARD_NAME diff --git a/app/boards/shields/corne/corne_left.conf b/app/boards/shields/corne/corne_left.conf index 1e028a78..e69de29b 100644 --- a/app/boards/shields/corne/corne_left.conf +++ b/app/boards/shields/corne/corne_left.conf @@ -1,2 +0,0 @@ -CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y diff --git a/app/boards/shields/corne/corne_right.conf b/app/boards/shields/corne/corne_right.conf index 990cf7c0..e69de29b 100644 --- a/app/boards/shields/corne/corne_right.conf +++ b/app/boards/shields/corne/corne_right.conf @@ -1,2 +0,0 @@ -CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y diff --git a/app/boards/shields/cradio/Kconfig.defconfig b/app/boards/shields/cradio/Kconfig.defconfig index 81246baf..5e826bf0 100644 --- a/app/boards/shields/cradio/Kconfig.defconfig +++ b/app/boards/shields/cradio/Kconfig.defconfig @@ -6,6 +6,9 @@ if SHIELD_CRADIO_LEFT config ZMK_KEYBOARD_NAME default "cradio left" +config ZMK_SPLIT_BLE_ROLE_CENTRAL + default y + endif if SHIELD_CRADIO_RIGHT @@ -14,3 +17,10 @@ config ZMK_KEYBOARD_NAME default "cradio right" endif + +if SHIELD_CRADIO_LEFT || SHIELD_CRADIO_RIGHT + +config ZMK_SPLIT + default y + +endif \ No newline at end of file diff --git a/app/boards/shields/cradio/cradio_left.conf b/app/boards/shields/cradio/cradio_left.conf index 405f04db..c9f7988a 100644 --- a/app/boards/shields/cradio/cradio_left.conf +++ b/app/boards/shields/cradio/cradio_left.conf @@ -1,5 +1,2 @@ # Copyright (c) 2020 The ZMK Contributors # SPDX-License-Identifier: MIT - -CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y diff --git a/app/boards/shields/cradio/cradio_right.conf b/app/boards/shields/cradio/cradio_right.conf index bd2c93bf..80a6177e 100644 --- a/app/boards/shields/cradio/cradio_right.conf +++ b/app/boards/shields/cradio/cradio_right.conf @@ -1,5 +1,3 @@ # Copyright (c) 2020 The ZMK Contributors # SPDX-License-Identifier: MIT -CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y diff --git a/app/boards/shields/iris/Kconfig.defconfig b/app/boards/shields/iris/Kconfig.defconfig index 6439780c..57b8c1ee 100644 --- a/app/boards/shields/iris/Kconfig.defconfig +++ b/app/boards/shields/iris/Kconfig.defconfig @@ -6,6 +6,9 @@ if SHIELD_IRIS_LEFT config ZMK_KEYBOARD_NAME default "Iris Left" +config ZMK_SPLIT_BLE_ROLE_CENTRAL + default y + endif if SHIELD_IRIS_RIGHT @@ -14,3 +17,10 @@ config ZMK_KEYBOARD_NAME default "Iris Right" endif + +if SHIELD_IRIS_LEFT || SHIELD_IRIS_RIGHT + +config ZMK_SPLIT + default y + +endif \ No newline at end of file diff --git a/app/boards/shields/iris/iris_left.conf b/app/boards/shields/iris/iris_left.conf index 1e028a78..e69de29b 100644 --- a/app/boards/shields/iris/iris_left.conf +++ b/app/boards/shields/iris/iris_left.conf @@ -1,2 +0,0 @@ -CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y diff --git a/app/boards/shields/iris/iris_right.conf b/app/boards/shields/iris/iris_right.conf index 990cf7c0..e69de29b 100644 --- a/app/boards/shields/iris/iris_right.conf +++ b/app/boards/shields/iris/iris_right.conf @@ -1,2 +0,0 @@ -CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y diff --git a/app/boards/shields/jian/Kconfig.defconfig b/app/boards/shields/jian/Kconfig.defconfig index b743e7a4..9e1da623 100644 --- a/app/boards/shields/jian/Kconfig.defconfig +++ b/app/boards/shields/jian/Kconfig.defconfig @@ -4,6 +4,9 @@ if SHIELD_JIAN_LEFT config ZMK_KEYBOARD_NAME default "Jian Left" +config ZMK_SPLIT_BLE_ROLE_CENTRAL + default y + endif @@ -18,6 +21,5 @@ if SHIELD_JIAN_LEFT || SHIELD_JIAN_RIGHT config ZMK_SPLIT default y - endif diff --git a/app/boards/shields/jian/jian_left.conf b/app/boards/shields/jian/jian_left.conf index 1e028a78..e69de29b 100644 --- a/app/boards/shields/jian/jian_left.conf +++ b/app/boards/shields/jian/jian_left.conf @@ -1,2 +0,0 @@ -CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y diff --git a/app/boards/shields/jian/jian_right.conf b/app/boards/shields/jian/jian_right.conf index 990cf7c0..e69de29b 100644 --- a/app/boards/shields/jian/jian_right.conf +++ b/app/boards/shields/jian/jian_right.conf @@ -1,2 +0,0 @@ -CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y diff --git a/app/boards/shields/jorne/Kconfig.defconfig b/app/boards/shields/jorne/Kconfig.defconfig index c0df54bb..5b0e0b95 100644 --- a/app/boards/shields/jorne/Kconfig.defconfig +++ b/app/boards/shields/jorne/Kconfig.defconfig @@ -4,6 +4,9 @@ if SHIELD_JORNE_LEFT config ZMK_KEYBOARD_NAME default "Jorne Left" +config ZMK_SPLIT_BLE_ROLE_CENTRAL + default y + endif diff --git a/app/boards/shields/jorne/jorne_left.conf b/app/boards/shields/jorne/jorne_left.conf index 1e028a78..e69de29b 100644 --- a/app/boards/shields/jorne/jorne_left.conf +++ b/app/boards/shields/jorne/jorne_left.conf @@ -1,2 +0,0 @@ -CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y diff --git a/app/boards/shields/jorne/jorne_right.conf b/app/boards/shields/jorne/jorne_right.conf index 990cf7c0..e69de29b 100644 --- a/app/boards/shields/jorne/jorne_right.conf +++ b/app/boards/shields/jorne/jorne_right.conf @@ -1,2 +0,0 @@ -CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y diff --git a/app/boards/shields/kyria/Kconfig.defconfig b/app/boards/shields/kyria/Kconfig.defconfig index 8d5fe811..99e47bfe 100644 --- a/app/boards/shields/kyria/Kconfig.defconfig +++ b/app/boards/shields/kyria/Kconfig.defconfig @@ -4,6 +4,9 @@ if SHIELD_KYRIA_LEFT config ZMK_KEYBOARD_NAME default "Kyria Left" +config ZMK_SPLIT_BLE_ROLE_CENTRAL + default y + endif diff --git a/app/boards/shields/kyria/kyria_left.conf b/app/boards/shields/kyria/kyria_left.conf index e51dee44..e69de29b 100644 --- a/app/boards/shields/kyria/kyria_left.conf +++ b/app/boards/shields/kyria/kyria_left.conf @@ -1,2 +0,0 @@ -CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y \ No newline at end of file diff --git a/app/boards/shields/kyria/kyria_right.conf b/app/boards/shields/kyria/kyria_right.conf index 990cf7c0..e69de29b 100644 --- a/app/boards/shields/kyria/kyria_right.conf +++ b/app/boards/shields/kyria/kyria_right.conf @@ -1,2 +0,0 @@ -CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y diff --git a/app/boards/shields/lily58/Kconfig.defconfig b/app/boards/shields/lily58/Kconfig.defconfig index 81feefde..915cc70e 100644 --- a/app/boards/shields/lily58/Kconfig.defconfig +++ b/app/boards/shields/lily58/Kconfig.defconfig @@ -4,6 +4,9 @@ if SHIELD_LILY58_LEFT config ZMK_KEYBOARD_NAME default "Lily58 Left" +config ZMK_SPLIT_BLE_ROLE_CENTRAL + default y + endif if SHIELD_LILY58_RIGHT @@ -15,6 +18,9 @@ endif if SHIELD_LILY58_LEFT || SHIELD_LILY58_RIGHT +config ZMK_SPLIT + default y + if ZMK_DISPLAY config I2C @@ -52,3 +58,4 @@ endchoice endif # LVGL endif + diff --git a/app/boards/shields/lily58/lily58_left.conf b/app/boards/shields/lily58/lily58_left.conf index 6ff95d54..24f8d779 100644 --- a/app/boards/shields/lily58/lily58_left.conf +++ b/app/boards/shields/lily58/lily58_left.conf @@ -1,6 +1,3 @@ # Uncomment to enable encoder # CONFIG_EC11=y # CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y - -CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y \ No newline at end of file diff --git a/app/boards/shields/lily58/lily58_right.conf b/app/boards/shields/lily58/lily58_right.conf index 990cf7c0..8b137891 100644 --- a/app/boards/shields/lily58/lily58_right.conf +++ b/app/boards/shields/lily58/lily58_right.conf @@ -1,2 +1 @@ -CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y + diff --git a/app/boards/shields/microdox/Kconfig.defconfig b/app/boards/shields/microdox/Kconfig.defconfig index 3f8b7481..be39c9f8 100644 --- a/app/boards/shields/microdox/Kconfig.defconfig +++ b/app/boards/shields/microdox/Kconfig.defconfig @@ -6,6 +6,9 @@ if SHIELD_MICRODOX_LEFT config ZMK_KEYBOARD_NAME default "Microdox Left" +config ZMK_SPLIT_BLE_ROLE_CENTRAL + default y + endif diff --git a/app/boards/shields/microdox/microdox_left.conf b/app/boards/shields/microdox/microdox_left.conf index 1e028a78..e69de29b 100644 --- a/app/boards/shields/microdox/microdox_left.conf +++ b/app/boards/shields/microdox/microdox_left.conf @@ -1,2 +0,0 @@ -CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y diff --git a/app/boards/shields/microdox/microdox_right.conf b/app/boards/shields/microdox/microdox_right.conf index 990cf7c0..e69de29b 100644 --- a/app/boards/shields/microdox/microdox_right.conf +++ b/app/boards/shields/microdox/microdox_right.conf @@ -1,2 +0,0 @@ -CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y diff --git a/app/boards/shields/quefrency/Kconfig.defconfig b/app/boards/shields/quefrency/Kconfig.defconfig index 2b00cb62..9c7e8b13 100644 --- a/app/boards/shields/quefrency/Kconfig.defconfig +++ b/app/boards/shields/quefrency/Kconfig.defconfig @@ -7,6 +7,9 @@ if SHIELD_QUEFRENCY_LEFT config ZMK_KEYBOARD_NAME default "Quefrency Left" +config ZMK_SPLIT_BLE_ROLE_CENTRAL + default y + endif if SHIELD_QUEFRENCY_RIGHT @@ -15,3 +18,10 @@ config ZMK_KEYBOARD_NAME default "Quefrency Right" endif + +if SHIELD_QUEFRENCY_LEFT || SHIELD_QUEFRENCY_RIGHT + +config ZMK_SPLIT + default y + +endif \ No newline at end of file diff --git a/app/boards/shields/quefrency/quefrency_left.conf b/app/boards/shields/quefrency/quefrency_left.conf index 1e028a78..e69de29b 100644 --- a/app/boards/shields/quefrency/quefrency_left.conf +++ b/app/boards/shields/quefrency/quefrency_left.conf @@ -1,2 +0,0 @@ -CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y diff --git a/app/boards/shields/quefrency/quefrency_right.conf b/app/boards/shields/quefrency/quefrency_right.conf index 990cf7c0..e69de29b 100644 --- a/app/boards/shields/quefrency/quefrency_right.conf +++ b/app/boards/shields/quefrency/quefrency_right.conf @@ -1,2 +0,0 @@ -CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y diff --git a/app/boards/shields/sofle/Kconfig.defconfig b/app/boards/shields/sofle/Kconfig.defconfig index 6a4f863b..cde094a6 100644 --- a/app/boards/shields/sofle/Kconfig.defconfig +++ b/app/boards/shields/sofle/Kconfig.defconfig @@ -5,6 +5,10 @@ if SHIELD_SOFLE_LEFT config ZMK_KEYBOARD_NAME default "Sofle Left" + +config ZMK_SPLIT_BLE_ROLE_CENTRAL + default y + endif if SHIELD_SOFLE_RIGHT @@ -15,6 +19,9 @@ endif if SHIELD_SOFLE_LEFT || SHIELD_SOFLE_RIGHT +config ZMK_SPLIT + default y + if ZMK_DISPLAY config I2C diff --git a/app/boards/shields/sofle/sofle_left.conf b/app/boards/shields/sofle/sofle_left.conf index bbac7359..e8137201 100644 --- a/app/boards/shields/sofle/sofle_left.conf +++ b/app/boards/shields/sofle/sofle_left.conf @@ -1,5 +1,2 @@ # Copyright (c) 2020 Ryan Cross # SPDX-License-Identifier: MIT - -CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y diff --git a/app/boards/shields/sofle/sofle_right.conf b/app/boards/shields/sofle/sofle_right.conf index ca5de382..e8137201 100644 --- a/app/boards/shields/sofle/sofle_right.conf +++ b/app/boards/shields/sofle/sofle_right.conf @@ -1,5 +1,2 @@ # Copyright (c) 2020 Ryan Cross # SPDX-License-Identifier: MIT - -CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y diff --git a/app/boards/shields/splitreus62/Kconfig.defconfig b/app/boards/shields/splitreus62/Kconfig.defconfig index a2464a79..06ac131d 100644 --- a/app/boards/shields/splitreus62/Kconfig.defconfig +++ b/app/boards/shields/splitreus62/Kconfig.defconfig @@ -8,6 +8,9 @@ if SHIELD_SPLITREUS62_LEFT config ZMK_KEYBOARD_NAME default "Splitreus62 Left" +config ZMK_SPLIT_BLE_ROLE_CENTRAL + default y + endif if SHIELD_SPLITREUS62_RIGHT @@ -19,4 +22,7 @@ endif if SHIELD_SPLITREUS62_LEFT || SHIELD_SPLITREUS62_RIGHT +config ZMK_SPLIT + default y + endif diff --git a/app/boards/shields/splitreus62/splitreus62_left.conf b/app/boards/shields/splitreus62/splitreus62_left.conf index e51dee44..e69de29b 100644 --- a/app/boards/shields/splitreus62/splitreus62_left.conf +++ b/app/boards/shields/splitreus62/splitreus62_left.conf @@ -1,2 +0,0 @@ -CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y \ No newline at end of file diff --git a/app/boards/shields/splitreus62/splitreus62_right.conf b/app/boards/shields/splitreus62/splitreus62_right.conf index a835adc1..e69de29b 100644 --- a/app/boards/shields/splitreus62/splitreus62_right.conf +++ b/app/boards/shields/splitreus62/splitreus62_right.conf @@ -1,2 +0,0 @@ -CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y \ No newline at end of file diff --git a/app/src/ble.c b/app/src/ble.c index 4d422877..be84de8b 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -63,19 +63,24 @@ static uint8_t active_profile; #define DEVICE_NAME CONFIG_BT_DEVICE_NAME #define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1) +#define IS_HOST_PERIPHERAL \ + (!IS_ENABLED(CONFIG_ZMK_SPLIT) || IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL)) +#define IS_SPLIT_PERIPHERAL \ + (IS_ENABLED(CONFIG_ZMK_SPLIT) && !IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL)) + static const struct bt_data zmk_ble_ad[] = { -#if !IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) +#if IS_HOST_PERIPHERAL BT_DATA(BT_DATA_NAME_COMPLETE, DEVICE_NAME, DEVICE_NAME_LEN), BT_DATA_BYTES(BT_DATA_GAP_APPEARANCE, 0xC1, 0x03), #endif BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), BT_DATA_BYTES(BT_DATA_UUID16_SOME, -#if !IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) +#if IS_HOST_PERIPHERAL 0x12, 0x18, /* HID Service */ #endif 0x0f, 0x18 /* Battery Service */ ), -#if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) +#if IS_SPLIT_PERIPHERAL BT_DATA_BYTES(BT_DATA_UUID128_ALL, ZMK_SPLIT_BT_SERVICE_UUID) #endif }; @@ -373,7 +378,7 @@ static void connected(struct bt_conn *conn, uint8_t err) { bt_conn_le_param_update(conn, BT_LE_CONN_PARAM(0x0006, 0x000c, 30, 400)); -#if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) +#if IS_SPLIT_PERIPHERAL bt_conn_le_phy_update(conn, BT_CONN_LE_PHY_PARAM_2M); #endif @@ -462,7 +467,7 @@ static void auth_cancel(struct bt_conn *conn) { LOG_DBG("Pairing cancelled: %s", log_strdup(addr)); } -#if !IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) +#if IS_HOST_PERIPHERAL static enum bt_security_err auth_pairing_accept(struct bt_conn *conn, const struct bt_conn_pairing_feat *const feat) { struct bt_conn_info info; @@ -476,7 +481,7 @@ static enum bt_security_err auth_pairing_accept(struct bt_conn *conn, return BT_SECURITY_ERR_SUCCESS; }; -#endif /* !IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) */ +#endif /* IS_HOST_PERIPHERAL */ static void auth_pairing_complete(struct bt_conn *conn, bool bonded) { struct bt_conn_info info; @@ -491,22 +496,22 @@ static void auth_pairing_complete(struct bt_conn *conn, bool bonded) { return; } -#if !IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) +#if IS_HOST_PERIPHERAL if (!zmk_ble_active_profile_is_open()) { LOG_ERR("Pairing completed but current profile is not open: %s", log_strdup(addr)); bt_unpair(BT_ID_DEFAULT, dst); return; } -#endif /* !IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) */ +#endif /* IS_HOST_PERIPHERAL */ set_profile_address(active_profile, dst); update_advertising(); }; static struct bt_conn_auth_cb zmk_ble_auth_cb_display = { -#if !IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) +#if IS_HOST_PERIPHERAL .pairing_accept = auth_pairing_accept, -#endif /* !IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) */ +#endif /* IS_HOST_PERIPHERAL */ .pairing_complete = auth_pairing_complete, // .passkey_display = auth_passkey_display, From 4fc17e0b3a32096923790f28226a15beffacc686 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Thu, 17 Dec 2020 00:19:03 -0500 Subject: [PATCH 04/59] fix(shields): Enable USB by default on right side. * Ensures USB power detection for sleep/charging is properly detected on the right side by deafult. --- app/boards/shields/corne/Kconfig.defconfig | 3 +++ app/boards/shields/cradio/Kconfig.defconfig | 3 +++ app/boards/shields/iris/Kconfig.defconfig | 3 +++ app/boards/shields/jian/Kconfig.defconfig | 3 +++ app/boards/shields/jorne/Kconfig.defconfig | 3 +++ app/boards/shields/kyria/Kconfig.defconfig | 3 +++ app/boards/shields/lily58/Kconfig.defconfig | 3 +++ app/boards/shields/microdox/Kconfig.defconfig | 3 +++ app/boards/shields/quefrency/Kconfig.defconfig | 3 +++ app/boards/shields/sofle/Kconfig.defconfig | 4 ++++ app/boards/shields/splitreus62/Kconfig.defconfig | 3 +++ 11 files changed, 34 insertions(+) diff --git a/app/boards/shields/corne/Kconfig.defconfig b/app/boards/shields/corne/Kconfig.defconfig index 9e33e089..6cf60b18 100644 --- a/app/boards/shields/corne/Kconfig.defconfig +++ b/app/boards/shields/corne/Kconfig.defconfig @@ -13,6 +13,9 @@ if SHIELD_CORNE_RIGHT config ZMK_KEYBOARD_NAME default "Corne Right" +config USB + default y + endif if SHIELD_CORNE_LEFT || SHIELD_CORNE_RIGHT diff --git a/app/boards/shields/cradio/Kconfig.defconfig b/app/boards/shields/cradio/Kconfig.defconfig index 5e826bf0..25bb4331 100644 --- a/app/boards/shields/cradio/Kconfig.defconfig +++ b/app/boards/shields/cradio/Kconfig.defconfig @@ -16,6 +16,9 @@ if SHIELD_CRADIO_RIGHT config ZMK_KEYBOARD_NAME default "cradio right" +config USB + default y + endif if SHIELD_CRADIO_LEFT || SHIELD_CRADIO_RIGHT diff --git a/app/boards/shields/iris/Kconfig.defconfig b/app/boards/shields/iris/Kconfig.defconfig index 57b8c1ee..a43c0073 100644 --- a/app/boards/shields/iris/Kconfig.defconfig +++ b/app/boards/shields/iris/Kconfig.defconfig @@ -16,6 +16,9 @@ if SHIELD_IRIS_RIGHT config ZMK_KEYBOARD_NAME default "Iris Right" +config USB + default y + endif if SHIELD_IRIS_LEFT || SHIELD_IRIS_RIGHT diff --git a/app/boards/shields/jian/Kconfig.defconfig b/app/boards/shields/jian/Kconfig.defconfig index 9e1da623..07023a24 100644 --- a/app/boards/shields/jian/Kconfig.defconfig +++ b/app/boards/shields/jian/Kconfig.defconfig @@ -15,6 +15,9 @@ if SHIELD_JIAN_RIGHT config ZMK_KEYBOARD_NAME default "Jian Right" +config USB + default y + endif if SHIELD_JIAN_LEFT || SHIELD_JIAN_RIGHT diff --git a/app/boards/shields/jorne/Kconfig.defconfig b/app/boards/shields/jorne/Kconfig.defconfig index 5b0e0b95..18dcabe1 100644 --- a/app/boards/shields/jorne/Kconfig.defconfig +++ b/app/boards/shields/jorne/Kconfig.defconfig @@ -15,6 +15,9 @@ if SHIELD_JORNE_RIGHT config ZMK_KEYBOARD_NAME default "Jorne Right" +config USB + default y + endif if SHIELD_JORNE_LEFT || SHIELD_JORNE_RIGHT diff --git a/app/boards/shields/kyria/Kconfig.defconfig b/app/boards/shields/kyria/Kconfig.defconfig index 99e47bfe..d0c17105 100644 --- a/app/boards/shields/kyria/Kconfig.defconfig +++ b/app/boards/shields/kyria/Kconfig.defconfig @@ -15,6 +15,9 @@ if SHIELD_KYRIA_RIGHT config ZMK_KEYBOARD_NAME default "Kyria Right" +config USB + default y + endif if SHIELD_KYRIA_LEFT || SHIELD_KYRIA_RIGHT diff --git a/app/boards/shields/lily58/Kconfig.defconfig b/app/boards/shields/lily58/Kconfig.defconfig index 915cc70e..ebcfa7b7 100644 --- a/app/boards/shields/lily58/Kconfig.defconfig +++ b/app/boards/shields/lily58/Kconfig.defconfig @@ -14,6 +14,9 @@ if SHIELD_LILY58_RIGHT config ZMK_KEYBOARD_NAME default "Lily58 Right" +config USB + default y + endif if SHIELD_LILY58_LEFT || SHIELD_LILY58_RIGHT diff --git a/app/boards/shields/microdox/Kconfig.defconfig b/app/boards/shields/microdox/Kconfig.defconfig index be39c9f8..0afd7491 100644 --- a/app/boards/shields/microdox/Kconfig.defconfig +++ b/app/boards/shields/microdox/Kconfig.defconfig @@ -17,6 +17,9 @@ if SHIELD_MICRODOX_RIGHT config ZMK_KEYBOARD_NAME default "Microdox Right" +config USB + default y + endif if SHIELD_MICRODOX_LEFT || SHIELD_MICRODOX_RIGHT diff --git a/app/boards/shields/quefrency/Kconfig.defconfig b/app/boards/shields/quefrency/Kconfig.defconfig index 9c7e8b13..b4041cbf 100644 --- a/app/boards/shields/quefrency/Kconfig.defconfig +++ b/app/boards/shields/quefrency/Kconfig.defconfig @@ -17,6 +17,9 @@ if SHIELD_QUEFRENCY_RIGHT config ZMK_KEYBOARD_NAME default "Quefrency Right" +config USB + default y + endif if SHIELD_QUEFRENCY_LEFT || SHIELD_QUEFRENCY_RIGHT diff --git a/app/boards/shields/sofle/Kconfig.defconfig b/app/boards/shields/sofle/Kconfig.defconfig index cde094a6..765afea4 100644 --- a/app/boards/shields/sofle/Kconfig.defconfig +++ b/app/boards/shields/sofle/Kconfig.defconfig @@ -15,6 +15,10 @@ if SHIELD_SOFLE_RIGHT config ZMK_KEYBOARD_NAME default "Sofle Right" + +config USB + default y + endif if SHIELD_SOFLE_LEFT || SHIELD_SOFLE_RIGHT diff --git a/app/boards/shields/splitreus62/Kconfig.defconfig b/app/boards/shields/splitreus62/Kconfig.defconfig index 06ac131d..988041c0 100644 --- a/app/boards/shields/splitreus62/Kconfig.defconfig +++ b/app/boards/shields/splitreus62/Kconfig.defconfig @@ -18,6 +18,9 @@ if SHIELD_SPLITREUS62_RIGHT config ZMK_KEYBOARD_NAME default "Splitreus62 Right" +config USB + default y + endif if SHIELD_SPLITREUS62_LEFT || SHIELD_SPLITREUS62_RIGHT From 87179698b42a627f4ab7653749377001cb090fed Mon Sep 17 00:00:00 2001 From: innovaker <66737976+innovaker@users.noreply.github.com> Date: Sat, 19 Dec 2020 17:32:02 +0000 Subject: [PATCH 05/59] refactor(app): replace zmk_key with zmk_key_t Aligns with typedef _t convention. PR: #531 --- app/include/zmk/hid.h | 8 ++++---- app/include/zmk/keys.h | 4 ++-- app/src/ble.c | 2 +- app/src/hid.c | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/include/zmk/hid.h b/app/include/zmk/hid.h index 1f755aa2..c664082e 100644 --- a/app/include/zmk/hid.h +++ b/app/include/zmk/hid.h @@ -170,12 +170,12 @@ int zmk_hid_register_mod(zmk_mod modifier); int zmk_hid_unregister_mod(zmk_mod modifier); int zmk_hid_implicit_modifiers_press(zmk_mod_flags implicit_modifiers); int zmk_hid_implicit_modifiers_release(); -int zmk_hid_keyboard_press(zmk_key key); -int zmk_hid_keyboard_release(zmk_key key); +int zmk_hid_keyboard_press(zmk_key_t key); +int zmk_hid_keyboard_release(zmk_key_t key); void zmk_hid_keyboard_clear(); -int zmk_hid_consumer_press(zmk_key key); -int zmk_hid_consumer_release(zmk_key key); +int zmk_hid_consumer_press(zmk_key_t key); +int zmk_hid_consumer_release(zmk_key_t key); void zmk_hid_consumer_clear(); struct zmk_hid_keyboard_report *zmk_hid_get_keyboard_report(); diff --git a/app/include/zmk/keys.h b/app/include/zmk/keys.h index 204de9c8..330f0adb 100644 --- a/app/include/zmk/keys.h +++ b/app/include/zmk/keys.h @@ -9,13 +9,13 @@ #include #include -typedef uint32_t zmk_key; +typedef uint32_t zmk_key_t; typedef uint8_t zmk_mod; typedef uint8_t zmk_mod_flags; struct zmk_key_event { uint32_t column; uint32_t row; - zmk_key key; + zmk_key_t key; bool pressed; }; \ No newline at end of file diff --git a/app/src/ble.c b/app/src/ble.c index be84de8b..b32696ff 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -596,7 +596,7 @@ int zmk_ble_unpair_all() { }; bool zmk_ble_handle_key_user(struct zmk_key_event *key_event) { - zmk_key key = key_event->key; + zmk_key_t key = key_event->key; if (!auth_passkey_entry_conn) { return true; diff --git a/app/src/hid.c b/app/src/hid.c index 2d6e6f2b..50166c43 100644 --- a/app/src/hid.c +++ b/app/src/hid.c @@ -77,7 +77,7 @@ int zmk_hid_implicit_modifiers_release() { return 0; } -int zmk_hid_keyboard_press(zmk_key code) { +int zmk_hid_keyboard_press(zmk_key_t code) { if (code >= HID_USAGE_KEY_KEYBOARD_LEFTCONTROL && code <= HID_USAGE_KEY_KEYBOARD_RIGHT_GUI) { return zmk_hid_register_mod(code - HID_USAGE_KEY_KEYBOARD_LEFTCONTROL); } @@ -85,7 +85,7 @@ int zmk_hid_keyboard_press(zmk_key code) { return 0; }; -int zmk_hid_keyboard_release(zmk_key code) { +int zmk_hid_keyboard_release(zmk_key_t code) { if (code >= HID_USAGE_KEY_KEYBOARD_LEFTCONTROL && code <= HID_USAGE_KEY_KEYBOARD_RIGHT_GUI) { return zmk_hid_unregister_mod(code - HID_USAGE_KEY_KEYBOARD_LEFTCONTROL); } @@ -95,12 +95,12 @@ int zmk_hid_keyboard_release(zmk_key code) { void zmk_hid_keyboard_clear() { memset(&keyboard_report.body, 0, sizeof(keyboard_report.body)); } -int zmk_hid_consumer_press(zmk_key code) { +int zmk_hid_consumer_press(zmk_key_t code) { TOGGLE_CONSUMER(0U, code); return 0; }; -int zmk_hid_consumer_release(zmk_key code) { +int zmk_hid_consumer_release(zmk_key_t code) { TOGGLE_CONSUMER(code, 0U); return 0; }; From 05b0d185a8c8c4eb19f63968e54f859a0f3e6484 Mon Sep 17 00:00:00 2001 From: innovaker <66737976+innovaker@users.noreply.github.com> Date: Sat, 19 Dec 2020 17:32:40 +0000 Subject: [PATCH 06/59] refactor(app): replace zmk_mod with zmk_mod_t Aligns with typedef _t convention. PR: #531 --- app/include/zmk/hid.h | 4 ++-- app/include/zmk/keys.h | 2 +- app/src/hid.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/include/zmk/hid.h b/app/include/zmk/hid.h index c664082e..a2a4bf59 100644 --- a/app/include/zmk/hid.h +++ b/app/include/zmk/hid.h @@ -166,8 +166,8 @@ struct zmk_hid_consumer_report { struct zmk_hid_consumer_report_body body; } __packed; -int zmk_hid_register_mod(zmk_mod modifier); -int zmk_hid_unregister_mod(zmk_mod modifier); +int zmk_hid_register_mod(zmk_mod_t modifier); +int zmk_hid_unregister_mod(zmk_mod_t modifier); int zmk_hid_implicit_modifiers_press(zmk_mod_flags implicit_modifiers); int zmk_hid_implicit_modifiers_release(); int zmk_hid_keyboard_press(zmk_key_t key); diff --git a/app/include/zmk/keys.h b/app/include/zmk/keys.h index 330f0adb..8e372ff8 100644 --- a/app/include/zmk/keys.h +++ b/app/include/zmk/keys.h @@ -10,7 +10,7 @@ #include typedef uint32_t zmk_key_t; -typedef uint8_t zmk_mod; +typedef uint8_t zmk_mod_t; typedef uint8_t zmk_mod_flags; struct zmk_key_event { diff --git a/app/src/hid.c b/app/src/hid.c index 50166c43..de853d84 100644 --- a/app/src/hid.c +++ b/app/src/hid.c @@ -26,7 +26,7 @@ static zmk_mod_flags explicit_modifiers = 0; LOG_DBG("Modifiers set to 0x%02X", keyboard_report.body.modifiers); \ } -int zmk_hid_register_mod(zmk_mod modifier) { +int zmk_hid_register_mod(zmk_mod_t modifier) { explicit_modifier_counts[modifier]++; LOG_DBG("Modifier %d count %d", modifier, explicit_modifier_counts[modifier]); WRITE_BIT(explicit_modifiers, modifier, true); @@ -34,7 +34,7 @@ int zmk_hid_register_mod(zmk_mod modifier) { return 0; } -int zmk_hid_unregister_mod(zmk_mod modifier) { +int zmk_hid_unregister_mod(zmk_mod_t modifier) { if (explicit_modifier_counts[modifier] <= 0) { LOG_ERR("Tried to unregister modifier %d too often", modifier); return -EINVAL; From 87e7c04b00b2cb83540b757a8c909200cdb28255 Mon Sep 17 00:00:00 2001 From: innovaker <66737976+innovaker@users.noreply.github.com> Date: Sat, 19 Dec 2020 17:33:15 +0000 Subject: [PATCH 07/59] refactor(app): replace zmk_mod_flags with zmk_mod_flags_t Aligns with typedef _t convention. PR: #531 --- app/include/zmk/events/keycode_state_changed.h | 2 +- app/include/zmk/events/modifiers_state_changed.h | 4 ++-- app/include/zmk/hid.h | 4 ++-- app/include/zmk/keys.h | 2 +- app/src/hid.c | 4 ++-- app/src/hid_listener.c | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/include/zmk/events/keycode_state_changed.h b/app/include/zmk/events/keycode_state_changed.h index 28282b6b..d175605b 100644 --- a/app/include/zmk/events/keycode_state_changed.h +++ b/app/include/zmk/events/keycode_state_changed.h @@ -27,7 +27,7 @@ static inline struct keycode_state_changed * keycode_state_changed_from_encoded(uint32_t encoded, bool pressed, int64_t timestamp) { uint16_t page = HID_USAGE_PAGE(encoded) & 0xFF; uint16_t id = HID_USAGE_ID(encoded); - zmk_mod_flags implicit_mods = SELECT_MODS(encoded); + zmk_mod_flags_t implicit_mods = SELECT_MODS(encoded); if (!page) { page = HID_USAGE_KEY; diff --git a/app/include/zmk/events/modifiers_state_changed.h b/app/include/zmk/events/modifiers_state_changed.h index c4daede0..4f40f4c9 100644 --- a/app/include/zmk/events/modifiers_state_changed.h +++ b/app/include/zmk/events/modifiers_state_changed.h @@ -12,13 +12,13 @@ struct modifiers_state_changed { struct zmk_event_header header; - zmk_mod_flags modifiers; + zmk_mod_flags_t modifiers; bool state; }; ZMK_EVENT_DECLARE(modifiers_state_changed); -inline struct modifiers_state_changed *create_modifiers_state_changed(zmk_mod_flags modifiers, +inline struct modifiers_state_changed *create_modifiers_state_changed(zmk_mod_flags_t modifiers, bool state) { struct modifiers_state_changed *ev = new_modifiers_state_changed(); ev->modifiers = modifiers; diff --git a/app/include/zmk/hid.h b/app/include/zmk/hid.h index a2a4bf59..1ec51262 100644 --- a/app/include/zmk/hid.h +++ b/app/include/zmk/hid.h @@ -147,7 +147,7 @@ static const uint8_t zmk_hid_report_desc[] = { // } __packed; struct zmk_hid_keyboard_report_body { - zmk_mod_flags modifiers; + zmk_mod_flags_t modifiers; uint8_t _reserved; uint8_t keys[ZMK_HID_KEYBOARD_NKRO_SIZE]; } __packed; @@ -168,7 +168,7 @@ struct zmk_hid_consumer_report { int zmk_hid_register_mod(zmk_mod_t modifier); int zmk_hid_unregister_mod(zmk_mod_t modifier); -int zmk_hid_implicit_modifiers_press(zmk_mod_flags implicit_modifiers); +int zmk_hid_implicit_modifiers_press(zmk_mod_flags_t implicit_modifiers); int zmk_hid_implicit_modifiers_release(); int zmk_hid_keyboard_press(zmk_key_t key); int zmk_hid_keyboard_release(zmk_key_t key); diff --git a/app/include/zmk/keys.h b/app/include/zmk/keys.h index 8e372ff8..62e3cce8 100644 --- a/app/include/zmk/keys.h +++ b/app/include/zmk/keys.h @@ -11,7 +11,7 @@ typedef uint32_t zmk_key_t; typedef uint8_t zmk_mod_t; -typedef uint8_t zmk_mod_flags; +typedef uint8_t zmk_mod_flags_t; struct zmk_key_event { uint32_t column; diff --git a/app/src/hid.c b/app/src/hid.c index de853d84..37378b45 100644 --- a/app/src/hid.c +++ b/app/src/hid.c @@ -18,7 +18,7 @@ static struct zmk_hid_consumer_report consumer_report = {.report_id = 2, .body = // Keep track of how often a modifier was pressed. // Only release the modifier if the count is 0. static int explicit_modifier_counts[8] = {0, 0, 0, 0, 0, 0, 0, 0}; -static zmk_mod_flags explicit_modifiers = 0; +static zmk_mod_flags_t explicit_modifiers = 0; #define SET_MODIFIERS(mods) \ { \ @@ -67,7 +67,7 @@ int zmk_hid_unregister_mod(zmk_mod_t modifier) { break; \ } -int zmk_hid_implicit_modifiers_press(zmk_mod_flags implicit_modifiers) { +int zmk_hid_implicit_modifiers_press(zmk_mod_flags_t implicit_modifiers) { SET_MODIFIERS(explicit_modifiers | implicit_modifiers); return 0; } diff --git a/app/src/hid_listener.c b/app/src/hid_listener.c index cf8835a2..80e9054a 100644 --- a/app/src/hid_listener.c +++ b/app/src/hid_listener.c @@ -17,7 +17,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include static int hid_listener_keycode_pressed(uint8_t usage_page, uint32_t keycode, - zmk_mod_flags implicit_modifiers) { + zmk_mod_flags_t implicit_modifiers) { int err; LOG_DBG("usage_page 0x%02X keycode 0x%02X mods 0x%02X", usage_page, keycode, implicit_modifiers); @@ -42,7 +42,7 @@ static int hid_listener_keycode_pressed(uint8_t usage_page, uint32_t keycode, } static int hid_listener_keycode_released(uint8_t usage_page, uint32_t keycode, - zmk_mod_flags implicit_modifiers) { + zmk_mod_flags_t implicit_modifiers) { int err; LOG_DBG("usage_page 0x%02X keycode 0x%02X mods 0x%02X", usage_page, keycode, implicit_modifiers); From 0e71dbc860e19f8eb269841a15b9fccd9ef7d37f Mon Sep 17 00:00:00 2001 From: innovaker <66737976+innovaker@users.noreply.github.com> Date: Sat, 19 Dec 2020 17:37:12 +0000 Subject: [PATCH 08/59] refactor(app): replace zmk_keymap_layers_state with zmk_keymap_layers_state_t Aligns with typedef _t convention. PR: #531 --- app/include/zmk/keymap.h | 4 ++-- app/src/keymap.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/include/zmk/keymap.h b/app/include/zmk/keymap.h index 7303d4aa..1070af71 100644 --- a/app/include/zmk/keymap.h +++ b/app/include/zmk/keymap.h @@ -6,10 +6,10 @@ #pragma once -typedef uint32_t zmk_keymap_layers_state; +typedef uint32_t zmk_keymap_layers_state_t; uint8_t zmk_keymap_layer_default(); -zmk_keymap_layers_state zmk_keymap_layer_state(); +zmk_keymap_layers_state_t zmk_keymap_layer_state(); bool zmk_keymap_layer_active(uint8_t layer); uint8_t zmk_keymap_highest_layer_active(); int zmk_keymap_layer_activate(uint8_t layer); diff --git a/app/src/keymap.c b/app/src/keymap.c index cafe2ffe..3a3d4e99 100644 --- a/app/src/keymap.c +++ b/app/src/keymap.c @@ -19,7 +19,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include #include -static zmk_keymap_layers_state _zmk_keymap_layer_state = 0; +static zmk_keymap_layers_state_t _zmk_keymap_layer_state = 0; static uint8_t _zmk_keymap_layer_default = 0; #define DT_DRV_COMPAT zmk_keymap @@ -88,7 +88,7 @@ static inline int set_layer_state(uint8_t layer, bool state) { uint8_t zmk_keymap_layer_default() { return _zmk_keymap_layer_default; } -zmk_keymap_layers_state zmk_keymap_layer_state() { return _zmk_keymap_layer_state; } +zmk_keymap_layers_state_t zmk_keymap_layer_state() { return _zmk_keymap_layer_state; } bool zmk_keymap_layer_active(uint8_t layer) { return (_zmk_keymap_layer_state & (BIT(layer))) == (BIT(layer)); @@ -115,7 +115,7 @@ int zmk_keymap_layer_toggle(uint8_t layer) { return zmk_keymap_layer_activate(layer); }; -bool is_active_layer(uint8_t layer, zmk_keymap_layers_state layer_state) { +bool is_active_layer(uint8_t layer, zmk_keymap_layers_state_t layer_state) { return (layer_state & BIT(layer)) == BIT(layer) || layer == _zmk_keymap_layer_default; } From 9a9f155e696935f4b576b4213b5256af8adbca93 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Fri, 11 Dec 2020 11:09:07 -0500 Subject: [PATCH 09/59] feature(ci): Build split w/ display enabled for testing. --- .github/workflows/build.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ac5bded1..0aee5d7f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -55,6 +55,7 @@ jobs: - splitreus62_right - tg4x - tidbit + cmake-args: [""] include: - board: dz60rgb_rev1 - board: nrf52840_m2 @@ -62,6 +63,14 @@ jobs: - board: planck_rev6 - board: proton_c shield: clueboard_california + - board: nice_nano + shield: kyria_left + cmake-args: -DCONFIG_ZMK_DISPLAY=y + skip-archive: true + - board: nice_nano + shield: kyria_right + cmake-args: -DCONFIG_ZMK_DISPLAY=y + skip-archive: true steps: - name: Checkout uses: actions/checkout@v2 @@ -104,8 +113,9 @@ jobs: echo ::set-output name=shield-arg::${SHIELD_ARG} echo ::set-output name=artifact-name::${ARTIFACT_NAME} - name: Build (west build) - run: west build -s app -b ${{ matrix.board }} -- ${{ steps.variables.outputs.shield-arg }} + run: west build -s app -b ${{ matrix.board }} -- ${{ steps.variables.outputs.shield-arg }} ${{ matrix.cmake-args }} - name: Archive artifacts + if: ${{ !matrix.skip-archive }} uses: actions/upload-artifact@v2 with: name: "${{ steps.variables.outputs.artifact-name }}" From 87dbd4ca28405ab3d17cf62f3df86581606279b7 Mon Sep 17 00:00:00 2001 From: KemoNine Date: Mon, 28 Dec 2020 20:17:32 -0500 Subject: [PATCH 10/59] Add uppermost, current layer status widget to oled (#493) * Add uppermost, current layer status widget to oled * Run clang format * Fixup display widget source includes in CMakeLists * Update layer widget to only be enabled on primary half of a split keyboard and shuffle some of the options specific to the widget to be enabled via the widget * Update to latest lvgl/zmk/zephyr ; remove version text from oled per PR * Fixup file names * Remove last remenants of the version display text from the oled * Fixup clang-format Co-authored-by: KemoNine --- .../zmk/display/widgets/layer_status.h | 18 +++++ app/src/display/CMakeLists.txt | 2 +- app/src/display/status_screen.c | 15 ++-- app/src/display/widgets/CMakeLists.txt | 1 + app/src/display/widgets/Kconfig | 6 ++ app/src/display/widgets/layer_status.c | 68 +++++++++++++++++++ 6 files changed, 104 insertions(+), 6 deletions(-) create mode 100644 app/include/zmk/display/widgets/layer_status.h create mode 100644 app/src/display/widgets/layer_status.c diff --git a/app/include/zmk/display/widgets/layer_status.h b/app/include/zmk/display/widgets/layer_status.h new file mode 100644 index 00000000..3779351a --- /dev/null +++ b/app/include/zmk/display/widgets/layer_status.h @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#pragma once + +#include +#include + +struct zmk_widget_layer_status { + sys_snode_t node; + lv_obj_t *obj; +}; + +int zmk_widget_layer_status_init(struct zmk_widget_layer_status *widget, lv_obj_t *parent); +lv_obj_t *zmk_widget_layer_status_obj(struct zmk_widget_layer_status *widget); \ No newline at end of file diff --git a/app/src/display/CMakeLists.txt b/app/src/display/CMakeLists.txt index 3b85fc0f..d289f074 100644 --- a/app/src/display/CMakeLists.txt +++ b/app/src/display/CMakeLists.txt @@ -4,4 +4,4 @@ target_sources_ifdef(CONFIG_ZMK_DISPLAY app PRIVATE main.c) target_sources_ifdef(CONFIG_ZMK_DISPLAY_STATUS_SCREEN_BUILT_IN app PRIVATE status_screen.c) -add_subdirectory(widgets/) \ No newline at end of file +add_subdirectory_ifdef(CONFIG_ZMK_DISPLAY widgets/) diff --git a/app/src/display/status_screen.c b/app/src/display/status_screen.c index 9a5c7b41..0c88717a 100644 --- a/app/src/display/status_screen.c +++ b/app/src/display/status_screen.c @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -19,14 +20,15 @@ static struct zmk_widget_battery_status battery_status_widget; static struct zmk_widget_output_status output_status_widget; #endif +#if IS_ENABLED(CONFIG_ZMK_WIDGET_LAYER_STATUS) +static struct zmk_widget_layer_status layer_status_widget; +#endif + lv_obj_t *zmk_display_status_screen() { lv_obj_t *screen; - lv_obj_t *zmk_version_label; screen = lv_obj_create(NULL, NULL); - zmk_version_label = lv_label_create(screen, NULL); - #if IS_ENABLED(CONFIG_ZMK_WIDGET_BATTERY_STATUS) zmk_widget_battery_status_init(&battery_status_widget, screen); lv_obj_align(zmk_widget_battery_status_obj(&battery_status_widget), NULL, LV_ALIGN_IN_TOP_RIGHT, @@ -39,8 +41,11 @@ lv_obj_t *zmk_display_status_screen() { 0); #endif - lv_label_set_text(zmk_version_label, "ZMK v0.1.0"); - lv_obj_align(zmk_version_label, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0); +#if IS_ENABLED(CONFIG_ZMK_WIDGET_LAYER_STATUS) + zmk_widget_layer_status_init(&layer_status_widget, screen); + lv_obj_align(zmk_widget_layer_status_obj(&layer_status_widget), NULL, LV_ALIGN_IN_BOTTOM_LEFT, + 0, 0); +#endif return screen; } diff --git a/app/src/display/widgets/CMakeLists.txt b/app/src/display/widgets/CMakeLists.txt index 1d4cca1f..ad7e132a 100644 --- a/app/src/display/widgets/CMakeLists.txt +++ b/app/src/display/widgets/CMakeLists.txt @@ -3,3 +3,4 @@ target_sources_ifdef(CONFIG_ZMK_WIDGET_BATTERY_STATUS app PRIVATE battery_status.c) target_sources_ifdef(CONFIG_ZMK_WIDGET_OUTPUT_STATUS app PRIVATE output_status.c) +target_sources_ifdef(CONFIG_ZMK_WIDGET_LAYER_STATUS app PRIVATE layer_status.c) diff --git a/app/src/display/widgets/Kconfig b/app/src/display/widgets/Kconfig index 01bc587e..bdb3024e 100644 --- a/app/src/display/widgets/Kconfig +++ b/app/src/display/widgets/Kconfig @@ -3,6 +3,12 @@ menu "ZMK Display Widgets" +config ZMK_WIDGET_LAYER_STATUS + bool "Widget for highest, active layer using small icons" + default y + depends on !ZMK_SPLIT || ZMK_SPLIT_BLE_ROLE_CENTRAL + select LVGL_FONT_MONTSERRAT_12 + config ZMK_WIDGET_BATTERY_STATUS bool "Widget for battery charge information, using small icons" depends on BT diff --git a/app/src/display/widgets/layer_status.c b/app/src/display/widgets/layer_status.c new file mode 100644 index 00000000..fb9f6897 --- /dev/null +++ b/app/src/display/widgets/layer_status.c @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include +LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); + +#include +#include +#include +#include +#include + +static sys_slist_t widgets = SYS_SLIST_STATIC_INIT(&widgets); +static lv_style_t label_style; + +static bool style_initialized = false; + +void layer_status_init() { + if (style_initialized) { + return; + } + + style_initialized = true; + lv_style_init(&label_style); + lv_style_set_text_color(&label_style, LV_STATE_DEFAULT, LV_COLOR_BLACK); + lv_style_set_text_font(&label_style, LV_STATE_DEFAULT, &lv_font_montserrat_12); + lv_style_set_text_letter_space(&label_style, LV_STATE_DEFAULT, 1); + lv_style_set_text_line_space(&label_style, LV_STATE_DEFAULT, 1); +} + +void set_layer_symbol(lv_obj_t *label) { + int active_layer_index = zmk_keymap_highest_layer_active(); + char text[6] = {}; + + LOG_DBG("Layer changed to %i", active_layer_index); + sprintf(text, LV_SYMBOL_KEYBOARD "%i ", active_layer_index); + + lv_label_set_text(label, text); +} + +int zmk_widget_layer_status_init(struct zmk_widget_layer_status *widget, lv_obj_t *parent) { + layer_status_init(); + widget->obj = lv_label_create(parent, NULL); + lv_obj_add_style(widget->obj, LV_LABEL_PART_MAIN, &label_style); + + lv_obj_set_size(widget->obj, 40, 15); + set_layer_symbol(widget->obj); + + sys_slist_append(&widgets, &widget->node); + + return 0; +} + +lv_obj_t *zmk_widget_layer_status_obj(struct zmk_widget_layer_status *widget) { + return widget->obj; +} + +int layer_status_listener(const struct zmk_event_header *eh) { + struct zmk_widget_layer_status *widget; + SYS_SLIST_FOR_EACH_CONTAINER(&widgets, widget, node) { set_layer_symbol(widget->obj); } + return 0; +} + +ZMK_LISTENER(widget_layer_status, layer_status_listener) +ZMK_SUBSCRIPTION(widget_layer_status, layer_state_changed); \ No newline at end of file From 43f6d798be70ef247b0717730ec34202cb81e96d Mon Sep 17 00:00:00 2001 From: Nick Winans Date: Tue, 15 Dec 2020 13:22:16 -0600 Subject: [PATCH 11/59] feat(ext-power): Cut power when PM is sleeping --- app/Kconfig | 3 +++ app/src/ext_power_generic.c | 46 +++++++++++++++++++++++++++++++++++++ app/src/power.c | 4 ++++ 3 files changed, 53 insertions(+) diff --git a/app/Kconfig b/app/Kconfig index acb288cb..4341df11 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -234,6 +234,9 @@ choice SYS_PM_POLICY default SYS_PM_POLICY_APP endchoice +config DEVICE_POWER_MANAGEMENT + default y + config ZMK_IDLE_SLEEP_TIMEOUT int "Milliseconds of inactivity before entering deep sleep" default 900000 diff --git a/app/src/ext_power_generic.c b/app/src/ext_power_generic.c index 7e42d495..c2e89ab8 100644 --- a/app/src/ext_power_generic.c +++ b/app/src/ext_power_generic.c @@ -31,6 +31,9 @@ struct ext_power_generic_data { #if IS_ENABLED(CONFIG_SETTINGS) bool settings_init; #endif +#ifdef CONFIG_DEVICE_POWER_MANAGEMENT + uint32_t pm_state; +#endif }; #if IS_ENABLED(CONFIG_SETTINGS) @@ -139,6 +142,10 @@ static int ext_power_generic_init(const struct device *dev) { return -EIO; } +#ifdef CONFIG_DEVICE_POWER_MANAGEMENT + data->pm_state = DEVICE_PM_ACTIVE_STATE; +#endif + #if IS_ENABLED(CONFIG_SETTINGS) settings_subsys_init(); @@ -167,6 +174,39 @@ static int ext_power_generic_init(const struct device *dev) { return 0; } +#ifdef CONFIG_DEVICE_POWER_MANAGEMENT +static int ext_power_generic_pm_control(const struct device *dev, uint32_t ctrl_command, + void *context, device_pm_cb cb, void *arg) { + int rc; + struct ext_power_generic_data *data = dev->driver_data; + + switch (ctrl_command) { + case DEVICE_PM_SET_POWER_STATE: + if (*((uint32_t *)context) == DEVICE_PM_ACTIVE_STATE) { + data->pm_state = DEVICE_PM_ACTIVE_STATE; + rc = 0; + } else { + ext_power_generic_disable(dev); + data->pm_state = DEVICE_PM_LOW_POWER_STATE; + rc = 0; + } + break; + case DEVICE_PM_GET_POWER_STATE: + *((uint32_t *)context) = data->pm_state; + rc = 0; + break; + default: + rc = -EINVAL; + } + + if (cb != NULL) { + cb(dev, rc, context, arg); + } + + return rc; +} +#endif /* CONFIG_DEVICE_POWER_MANAGEMENT */ + static const struct ext_power_generic_config config = { .label = DT_INST_GPIO_LABEL(0, control_gpios), .pin = DT_INST_GPIO_PIN(0, control_gpios), @@ -183,7 +223,13 @@ static const struct ext_power_api api = {.enable = ext_power_generic_enable, .disable = ext_power_generic_disable, .get = ext_power_generic_get}; +#ifdef CONFIG_DEVICE_POWER_MANAGEMENT +DEVICE_DEFINE(ext_power_generic, DT_INST_LABEL(0), ext_power_generic_init, + &ext_power_generic_pm_control, &data, &config, APPLICATION, + CONFIG_APPLICATION_INIT_PRIORITY, &api); +#else DEVICE_AND_API_INIT(ext_power_generic, DT_INST_LABEL(0), ext_power_generic_init, &data, &config, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY, &api); +#endif /* CONFIG_DEVICE_POWER_MANAGEMENT */ #endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */ diff --git a/app/src/power.c b/app/src/power.c index d014a524..4af18cf4 100644 --- a/app/src/power.c +++ b/app/src/power.c @@ -34,3 +34,7 @@ enum power_states sys_pm_policy_next_state(int32_t ticks) { return SYS_POWER_STATE_ACTIVE; } + +bool sys_pm_policy_low_power_devices(enum power_states pm_state) { + return sys_pm_is_sleep_state(pm_state); +} \ No newline at end of file From d207c3c30f7f2d0648b32d59f481498fe048230c Mon Sep 17 00:00:00 2001 From: KemoNine Date: Tue, 29 Dec 2020 11:57:49 -0500 Subject: [PATCH 12/59] (feature) Add &to keycode/behavior (#489) feat(behaviors): Add `&to` behavior to switch to a layer. --- app/CMakeLists.txt | 1 + app/dts/behaviors.dtsi | 1 + app/dts/behaviors/to_layer.dtsi | 15 +++++++ .../behaviors/zmk,behavior-to-layer.yaml | 8 ++++ app/include/zmk/keymap.h | 1 + app/src/behaviors/behavior_to_layer.c | 38 +++++++++++++++++ app/src/keymap.c | 42 ++++++++++++++----- app/tests/to-layer/behavior_keymap.dtsi | 22 ++++++++++ app/tests/to-layer/normal/events.patterns | 3 ++ .../to-layer/normal/keycode_events.snapshot | 18 ++++++++ app/tests/to-layer/normal/native_posix.keymap | 29 +++++++++++++ docs/docs/behaviors/layers.md | 15 +++++++ 12 files changed, 183 insertions(+), 10 deletions(-) create mode 100644 app/dts/behaviors/to_layer.dtsi create mode 100644 app/dts/bindings/behaviors/zmk,behavior-to-layer.yaml create mode 100644 app/src/behaviors/behavior_to_layer.c create mode 100644 app/tests/to-layer/behavior_keymap.dtsi create mode 100644 app/tests/to-layer/normal/events.patterns create mode 100644 app/tests/to-layer/normal/keycode_events.snapshot create mode 100644 app/tests/to-layer/normal/native_posix.keymap diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 9e0612de..5fb3827c 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -47,6 +47,7 @@ if ((NOT CONFIG_ZMK_SPLIT) OR CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) target_sources(app PRIVATE src/behaviors/behavior_momentary_layer.c) target_sources(app PRIVATE src/behaviors/behavior_outputs.c) target_sources(app PRIVATE src/behaviors/behavior_toggle_layer.c) + target_sources(app PRIVATE src/behaviors/behavior_to_layer.c) target_sources(app PRIVATE src/behaviors/behavior_transparent.c) target_sources(app PRIVATE src/behaviors/behavior_none.c) target_sources(app PRIVATE src/behaviors/behavior_sensor_rotate_key_press.c) diff --git a/app/dts/behaviors.dtsi b/app/dts/behaviors.dtsi index 9a64fc6c..daa073f1 100644 --- a/app/dts/behaviors.dtsi +++ b/app/dts/behaviors.dtsi @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include diff --git a/app/dts/behaviors/to_layer.dtsi b/app/dts/behaviors/to_layer.dtsi new file mode 100644 index 00000000..b09616ff --- /dev/null +++ b/app/dts/behaviors/to_layer.dtsi @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +/ { + behaviors { + to: behavior_to_layer { + compatible = "zmk,behavior-to-layer"; + label = "TO_LAYER"; + #binding-cells = <1>; + }; + }; +}; diff --git a/app/dts/bindings/behaviors/zmk,behavior-to-layer.yaml b/app/dts/bindings/behaviors/zmk,behavior-to-layer.yaml new file mode 100644 index 00000000..cbafddf7 --- /dev/null +++ b/app/dts/bindings/behaviors/zmk,behavior-to-layer.yaml @@ -0,0 +1,8 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + +description: To Layer + +compatible: "zmk,behavior-to-layer" + +include: one_param.yaml diff --git a/app/include/zmk/keymap.h b/app/include/zmk/keymap.h index 1070af71..9192772f 100644 --- a/app/include/zmk/keymap.h +++ b/app/include/zmk/keymap.h @@ -15,5 +15,6 @@ uint8_t zmk_keymap_highest_layer_active(); int zmk_keymap_layer_activate(uint8_t layer); int zmk_keymap_layer_deactivate(uint8_t layer); int zmk_keymap_layer_toggle(uint8_t layer); +int zmk_keymap_layer_to(uint8_t layer); int zmk_keymap_position_state_changed(uint32_t position, bool pressed, int64_t timestamp); diff --git a/app/src/behaviors/behavior_to_layer.c b/app/src/behaviors/behavior_to_layer.c new file mode 100644 index 00000000..3ec1bf81 --- /dev/null +++ b/app/src/behaviors/behavior_to_layer.c @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#define DT_DRV_COMPAT zmk_behavior_to_layer + +#include +#include +#include + +#include +#include + +LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); + +static int behavior_to_init(const struct device *dev) { return 0; }; + +static int to_keymap_binding_pressed(struct zmk_behavior_binding *binding, + struct zmk_behavior_binding_event event) { + LOG_DBG("position %d layer %d", event.position, binding->param1); + return zmk_keymap_layer_to(binding->param1); +} + +static int to_keymap_binding_released(struct zmk_behavior_binding *binding, + struct zmk_behavior_binding_event event) { + LOG_DBG("position %d layer %d", event.position, binding->param1); + return 0; +} + +static const struct behavior_driver_api behavior_to_driver_api = { + .binding_pressed = to_keymap_binding_pressed, + .binding_released = to_keymap_binding_released, +}; + +DEVICE_AND_API_INIT(behavior_to, DT_INST_LABEL(0), behavior_to_init, NULL, NULL, APPLICATION, + CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_to_driver_api); diff --git a/app/src/keymap.c b/app/src/keymap.c index 3a3d4e99..786a1773 100644 --- a/app/src/keymap.c +++ b/app/src/keymap.c @@ -78,11 +78,23 @@ static struct zmk_behavior_binding zmk_sensor_keymap[ZMK_KEYMAP_LAYERS_LEN] #endif /* ZMK_KEYMAP_HAS_SENSORS */ static inline int set_layer_state(uint8_t layer, bool state) { - if (layer >= 32) { + if (layer >= ZMK_KEYMAP_LAYERS_LEN) { return -EINVAL; } + + // Default layer should *always* remain active + if (layer == _zmk_keymap_layer_default && !state) { + return 0; + } + + zmk_keymap_layers_state_t old_state = _zmk_keymap_layer_state; WRITE_BIT(_zmk_keymap_layer_state, layer, state); - ZMK_EVENT_RAISE(create_layer_state_changed(layer, state)); + // Don't send state changes unless there was an actual change + if (old_state != _zmk_keymap_layer_state) { + LOG_DBG("layer_changed: layer %d state %d", layer, state); + ZMK_EVENT_RAISE(create_layer_state_changed(layer, state)); + } + return 0; } @@ -90,12 +102,18 @@ uint8_t zmk_keymap_layer_default() { return _zmk_keymap_layer_default; } zmk_keymap_layers_state_t zmk_keymap_layer_state() { return _zmk_keymap_layer_state; } +bool zmk_keymap_layer_active_with_state(uint8_t layer, zmk_keymap_layers_state_t state_to_test) { + // The default layer is assumed to be ALWAYS ACTIVE so we include an || here to ensure nobody + // breaks up that assumption by accident + return (state_to_test & (BIT(layer))) == (BIT(layer)) || layer == _zmk_keymap_layer_default; +}; + bool zmk_keymap_layer_active(uint8_t layer) { - return (_zmk_keymap_layer_state & (BIT(layer))) == (BIT(layer)); + return zmk_keymap_layer_active_with_state(layer, _zmk_keymap_layer_state); }; uint8_t zmk_keymap_highest_layer_active() { - for (uint8_t layer = 31; layer > 0; layer--) { + for (uint8_t layer = ZMK_KEYMAP_LAYERS_LEN - 1; layer > 0; layer--) { if (zmk_keymap_layer_active(layer)) { return layer; } @@ -115,8 +133,14 @@ int zmk_keymap_layer_toggle(uint8_t layer) { return zmk_keymap_layer_activate(layer); }; -bool is_active_layer(uint8_t layer, zmk_keymap_layers_state_t layer_state) { - return (layer_state & BIT(layer)) == BIT(layer) || layer == _zmk_keymap_layer_default; +int zmk_keymap_layer_to(uint8_t layer) { + for (int i = ZMK_KEYMAP_LAYERS_LEN - 1; i >= 0; i--) { + zmk_keymap_layer_deactivate(i); + } + + zmk_keymap_layer_activate(layer); + + return 0; } int zmk_keymap_apply_position_state(int layer, uint32_t position, bool pressed, int64_t timestamp) { @@ -150,7 +174,7 @@ int zmk_keymap_position_state_changed(uint32_t position, bool pressed, int64_t t zmk_keymap_active_behavior_layer[position] = _zmk_keymap_layer_state; } for (int layer = ZMK_KEYMAP_LAYERS_LEN - 1; layer >= _zmk_keymap_layer_default; layer--) { - if (is_active_layer(layer, zmk_keymap_active_behavior_layer[position])) { + if (zmk_keymap_layer_active_with_state(layer, zmk_keymap_active_behavior_layer[position])) { int ret = zmk_keymap_apply_position_state(layer, position, pressed, timestamp); if (ret > 0) { LOG_DBG("behavior processing to continue to next layer"); @@ -171,9 +195,7 @@ int zmk_keymap_position_state_changed(uint32_t position, bool pressed, int64_t t int zmk_keymap_sensor_triggered(uint8_t sensor_number, const struct device *sensor, int64_t timestamp) { for (int layer = ZMK_KEYMAP_LAYERS_LEN - 1; layer >= _zmk_keymap_layer_default; layer--) { - if (((_zmk_keymap_layer_state & BIT(layer)) == BIT(layer) || - layer == _zmk_keymap_layer_default) && - zmk_sensor_keymap[layer] != NULL) { + if (zmk_keymap_layer_active(layer) && zmk_sensor_keymap[layer] != NULL) { struct zmk_behavior_binding *binding = &zmk_sensor_keymap[layer][sensor_number]; const struct device *behavior; int ret; diff --git a/app/tests/to-layer/behavior_keymap.dtsi b/app/tests/to-layer/behavior_keymap.dtsi new file mode 100644 index 00000000..81e7e809 --- /dev/null +++ b/app/tests/to-layer/behavior_keymap.dtsi @@ -0,0 +1,22 @@ +#include +#include +#include + +/ { + keymap { + compatible = "zmk,keymap"; + label ="Default keymap"; + + default_layer { + bindings = < + &to 0 &to 1 + &kp A &kp S>; + }; + + second_layer { + bindings = < + &to 0 &to 1 + &kp J &kp K>; + }; + }; +}; diff --git a/app/tests/to-layer/normal/events.patterns b/app/tests/to-layer/normal/events.patterns new file mode 100644 index 00000000..fcebc4b0 --- /dev/null +++ b/app/tests/to-layer/normal/events.patterns @@ -0,0 +1,3 @@ +s/.*hid_listener_keycode/kp/p +s/.*to_keymap_binding/to/p +s/.*layer_changed/layer_changed/p \ No newline at end of file diff --git a/app/tests/to-layer/normal/keycode_events.snapshot b/app/tests/to-layer/normal/keycode_events.snapshot new file mode 100644 index 00000000..930a977a --- /dev/null +++ b/app/tests/to-layer/normal/keycode_events.snapshot @@ -0,0 +1,18 @@ +kp_pressed: usage_page 0x07 keycode 0x16 mods 0x00 +kp_released: usage_page 0x07 keycode 0x16 mods 0x00 +to_pressed: position 1 layer 1 +layer_changed: layer 1 state 1 +to_released: position 1 layer 1 +kp_pressed: usage_page 0x07 keycode 0x0e mods 0x00 +kp_released: usage_page 0x07 keycode 0x0e mods 0x00 +to_pressed: position 0 layer 0 +layer_changed: layer 1 state 0 +layer_changed: layer 0 state 1 +to_released: position 0 layer 0 +kp_pressed: usage_page 0x07 keycode 0x16 mods 0x00 +kp_released: usage_page 0x07 keycode 0x16 mods 0x00 +to_pressed: position 0 layer 0 +to_released: position 0 layer 0 +to_pressed: position 1 layer 1 +layer_changed: layer 1 state 1 +to_released: position 1 layer 1 diff --git a/app/tests/to-layer/normal/native_posix.keymap b/app/tests/to-layer/normal/native_posix.keymap new file mode 100644 index 00000000..056341f7 --- /dev/null +++ b/app/tests/to-layer/normal/native_posix.keymap @@ -0,0 +1,29 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +// Press key A +// To layer 1 +// Press key J +// To layer 0 +// Press key S +// To layer 0 -- does nothing + +&kscan { + events = ; +}; \ No newline at end of file diff --git a/docs/docs/behaviors/layers.md b/docs/docs/behaviors/layers.md index fcfdc93a..35e37aef 100644 --- a/docs/docs/behaviors/layers.md +++ b/docs/docs/behaviors/layers.md @@ -57,6 +57,21 @@ Example: < LOWER SPACE ``` +## To Layer + +The "to layer" behavior enables a layer and disables _all_ other layers _except_ the default layer. + +### Behavior Binding + +- Reference: `&to` +- Parameter: The layer number to enable, e.g. `1` + +Example: + +``` +&to 3 +``` + ## Toggle Layer The "toggle layer" behavior enables a layer until the layer is manually disabled. From 1c822754c018ad88e281f834f62b38a690ce38c2 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Tue, 29 Dec 2020 23:30:30 -0500 Subject: [PATCH 13/59] fix(west): Restore atmel west module. --- app/west.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/west.yml b/app/west.yml index d49eee9a..ca5efad2 100644 --- a/app/west.yml +++ b/app/west.yml @@ -15,7 +15,6 @@ manifest: # TODO: Rename once upstream offers option like `exclude` or `denylist` name-blacklist: - ci-tools - - hal_atmel - hal_altera - hal_cypress - hal_infineon From d6988477692f6892096885ed39953a7814a8f53a Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Wed, 30 Dec 2020 09:29:57 -0500 Subject: [PATCH 14/59] fix(power): Fix for 2.4 API changes. --- app/src/ext_power_generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/ext_power_generic.c b/app/src/ext_power_generic.c index c2e89ab8..d8e7844e 100644 --- a/app/src/ext_power_generic.c +++ b/app/src/ext_power_generic.c @@ -178,7 +178,7 @@ static int ext_power_generic_init(const struct device *dev) { static int ext_power_generic_pm_control(const struct device *dev, uint32_t ctrl_command, void *context, device_pm_cb cb, void *arg) { int rc; - struct ext_power_generic_data *data = dev->driver_data; + struct ext_power_generic_data *data = dev->data; switch (ctrl_command) { case DEVICE_PM_SET_POWER_STATE: From 5072590af523cf25941e05945d490d350f148797 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Wed, 30 Dec 2020 15:43:46 -0500 Subject: [PATCH 15/59] fix(sensors): Use status filter on sensors node. --- app/include/zmk/sensors.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/include/zmk/sensors.h b/app/include/zmk/sensors.h index 63dcade0..8c6c28b3 100644 --- a/app/include/zmk/sensors.h +++ b/app/include/zmk/sensors.h @@ -7,6 +7,6 @@ #pragma once #define ZMK_KEYMAP_SENSORS_NODE DT_INST(0, zmk_keymap_sensors) -#define ZMK_KEYMAP_HAS_SENSORS DT_NODE_EXISTS(ZMK_KEYMAP_SENSORS_NODE) +#define ZMK_KEYMAP_HAS_SENSORS DT_NODE_HAS_STATUS(ZMK_KEYMAP_SENSORS_NODE, okay) #define ZMK_KEYMAP_SENSORS_LEN DT_PROP_LEN(ZMK_KEYMAP_SENSORS_NODE, sensors) -#define ZMK_KEYMAP_SENSORS_BY_IDX(idx) DT_PHANDLE_BY_IDX(ZMK_KEYMAP_SENSORS_NODE, sensors, idx) \ No newline at end of file +#define ZMK_KEYMAP_SENSORS_BY_IDX(idx) DT_PHANDLE_BY_IDX(ZMK_KEYMAP_SENSORS_NODE, sensors, idx) From 39490552f2a84282143e0ec039fdaf4b2f309539 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Wed, 30 Dec 2020 15:44:03 -0500 Subject: [PATCH 16/59] feat(boards): Add BDN9 Rev2 board. * Onboard stm32f072. * 3 possible encoder positions. * Underglow/per-key not yet support. --- .github/workflows/build.yml | 1 + app/boards/arm/bdn9/Kconfig.board | 8 ++ app/boards/arm/bdn9/Kconfig.defconfig | 17 ++++ app/boards/arm/bdn9/README.md | 37 ++++++++ app/boards/arm/bdn9/bdn9_rev2.dts | 107 ++++++++++++++++++++++++ app/boards/arm/bdn9/bdn9_rev2.keymap | 38 +++++++++ app/boards/arm/bdn9/bdn9_rev2.yaml | 14 ++++ app/boards/arm/bdn9/bdn9_rev2_defconfig | 29 +++++++ app/boards/arm/bdn9/board.cmake | 7 ++ docs/docs/hardware.md | 1 + 10 files changed, 259 insertions(+) create mode 100644 app/boards/arm/bdn9/Kconfig.board create mode 100644 app/boards/arm/bdn9/Kconfig.defconfig create mode 100644 app/boards/arm/bdn9/README.md create mode 100644 app/boards/arm/bdn9/bdn9_rev2.dts create mode 100644 app/boards/arm/bdn9/bdn9_rev2.keymap create mode 100644 app/boards/arm/bdn9/bdn9_rev2.yaml create mode 100644 app/boards/arm/bdn9/bdn9_rev2_defconfig create mode 100644 app/boards/arm/bdn9/board.cmake diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0aee5d7f..288a2dee 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,6 +57,7 @@ jobs: - tidbit cmake-args: [""] include: + - board: bdn9_rev2 - board: dz60rgb_rev1 - board: nrf52840_m2 shield: m60 diff --git a/app/boards/arm/bdn9/Kconfig.board b/app/boards/arm/bdn9/Kconfig.board new file mode 100644 index 00000000..a67e9a51 --- /dev/null +++ b/app/boards/arm/bdn9/Kconfig.board @@ -0,0 +1,8 @@ +# keeb.io BDN9 board configuration + +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + +config BOARD_BDN9 + bool "BDN9 rev2" + depends on SOC_STM32F072XB diff --git a/app/boards/arm/bdn9/Kconfig.defconfig b/app/boards/arm/bdn9/Kconfig.defconfig new file mode 100644 index 00000000..9af7ca4c --- /dev/null +++ b/app/boards/arm/bdn9/Kconfig.defconfig @@ -0,0 +1,17 @@ +# keeb.io BDN9 board configuration + +# Copyright (c) 2020 Pete Johanson +# SPDX-License-Identifier: MIT + +if BOARD_BDN9 + +config BOARD + default "bdn9_rev2" + +config ZMK_KEYBOARD_NAME + default "BDN9 Rev2" + +config ZMK_USB + default y + +endif # BOARD_BDN9 diff --git a/app/boards/arm/bdn9/README.md b/app/boards/arm/bdn9/README.md new file mode 100644 index 00000000..7b4ef441 --- /dev/null +++ b/app/boards/arm/bdn9/README.md @@ -0,0 +1,37 @@ +# Building ZMK for the BDN9 + +Some general notes/commands for building standard BDN9 layouts from the assembly documentation. + +## Standard Build + +``` +west build -p -d build/bdn9 --board bdn9_rev2 +``` + +## Encoder Notes + +If you built your BDN9 with encoders, you'll need to change the following in your local BDN9 config or add them to the end of the file. + +``` +CONFIG_EC11=y +CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y +``` + +Then, you'll want to uncomment the necessary encoder lines in your `bdn9_rev2.keymap`: + +``` +&sensors { + status = "okay"; + sensors = <&left_encoder &mid_encoder &right_encoder>; +}; + +&left_encoder { status = "okay"; }; +&mid_encoder { status = "okay"; }; +&right_encoder { status = "okay"; }; +``` + +And then add the correct `sensor-bindings` array to each keymap layer, e.g.: + +``` +sensor-bindings = <&inc_dec_kp PG_UP PG_DN &inc_dec_kp M_VOLU M_VOLD &inc_dec_kp C_PREV C_NEXT>; +``` diff --git a/app/boards/arm/bdn9/bdn9_rev2.dts b/app/boards/arm/bdn9/bdn9_rev2.dts new file mode 100644 index 00000000..43854a16 --- /dev/null +++ b/app/boards/arm/bdn9/bdn9_rev2.dts @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +/dts-v1/; +#include + +/ { + model = "Keeb.io BDN9 rev2"; + compatible = "keebio,bdn9", "st,stm32f072"; + + chosen { + zephyr,sram = &sram0; + zephyr,flash = &flash0; + zmk,kscan = &kscan; + /* TODO: Enable once the GPIO bitbanging driver supports STM32 + zmk,underglow = &led_strip; + */ + }; + + kscan: kscan { + compatible = "zmk,kscan-gpio-direct"; + label = "KSCAN"; + + input-gpios + = <&gpiob 12 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&gpiob 5 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&gpiob 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&gpiob 14 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&gpiob 4 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&gpiob 7 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&gpioa 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&gpiof 1 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&gpiof 0 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + ; + }; + + /* + led_strip: ws2812 { + compatible = "worldsemi,ws2812-gpio"; + label = "WS2812"; + + in-gpios = <&gpiob 15 0>; + + chain-length = <9>; + }; + */ + + left_encoder: encoder_left { + compatible = "alps,ec11"; + label = "LEFT_ENCODER"; + a-gpios = <&gpioa 4 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + b-gpios = <&gpioa 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + resolution = <4>; + status = "disabled"; + }; + mid_encoder: encoder_mid { + compatible = "alps,ec11"; + label = "MID_ENCODER"; + a-gpios = <&gpioa 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + b-gpios = <&gpioa 10 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + resolution = <4>; + status = "disabled"; + }; + right_encoder: encoder_right { + compatible = "alps,ec11"; + label = "RIGHT_ENCODER"; + a-gpios = <&gpioa 15 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + b-gpios = <&gpiob 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + resolution = <4>; + status = "disabled"; + }; + + sensors: sensors { + compatible = "zmk,keymap-sensors"; + status = "disabled"; + sensors = <>; + }; +}; + +&usb { + status = "okay"; +}; + +&rtc { + status = "okay"; +}; + +&flash0 { + /* + * For more information, see: + * http://docs.zephyrproject.org/latest/guides/dts/index.html#flash-partitions + */ + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + /* Set 6Kb of storage at the end of the 128Kb of flash */ + storage_partition: partition@3e800 { + label = "storage"; + reg = <0x0001e800 0x00001800>; + }; + }; +}; diff --git a/app/boards/arm/bdn9/bdn9_rev2.keymap b/app/boards/arm/bdn9/bdn9_rev2.keymap new file mode 100644 index 00000000..50c273c7 --- /dev/null +++ b/app/boards/arm/bdn9/bdn9_rev2.keymap @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include +#include + +/* Uncomment and keep whatever encoders are on your BDN9 +&sensors { + status = "okay"; + sensors = <&left_encoder &mid_encoder &right_encoder>; +}; +*/ + +// Uncomment each encoder installed on your BDN9 +// &left_encoder { status = "okay"; }; +// &mid_encoder { status = "okay"; }; +// &right_encoder { status = "okay"; }; + +/ { + keymap { + compatible = "zmk,keymap"; + + default_layer { + bindings = < + &kp HOME &kp K_PP &kp END + &kp PG_UP &kp UP &kp PG_DN + &kp LEFT &kp DOWN &kp RIGHT + >; + /* Uncomment and add necessary bindings. This examples is for one encoder + sensor-bindings = <&inc_dec_kp PG_UP PG_DN>; + */ + }; + }; +}; + diff --git a/app/boards/arm/bdn9/bdn9_rev2.yaml b/app/boards/arm/bdn9/bdn9_rev2.yaml new file mode 100644 index 00000000..bbae8833 --- /dev/null +++ b/app/boards/arm/bdn9/bdn9_rev2.yaml @@ -0,0 +1,14 @@ +identifier: bdn9 +name: keeb.io BDN9 +type: mcu +arch: arm +toolchain: + - zephyr + - gnuarmemb + - xtools +ram: 40 +supported: + - encoders + - switches + - underglow + - per_key diff --git a/app/boards/arm/bdn9/bdn9_rev2_defconfig b/app/boards/arm/bdn9/bdn9_rev2_defconfig new file mode 100644 index 00000000..139cf853 --- /dev/null +++ b/app/boards/arm/bdn9/bdn9_rev2_defconfig @@ -0,0 +1,29 @@ +# SPDX-License-Identifier: MIT + +CONFIG_SOC_SERIES_STM32F0X=y +CONFIG_SOC_STM32F072XB=y +# 72MHz system clock +CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=72000000 + +# Floating Point Options +CONFIG_FPU=y + +# enable GPIO +CONFIG_GPIO=y + +# Needed to reduce this to size that will fit on F072 +CONFIG_HEAP_MEM_POOL_SIZE=1024 + +# clock configuration +CONFIG_CLOCK_CONTROL=y + +# Clock configuration for Cube Clock control driver +CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL=y +# use HSI as PLL input +CONFIG_CLOCK_STM32_PLL_SRC_HSI=y +# produce 72MHz clock at PLL output +CONFIG_CLOCK_STM32_PLL_PREDIV=1 +CONFIG_CLOCK_STM32_PLL_MULTIPLIER=12 +CONFIG_CLOCK_STM32_AHB_PRESCALER=1 +CONFIG_CLOCK_STM32_APB1_PRESCALER=2 +CONFIG_CLOCK_STM32_APB2_PRESCALER=1 diff --git a/app/boards/arm/bdn9/board.cmake b/app/boards/arm/bdn9/board.cmake new file mode 100644 index 00000000..4f430e12 --- /dev/null +++ b/app/boards/arm/bdn9/board.cmake @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: MIT + +board_runner_args(dfu-util "--pid=0483:df11" "--alt=0" "--dfuse") +board_runner_args(jlink "--device=STM32F072CB" "--speed=4000") + +include(${ZEPHYR_BASE}/boards/common/dfu-util.board.cmake) +include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) diff --git a/docs/docs/hardware.md b/docs/docs/hardware.md index 406b9ad8..89761c42 100644 --- a/docs/docs/hardware.md +++ b/docs/docs/hardware.md @@ -19,6 +19,7 @@ That being said, there are currently only a few specific [boards](/docs/faq#what - [nrfMicro](https://github.com/joric/nrfmicro) (`nrfmicro_13`, `nrfmicro_11`, `nrfmicro_11_flipped`) - [BlueMicro840](https://store.jpconstantineau.com/#/group/bluemicro) (`bluemicro840_v1`) - [QMK Proton-C](https://qmk.fm/proton-c/) (`proton_c`) +- [BDN9 Rev2](https://keeb.io/products/bdn9-rev-2-3x3-9-key-macropad-rotary-encoder-and-rgb) (`bdn9_rev2`) ## Keyboard Shields From 2b4fda6948970ef236791472c0f3e461a23abf33 Mon Sep 17 00:00:00 2001 From: Stephen Wu Date: Fri, 1 Jan 2021 03:06:40 -0800 Subject: [PATCH 17/59] docs(codes): improve macOS support data (volume, brightness, media controls) Codes: - K_VOLUME_UP, C_VOLUME_UP, K_VOLUME_DOWN, C_VOLUME_DOWN, K_MUTE - C_BRIGHTNESS_INC, C_BRIGHTNESS_DEC - C_PLAY_PAUSE, C_NEXT, C_PREVIOUS Tested on: - Catalina 10.15.7 - Big Sur 11.2 Beta PR: #541 See: #375 --- docs/src/data/hid.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/src/data/hid.js b/docs/src/data/hid.js index 35fc7fb7..ba3d2bf6 100644 --- a/docs/src/data/hid.js +++ b/docs/src/data/hid.js @@ -3218,7 +3218,7 @@ export default [ windows: null, linux: true, android: true, - macos: null, + macos: true, ios: null, }, footnotes: {}, @@ -3239,7 +3239,7 @@ export default [ windows: null, linux: true, android: true, - macos: null, + macos: false, ios: null, }, footnotes: {}, @@ -3260,7 +3260,7 @@ export default [ windows: null, linux: true, android: true, - macos: null, + macos: false, ios: null, }, footnotes: {}, @@ -5172,7 +5172,7 @@ export default [ windows: null, linux: true, android: null, - macos: null, + macos: true, ios: null, }, footnotes: {}, @@ -5193,7 +5193,7 @@ export default [ windows: null, linux: true, android: null, - macos: null, + macos: true, ios: null, }, footnotes: {}, @@ -5886,7 +5886,7 @@ export default [ windows: null, linux: true, android: true, - macos: null, + macos: true, ios: null, }, footnotes: {}, @@ -5907,7 +5907,7 @@ export default [ windows: null, linux: true, android: true, - macos: null, + macos: true, ios: null, }, footnotes: {}, @@ -6054,7 +6054,7 @@ export default [ windows: null, linux: true, android: true, - macos: null, + macos: true, ios: null, }, footnotes: {}, @@ -6138,7 +6138,7 @@ export default [ windows: null, linux: true, android: true, - macos: null, + macos: true, ios: null, }, footnotes: {}, @@ -6159,7 +6159,7 @@ export default [ windows: null, linux: true, android: true, - macos: null, + macos: true, ios: null, }, footnotes: {}, From 5752b4fbda757768e5356a99750066df53aee0a7 Mon Sep 17 00:00:00 2001 From: Mango The Fourth <40720523+MangoIV@users.noreply.github.com> Date: Fri, 1 Jan 2021 15:33:19 +0100 Subject: [PATCH 18/59] feat(shields): add eek shield PR: #529 --- .github/workflows/build.yml | 1 + app/boards/shields/eek/Kconfig.defconfig | 12 +++++ app/boards/shields/eek/Kconfig.shield | 8 ++++ app/boards/shields/eek/eek.conf | 0 app/boards/shields/eek/eek.keymap | 56 ++++++++++++++++++++++++ app/boards/shields/eek/eek.overlay | 52 ++++++++++++++++++++++ app/boards/shields/eek/readme.md | 1 + docs/docs/hardware.md | 1 + docs/static/setup.ps1 | 6 +-- docs/static/setup.sh | 3 +- 10 files changed, 136 insertions(+), 4 deletions(-) create mode 100644 app/boards/shields/eek/Kconfig.defconfig create mode 100644 app/boards/shields/eek/Kconfig.shield create mode 100644 app/boards/shields/eek/eek.conf create mode 100644 app/boards/shields/eek/eek.keymap create mode 100644 app/boards/shields/eek/eek.overlay create mode 100644 app/boards/shields/eek/readme.md diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 288a2dee..1c2a5119 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,6 +29,7 @@ jobs: - cradio_left - cradio_right - crbn + - eek - iris_left - iris_right - jian_left diff --git a/app/boards/shields/eek/Kconfig.defconfig b/app/boards/shields/eek/Kconfig.defconfig new file mode 100644 index 00000000..65d69b7d --- /dev/null +++ b/app/boards/shields/eek/Kconfig.defconfig @@ -0,0 +1,12 @@ +# +# Copyright (c) 2020 The ZMK Contributors +# +# SPDX-License-Identifier: MIT +# + +if SHIELD_EEK + +config ZMK_KEYBOARD_NAME + default "eek! ~ Keyboard" + +endif \ No newline at end of file diff --git a/app/boards/shields/eek/Kconfig.shield b/app/boards/shields/eek/Kconfig.shield new file mode 100644 index 00000000..220b63ea --- /dev/null +++ b/app/boards/shields/eek/Kconfig.shield @@ -0,0 +1,8 @@ + # + # Copyright (c) 2020 The ZMK Contributors + # + # SPDX-License-Identifier: MIT + # + +config SHIELD_EEK + def_bool $(shields_list_contains,eek) \ No newline at end of file diff --git a/app/boards/shields/eek/eek.conf b/app/boards/shields/eek/eek.conf new file mode 100644 index 00000000..e69de29b diff --git a/app/boards/shields/eek/eek.keymap b/app/boards/shields/eek/eek.keymap new file mode 100644 index 00000000..f54dc013 --- /dev/null +++ b/app/boards/shields/eek/eek.keymap @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include +#include +#include +#include + +/ { + keymap { + compatible = "zmk,keymap"; + + default { +// -------------------------------------------------------------------------------------------------------------------------------------------------------------------- +// Q | W | E | R | T | | Y | U | I | O | P | +// A | S | D | F | G | | H | J | K | L | ; | +// Lsft/Z| X | C | V | B | | N | M | , | . |Rsft//| +// | LCTL | Bspc/LMOD | SPC | | Del/Num | Ent | Sym | + bindings = < + &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P + &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SEMI + &mt LSHFT Z &kp X &kp C &kp V &kp B &kp N &kp M &kp COMMA &kp DOT &mt RSHFT FSLH + &kp LCTRL &mt LGUI BSPC &kp SPACE < 1 DEL &kp RET &mo 2 + >; + }; + numbers { +// -------------------------------------------------------------------------------------------------------------------------------------------------------------------- +// 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | +// TAB | BT_PRV | BT_NXT | VOL-| VOL+| | < | v | ∧ | > | ' | +// Lsft| BT_SEL0| BT_CLR | MUTE| | | HOME| END | PGUP| PGDN| Rsft| +// | LCTL | LMOD| LALT | | Num | | BL-reset | + bindings = < + &kp N1 &kp N2 &kp N3 &kp N4 &kp N5 &kp N6 &kp N7 &kp N8 &kp N9 &kp N0 + &kp TAB &bt BT_PRV &bt BT_NXT &kp C_VOL_DN &kp C_VOL_UP &kp LEFT &kp DOWN &kp UP &kp RIGHT &kp SQT + &kp LSHFT &bt BT_SEL 0 &bt BT_CLR &kp C_MUTE &none &kp HOME &kp END &kp PG_UP &kp PG_DN &kp RSHFT + &kp LCTRL &kp LGUI &kp LALT &trans &none &bootloader + >; + }; + symbols { +// -------------------------------------------------------------------------------------------------------------------------------------------------------------------- +// ESC | F1 | F2 | F3 | F4 | | OUT_USB | OUT_BLE | | = | - | +// CAPS| F5 | F6 | F7 | F8 | | [ | ] | | ` | \ | +// LSFT| F9 | F10 | F11 | F12 | | | | | | RSFT | +// | LCTL | LMOD| LALT | | RESET | | SYM | + bindings = < + &kp ESC &kp F1 &kp F2 &kp F3 &kp F4 &out OUT_USB &out OUT_BLE &none &kp EQUAL &kp MINUS + &kp CAPS &kp F5 &kp F6 &kp F7 &kp F8 &kp LBKT &kp RBKT &none &kp GRAVE &kp BSLH + &kp LSHFT &kp F9 &kp F10 &kp F11 &kp F12 &none &none &none &kp RSHFT + &kp LCTRL &kp LGUI &kp LALT &reset &none &trans + >; + }; + }; +}; \ No newline at end of file diff --git a/app/boards/shields/eek/eek.overlay b/app/boards/shields/eek/eek.overlay new file mode 100644 index 00000000..11b98686 --- /dev/null +++ b/app/boards/shields/eek/eek.overlay @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include + +/ { + chosen { + zmk,kscan = &kscan0; + zmk,matrix_transform = &default_transform; + }; + + default_transform: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + columns = <10>; + rows = <4>; + map = < + RC(0,9) RC(0,8) RC(0,7) RC(0,6) RC(0,5) RC(0,4) RC(0,3) RC(0,2) RC(0,1) RC(0,0) + RC(1,9) RC(1,8) RC(1,7) RC(1,6) RC(1,5) RC(1,4) RC(1,3) RC(1,2) RC(1,1) RC(1,0) + RC(2,9) RC(2,8) RC(2,7) RC(2,6) RC(2,5) RC(2,4) RC(2,3) RC(2,2) RC(2,1) RC(2,0) + RC(3,7) RC(3,6) RC(3,5) RC(3,4) RC(3,3) RC(3,2) + >; + }; + + kscan0: kscan_0 { + compatible = "zmk,kscan-gpio-matrix"; + label = "KSCAN"; + diode-direction = "col2row"; + + col-gpios + = <&pro_micro_d 4 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 5 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 10 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 16 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 14 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 15 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 0 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 1 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 2 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 3 GPIO_ACTIVE_HIGH> + ; + + row-gpios + = <&pro_micro_d 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + ; + }; +}; \ No newline at end of file diff --git a/app/boards/shields/eek/readme.md b/app/boards/shields/eek/readme.md new file mode 100644 index 00000000..77e7be06 --- /dev/null +++ b/app/boards/shields/eek/readme.md @@ -0,0 +1 @@ +A fixed split 36key-board with a typing angle of 90 degrees distributed by cbkbd \ No newline at end of file diff --git a/docs/docs/hardware.md b/docs/docs/hardware.md index 89761c42..98f8715f 100644 --- a/docs/docs/hardware.md +++ b/docs/docs/hardware.md @@ -37,6 +37,7 @@ That being said, there are currently only a few specific [boards](/docs/faq#what - [QAZ](https://www.cbkbd.com/product/qaz-keyboard-kit) (`qaz`) - [CRBN](https://keygem.store/collections/group-buys/products/group-buy-featherlight-40-kit) (`crbn`) - [tidbit](https://nullbits.co/tidbit/) (`tidbit`) +- [Eek!](https://www.cbkbd.com/product/eek-keyboard) (`eek`) ## Other Hardware diff --git a/docs/static/setup.ps1 b/docs/static/setup.ps1 index a2193228..a521934e 100644 --- a/docs/static/setup.ps1 +++ b/docs/static/setup.ps1 @@ -91,9 +91,9 @@ Write-Host "Keyboard Shield Selection:" $prompt = "Pick a keyboard" # TODO: Add support for "Other" and linking to docs on adding custom shields in user config repos. -$options = "Kyria", "Lily58", "Corne", "Splitreus62", "Sofle", "Iris", "Reviung41", "RoMac", "RoMac+", "makerdiary M60", "Microdox", "TG4X", "QAZ", "NIBBLE", "Jorne", "Jian", "CRBN", "Tidbit" -$names = "kyria", "lily58", "corne", "splitreus62", "sofle", "iris", "reviung41", "romac", "romac_plus", "m60", "microdox", "tg4x", "qaz", "nibble", "jorne", "jian", "crbn", "tidbit" -$splits = "y", "y", "y", "y", "y", "y", "n", "n", "n", "n", "y", "n", "n", "n", "y", "y", "n", "n" +$options = "Kyria", "Lily58", "Corne", "Splitreus62", "Sofle", "Iris", "Reviung41", "RoMac", "RoMac+", "makerdiary M60", "Microdox", "TG4X", "QAZ", "NIBBLE", "Jorne", "Jian", "CRBN", "Tidbit", "Eek!" +$names = "kyria", "lily58", "corne", "splitreus62", "sofle", "iris", "reviung41", "romac", "romac_plus", "m60", "microdox", "tg4x", "qaz", "nibble", "jorne", "jian", "crbn", "tidbit", "eek" +$splits = "y", "y", "y", "y", "y", "y", "n", "n", "n", "n", "y", "n", "n", "n", "y", "y", "n", "n", "n" $choice = Get-Choice-From-Options -Options $options -Prompt $prompt $shield_title = $($options[$choice]) diff --git a/docs/static/setup.sh b/docs/static/setup.sh index 5768fa6b..5ceff674 100644 --- a/docs/static/setup.sh +++ b/docs/static/setup.sh @@ -92,7 +92,7 @@ echo "" echo "Keyboard Shield Selection:" prompt="Pick an keyboard:" -options=("Kyria" "Lily58" "Corne" "Splitreus62" "Sofle" "Iris" "Reviung41" "RoMac" "RoMac+" "makerdiary M60" "Microdox" "TG4X" "QAZ" "Jorne" "Jian" "CRBN" "Tidbit") +options=("Kyria" "Lily58" "Corne" "Splitreus62" "Sofle" "Iris" "Reviung41" "RoMac" "RoMac+" "makerdiary M60" "Microdox" "TG4X" "QAZ" "Jorne" "Jian" "CRBN" "Tidbit" "Eek!") PS3="$prompt " # TODO: Add support for "Other" and linking to docs on adding custom shields in user config repos. @@ -119,6 +119,7 @@ select opt in "${options[@]}" "Quit"; do 16 ) shield_title="Jian" shield="jian"; split="y"; break;; 17 ) shield_title="CRBN" shield="crbn"; split="n"; break;; 18 ) shield_title="Tidbit" shield="tidbit"; split="n" break;; + 19 ) shield_title="Eek!" shield="eek"; split="n" break;; # Add link to docs on adding your own custom shield in your ZMK config! # $(( ${#options[@]}+1 )) ) echo "Other!"; break;; From a3ac0cb5be0f7918179bc422404a1d7d1f050ad1 Mon Sep 17 00:00:00 2001 From: KemoNine Date: Fri, 1 Jan 2021 21:16:20 +0000 Subject: [PATCH 19/59] feat(shields): add ws2812 underglow support to lily58 (nice_nano) --- .../shields/lily58/boards/nice_nano.overlay | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 app/boards/shields/lily58/boards/nice_nano.overlay diff --git a/app/boards/shields/lily58/boards/nice_nano.overlay b/app/boards/shields/lily58/boards/nice_nano.overlay new file mode 100644 index 00000000..0d28726d --- /dev/null +++ b/app/boards/shields/lily58/boards/nice_nano.overlay @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +&spi1 { + compatible = "nordic,nrf-spim"; + status = "okay"; + mosi-pin = <6>; + // Unused pins, needed for SPI definition, but not used by the ws2812 driver itself. + sck-pin = <5>; + miso-pin = <7>; + + led_strip: ws2812@0 { + compatible = "worldsemi,ws2812-spi"; + label = "WS2812"; + + /* SPI */ + reg = <0>; /* ignored, but necessary for SPI bindings */ + spi-max-frequency = <4000000>; + + /* WS2812 */ + chain-length = <5>; /* number of LEDs */ + spi-one-frame = <0x70>; + spi-zero-frame = <0x40>; + }; +}; + +/ { + chosen { + zmk,underglow = &led_strip; + }; +}; From 61893e453b90dcb8fb84745b009457375764f7f4 Mon Sep 17 00:00:00 2001 From: innovaker <66737976+innovaker@users.noreply.github.com> Date: Sat, 2 Jan 2021 03:55:52 +0000 Subject: [PATCH 20/59] refactor(app): format with prettier (#563) prettier --write . PR: #563 --- app/boards/shields/eek/readme.md | 2 +- .../zephyr/dts/bindings/sensor/zmk,battery-voltage-divider.yaml | 1 - app/dts/bindings/behaviors/zmk,behavior-sticky-key.yaml | 2 +- app/dts/bindings/zmk,ext-power-generic.yaml | 1 - 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/boards/shields/eek/readme.md b/app/boards/shields/eek/readme.md index 77e7be06..2a1b46b4 100644 --- a/app/boards/shields/eek/readme.md +++ b/app/boards/shields/eek/readme.md @@ -1 +1 @@ -A fixed split 36key-board with a typing angle of 90 degrees distributed by cbkbd \ No newline at end of file +A fixed split 36key-board with a typing angle of 90 degrees distributed by cbkbd diff --git a/app/drivers/zephyr/dts/bindings/sensor/zmk,battery-voltage-divider.yaml b/app/drivers/zephyr/dts/bindings/sensor/zmk,battery-voltage-divider.yaml index 3f391d78..c4c6f80c 100644 --- a/app/drivers/zephyr/dts/bindings/sensor/zmk,battery-voltage-divider.yaml +++ b/app/drivers/zephyr/dts/bindings/sensor/zmk,battery-voltage-divider.yaml @@ -11,4 +11,3 @@ properties: label: required: true type: string - \ No newline at end of file diff --git a/app/dts/bindings/behaviors/zmk,behavior-sticky-key.yaml b/app/dts/bindings/behaviors/zmk,behavior-sticky-key.yaml index d73a107d..df9c423c 100644 --- a/app/dts/bindings/behaviors/zmk,behavior-sticky-key.yaml +++ b/app/dts/bindings/behaviors/zmk,behavior-sticky-key.yaml @@ -12,4 +12,4 @@ properties: type: phandles required: true release-after-ms: - type: int \ No newline at end of file + type: int diff --git a/app/dts/bindings/zmk,ext-power-generic.yaml b/app/dts/bindings/zmk,ext-power-generic.yaml index 5a38a09a..6d36d213 100644 --- a/app/dts/bindings/zmk,ext-power-generic.yaml +++ b/app/dts/bindings/zmk,ext-power-generic.yaml @@ -17,4 +17,3 @@ properties: label: type: string required: true - From 5a7266289879c429982e33b80a33a11f4485c0da Mon Sep 17 00:00:00 2001 From: innovaker <66737976+innovaker@users.noreply.github.com> Date: Fri, 1 Jan 2021 23:56:40 +0000 Subject: [PATCH 21/59] chore: standardize C style headers Changes made with regex plus some manual tweaks. Find: /^\/\*.*\n(?:^\*.*\n)*^.*\*.*?[Cc]opyright.*?(\d{4}) *([0-9A-z,_\- ]+).*?\n(?:^.*\*.*\n)*^.*\*.*?SPDX-License-Identifier:? *(.+) *?\n(?:^.*\*.*\n)*.*\*\//gm Replace: /* * Copyright (c) $1 $2 * * SPDX-License-Identifier: $3 */ PR: #565 --- app/boards/arm/nrf52840_m2/nrf52840_m2.dts | 1 + app/boards/shields/jorne/jorne.dtsi | 2 +- app/boards/shields/jorne/jorne_left.overlay | 2 +- app/boards/shields/jorne/jorne_right.overlay | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/boards/arm/nrf52840_m2/nrf52840_m2.dts b/app/boards/arm/nrf52840_m2/nrf52840_m2.dts index f9354edf..e090842c 100644 --- a/app/boards/arm/nrf52840_m2/nrf52840_m2.dts +++ b/app/boards/arm/nrf52840_m2/nrf52840_m2.dts @@ -1,5 +1,6 @@ /* * Copyright (c) 2020 The ZMK Contributors + * * SPDX-License-Identifier: MIT */ diff --git a/app/boards/shields/jorne/jorne.dtsi b/app/boards/shields/jorne/jorne.dtsi index 67ea9d1c..c782d520 100644 --- a/app/boards/shields/jorne/jorne.dtsi +++ b/app/boards/shields/jorne/jorne.dtsi @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 The ZMK Contributors + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/boards/shields/jorne/jorne_left.overlay b/app/boards/shields/jorne/jorne_left.overlay index ca6ad431..065a23da 100644 --- a/app/boards/shields/jorne/jorne_left.overlay +++ b/app/boards/shields/jorne/jorne_left.overlay @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 The ZMK Contributors + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/boards/shields/jorne/jorne_right.overlay b/app/boards/shields/jorne/jorne_right.overlay index 6ae232eb..5a0be2cc 100644 --- a/app/boards/shields/jorne/jorne_right.overlay +++ b/app/boards/shields/jorne/jorne_right.overlay @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 The ZMK Contributors + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ From caa285852adc2d18ebd925171d11d0fd20d88dc8 Mon Sep 17 00:00:00 2001 From: Okke Formsma Date: Wed, 16 Dec 2020 19:41:53 +0100 Subject: [PATCH 22/59] refactor(events): return 'ZMK_EV_EVENT_BUBBLE' instead of magic number 0 --- app/include/zmk/event_manager.h | 1 + app/src/behaviors/behavior_hold_tap.c | 14 +++++++------- app/src/behaviors/behavior_sticky_key.c | 4 ++-- app/src/display/widgets/battery_status.c | 2 +- app/src/display/widgets/output_status.c | 2 +- app/src/split_listener.c | 2 +- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/app/include/zmk/event_manager.h b/app/include/zmk/event_manager.h index 31c53228..e5b6ed53 100644 --- a/app/include/zmk/event_manager.h +++ b/app/include/zmk/event_manager.h @@ -19,6 +19,7 @@ struct zmk_event_header { uint8_t last_listener_index; }; +#define ZMK_EV_EVENT_BUBBLE 0 #define ZMK_EV_EVENT_HANDLED 1 #define ZMK_EV_EVENT_CAPTURED 2 diff --git a/app/src/behaviors/behavior_hold_tap.c b/app/src/behaviors/behavior_hold_tap.c index d3039605..7ad1d32b 100644 --- a/app/src/behaviors/behavior_hold_tap.c +++ b/app/src/behaviors/behavior_hold_tap.c @@ -392,16 +392,16 @@ static int position_state_changed_listener(const struct zmk_event_header *eh) { if (undecided_hold_tap == NULL) { LOG_DBG("%d bubble (no undecided hold_tap active)", ev->position); - return 0; + return ZMK_EV_EVENT_BUBBLE; } if (undecided_hold_tap->position == ev->position) { if (ev->state) { // keydown LOG_ERR("hold-tap listener should be called before before most other listeners!"); - return 0; + return ZMK_EV_EVENT_BUBBLE; } else { // keyup LOG_DBG("%d bubble undecided hold-tap keyrelease event", undecided_hold_tap->position); - return 0; + return ZMK_EV_EVENT_BUBBLE; } } @@ -418,7 +418,7 @@ static int position_state_changed_listener(const struct zmk_event_header *eh) { // we'll catch modifiers later in modifier_state_changed_listener LOG_DBG("%d bubbling %d %s event", undecided_hold_tap->position, ev->position, ev->state ? "down" : "up"); - return 0; + return ZMK_EV_EVENT_BUBBLE; } LOG_DBG("%d capturing %d %s event", undecided_hold_tap->position, ev->position, @@ -439,12 +439,12 @@ static int keycode_state_changed_listener(const struct zmk_event_header *eh) { if (undecided_hold_tap == NULL) { // LOG_DBG("0x%02X bubble (no undecided hold_tap active)", ev->keycode); - return 0; + return ZMK_EV_EVENT_BUBBLE; } if (!only_mods(ev)) { // LOG_DBG("0x%02X bubble (not a mod)", ev->keycode); - return 0; + return ZMK_EV_EVENT_BUBBLE; } // only key-up events will bubble through position_state_changed_listener @@ -461,7 +461,7 @@ int behavior_hold_tap_listener(const struct zmk_event_header *eh) { } else if (is_keycode_state_changed(eh)) { return keycode_state_changed_listener(eh); } - return 0; + return ZMK_EV_EVENT_BUBBLE; } ZMK_LISTENER(behavior_hold_tap, behavior_hold_tap_listener); diff --git a/app/src/behaviors/behavior_sticky_key.c b/app/src/behaviors/behavior_sticky_key.c index 643ae48b..271b168b 100644 --- a/app/src/behaviors/behavior_sticky_key.c +++ b/app/src/behaviors/behavior_sticky_key.c @@ -177,7 +177,7 @@ static const struct behavior_driver_api behavior_sticky_key_driver_api = { static int sticky_key_keycode_state_changed_listener(const struct zmk_event_header *eh) { if (!is_keycode_state_changed(eh)) { - return 0; + return ZMK_EV_EVENT_BUBBLE; } struct keycode_state_changed *ev = cast_keycode_state_changed(eh); for (int i = 0; i < ZMK_BHV_STICKY_KEY_MAX_HELD; i++) { @@ -222,7 +222,7 @@ static int sticky_key_keycode_state_changed_listener(const struct zmk_event_head } } } - return 0; + return ZMK_EV_EVENT_BUBBLE; } ZMK_LISTENER(behavior_sticky_key, sticky_key_keycode_state_changed_listener); diff --git a/app/src/display/widgets/battery_status.c b/app/src/display/widgets/battery_status.c index 346c5193..f1f1c9f1 100644 --- a/app/src/display/widgets/battery_status.c +++ b/app/src/display/widgets/battery_status.c @@ -78,7 +78,7 @@ lv_obj_t *zmk_widget_battery_status_obj(struct zmk_widget_battery_status *widget int battery_status_listener(const struct zmk_event_header *eh) { struct zmk_widget_battery_status *widget; SYS_SLIST_FOR_EACH_CONTAINER(&widgets, widget, node) { set_battery_symbol(widget->obj); } - return 0; + return ZMK_EV_EVENT_BUBBLE; } ZMK_LISTENER(widget_battery_status, battery_status_listener) diff --git a/app/src/display/widgets/output_status.c b/app/src/display/widgets/output_status.c index 9a725113..716228b7 100644 --- a/app/src/display/widgets/output_status.c +++ b/app/src/display/widgets/output_status.c @@ -82,7 +82,7 @@ lv_obj_t *zmk_widget_output_status_obj(struct zmk_widget_output_status *widget) int output_status_listener(const struct zmk_event_header *eh) { struct zmk_widget_output_status *widget; SYS_SLIST_FOR_EACH_CONTAINER(&widgets, widget, node) { set_status_symbol(widget->obj); } - return 0; + return ZMK_EV_EVENT_BUBBLE; } ZMK_LISTENER(widget_output_status, output_status_listener) diff --git a/app/src/split_listener.c b/app/src/split_listener.c index 153ed99d..f475002c 100644 --- a/app/src/split_listener.c +++ b/app/src/split_listener.c @@ -29,7 +29,7 @@ int split_listener(const struct zmk_event_header *eh) { return zmk_split_bt_position_released(ev->position); } } - return 0; + return ZMK_EV_EVENT_BUBBLE; } ZMK_LISTENER(split_listener, split_listener); From fa07ba9d32ab65c4443f1b315beff621c8cf0a9a Mon Sep 17 00:00:00 2001 From: Okke Formsma Date: Fri, 18 Dec 2020 14:24:28 +0100 Subject: [PATCH 23/59] refactor(behaviors): use ZMK_BEHAVIOR_OPAQUE and ZMK_BEHAVIOR_TRANSPARENT Use these instead of the magic return values 0 and 1 for behavior_driver_api return values. --- app/include/zmk/behavior.h | 3 +++ app/src/behaviors/behavior_bt.c | 2 +- app/src/behaviors/behavior_ext_power.c | 2 +- app/src/behaviors/behavior_hold_tap.c | 10 +++++----- app/src/behaviors/behavior_none.c | 4 ++-- app/src/behaviors/behavior_reset.c | 2 +- app/src/behaviors/behavior_rgb_underglow.c | 2 +- app/src/behaviors/behavior_sticky_key.c | 8 ++++---- app/src/behaviors/behavior_toggle_layer.c | 2 +- app/src/behaviors/behavior_transparent.c | 4 ++-- 10 files changed, 21 insertions(+), 18 deletions(-) diff --git a/app/include/zmk/behavior.h b/app/include/zmk/behavior.h index f00ea4f9..31fb43ed 100644 --- a/app/include/zmk/behavior.h +++ b/app/include/zmk/behavior.h @@ -6,6 +6,9 @@ #pragma once +#define ZMK_BEHAVIOR_OPAQUE 0 +#define ZMK_BEHAVIOR_TRANSPARENT 1 + struct zmk_behavior_binding { char *behavior_dev; uint32_t param1; diff --git a/app/src/behaviors/behavior_bt.c b/app/src/behaviors/behavior_bt.c index bfafc4b3..3149c8ce 100644 --- a/app/src/behaviors/behavior_bt.c +++ b/app/src/behaviors/behavior_bt.c @@ -39,7 +39,7 @@ static int behavior_bt_init(const struct device *dev) { return 0; }; static int on_keymap_binding_released(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event) { - return 0; + return ZMK_BEHAVIOR_OPAQUE; } static const struct behavior_driver_api behavior_bt_driver_api = { diff --git a/app/src/behaviors/behavior_ext_power.c b/app/src/behaviors/behavior_ext_power.c index dbc6fd94..18520f7d 100644 --- a/app/src/behaviors/behavior_ext_power.c +++ b/app/src/behaviors/behavior_ext_power.c @@ -43,7 +43,7 @@ static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, static int on_keymap_binding_released(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event) { - return 0; + return ZMK_BEHAVIOR_OPAQUE; } static int behavior_ext_power_init(const struct device *dev) { return 0; }; diff --git a/app/src/behaviors/behavior_hold_tap.c b/app/src/behaviors/behavior_hold_tap.c index 7ad1d32b..9b62eb15 100644 --- a/app/src/behaviors/behavior_hold_tap.c +++ b/app/src/behaviors/behavior_hold_tap.c @@ -310,7 +310,7 @@ static int on_hold_tap_binding_pressed(struct zmk_behavior_binding *binding, if (undecided_hold_tap != NULL) { LOG_DBG("ERROR another hold-tap behavior is undecided."); // if this happens, make sure the behavior events occur AFTER other position events. - return 0; + return ZMK_BEHAVIOR_OPAQUE; } struct active_hold_tap *hold_tap = @@ -318,7 +318,7 @@ static int on_hold_tap_binding_pressed(struct zmk_behavior_binding *binding, if (hold_tap == NULL) { LOG_ERR("unable to store hold-tap info, did you press more than %d hold-taps?", ZMK_BHV_HOLD_TAP_MAX_HELD); - return 0; + return ZMK_BEHAVIOR_OPAQUE; } LOG_DBG("%d new undecided hold_tap", event.position); @@ -331,7 +331,7 @@ static int on_hold_tap_binding_pressed(struct zmk_behavior_binding *binding, k_delayed_work_submit(&hold_tap->work, K_MSEC(tapping_term_ms_left)); } - return 0; + return ZMK_BEHAVIOR_OPAQUE; } static int on_hold_tap_binding_released(struct zmk_behavior_binding *binding, @@ -339,7 +339,7 @@ static int on_hold_tap_binding_released(struct zmk_behavior_binding *binding, struct active_hold_tap *hold_tap = find_hold_tap(event.position); if (hold_tap == NULL) { LOG_ERR("ACTIVE_HOLD_TAP_CLEANED_UP_TOO_EARLY"); - return 0; + return ZMK_BEHAVIOR_OPAQUE; } // If these events were queued, the timer event may be queued too late or not at all. @@ -379,7 +379,7 @@ static int on_hold_tap_binding_released(struct zmk_behavior_binding *binding, clear_hold_tap(hold_tap); } - return 0; + return ZMK_BEHAVIOR_OPAQUE; } static const struct behavior_driver_api behavior_hold_tap_driver_api = { diff --git a/app/src/behaviors/behavior_none.c b/app/src/behaviors/behavior_none.c index 12542f05..e0eaa159 100644 --- a/app/src/behaviors/behavior_none.c +++ b/app/src/behaviors/behavior_none.c @@ -22,12 +22,12 @@ static int behavior_none_init(const struct device *dev) { return 0; }; static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event) { - return 0; + return ZMK_BEHAVIOR_OPAQUE; } static int on_keymap_binding_released(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event) { - return 0; + return ZMK_BEHAVIOR_OPAQUE; } static const struct behavior_driver_api behavior_none_driver_api = { diff --git a/app/src/behaviors/behavior_reset.c b/app/src/behaviors/behavior_reset.c index cb77a838..e4b720f7 100644 --- a/app/src/behaviors/behavior_reset.c +++ b/app/src/behaviors/behavior_reset.c @@ -30,7 +30,7 @@ static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, // See // https://github.com/adafruit/Adafruit_nRF52_Bootloader/blob/d6b28e66053eea467166f44875e3c7ec741cb471/src/main.c#L107 sys_reboot(cfg->type); - return 0; + return ZMK_BEHAVIOR_OPAQUE; } static const struct behavior_driver_api behavior_reset_driver_api = { diff --git a/app/src/behaviors/behavior_rgb_underglow.c b/app/src/behaviors/behavior_rgb_underglow.c index a0db9a9b..399123a3 100644 --- a/app/src/behaviors/behavior_rgb_underglow.c +++ b/app/src/behaviors/behavior_rgb_underglow.c @@ -50,7 +50,7 @@ static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, static int on_keymap_binding_released(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event) { - return 0; + return ZMK_BEHAVIOR_OPAQUE; } static const struct behavior_driver_api behavior_rgb_underglow_driver_api = { diff --git a/app/src/behaviors/behavior_sticky_key.c b/app/src/behaviors/behavior_sticky_key.c index 271b168b..15c9e21c 100644 --- a/app/src/behaviors/behavior_sticky_key.c +++ b/app/src/behaviors/behavior_sticky_key.c @@ -138,12 +138,12 @@ static int on_sticky_key_binding_pressed(struct zmk_behavior_binding *binding, if (sticky_key == NULL) { LOG_ERR("unable to store sticky key, did you press more than %d sticky_key?", ZMK_BHV_STICKY_KEY_MAX_HELD); - return 0; + return ZMK_BEHAVIOR_OPAQUE; } press_sticky_key_behavior(sticky_key, event.timestamp); LOG_DBG("%d new sticky_key", event.position); - return 0; + return ZMK_BEHAVIOR_OPAQUE; } static int on_sticky_key_binding_released(struct zmk_behavior_binding *binding, @@ -151,7 +151,7 @@ static int on_sticky_key_binding_released(struct zmk_behavior_binding *binding, struct active_sticky_key *sticky_key = find_sticky_key(event.position); if (sticky_key == NULL) { LOG_ERR("ACTIVE STICKY KEY CLEARED TOO EARLY"); - return 0; + return ZMK_BEHAVIOR_OPAQUE; } if (sticky_key->modified_key_usage_page != 0 && sticky_key->modified_key_keycode != 0) { @@ -167,7 +167,7 @@ static int on_sticky_key_binding_released(struct zmk_behavior_binding *binding, if (ms_left > 0) { k_delayed_work_submit(&sticky_key->release_timer, K_MSEC(ms_left)); } - return 0; + return ZMK_BEHAVIOR_OPAQUE; } static const struct behavior_driver_api behavior_sticky_key_driver_api = { diff --git a/app/src/behaviors/behavior_toggle_layer.c b/app/src/behaviors/behavior_toggle_layer.c index 32833775..21daa004 100644 --- a/app/src/behaviors/behavior_toggle_layer.c +++ b/app/src/behaviors/behavior_toggle_layer.c @@ -29,7 +29,7 @@ static int tog_keymap_binding_pressed(struct zmk_behavior_binding *binding, static int tog_keymap_binding_released(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event) { LOG_DBG("position %d layer %d", event.position, binding->param1); - return 0; + return ZMK_BEHAVIOR_OPAQUE; } static const struct behavior_driver_api behavior_tog_driver_api = { diff --git a/app/src/behaviors/behavior_transparent.c b/app/src/behaviors/behavior_transparent.c index 17a5e436..ca3d279f 100644 --- a/app/src/behaviors/behavior_transparent.c +++ b/app/src/behaviors/behavior_transparent.c @@ -22,12 +22,12 @@ static int behavior_transparent_init(const struct device *dev) { return 0; }; static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event) { - return 1; + return ZMK_BEHAVIOR_TRANSPARENT; } static int on_keymap_binding_released(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event) { - return 1; + return ZMK_BEHAVIOR_TRANSPARENT; } static const struct behavior_driver_api behavior_transparent_driver_api = { From 319ce302700eec9bf2a38b308ac1320aea548453 Mon Sep 17 00:00:00 2001 From: Okke Formsma Date: Sat, 2 Jan 2021 13:45:36 +0100 Subject: [PATCH 24/59] chore(behavior): use ZMK_BEHAVIOR_OPAQUE in to-layer behavior --- app/src/behaviors/behavior_to_layer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/behaviors/behavior_to_layer.c b/app/src/behaviors/behavior_to_layer.c index 3ec1bf81..bb64026d 100644 --- a/app/src/behaviors/behavior_to_layer.c +++ b/app/src/behaviors/behavior_to_layer.c @@ -20,13 +20,14 @@ static int behavior_to_init(const struct device *dev) { return 0; }; static int to_keymap_binding_pressed(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event) { LOG_DBG("position %d layer %d", event.position, binding->param1); - return zmk_keymap_layer_to(binding->param1); + zmk_keymap_layer_to(binding->param1); + return ZMK_BEHAVIOR_OPAQUE; } static int to_keymap_binding_released(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event) { LOG_DBG("position %d layer %d", event.position, binding->param1); - return 0; + return ZMK_BEHAVIOR_OPAQUE; } static const struct behavior_driver_api behavior_to_driver_api = { From dcd665999a5ee04372559d56fc22b9a2d0784bf2 Mon Sep 17 00:00:00 2001 From: pbz Date: Sat, 2 Jan 2021 13:52:50 -0500 Subject: [PATCH 25/59] feat(shields): add bfo9000 shield PR: #472 --- .github/workflows/build.yml | 2 + app/boards/shields/bfo9000/Kconfig.defconfig | 26 +++++++++ app/boards/shields/bfo9000/Kconfig.shield | 8 +++ app/boards/shields/bfo9000/bfo9000.conf | 0 app/boards/shields/bfo9000/bfo9000.dtsi | 44 +++++++++++++++ app/boards/shields/bfo9000/bfo9000.keymap | 55 +++++++++++++++++++ app/boards/shields/bfo9000/bfo9000_left.conf | 0 .../shields/bfo9000/bfo9000_left.overlay | 21 +++++++ app/boards/shields/bfo9000/bfo9000_right.conf | 0 .../shields/bfo9000/bfo9000_right.overlay | 25 +++++++++ app/boards/shields/bfo9000/readme.md | 13 +++++ docs/docs/hardware.md | 1 + docs/static/setup.ps1 | 6 +- docs/static/setup.sh | 3 +- 14 files changed, 200 insertions(+), 4 deletions(-) create mode 100644 app/boards/shields/bfo9000/Kconfig.defconfig create mode 100644 app/boards/shields/bfo9000/Kconfig.shield create mode 100644 app/boards/shields/bfo9000/bfo9000.conf create mode 100644 app/boards/shields/bfo9000/bfo9000.dtsi create mode 100644 app/boards/shields/bfo9000/bfo9000.keymap create mode 100644 app/boards/shields/bfo9000/bfo9000_left.conf create mode 100644 app/boards/shields/bfo9000/bfo9000_left.overlay create mode 100644 app/boards/shields/bfo9000/bfo9000_right.conf create mode 100644 app/boards/shields/bfo9000/bfo9000_right.overlay create mode 100644 app/boards/shields/bfo9000/readme.md diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1c2a5119..58da8c41 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,6 +23,8 @@ jobs: - nrfmicro_13 - proton_c shield: + - bfo9000_left + - bfo9000_right - boardsource3x4 - corne_left - corne_right diff --git a/app/boards/shields/bfo9000/Kconfig.defconfig b/app/boards/shields/bfo9000/Kconfig.defconfig new file mode 100644 index 00000000..e4b02e8c --- /dev/null +++ b/app/boards/shields/bfo9000/Kconfig.defconfig @@ -0,0 +1,26 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + +if SHIELD_BFO9000_LEFT + +config ZMK_SPLIT_BLE_ROLE_CENTRAL + default y + +config ZMK_KEYBOARD_NAME + default "BFO9000 Left" + +endif + +if SHIELD_BFO9000_RIGHT + +config ZMK_KEYBOARD_NAME + default "BFO9000 Right" + +endif + +if SHIELD_BFO9000_LEFT || SHIELD_BFO9000_RIGHT + +config ZMK_SPLIT + default y + +endif \ No newline at end of file diff --git a/app/boards/shields/bfo9000/Kconfig.shield b/app/boards/shields/bfo9000/Kconfig.shield new file mode 100644 index 00000000..4750e43a --- /dev/null +++ b/app/boards/shields/bfo9000/Kconfig.shield @@ -0,0 +1,8 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + +config SHIELD_BFO9000_LEFT + def_bool $(shields_list_contains,bfo9000_left) + +config SHIELD_BFO9000_RIGHT + def_bool $(shields_list_contains,bfo9000_right) diff --git a/app/boards/shields/bfo9000/bfo9000.conf b/app/boards/shields/bfo9000/bfo9000.conf new file mode 100644 index 00000000..e69de29b diff --git a/app/boards/shields/bfo9000/bfo9000.dtsi b/app/boards/shields/bfo9000/bfo9000.dtsi new file mode 100644 index 00000000..33b364e1 --- /dev/null +++ b/app/boards/shields/bfo9000/bfo9000.dtsi @@ -0,0 +1,44 @@ + /* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include + +/ { + chosen { + zmk,kscan = &kscan0; + zmk,matrix_transform = &default_transform; + }; + + default_transform: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + columns = <18>; + rows = <6>; + map = < + RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(0,10) RC(0,11) RC(0,12) RC(0,13) RC(0,14) RC(0,15) RC(0,16) RC(0,17) + RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,6) RC(1,7) RC(1,8) RC(1,9) RC(1,10) RC(1,11) RC(1,12) RC(1,13) RC(1,14) RC(1,15) RC(1,16) RC(1,17) + RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(2,7) RC(2,8) RC(2,9) RC(2,10) RC(2,11) RC(2,12) RC(2,13) RC(2,14) RC(2,15) RC(2,16) RC(2,17) + RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(3,6) RC(3,7) RC(3,8) RC(3,9) RC(3,10) RC(3,11) RC(3,12) RC(3,13) RC(3,14) RC(3,15) RC(3,16) RC(3,17) + RC(4,0) RC(4,1) RC(4,2) RC(4,3) RC(4,4) RC(4,5) RC(4,6) RC(4,7) RC(4,8) RC(4,9) RC(4,10) RC(4,11) RC(4,12) RC(4,13) RC(4,14) RC(4,15) RC(4,16) RC(4,17) + RC(5,0) RC(5,1) RC(5,2) RC(5,3) RC(5,4) RC(5,5) RC(5,6) RC(5,7) RC(5,8) RC(5,9) RC(5,10) RC(5,11) RC(5,12) RC(5,13) RC(5,14) RC(5,15) RC(5,16) RC(5,17) + >; + }; + + kscan0: kscan { + compatible = "zmk,kscan-gpio-matrix"; + label = "KSCAN"; + + diode-direction = "col2row"; + row-gpios + = <&pro_micro_d 1 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 0 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 4 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + ; + + }; +}; \ No newline at end of file diff --git a/app/boards/shields/bfo9000/bfo9000.keymap b/app/boards/shields/bfo9000/bfo9000.keymap new file mode 100644 index 00000000..fe904931 --- /dev/null +++ b/app/boards/shields/bfo9000/bfo9000.keymap @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include +#include +#include +#include +#include +#include + +#define DEFAULT 0 +#define LOWER 1 + +/ { + keymap { + compatible = "zmk,keymap"; + + default_layer { + // | Esc | Vol Up | Esc | F1 | F2 | F3 | F4 | F5 | F6 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | Del | + // | Home | Vol Dn | ` | 1 | 2 | 3 | 4 | 5 | 6 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | Bk Spc | + // | End | Tab | Tab | Q | W | E | R | T | Y | T | Y | U | I | O | P | [ | ] | \ | + // | Pg Up | Caps | Ctrl | A | S | D | F | G | H | G | H | J | K | L | ; | ' | Enter | Enter | + // | Pg Dn | Up | Shift | Z | X | C | V | B | N | B | N | M | , | . | / | Shift | Up | | + // | Left | Dn | Right | Ctrl | Alt | Win | Spc | Spc | Enter | Bk Spc | Spc | Spc | Win | Alt | Ctrl | Left | Dn | Right | + bindings = < + &kp ESC &kp C_VOL_UP &kp ESC &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &kp DEL + &kp HOME &kp C_VOL_DN &kp GRAVE &kp N1 &kp N2 &kp N3 &kp N4 &kp N5 &kp N6 &kp N5 &kp N6 &kp N7 &kp N8 &kp N9 &kp N0 &kp MINUS &kp EQUAL &kp BSPC + &kp END &kp TAB &kp TAB &kp Q &kp W &kp E &kp R &kp T &kp Y &kp T &kp Y &kp U &kp I &kp O &kp P &kp LBKT &kp RBKT &kp BSLH + &kp PG_UP &kp CAPS &kp LCTRL &kp A &kp S &kp D &kp F &kp G &kp H &kp G &kp H &kp J &kp K &kp L &kp SEMI &kp APOS &kp ENTER &kp ENTER + &kp PG_DN &kp UP &kp LSHFT &kp Z &kp X &kp C &kp V &kp B &kp N &kp B &kp N &kp M &kp COMMA &kp DOT &kp SLASH &kp RSHFT &kp UP &mo LOWER + &kp LEFT &kp DOWN &kp RIGHT &kp LCTRL &kp LALT &kp LMETA &kp SPACE &kp SPACE &kp ENTER &kp BSPC &kp SPACE &kp SPACE &kp RMETA &kp RALT &kp RCTRL &kp LEFT &kp DOWN &kp RIGHT + >; + }; + + lower_layer { + // | | | | | | | | | | | | | | | | | | | + // | | | | | | | | | | | | | | | | | | | + // | | | | | | | | | | | | | | | | | | | + // | | | | | | | | | | | | | | | | | | | + // | | | | | | | | | | | | | | | | | | | + // | | | | | | | | | | | | | | | | | | | + bindings = < + &bt BT_CLR &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &bt BT_SEL 5 &bt BT_SEL 6 &bt BT_SEL 7 &bt BT_CLR &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &bt BT_SEL 5 &bt BT_SEL 6 &bt BT_SEL 7 + &out OUT_USB &out OUT_BLE &trans &trans &trans &trans &trans &trans &trans &out OUT_USB &out OUT_BLE &trans &trans &trans &trans &trans &trans &trans + &ext_power EP_ON &ext_power EP_OFF &trans &trans &trans &trans &trans &trans &trans &ext_power EP_ON &ext_power EP_OFF &trans &trans &trans &trans &trans &trans &trans + &reset &bootloader &trans &trans &trans &trans &trans &trans &trans &reset &bootloader &trans &trans &trans &trans &trans &trans &trans + &rgb_ug RGB_TOG &rgb_ug RGB_HUI &rgb_ug RGB_SAI &rgb_ug RGB_BRI &rgb_ug RGB_SPI &rgb_ug RGB_EFF &trans &trans &trans &rgb_ug RGB_TOG &rgb_ug RGB_HUI &rgb_ug RGB_SAI &rgb_ug RGB_BRI &rgb_ug RGB_SPI &rgb_ug RGB_EFF &trans &trans &trans + &trans &rgb_ug RGB_HUD &rgb_ug RGB_SAD &rgb_ug RGB_BRD &rgb_ug RGB_SPD &rgb_ug RGB_EFR &trans &trans &trans &trans &rgb_ug RGB_HUD &rgb_ug RGB_SAD &rgb_ug RGB_BRD &rgb_ug RGB_SPD &rgb_ug RGB_EFR &trans &trans &trans + >; + }; + }; +}; diff --git a/app/boards/shields/bfo9000/bfo9000_left.conf b/app/boards/shields/bfo9000/bfo9000_left.conf new file mode 100644 index 00000000..e69de29b diff --git a/app/boards/shields/bfo9000/bfo9000_left.overlay b/app/boards/shields/bfo9000/bfo9000_left.overlay new file mode 100644 index 00000000..777f0835 --- /dev/null +++ b/app/boards/shields/bfo9000/bfo9000_left.overlay @@ -0,0 +1,21 @@ + /* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include "bfo9000.dtsi" + +&kscan0 { + col-gpios + = <&pro_micro_d 9 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 10 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 16 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 14 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 15 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 0 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 1 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 2 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 3 GPIO_ACTIVE_HIGH> + ; +}; diff --git a/app/boards/shields/bfo9000/bfo9000_right.conf b/app/boards/shields/bfo9000/bfo9000_right.conf new file mode 100644 index 00000000..e69de29b diff --git a/app/boards/shields/bfo9000/bfo9000_right.overlay b/app/boards/shields/bfo9000/bfo9000_right.overlay new file mode 100644 index 00000000..ab3fb55f --- /dev/null +++ b/app/boards/shields/bfo9000/bfo9000_right.overlay @@ -0,0 +1,25 @@ + /* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include "bfo9000.dtsi" + +&default_transform { + col-offset = <9>; +}; + +&kscan0 { + col-gpios + = <&pro_micro_d 9 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 10 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 16 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 14 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 15 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 0 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 1 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 2 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 3 GPIO_ACTIVE_HIGH> + ; +}; diff --git a/app/boards/shields/bfo9000/readme.md b/app/boards/shields/bfo9000/readme.md new file mode 100644 index 00000000..1e91fdcf --- /dev/null +++ b/app/boards/shields/bfo9000/readme.md @@ -0,0 +1,13 @@ +# [BFO-9000](https://keeb.io/products/bfo-9000-keyboard-customizable-full-size-split-ortholinear) + +Customizable full-size split ortholinear. + +## Features + +* Compatible with MX-compatible, Alps-compatible, and Kailh Low-Profile Choc switches. +* Breakoff pieces to allow for 4 to 6 rows and 7 to 9 columns. +* RGB LED connections + +## Hardware Notes + +[Included default keymap](http://www.keyboard-layout-editor.com/#/gists/51293c31afcd5f1765e8f413a46bfcf8) \ No newline at end of file diff --git a/docs/docs/hardware.md b/docs/docs/hardware.md index 98f8715f..244bdd60 100644 --- a/docs/docs/hardware.md +++ b/docs/docs/hardware.md @@ -38,6 +38,7 @@ That being said, there are currently only a few specific [boards](/docs/faq#what - [CRBN](https://keygem.store/collections/group-buys/products/group-buy-featherlight-40-kit) (`crbn`) - [tidbit](https://nullbits.co/tidbit/) (`tidbit`) - [Eek!](https://www.cbkbd.com/product/eek-keyboard) (`eek`) +- [BFO-9000](https://keeb.io/products/bfo-9000-keyboard-customizable-full-size-split-ortholinear) (`bfo9000_left` and `bfo9000_right`) ## Other Hardware diff --git a/docs/static/setup.ps1 b/docs/static/setup.ps1 index a521934e..ffd938f4 100644 --- a/docs/static/setup.ps1 +++ b/docs/static/setup.ps1 @@ -91,9 +91,9 @@ Write-Host "Keyboard Shield Selection:" $prompt = "Pick a keyboard" # TODO: Add support for "Other" and linking to docs on adding custom shields in user config repos. -$options = "Kyria", "Lily58", "Corne", "Splitreus62", "Sofle", "Iris", "Reviung41", "RoMac", "RoMac+", "makerdiary M60", "Microdox", "TG4X", "QAZ", "NIBBLE", "Jorne", "Jian", "CRBN", "Tidbit", "Eek!" -$names = "kyria", "lily58", "corne", "splitreus62", "sofle", "iris", "reviung41", "romac", "romac_plus", "m60", "microdox", "tg4x", "qaz", "nibble", "jorne", "jian", "crbn", "tidbit", "eek" -$splits = "y", "y", "y", "y", "y", "y", "n", "n", "n", "n", "y", "n", "n", "n", "y", "y", "n", "n", "n" +$options = "Kyria", "Lily58", "Corne", "Splitreus62", "Sofle", "Iris", "Reviung41", "RoMac", "RoMac+", "makerdiary M60", "Microdox", "TG4X", "QAZ", "NIBBLE", "Jorne", "Jian", "CRBN", "Tidbit", "Eek!", "BFO-9000" +$names = "kyria", "lily58", "corne", "splitreus62", "sofle", "iris", "reviung41", "romac", "romac_plus", "m60", "microdox", "tg4x", "qaz", "nibble", "jorne", "jian", "crbn", "tidbit", "eek", "bfo9000" +$splits = "y", "y", "y", "y", "y", "y", "n", "n", "n", "n", "y", "n", "n", "n", "y", "y", "n", "n", "n", "n" $choice = Get-Choice-From-Options -Options $options -Prompt $prompt $shield_title = $($options[$choice]) diff --git a/docs/static/setup.sh b/docs/static/setup.sh index 5ceff674..486bb06c 100644 --- a/docs/static/setup.sh +++ b/docs/static/setup.sh @@ -92,7 +92,7 @@ echo "" echo "Keyboard Shield Selection:" prompt="Pick an keyboard:" -options=("Kyria" "Lily58" "Corne" "Splitreus62" "Sofle" "Iris" "Reviung41" "RoMac" "RoMac+" "makerdiary M60" "Microdox" "TG4X" "QAZ" "Jorne" "Jian" "CRBN" "Tidbit" "Eek!") +options=("Kyria" "Lily58" "Corne" "Splitreus62" "Sofle" "Iris" "Reviung41" "RoMac" "RoMac+" "makerdiary M60" "Microdox" "TG4X" "QAZ" "Jorne" "Jian" "CRBN" "Tidbit" "Eek!" "BF0-9000") PS3="$prompt " # TODO: Add support for "Other" and linking to docs on adding custom shields in user config repos. @@ -120,6 +120,7 @@ select opt in "${options[@]}" "Quit"; do 17 ) shield_title="CRBN" shield="crbn"; split="n"; break;; 18 ) shield_title="Tidbit" shield="tidbit"; split="n" break;; 19 ) shield_title="Eek!" shield="eek"; split="n" break;; + 17 ) shield_title="BFO-9000" shield="bfo9000"; split="y"; break;; # Add link to docs on adding your own custom shield in your ZMK config! # $(( ${#options[@]}+1 )) ) echo "Other!"; break;; From 4ddda7e024996480051c2c24cf1302a7d0685533 Mon Sep 17 00:00:00 2001 From: Nick Winans Date: Sun, 3 Jan 2021 18:13:49 -0600 Subject: [PATCH 26/59] docs(shield): Remove SPLIT_BLE_ROLE_PERIPHERAL Removes CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL from the new shield docs See: #510 Refs: 4db5b169bff1f3de5353324baef5724be4f9a6a5 --- docs/docs/development/new-shield.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/docs/development/new-shield.md b/docs/docs/development/new-shield.md index 18f8b420..9de05b7a 100644 --- a/docs/docs/development/new-shield.md +++ b/docs/docs/development/new-shield.md @@ -278,7 +278,6 @@ CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y // Peripheral Half (Usually the right side: my_awesome_split_board_right.conf) CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_Peripheral=y ``` Using the .conf file that affects both halves of a split board would be for adding features like deep-sleep or rotary encoders. From 74b397ab9136ba23b96e1fd8120bd7e32a1944af Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Mon, 4 Jan 2021 11:59:25 -0500 Subject: [PATCH 27/59] fix(docs): Add closing bracket for new shield. --- docs/docs/development/new-shield.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/docs/development/new-shield.md b/docs/docs/development/new-shield.md index 9de05b7a..acc636fd 100644 --- a/docs/docs/development/new-shield.md +++ b/docs/docs/development/new-shield.md @@ -203,6 +203,7 @@ RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(4,2) RC(4,9) RC(3,6) RC(3,7) ; }; +}; ``` :::note From a55b1397c9558cead989dfc5920b162f7c8b4c8b Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Tue, 29 Dec 2020 00:19:25 -0500 Subject: [PATCH 28/59] feat(keymap): API for retrieving label for a layer --- app/include/zmk/keymap.h | 1 + app/src/keymap.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/app/include/zmk/keymap.h b/app/include/zmk/keymap.h index 9192772f..4bcdc2b4 100644 --- a/app/include/zmk/keymap.h +++ b/app/include/zmk/keymap.h @@ -16,5 +16,6 @@ int zmk_keymap_layer_activate(uint8_t layer); int zmk_keymap_layer_deactivate(uint8_t layer); int zmk_keymap_layer_toggle(uint8_t layer); int zmk_keymap_layer_to(uint8_t layer); +const char *zmk_keymap_layer_label(uint8_t layer); int zmk_keymap_position_state_changed(uint32_t position, bool pressed, int64_t timestamp); diff --git a/app/src/keymap.c b/app/src/keymap.c index 786a1773..322a9369 100644 --- a/app/src/keymap.c +++ b/app/src/keymap.c @@ -59,6 +59,8 @@ static uint8_t _zmk_keymap_layer_default = 0; #endif /* ZMK_KEYMAP_HAS_SENSORS */ +#define LAYER_LABEL(node) COND_CODE_0(DT_NODE_HAS_PROP(node, label), (NULL), (DT_LABEL(node))), + // State // When a behavior handles a key position "down" event, we record the layer state @@ -69,6 +71,9 @@ static uint32_t zmk_keymap_active_behavior_layer[ZMK_KEYMAP_LEN]; static struct zmk_behavior_binding zmk_keymap[ZMK_KEYMAP_LAYERS_LEN][ZMK_KEYMAP_LEN] = { DT_INST_FOREACH_CHILD(0, TRANSFORMED_LAYER)}; +static const char *zmk_keymap_layer_names[ZMK_KEYMAP_LAYERS_LEN] = { + DT_INST_FOREACH_CHILD(0, LAYER_LABEL)}; + #if ZMK_KEYMAP_HAS_SENSORS static struct zmk_behavior_binding zmk_sensor_keymap[ZMK_KEYMAP_LAYERS_LEN] @@ -143,6 +148,18 @@ int zmk_keymap_layer_to(uint8_t layer) { return 0; } +bool is_active_layer(uint8_t layer, zmk_keymap_layers_state_t layer_state) { + return (layer_state & BIT(layer)) == BIT(layer) || layer == _zmk_keymap_layer_default; +} + +const char *zmk_keymap_layer_label(uint8_t layer) { + if (layer >= ZMK_KEYMAP_LAYERS_LEN) { + return NULL; + } + + return zmk_keymap_layer_names[layer]; +} + int zmk_keymap_apply_position_state(int layer, uint32_t position, bool pressed, int64_t timestamp) { struct zmk_behavior_binding *binding = &zmk_keymap[layer][position]; const struct device *behavior; From 992cee1bac816696839e52eb1f7c4e5f3e51c4db Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Tue, 29 Dec 2020 00:19:51 -0500 Subject: [PATCH 29/59] feat(display): Show layer label in widget. --- app/src/display/widgets/layer_status.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/app/src/display/widgets/layer_status.c b/app/src/display/widgets/layer_status.c index fb9f6897..6700bb30 100644 --- a/app/src/display/widgets/layer_status.c +++ b/app/src/display/widgets/layer_status.c @@ -33,12 +33,23 @@ void layer_status_init() { void set_layer_symbol(lv_obj_t *label) { int active_layer_index = zmk_keymap_highest_layer_active(); - char text[6] = {}; LOG_DBG("Layer changed to %i", active_layer_index); - sprintf(text, LV_SYMBOL_KEYBOARD "%i ", active_layer_index); - lv_label_set_text(label, text); + const char *layer_label = zmk_keymap_layer_label(active_layer_index); + if (layer_label == NULL) { + char text[6] = {}; + + sprintf(text, LV_SYMBOL_KEYBOARD "%i", active_layer_index); + + lv_label_set_text(label, text); + } else { + char text[12] = {}; + + snprintf(text, 12, LV_SYMBOL_KEYBOARD "%s", layer_label); + + lv_label_set_text(label, text); + } } int zmk_widget_layer_status_init(struct zmk_widget_layer_status *widget, lv_obj_t *parent) { From e5b1f1e1beb3ca9ad11de2cc3aac64bfa8b4ca4c Mon Sep 17 00:00:00 2001 From: Nick Winans Date: Mon, 4 Jan 2021 12:20:31 -0600 Subject: [PATCH 30/59] fix(shield): BFO9000 uses USB on right --- app/boards/shields/bfo9000/Kconfig.defconfig | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/boards/shields/bfo9000/Kconfig.defconfig b/app/boards/shields/bfo9000/Kconfig.defconfig index e4b02e8c..1251113f 100644 --- a/app/boards/shields/bfo9000/Kconfig.defconfig +++ b/app/boards/shields/bfo9000/Kconfig.defconfig @@ -3,12 +3,12 @@ if SHIELD_BFO9000_LEFT -config ZMK_SPLIT_BLE_ROLE_CENTRAL - default y - config ZMK_KEYBOARD_NAME default "BFO9000 Left" +config ZMK_SPLIT_BLE_ROLE_CENTRAL + default y + endif if SHIELD_BFO9000_RIGHT @@ -16,6 +16,9 @@ if SHIELD_BFO9000_RIGHT config ZMK_KEYBOARD_NAME default "BFO9000 Right" +config USB + default y + endif if SHIELD_BFO9000_LEFT || SHIELD_BFO9000_RIGHT From a4703537603d1ae7f5a904fc57d61af7382b6f9f Mon Sep 17 00:00:00 2001 From: Nick Winans Date: Mon, 4 Jan 2021 12:42:22 -0600 Subject: [PATCH 31/59] docs(shield): Add docs based on #510 changes --- docs/docs/development/new-shield.md | 34 ++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/docs/docs/development/new-shield.md b/docs/docs/development/new-shield.md index acc636fd..ceb81d10 100644 --- a/docs/docs/development/new-shield.md +++ b/docs/docs/development/new-shield.md @@ -91,6 +91,9 @@ endif ``` Similarly to defining the halves of a split board in `Kconfig.shield` it is important to set the `ZMK_KEYBOARD_NAME` for each half of a split keyboard. +You'll also want to set which half is the central side. Most boards set it to the left. +Then on the peripheral half, you'll want to turn USB on so that it shows USB status on displays properly. +Finally, you'll want to turn on the split option for both sides. This can all be seen below. ``` if SHIELD_MY_BOARD_LEFT @@ -98,6 +101,9 @@ if SHIELD_MY_BOARD_LEFT config ZMK_KEYBOARD_NAME default "My Awesome Keyboard Left" +config ZMK_SPLIT_BLE_ROLE_CENTRAL + default y + endif if SHIELD_MY_BOARD_RIGHT @@ -105,6 +111,16 @@ if SHIELD_MY_BOARD_RIGHT config ZMK_KEYBOARD_NAME default "My Awesome Keyboard Right" +config USB + default y + +endif + +if SHIELD_MY_BOARD_LEFT || SHIELD_MY_BOARD_RIGHT + +config ZMK_SPLIT + default y + endif ``` @@ -265,23 +281,7 @@ For example, a split board called `my_awesome_split_board` would have the follow - `my_awesome_split_board_left.conf` - Configuration elements only affect left half - `my_awesome_split_board_right.conf` - Configuration elements only affect right half -For proper communication between keyboard halves and that between the central half and the computer, -the **the central and peripheral halves of the keyboard must be defined**. This can be seen below. - -``` -// Central Half (Usually the left side: my_awesome_split_board_left.conf) - -CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y -``` - -``` -// Peripheral Half (Usually the right side: my_awesome_split_board_right.conf) - -CONFIG_ZMK_SPLIT=y -``` - -Using the .conf file that affects both halves of a split board would be for adding features like deep-sleep or rotary encoders. +In most case you'll only need to use the .conf file that affects both halves of a split board. It's used for adding features like deep-sleep or rotary encoders. ``` // my_awesome_split_board.conf From 5c11962d986753d5da9244cf572242f43f4d126c Mon Sep 17 00:00:00 2001 From: KingCoinless <33333456+KingCoinless@users.noreply.github.com> Date: Tue, 5 Jan 2021 10:56:47 -0800 Subject: [PATCH 32/59] feat(shields): add helix shield PR: #429 --- .github/workflows/build.yml | 2 + app/boards/shields/helix/Kconfig.defconfig | 29 ++++++ app/boards/shields/helix/Kconfig.shield | 8 ++ app/boards/shields/helix/README.md | 12 +++ .../shields/helix/boards/nice_nano.overlay | 34 +++++++ app/boards/shields/helix/helix.conf | 6 ++ app/boards/shields/helix/helix.dtsi | 47 ++++++++++ app/boards/shields/helix/helix.keymap | 88 +++++++++++++++++++ app/boards/shields/helix/helix_left.overlay | 19 ++++ app/boards/shields/helix/helix_right.overlay | 23 +++++ docs/docs/hardware.md | 1 + docs/static/setup.ps1 | 6 +- docs/static/setup.sh | 5 +- 13 files changed, 275 insertions(+), 5 deletions(-) create mode 100644 app/boards/shields/helix/Kconfig.defconfig create mode 100644 app/boards/shields/helix/Kconfig.shield create mode 100644 app/boards/shields/helix/README.md create mode 100644 app/boards/shields/helix/boards/nice_nano.overlay create mode 100644 app/boards/shields/helix/helix.conf create mode 100644 app/boards/shields/helix/helix.dtsi create mode 100644 app/boards/shields/helix/helix.keymap create mode 100644 app/boards/shields/helix/helix_left.overlay create mode 100644 app/boards/shields/helix/helix_right.overlay diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 58da8c41..d7011283 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,6 +32,8 @@ jobs: - cradio_right - crbn - eek + - helix_left + - helix_right - iris_left - iris_right - jian_left diff --git a/app/boards/shields/helix/Kconfig.defconfig b/app/boards/shields/helix/Kconfig.defconfig new file mode 100644 index 00000000..f58684a8 --- /dev/null +++ b/app/boards/shields/helix/Kconfig.defconfig @@ -0,0 +1,29 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + +if SHIELD_HELIX_LEFT + +config ZMK_KEYBOARD_NAME + default "Helix Left" + +config ZMK_SPLIT_BLE_ROLE_CENTRAL + default y + +endif + +if SHIELD_HELIX_RIGHT + +config ZMK_KEYBOARD_NAME + default "Helix Right" + +config USB + default y + +endif + +if SHIELD_HELIX_LEFT || SHIELD_HELIX_RIGHT + +config ZMK_SPLIT + default y + +endif \ No newline at end of file diff --git a/app/boards/shields/helix/Kconfig.shield b/app/boards/shields/helix/Kconfig.shield new file mode 100644 index 00000000..7e5bb9ae --- /dev/null +++ b/app/boards/shields/helix/Kconfig.shield @@ -0,0 +1,8 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + +config SHIELD_HELIX_LEFT + def_bool $(shields_list_contains,helix_left) + +config SHIELD_HELIX_RIGHT + def_bool $(shields_list_contains,helix_right) \ No newline at end of file diff --git a/app/boards/shields/helix/README.md b/app/boards/shields/helix/README.md new file mode 100644 index 00000000..f8b0e13f --- /dev/null +++ b/app/boards/shields/helix/README.md @@ -0,0 +1,12 @@ +#### Note to user: + +- If desired, RGB underglow must be manually enabled before building and flashing. Check 'helix.conf' to do so. +- Peripheral RGB function is impaired until full support is implemented in the master branch. +- OLED displays are not currently included in this shield. This will be updated after OLED support is live. +- 'KANA' and 'EISUU' input is currently utilized under the 'LANG1' and 'LANG2' keycodes respectively. + +--- + +Thanks to Nicell, KemoNine, petejohanson, TJ "Chormbo The Great", joelspadin/Rinh, Wofiel, Okke, innovaker, +and the rest of the ZMK contributors for their support in constructing this shield. I appreciate your assistance greatly. +This has been a valuable learning experience for me. May this contribution serve the community well. diff --git a/app/boards/shields/helix/boards/nice_nano.overlay b/app/boards/shields/helix/boards/nice_nano.overlay new file mode 100644 index 00000000..78576d13 --- /dev/null +++ b/app/boards/shields/helix/boards/nice_nano.overlay @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +&spi1 { + compatible = "nordic,nrf-spim"; + status = "okay"; + mosi-pin = <6>; + // Unused pins, needed for SPI definition, but not used by the ws2812 driver itself. + sck-pin = <5>; + miso-pin = <7>; + + led_strip: ws2812@0 { + compatible = "worldsemi,ws2812-spi"; + label = "WS2812"; + + /* SPI */ + reg = <0>; /* ignored, but necessary for SPI bindings */ + spi-max-frequency = <4000000>; + + /* WS2812 */ + chain-length = <32>; /* number of LEDs */ + spi-one-frame = <0x70>; + spi-zero-frame = <0x40>; + }; +}; + +/ { + chosen { + zmk,underglow = &led_strip; + }; +}; diff --git a/app/boards/shields/helix/helix.conf b/app/boards/shields/helix/helix.conf new file mode 100644 index 00000000..a8e57338 --- /dev/null +++ b/app/boards/shields/helix/helix.conf @@ -0,0 +1,6 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + +# Enables RGB functionality (Uncomment lines below to enable.) +# CONFIG_ZMK_RGB_UNDERGLOW=y +# CONFIG_WS2812_STRIP=y \ No newline at end of file diff --git a/app/boards/shields/helix/helix.dtsi b/app/boards/shields/helix/helix.dtsi new file mode 100644 index 00000000..8df943f0 --- /dev/null +++ b/app/boards/shields/helix/helix.dtsi @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include + +/ { + chosen { + zmk,kscan = &kscan0; + zmk,matrix_transform = &default_transform; + }; + + default_transform: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + columns = <14>; + rows = <5>; +// | SW1 | SW2 | SW3 | SW4 | SW5 | SW6 | | SW6 | SW5 | SW4 | SW3 | SW2 | SW1 | +// | SW7 | SW8 | SW9 | SW10 | SW11 | SW12 | | SW12 | SW11 | SW10 | SW9 | SW8 | SW7 | +// | SW13 | SW14 | SW15 | SW16 | SW17 | SW18 | | SW18 | SW17 | SW16 | SW15 | SW14 | SW13 | +// | SW19 | SW20 | SW21 | SW22 | SW23 | SW24 | SW25 | | SW25 | SW24 | SW23 | SW22 | SW21 | SW20 | SW19 | +// | SW26 | SW27 | SW28 | SW29 | SW30 | SW31 | SW32 | | SW32 | SW31 | SW30 | SW29 | SW28 | SW27 | SW26 | + map = < +RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,8) RC(0,9) RC(0,10) RC(0,11) RC(0,12) RC(0,13) +RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,8) RC(1,9) RC(1,10) RC(1,11) RC(1,12) RC(1,13) +RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,8) RC(2,9) RC(2,10) RC(2,11) RC(2,12) RC(2,13) +RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(3,6) RC(3,7) RC(3,8) RC(3,9) RC(3,10) RC(3,11) RC(3,12) RC(3,13) +RC(4,0) RC(4,1) RC(4,2) RC(4,3) RC(4,4) RC(4,5) RC(4,6) RC(4,7) RC(4,8) RC(4,9) RC(4,10) RC(4,11) RC(4,12) RC(4,13) + >; + }; + + kscan0: kscan { + compatible = "zmk,kscan-gpio-matrix"; + label = "KSCAN"; + + diode-direction = "col2row"; + row-gpios + = <&pro_micro_d 4 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + ; + + }; +}; \ No newline at end of file diff --git a/app/boards/shields/helix/helix.keymap b/app/boards/shields/helix/helix.keymap new file mode 100644 index 00000000..82327c32 --- /dev/null +++ b/app/boards/shields/helix/helix.keymap @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + + #include + #include + #include + #include + #include + #include + + #define DEFAULT 0 + #define LOWER 1 + #define RAISE 2 + #define ADJUST 3 + +/* NOTE: At the time of the creation of this keymap, there are no specified codes for 'eisuu' and 'kana' input in ZMK. +However, 'LANG1' and 'LANG2' are fully-functioning candidates for 'kana' and 'eisuu' input respectively. +As such, those are in use within the default layer at this time.*/ + +/ { + keymap { + compatible = "zmk,keymap"; + + default_layer { + // --------------------------------------------------------------------------------------------------------------------------------- + // | GRAVE | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | DEL | + // | TAB | Q | W | E | R | T | | Y | U | I | O | P | BSPC | + // | CTRL | A | S | D | F | G | | H | J | K | L | ; | ' | + // | SHIFT | Z | X | C | V | B | LBKT | | RBKT | N | M | , | . | / | RET | + // | ADJUST | ESC | ALT | LGUI | EISUU | LOWER | SPACE | | SPACE | RAISE | KANA | LEFT | DOWN | UP | RIGHT | + bindings = < + &kp GRAVE &kp N1 &kp N2 &kp N3 &kp N4 &kp N5 &kp N6 &kp N7 &kp N8 &kp N9 &kp N0 &kp DEL + &kp TAB &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp BSPC + &kp LCTRL &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SEMI &kp SQT + &kp LSHFT &kp Z &kp X &kp C &kp V &kp B &kp LBKT &kp RBKT &kp N &kp M &kp COMMA &kp PERIOD &kp SLASH &kp RET + &mo ADJUST &kp ESC &kp LALT &kp LGUI &kp LANG2 &mo LOWER &kp SPACE &kp SPACE &mo RAISE &kp LANG1 &kp LEFT &kp DOWN &kp UP &kp RIGHT + >; + }; + lower_layer { + // --------------------------------------------------------------------------------------------------------------------------------- + // | | | | | | | | | | | | | | + // | ~ | ! | @ | # | $ | % | | ^ | & | * | ( | ) | | + // | | | | | | | | | _ | + | { | } | PIPE | + // | | | | | | | ( | | ) | | | | HOME | END | | + // | | | | | | | | | | | | | | | | + bindings = < + &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans + &kp TILDE &kp EXCL &kp AT &kp HASH &kp DLLR &kp PRCNT &kp CARET &kp AMPS &kp ASTRK &kp LPAR &kp RPAR &trans + &trans &trans &trans &trans &trans &trans &trans &kp UNDER &kp PLUS &kp LBRC &kp RBRC &kp PIPE + &trans &trans &trans &trans &trans &trans &kp LPAR &kp RPAR &trans &trans &trans &kp HOME &kp END &trans + &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans + >; + }; + raise_layer { + // --------------------------------------------------------------------------------------------------------------------------------- + // | | | | | | | | | | | | | | + // | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | DEL | + // | | F1 | F2 | F3 | F4 | F5 | | F6 | - | = | [ | ] | \ | + // | | F7 | F8 | F9 | F10 | F11 | | | | F12 | | PSCRN | PG_DN | PG_UP | | + // | | | | | | | | | | | | NEXT | VOL- | VOL+ | PLAY | + bindings = < + &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans + &kp GRAVE &kp N1 &kp N2 &kp N3 &kp N4 &kp N5 &kp N6 &kp N7 &kp N8 &kp N9 &kp N0 &kp DEL + &trans &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp MINUS &kp EQUAL &kp LBKT &kp RBKT &kp BSLH + &trans &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &trans &trans &kp F12 &trans &kp PSCRN &kp PG_DN &kp PG_UP &trans + &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &kp C_NEXT &kp C_VOL_DN &kp C_VOL_UP &kp C_PP + >; + }; + adjust_layer { + // --------------------------------------------------------------------------------------------------------------------------------- + // | ` | ! | @ | # | $ | % | | ^ | & | * | ( | ) | EP TOG | + // | BT CLR | BT SEL0 | BT SEL1 | BT SEL2 | BGT SEL3 | BT SEL4 | | RGB EFF+ | RGB HUE+ | RGB SAT+ | RGB SPD+ | RGB BRI+ | RGB TOG | + // | BT NXT | OUT TOG | OUT USB | OUT BLE | | | | RGB EFF- | RGB HUE- | RGB SAT- | RGB SPD- | RGB BRI- | | + // | BT PRV | | | | | | { | | } | | | | | | | + // | | | | | | | | | | | | | | | | + bindings = < + &kp GRAVE &kp EXCL &kp AT &kp HASH &kp DLLR &kp PRCNT &kp CARET &kp AMPS &kp ASTRK &kp LPAR &kp RPAR &ext_power EP_TOG + &bt BT_CLR &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &rgb_ug RGB_EFF &rgb_ug RGB_HUI &rgb_ug RGB_SAI &rgb_ug RGB_SPI &rgb_ug RGB_BRI &rgb_ug RGB_TOG + &bt BT_NXT &out OUT_TOG &out OUT_USB &out OUT_BLE &trans &trans &rgb_ug RGB_EFR &rgb_ug RGB_HUD &rgb_ug RGB_SAD &rgb_ug RGB_SPD &rgb_ug RGB_BRD &trans + &bt BT_PRV &trans &trans &trans &trans &trans &kp LBRC &kp RBRC &trans &trans &trans &trans &trans &trans + &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans + >; + }; + }; +}; \ No newline at end of file diff --git a/app/boards/shields/helix/helix_left.overlay b/app/boards/shields/helix/helix_left.overlay new file mode 100644 index 00000000..733e55f9 --- /dev/null +++ b/app/boards/shields/helix/helix_left.overlay @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include "helix.dtsi" + +&kscan0 { + col-gpios + = <&pro_micro_a 3 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 2 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 1 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 0 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 15 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 14 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 16 GPIO_ACTIVE_HIGH> + ; +}; diff --git a/app/boards/shields/helix/helix_right.overlay b/app/boards/shields/helix/helix_right.overlay new file mode 100644 index 00000000..2383a30e --- /dev/null +++ b/app/boards/shields/helix/helix_right.overlay @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include "helix.dtsi" + +&default_transform { + col-offset = <7>; +}; + +&kscan0 { + col-gpios + = <&pro_micro_d 16 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 14 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 15 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 0 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 1 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 2 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 3 GPIO_ACTIVE_HIGH> + ; +}; diff --git a/docs/docs/hardware.md b/docs/docs/hardware.md index 244bdd60..0dc17782 100644 --- a/docs/docs/hardware.md +++ b/docs/docs/hardware.md @@ -25,6 +25,7 @@ That being said, there are currently only a few specific [boards](/docs/faq#what - [Kyria](https://splitkb.com/products/kyria-pcb-kit) (`kyria_left` and `kyria_right`) - [Corne](https://github.com/foostan/crkbd) (`corne_left` and `corne_right`) +- [Helix](https://github.com/mcmadhatter/helix) (`helix_left` and `helix_right`) - [Lily58](https://github.com/kata0510/Lily58) (`lily58_left` and `lily58_right`) - [Sofle](https://github.com/josefadamcik/SofleKeyboard) (`sofle_left` and `sofle_right`) - [Splitreus62](https://github.com/Na-Cly/splitreus62) (`splitreus62_left` and `splitreus62_right`) diff --git a/docs/static/setup.ps1 b/docs/static/setup.ps1 index ffd938f4..63cdb725 100644 --- a/docs/static/setup.ps1 +++ b/docs/static/setup.ps1 @@ -91,9 +91,9 @@ Write-Host "Keyboard Shield Selection:" $prompt = "Pick a keyboard" # TODO: Add support for "Other" and linking to docs on adding custom shields in user config repos. -$options = "Kyria", "Lily58", "Corne", "Splitreus62", "Sofle", "Iris", "Reviung41", "RoMac", "RoMac+", "makerdiary M60", "Microdox", "TG4X", "QAZ", "NIBBLE", "Jorne", "Jian", "CRBN", "Tidbit", "Eek!", "BFO-9000" -$names = "kyria", "lily58", "corne", "splitreus62", "sofle", "iris", "reviung41", "romac", "romac_plus", "m60", "microdox", "tg4x", "qaz", "nibble", "jorne", "jian", "crbn", "tidbit", "eek", "bfo9000" -$splits = "y", "y", "y", "y", "y", "y", "n", "n", "n", "n", "y", "n", "n", "n", "y", "y", "n", "n", "n", "n" +$options = "Kyria", "Lily58", "Corne", "Splitreus62", "Sofle", "Iris", "Reviung41", "RoMac", "RoMac+", "makerdiary M60", "Microdox", "TG4X", "QAZ", "NIBBLE", "Jorne", "Jian", "CRBN", "Tidbit", "Eek!", "BFO-9000", "Helix" +$names = "kyria", "lily58", "corne", "splitreus62", "sofle", "iris", "reviung41", "romac", "romac_plus", "m60", "microdox", "tg4x", "qaz", "nibble", "jorne", "jian", "crbn", "tidbit", "eek", "bfo9000", "helix" +$splits = "y", "y", "y", "y", "y", "y", "n", "n", "n", "n", "y", "n", "n", "n", "y", "y", "n", "n", "n", "n", "y" $choice = Get-Choice-From-Options -Options $options -Prompt $prompt $shield_title = $($options[$choice]) diff --git a/docs/static/setup.sh b/docs/static/setup.sh index 486bb06c..89fd1af2 100644 --- a/docs/static/setup.sh +++ b/docs/static/setup.sh @@ -92,7 +92,7 @@ echo "" echo "Keyboard Shield Selection:" prompt="Pick an keyboard:" -options=("Kyria" "Lily58" "Corne" "Splitreus62" "Sofle" "Iris" "Reviung41" "RoMac" "RoMac+" "makerdiary M60" "Microdox" "TG4X" "QAZ" "Jorne" "Jian" "CRBN" "Tidbit" "Eek!" "BF0-9000") +options=("Kyria" "Lily58" "Corne" "Splitreus62" "Sofle" "Iris" "Reviung41" "RoMac" "RoMac+" "makerdiary M60" "Microdox" "TG4X" "QAZ" "Jorne" "Jian" "CRBN" "Tidbit" "Eek!" "BF0-9000" "Helix") PS3="$prompt " # TODO: Add support for "Other" and linking to docs on adding custom shields in user config repos. @@ -120,7 +120,8 @@ select opt in "${options[@]}" "Quit"; do 17 ) shield_title="CRBN" shield="crbn"; split="n"; break;; 18 ) shield_title="Tidbit" shield="tidbit"; split="n" break;; 19 ) shield_title="Eek!" shield="eek"; split="n" break;; - 17 ) shield_title="BFO-9000" shield="bfo9000"; split="y"; break;; + 20 ) shield_title="BFO-9000" shield="bfo9000"; split="y"; break;; + 21 ) shield_title="Helix" shield="helix"; split"y"; break;; # Add link to docs on adding your own custom shield in your ZMK config! # $(( ${#options[@]}+1 )) ) echo "Other!"; break;; From 4c1f615714e84a5b05fe76af69faf446cd09fb45 Mon Sep 17 00:00:00 2001 From: Okke Formsma Date: Tue, 5 Jan 2021 20:29:47 +0100 Subject: [PATCH 33/59] docs(troubleshooting): fix reset uf2 download instructions PR: #512 Co-authored-by: innovaker <66737976+innovaker@users.noreply.github.com> --- docs/docs/troubleshooting.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/docs/troubleshooting.md b/docs/docs/troubleshooting.md index 0fe0b665..23403eec 100644 --- a/docs/docs/troubleshooting.md +++ b/docs/docs/troubleshooting.md @@ -54,7 +54,10 @@ Since then, a much simpler procedure of performing a bluetooth reset for split k **New Procedure:** -1. Log into Github and download the "settings clear" UF2 image from the [latest build in Github Actions](https://github.com/zmkfirmware/zmk/actions?query=workflow%3ABuild+branch%3Amain) +1. [Open the GitHub `Actions` tab and select the `Build` workflow](https://github.com/zmkfirmware/zmk/actions?query=workflow%3ABuild+branch%3Amain). +1. Select the top 'result' on that page. +1. From the next page under "Artifacts", download the `$boardname-settings_reset-zmk` zip file. +1. Unzip the downloaded file. 1. Put each half of the split keyboard into bootloader mode 1. Flash one of the halves of the split with the "settings clear" UF2 image from step 1. Immediately after flashing "settings clear" to the chosen half, immediately put it into bootloader mode to avoid accidental bonding between the halves. From ad238d63dff93bcf33c9f91256699cc4ace09c4b Mon Sep 17 00:00:00 2001 From: Nick Winans Date: Wed, 30 Dec 2020 19:07:03 -0600 Subject: [PATCH 34/59] docs(intro): Update feature table --- docs/docs/intro.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/docs/intro.md b/docs/docs/intro.md index 564eedb7..1e801a46 100644 --- a/docs/docs/intro.md +++ b/docs/docs/intro.md @@ -23,16 +23,16 @@ ZMK is currently missing some features found in other popular firmware. This tab | [Keyboard Codes](codes/#keyboard) | ✅ | ✅ | ✅ | | [Media](codes/#media-controls) & [Consumer](codes/#consumer-controls) Codes | ✅ | ✅ | ✅ | | [Encoders](features/encoders)[^1] | ✅ | | ✅ | -| [OLED Display Support](features/displays)[^2] | 🚧 | 🚧 | ✅ | +| [Display Support](features/displays)[^2] | 🚧 | 🚧 | ✅ | | [RGB Underglow](features/underglow) | ✅ | ✅ | ✅ | -| One Shot Keys | 🚧 | ✅ | ✅ | -| Combo Keys | 🚧 | | ✅ | +| One Shot Keys | ✅ | ✅ | ✅ | +| [Combo Keys](https://github.com/zmkfirmware/zmk/pull/504) | 🚧 | | ✅ | | Macros | 🚧 | ✅ | ✅ | | Mouse Keys | | ✅ | ✅ | | Low Active Power Usage | ✅ | | | -| [Low Power Sleep States](https://github.com/zmkfirmware/zmk/pull/211) | 🚧 | ✅ | | -| [Low Power Mode (VCC Shutoff)](https://github.com/zmkfirmware/zmk/pull/242) | 🚧 | | | -| [Battery Reporting](https://github.com/zmkfirmware/zmk/issues/47) | 🚧 | ✅ | | +| Low Power Sleep States | ✅ | ✅ | | +| [Low Power Mode (VCC Shutoff)](behaviors/power) | ✅ | | | +| Battery Reporting | ✅ | ✅ | | | Shell over BLE | | | | | Realtime Keymap Updating | 💡 | | ✅ | | AVR/8 Bit | | | ✅ | From 56ec200bae7610bae32c558cf1302b02d433471d Mon Sep 17 00:00:00 2001 From: Nick Winans Date: Mon, 4 Jan 2021 15:29:55 -0600 Subject: [PATCH 35/59] =?UTF-8?q?docs(intro):=20Add=20=F0=9F=92=A1=20to=20?= =?UTF-8?q?Mouse=20Keys=20and=20BLE=20Shell?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/docs/intro.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/intro.md b/docs/docs/intro.md index 1e801a46..57670ea0 100644 --- a/docs/docs/intro.md +++ b/docs/docs/intro.md @@ -28,12 +28,12 @@ ZMK is currently missing some features found in other popular firmware. This tab | One Shot Keys | ✅ | ✅ | ✅ | | [Combo Keys](https://github.com/zmkfirmware/zmk/pull/504) | 🚧 | | ✅ | | Macros | 🚧 | ✅ | ✅ | -| Mouse Keys | | ✅ | ✅ | +| Mouse Keys | 💡 | ✅ | ✅ | | Low Active Power Usage | ✅ | | | | Low Power Sleep States | ✅ | ✅ | | | [Low Power Mode (VCC Shutoff)](behaviors/power) | ✅ | | | | Battery Reporting | ✅ | ✅ | | -| Shell over BLE | | | | +| Shell over BLE | 💡 | | | | Realtime Keymap Updating | 💡 | | ✅ | | AVR/8 Bit | | | ✅ | | [Wide Range of ARM Chips Supported](https://docs.zephyrproject.org/latest/boards/index.html) | ✅ | | | From f17584ca0ee4d6bbc0893c0a62a0dc2fa293d2b8 Mon Sep 17 00:00:00 2001 From: innovaker <66737976+innovaker@users.noreply.github.com> Date: Fri, 1 Jan 2021 22:37:34 +0000 Subject: [PATCH 36/59] chore: standardize # style headers Changes made with regex plus some manual tweaks. Find: /(?:(?" exit 1 diff --git a/app/scripts/west-commands.yml b/app/scripts/west-commands.yml index 75be89da..81d6946f 100644 --- a/app/scripts/west-commands.yml +++ b/app/scripts/west-commands.yml @@ -1,4 +1,4 @@ -# Copyright (c) 2020, ZMK Contributors +# Copyright (c) 2020 ZMK Contributors # SPDX-License-Identifier: MIT west-commands: diff --git a/app/scripts/west_commands/test.py b/app/scripts/west_commands/test.py index f79547b9..ac64bb6f 100644 --- a/app/scripts/west_commands/test.py +++ b/app/scripts/west_commands/test.py @@ -1,5 +1,4 @@ # Copyright (c) 2020 The ZMK Contributors -# # SPDX-License-Identifier: MIT '''Test runner for ZMK.''' diff --git a/docs/static/setup.ps1 b/docs/static/setup.ps1 index 63cdb725..bcea9f7a 100644 --- a/docs/static/setup.ps1 +++ b/docs/static/setup.ps1 @@ -1,5 +1,4 @@ # Copyright (c) 2020 The ZMK Contributors -# # SPDX-License-Identifier: MIT $ErrorActionPreference = "Stop" diff --git a/docs/static/setup.sh b/docs/static/setup.sh index 89fd1af2..652160b4 100644 --- a/docs/static/setup.sh +++ b/docs/static/setup.sh @@ -1,7 +1,6 @@ #!/bin/bash # Copyright (c) 2020 The ZMK Contributors -# # SPDX-License-Identifier: MIT set -e From d9265fa470bb916adf5f52e191db0e735dd67867 Mon Sep 17 00:00:00 2001 From: innovaker <66737976+innovaker@users.noreply.github.com> Date: Sat, 2 Jan 2021 14:36:04 +0000 Subject: [PATCH 37/59] ci: add dependabot Checks (daily): - github-actions - npm (docs) --- .github/dependabot.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..1df0848c --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + - package-ecosystem: "npm" + directory: "/docs" + schedule: + interval: "daily" From 561e535a583c437b96f1f4dd9d3325d42a8a9156 Mon Sep 17 00:00:00 2001 From: innovaker <66737976+innovaker@users.noreply.github.com> Date: Fri, 1 Jan 2021 15:17:19 +0000 Subject: [PATCH 38/59] refactor(shields): standardize README.md filenames Renames instances of `readme.md` to `README.md` so that it's easily noticed. PR: #561 --- app/boards/shields/bfo9000/{readme.md => README.md} | 0 app/boards/shields/clueboard_california/{readme.md => README.md} | 0 app/boards/shields/crbn/{readme.md => README.md} | 0 app/boards/shields/eek/{readme.md => README.md} | 0 app/boards/shields/m60/{readme.md => README.md} | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename app/boards/shields/bfo9000/{readme.md => README.md} (100%) rename app/boards/shields/clueboard_california/{readme.md => README.md} (100%) rename app/boards/shields/crbn/{readme.md => README.md} (100%) rename app/boards/shields/eek/{readme.md => README.md} (100%) rename app/boards/shields/m60/{readme.md => README.md} (100%) diff --git a/app/boards/shields/bfo9000/readme.md b/app/boards/shields/bfo9000/README.md similarity index 100% rename from app/boards/shields/bfo9000/readme.md rename to app/boards/shields/bfo9000/README.md diff --git a/app/boards/shields/clueboard_california/readme.md b/app/boards/shields/clueboard_california/README.md similarity index 100% rename from app/boards/shields/clueboard_california/readme.md rename to app/boards/shields/clueboard_california/README.md diff --git a/app/boards/shields/crbn/readme.md b/app/boards/shields/crbn/README.md similarity index 100% rename from app/boards/shields/crbn/readme.md rename to app/boards/shields/crbn/README.md diff --git a/app/boards/shields/eek/readme.md b/app/boards/shields/eek/README.md similarity index 100% rename from app/boards/shields/eek/readme.md rename to app/boards/shields/eek/README.md diff --git a/app/boards/shields/m60/readme.md b/app/boards/shields/m60/README.md similarity index 100% rename from app/boards/shields/m60/readme.md rename to app/boards/shields/m60/README.md From 3e4f2a3dc3555be055d1ae6f1ab91c246438008c Mon Sep 17 00:00:00 2001 From: KemoNine Date: Tue, 5 Jan 2021 21:44:47 +0000 Subject: [PATCH 39/59] feat(tg4x): Add underglow support for tg4x + nice_nano --- app/boards/shields/tg4x/boards/nice_nano.conf | 7 ++++ .../shields/tg4x/boards/nice_nano.overlay | 34 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 app/boards/shields/tg4x/boards/nice_nano.conf create mode 100644 app/boards/shields/tg4x/boards/nice_nano.overlay diff --git a/app/boards/shields/tg4x/boards/nice_nano.conf b/app/boards/shields/tg4x/boards/nice_nano.conf new file mode 100644 index 00000000..7b077948 --- /dev/null +++ b/app/boards/shields/tg4x/boards/nice_nano.conf @@ -0,0 +1,7 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + +# Enable underglow +CONFIG_ZMK_RGB_UNDERGLOW=y +# Use the STRIP config specific to the LEDs you're using +CONFIG_WS2812_STRIP=y \ No newline at end of file diff --git a/app/boards/shields/tg4x/boards/nice_nano.overlay b/app/boards/shields/tg4x/boards/nice_nano.overlay new file mode 100644 index 00000000..60492bec --- /dev/null +++ b/app/boards/shields/tg4x/boards/nice_nano.overlay @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +&spi1 { + compatible = "nordic,nrf-spim"; + status = "okay"; + mosi-pin = <8>; + // Unused pins, needed for SPI definition, but not used by the ws2812 driver itself. + sck-pin = <5>; + miso-pin = <7>; + + led_strip: ws2812@0 { + compatible = "worldsemi,ws2812-spi"; + label = "WS2812"; + + /* SPI */ + reg = <0>; /* ignored, but necessary for SPI bindings */ + spi-max-frequency = <4000000>; + + /* WS2812 */ + chain-length = <7>; /* number of LEDs */ + spi-one-frame = <0x70>; + spi-zero-frame = <0x40>; + }; +}; + +/ { + chosen { + zmk,underglow = &led_strip; + }; +}; From cd8567071be4e24a28fdcb91b33ad4d9bf9186c8 Mon Sep 17 00:00:00 2001 From: KemoNine Date: Tue, 5 Jan 2021 21:45:55 +0000 Subject: [PATCH 40/59] fix(tg4x): Fix tg4x keyboard name in Kconfig --- app/boards/shields/tg4x/Kconfig.defconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/boards/shields/tg4x/Kconfig.defconfig b/app/boards/shields/tg4x/Kconfig.defconfig index ca9fa2c3..6312c080 100644 --- a/app/boards/shields/tg4x/Kconfig.defconfig +++ b/app/boards/shields/tg4x/Kconfig.defconfig @@ -4,6 +4,6 @@ if SHIELD_TG4X config ZMK_KEYBOARD_NAME - default "TG4X" + default "TG4x" -endif \ No newline at end of file +endif From 185ff462d6d1fe488829f20e6664489d4fe371ea Mon Sep 17 00:00:00 2001 From: KemoNine Date: Tue, 5 Jan 2021 21:46:38 +0000 Subject: [PATCH 41/59] docs(tg4x): Add readme for tg4x --- app/boards/shields/tg4x/README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 app/boards/shields/tg4x/README.md diff --git a/app/boards/shields/tg4x/README.md b/app/boards/shields/tg4x/README.md new file mode 100644 index 00000000..087ce251 --- /dev/null +++ b/app/boards/shields/tg4x/README.md @@ -0,0 +1,11 @@ +# TG4x + +Standard setup for the [TG4x](https://github.com/MythosMann/tg4x/) 40% keyboard. + +## Board Revision and Layout Notes + +This TG4x implementation is for... + +* rev 2.1 of the board +* Split spacebar with 2.25U on the left and 2.75U on the right +* 2U right shift From de6ce053918f709cc66412746508d27fc91e22b6 Mon Sep 17 00:00:00 2001 From: innovaker <66737976+innovaker@users.noreply.github.com> Date: Wed, 6 Jan 2021 10:32:18 +0000 Subject: [PATCH 42/59] chore(tg4x): fix copyright header --- app/boards/shields/tg4x/tg4x.overlay | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/boards/shields/tg4x/tg4x.overlay b/app/boards/shields/tg4x/tg4x.overlay index 4b9d4f5b..4de960a3 100644 --- a/app/boards/shields/tg4x/tg4x.overlay +++ b/app/boards/shields/tg4x/tg4x.overlay @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 The ZMK Contrbutors + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ From 7fc28328d04ced9ff419c5cead6f1a971cb94e9d Mon Sep 17 00:00:00 2001 From: innovaker <66737976+innovaker@users.noreply.github.com> Date: Wed, 6 Jan 2021 10:34:04 +0000 Subject: [PATCH 43/59] refactor(tg4x): Cleanup tg4x overlay Tidies pin definitions and map. --- app/boards/shields/tg4x/tg4x.overlay | 71 ++++++++++++++-------------- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/app/boards/shields/tg4x/tg4x.overlay b/app/boards/shields/tg4x/tg4x.overlay index 4de960a3..38e4faa7 100644 --- a/app/boards/shields/tg4x/tg4x.overlay +++ b/app/boards/shields/tg4x/tg4x.overlay @@ -7,50 +7,49 @@ #include / { - chosen { - zmk,kscan = &kscan0; - zmk,matrix_transform = &default_transform; - }; - - default_transform: keymap_transform_0 { - compatible = "zmk,matrix-transform"; - columns = <7>; - rows = <8>; - map = < - RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,6) RC(4,0) RC(4,1) RC(4,2) RC(4,3) RC(4,5) - RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,6) RC(5,0) RC(5,1) RC(5,2) RC(5,3) RC(5,4) - RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(6,0) RC(6,1) RC(6,2) RC(6,3) RC(6,4) - RC(3,0) RC(3,1) RC(3,2) RC(3,4) RC(3,5) RC(7,1) RC(7,2) RC(7,3) RC(7,4) - >; - }; - kscan0: kscan { compatible = "zmk,kscan-gpio-matrix"; label = "KSCAN"; - diode-direction = "col2row"; - col-gpios - = <&pro_micro_d 1 GPIO_ACTIVE_HIGH> - , <&pro_micro_d 14 GPIO_ACTIVE_HIGH> - , <&pro_micro_d 15 GPIO_ACTIVE_HIGH> - , <&pro_micro_a 0 GPIO_ACTIVE_HIGH> - , <&pro_micro_a 1 GPIO_ACTIVE_HIGH> - , <&pro_micro_a 2 GPIO_ACTIVE_HIGH> - , <&pro_micro_a 3 GPIO_ACTIVE_HIGH> - ; + diode-direction = "col2row"; row-gpios - = <&pro_micro_a 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> - , <&pro_micro_a 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> - , <&pro_micro_d 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> - , <&pro_micro_a 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> - , <&pro_micro_d 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> - , <&pro_micro_a 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> - , <&pro_micro_d 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> - , <&pro_micro_d 2 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + = <&pro_micro_d 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 4 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 2 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> ; + col-gpios + = <&pro_micro_d 1 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 14 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 15 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 0 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 1 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 2 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 3 GPIO_ACTIVE_HIGH> + ; }; -}; + default_transform: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + rows = <8>; + columns = <7>; + map = < +RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,6) RC(4,0) RC(4,1) RC(4,2) RC(4,3) RC(4,4) RC(4,5) +RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,6) RC(5,0) RC(5,1) RC(5,2) RC(5,3) RC(5,4) +RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(6,0) RC(6,1) RC(6,2) RC(6,4) +RC(3,0) RC(3,1) RC(3,2) RC(3,4) RC(3,5) RC(7,1) RC(7,2) RC(7,3) RC(7,4) + >; + }; + + chosen { + zmk,kscan = &kscan0; + zmk,matrix_transform = &default_transform; + }; +}; From 7fd8561b457e83bea667b130d6c891bc738db9ab Mon Sep 17 00:00:00 2001 From: KemoNine Date: Tue, 5 Jan 2021 21:50:33 +0000 Subject: [PATCH 44/59] fix(tg4x): Add tg4x.conf to mirror other shield setups --- app/boards/shields/tg4x/tg4x.conf | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 app/boards/shields/tg4x/tg4x.conf diff --git a/app/boards/shields/tg4x/tg4x.conf b/app/boards/shields/tg4x/tg4x.conf new file mode 100644 index 00000000..9d65bb60 --- /dev/null +++ b/app/boards/shields/tg4x/tg4x.conf @@ -0,0 +1,2 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT \ No newline at end of file From 28bec8541b8bd8fe10d52c590700bb5022845f54 Mon Sep 17 00:00:00 2001 From: KemoNine Date: Tue, 5 Jan 2021 21:51:04 +0000 Subject: [PATCH 45/59] style(tg4x): Convert Kconfig spaces to tabs --- app/boards/shields/tg4x/Kconfig.shield | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/boards/shields/tg4x/Kconfig.shield b/app/boards/shields/tg4x/Kconfig.shield index 7e98b710..27166b10 100644 --- a/app/boards/shields/tg4x/Kconfig.shield +++ b/app/boards/shields/tg4x/Kconfig.shield @@ -2,4 +2,4 @@ # SPDX-License-Identifier: MIT config SHIELD_TG4X - def_bool $(shields_list_contains,tg4x) + def_bool $(shields_list_contains,tg4x) From 5880a284c1074d145bf90e66f1420f544502ed83 Mon Sep 17 00:00:00 2001 From: KemoNine Date: Tue, 5 Jan 2021 21:51:59 +0000 Subject: [PATCH 46/59] feat(tg4x): Reconcile with official keymap and tidy-up --- app/boards/shields/tg4x/tg4x.keymap | 88 ++++++++++++++--------------- 1 file changed, 42 insertions(+), 46 deletions(-) diff --git a/app/boards/shields/tg4x/tg4x.keymap b/app/boards/shields/tg4x/tg4x.keymap index cadc41a4..d5e20094 100644 --- a/app/boards/shields/tg4x/tg4x.keymap +++ b/app/boards/shields/tg4x/tg4x.keymap @@ -8,51 +8,47 @@ #include #include -#define DEFAULT 0 -#define LOWER 1 -#define RAISE 2 - / { - behaviors { - hm: homerow_mods { - compatible = "zmk,behavior-hold-tap"; - label = "homerow mods"; - #binding-cells = <2>; - tapping_term_ms = <225>; - flavor = "tap-preferred"; - bindings = <&kp>, <&kp>; - }; - }; + behaviors { + ht: hold_tap { + compatible = "zmk,behavior-hold-tap"; + label = "Hold Tap"; + #binding-cells = <2>; + tapping_term_ms = <200>; + flavor = "tap-preferred"; + bindings = <&kp>, <&kp>; + }; + }; + + keymap { + compatible = "zmk,keymap"; + + default_layer { + bindings = < +&kp ESC &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp SEMI &kp BSPC +&ht CAPS TAB &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp APOS &kp RET +&kp LSHFT &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp COMMA &kp DOT &kp RSHFT +&kp LCTRL &kp LGUI &kp LALT < 1 SPACE &kp SPACE &kp RALT &kp RGUI &mo 2 &kp RCTRL + >; + }; + + function_layer { + bindings = < +&kp GRAVE &kp N1 &kp N2 &kp N3 &kp N4 &kp N5 &kp N6 &kp N7 &kp N8 &kp N9 &kp N0 &kp MINUS &kp DEL +&none &kp HOME &kp PG_UP &trans &trans &trans &kp LBKT &kp RBKT &kp EQUAL &kp BSLH &kp FSLH &trans +&trans &kp END &kp PG_DN &trans &trans &trans &trans &trans &trans &kp UP &trans +&trans &trans &trans &trans &trans &trans &kp LEFT &kp DOWN &kp RIGHT + >; + }; + + other_layer { + bindings = < +&kp PRINTSCREEN &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 +&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans +&trans &bt BT_CLR &bt BT_PRV &bt BT_NXT &trans &trans &trans &trans &bootloader &reset &trans +&trans &trans &trans &trans &trans &kp C_VOL_UP &kp C_VOL_DN &kp C_PP + >; + }; + + }; }; - -/ { - keymap { - compatible = "zmk,keymap"; - - default_layer { - bindings = < - &kp ESC &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp BSPC - &kp TAB &hm LGUI A &hm LALT S &hm LCTRL D &hm LSHFT F &kp G &kp H &hm RSHFT J &hm RCTRL K &hm RALT L &hm RGUI SEMI &kp RET - &kp LSHFT &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp COMMA &kp DOT &kp FSLH &kp SQT - &kp LCTRL &kp LALT &kp LGUI < 1 BSPC < 2 SPACE &kp LEFT &kp DOWN &kp UP &kp RIGHT - >; - }; - lower { - bindings = < - &kp GRAVE &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &kp PSCRN - &kp DEL &trans &kp K_VOL_UP &trans &trans &trans &trans &kp LEFT &kp DOWN &kp UP &kp RIGHT &trans - &trans &trans &kp K_VOL_DN &trans &trans &trans &trans &trans &trans &bt BT_PRV &bt BT_NXT &bt BT_CLR - &bootloader &reset &trans &trans &trans &trans &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 - >; - }; - - raise { - bindings = < - &kp GRAVE &kp N1 &kp N2 &kp N3 &kp N4 &kp N5 &kp N6 &kp N7 &kp N8 &kp N9 &kp N0 &kp PSCRN - &kp DEL &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp MINUS &kp EQUAL &kp LBKT &kp RBKT &kp BSLH - &trans &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &kp TILDE &kp HOME &kp PG_UP &kp PG_DN &kp END - &trans &trans &trans &trans &trans &trans &kp C_NEXT &kp C_VOL_DN &kp C_VOL_UP &kp C_PP - >; - }; - }; -}; \ No newline at end of file From f0312092c7f3b9b24124b615bf438ad52aa4643f Mon Sep 17 00:00:00 2001 From: innovaker <66737976+innovaker@users.noreply.github.com> Date: Fri, 8 Jan 2021 15:55:51 +0000 Subject: [PATCH 47/59] fix(setup.sh): add NIBBLE to options This was missing from its original commit. Refs: f3153b17d293466160c03f7cb618a2be939c55f7 --- docs/static/setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/static/setup.sh b/docs/static/setup.sh index 652160b4..5384277b 100644 --- a/docs/static/setup.sh +++ b/docs/static/setup.sh @@ -91,7 +91,7 @@ echo "" echo "Keyboard Shield Selection:" prompt="Pick an keyboard:" -options=("Kyria" "Lily58" "Corne" "Splitreus62" "Sofle" "Iris" "Reviung41" "RoMac" "RoMac+" "makerdiary M60" "Microdox" "TG4X" "QAZ" "Jorne" "Jian" "CRBN" "Tidbit" "Eek!" "BF0-9000" "Helix") +options=("Kyria" "Lily58" "Corne" "Splitreus62" "Sofle" "Iris" "Reviung41" "RoMac" "RoMac+" "makerdiary M60" "Microdox" "TG4X" "QAZ" "NIBBLE" "Jorne" "Jian" "CRBN" "Tidbit" "Eek!" "BF0-9000" "Helix") PS3="$prompt " # TODO: Add support for "Other" and linking to docs on adding custom shields in user config repos. From 964b613e982a707e00c8cb5cb07d8dfcfab25419 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Fri, 8 Jan 2021 11:11:20 -0500 Subject: [PATCH 48/59] fix(setup): Fix typo for split variable assignment --- docs/static/setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/static/setup.sh b/docs/static/setup.sh index 5384277b..8ac39435 100644 --- a/docs/static/setup.sh +++ b/docs/static/setup.sh @@ -120,7 +120,7 @@ select opt in "${options[@]}" "Quit"; do 18 ) shield_title="Tidbit" shield="tidbit"; split="n" break;; 19 ) shield_title="Eek!" shield="eek"; split="n" break;; 20 ) shield_title="BFO-9000" shield="bfo9000"; split="y"; break;; - 21 ) shield_title="Helix" shield="helix"; split"y"; break;; + 21 ) shield_title="Helix" shield="helix"; split="y"; break;; # Add link to docs on adding your own custom shield in your ZMK config! # $(( ${#options[@]}+1 )) ) echo "Other!"; break;; From 97ed0cc733bc3fb411fe13ee776e37f932e67aa4 Mon Sep 17 00:00:00 2001 From: Nick Winans Date: Thu, 7 Jan 2021 00:08:34 -0600 Subject: [PATCH 49/59] feat(core): Add USB logging Kconfig option --- app/Kconfig | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/app/Kconfig b/app/Kconfig index 4341df11..f4860210 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -293,6 +293,50 @@ config ZMK_KSCAN_COMPOSITE_DRIVER #KSCAN Settings endmenu +menu "USB Logging" + +config ZMK_USB_LOGGING + bool "Enable USB CDC ACM logging to help debug" + select LOG + select USB + select USB_DEVICE_STACK + select USB_CDC_ACM + select SERIAL + select CONSOLE + select UART_INTERRUPT_DRIVEN + select UART_LINE_CTRL + select UART_CONSOLE + select USB_UART_CONSOLE + +if ZMK_USB_LOGGING + +config ZMK_LOG_LEVEL + default 4 + +config USB_CDC_ACM_RINGBUF_SIZE + default 1024 + +config USB_CDC_ACM_DEVICE_NAME + default "CDC_ACM" + +config USB_CDC_ACM_DEVICE_COUNT + default 1 + +config UART_CONSOLE_ON_DEV_NAME + default "CDC_ACM_0" + +config LOG_BUFFER_SIZE + default 8192 + +config LOG_STRDUP_BUF_COUNT + default 16 + +#ZMK_USB_LOGGING +endif + +#USB Logging +endmenu + if SETTINGS config ZMK_SETTINGS_SAVE_DEBOUNCE From 167600f01d0000539bf1f963dbcee0d9b15600cc Mon Sep 17 00:00:00 2001 From: Nick Winans Date: Wed, 30 Dec 2020 20:09:24 -0600 Subject: [PATCH 50/59] docs(logging): Update documentation on USB logging --- docs/docs/development/usb-logging.md | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/docs/docs/development/usb-logging.md b/docs/docs/development/usb-logging.md index 420b98d1..4149ef43 100644 --- a/docs/docs/development/usb-logging.md +++ b/docs/docs/development/usb-logging.md @@ -20,8 +20,8 @@ It is recommended to only enable logging when needed, and not leaving it on by d ## Kconfig -The following KConfig values need to be set, either by copy and pasting into the `app/prj.conf` file, or by running -`west build -t menuconfig` and manually enabling the various settings in that UI. +The `CONFIG_ZMK_USB_LOGGING` KConfig value needs to be set, either by copy and pasting into the `app/prj.conf` file, or by running +`west build -t menuconfig` and manually enabling the setting in that UI at `ZMK -> Advanced -> USB Logging`. :::note If you are debugging your own keyboard in your [user config repository](./user-setup.md), use @@ -32,27 +32,7 @@ for you successfully. ``` # Turn on logging, and set ZMK logging to debug output -CONFIG_LOG=y -CONFIG_ZMK_LOG_LEVEL_DBG=y - -# Turn on USB CDC ACM device -CONFIG_USB=y -CONFIG_USB_DEVICE_STACK=y -CONFIG_USB_CDC_ACM=y -CONFIG_USB_CDC_ACM_RINGBUF_SIZE=1024 -CONFIG_USB_CDC_ACM_DEVICE_NAME="CDC_ACM" -CONFIG_USB_CDC_ACM_DEVICE_COUNT=1 - -# Enable serial console -CONFIG_SERIAL=y -CONFIG_CONSOLE=y -CONFIG_UART_INTERRUPT_DRIVEN=y -CONFIG_UART_LINE_CTRL=y - -# Enable USB UART, and set the console device -CONFIG_UART_CONSOLE=y -CONFIG_USB_UART_CONSOLE=y -CONFIG_UART_CONSOLE_ON_DEV_NAME="CDC_ACM_0" +CONFIG_ZMK_USB_LOGGING=y ``` ## Viewing Logs From 99f932a47d4705c7ddde83256fada9aa7aa3bda6 Mon Sep 17 00:00:00 2001 From: KemoNine Date: Tue, 15 Dec 2020 06:00:52 +0000 Subject: [PATCH 51/59] (feat) Allow setting underglow color by key press --- app/dts/behaviors/rgb_underglow.dtsi | 2 +- .../behaviors/zmk,behavior-rgb-underglow.yaml | 2 +- app/include/dt-bindings/zmk/rgb.h | 37 +++++++++++++------ app/include/zmk/rgb_underglow.h | 1 + app/src/behaviors/behavior_rgb_underglow.c | 25 +++++++------ app/src/rgb_underglow.c | 13 +++++++ 6 files changed, 56 insertions(+), 24 deletions(-) diff --git a/app/dts/behaviors/rgb_underglow.dtsi b/app/dts/behaviors/rgb_underglow.dtsi index 22aff93f..8b88f8c8 100644 --- a/app/dts/behaviors/rgb_underglow.dtsi +++ b/app/dts/behaviors/rgb_underglow.dtsi @@ -9,7 +9,7 @@ rgb_ug: behavior_rgb_underglow { compatible = "zmk,behavior-rgb-underglow"; label = "RGB_UNDERGLOW"; - #binding-cells = <1>; + #binding-cells = <2>; }; }; }; diff --git a/app/dts/bindings/behaviors/zmk,behavior-rgb-underglow.yaml b/app/dts/bindings/behaviors/zmk,behavior-rgb-underglow.yaml index 2cb74b9c..d301998a 100644 --- a/app/dts/bindings/behaviors/zmk,behavior-rgb-underglow.yaml +++ b/app/dts/bindings/behaviors/zmk,behavior-rgb-underglow.yaml @@ -5,4 +5,4 @@ description: RGB Underglow Action compatible: "zmk,behavior-rgb-underglow" -include: one_param.yaml +include: two_param.yaml diff --git a/app/include/dt-bindings/zmk/rgb.h b/app/include/dt-bindings/zmk/rgb.h index eb721807..1f7b44ec 100644 --- a/app/include/dt-bindings/zmk/rgb.h +++ b/app/include/dt-bindings/zmk/rgb.h @@ -4,14 +4,29 @@ * SPDX-License-Identifier: MIT */ -#define RGB_TOG 0 -#define RGB_HUI 1 -#define RGB_HUD 2 -#define RGB_SAI 3 -#define RGB_SAD 4 -#define RGB_BRI 5 -#define RGB_BRD 6 -#define RGB_SPI 7 -#define RGB_SPD 8 -#define RGB_EFF 9 -#define RGB_EFR 10 +#define RGB_TOG_CMD 0 +#define RGB_HUI_CMD 1 +#define RGB_HUD_CMD 2 +#define RGB_SAI_CMD 3 +#define RGB_SAD_CMD 4 +#define RGB_BRI_CMD 5 +#define RGB_BRD_CMD 6 +#define RGB_SPI_CMD 7 +#define RGB_SPD_CMD 8 +#define RGB_EFF_CMD 9 +#define RGB_EFR_CMD 10 +#define RGB_COLOR_HSB_CMD 11 + +#define RGB_TOG RGB_TOG_CMD 0 +#define RGB_HUI RGB_HUI_CMD 0 +#define RGB_HUD RGB_HUD_CMD 0 +#define RGB_SAI RGB_SAI_CMD 0 +#define RGB_SAD RGB_SAD_CMD 0 +#define RGB_BRI RGB_BRI_CMD 0 +#define RGB_BRD RGB_BRD_CMD 0 +#define RGB_SPI RGB_SPI_CMD 0 +#define RGB_SPD RGB_SPD_CMD 0 +#define RGB_EFF RGB_EFF_CMD 0 +#define RGB_EFR RGB_EFR_CMD 0 +#define RGB_COLOR_HSB(h, s, v) RGB_COLOR_HSB_CMD(((h) << 16) + ((s) << 8) + (v)) +#define RGB_COLOR_HSV RGB_COLOR_HSB \ No newline at end of file diff --git a/app/include/zmk/rgb_underglow.h b/app/include/zmk/rgb_underglow.h index 94cc32cc..7fcd42dd 100644 --- a/app/include/zmk/rgb_underglow.h +++ b/app/include/zmk/rgb_underglow.h @@ -12,3 +12,4 @@ int zmk_rgb_underglow_change_hue(int direction); int zmk_rgb_underglow_change_sat(int direction); int zmk_rgb_underglow_change_brt(int direction); int zmk_rgb_underglow_change_spd(int direction); +int zmk_rgb_underglow_set_hsb(uint16_t hue, uint8_t saturation, uint8_t brightness); \ No newline at end of file diff --git a/app/src/behaviors/behavior_rgb_underglow.c b/app/src/behaviors/behavior_rgb_underglow.c index 399123a3..07f24940 100644 --- a/app/src/behaviors/behavior_rgb_underglow.c +++ b/app/src/behaviors/behavior_rgb_underglow.c @@ -21,28 +21,31 @@ static int behavior_rgb_underglow_init(const struct device *dev) { return 0; } static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event) { switch (binding->param1) { - case RGB_TOG: + case RGB_TOG_CMD: return zmk_rgb_underglow_toggle(); - case RGB_HUI: + case RGB_HUI_CMD: return zmk_rgb_underglow_change_hue(1); - case RGB_HUD: + case RGB_HUD_CMD: return zmk_rgb_underglow_change_hue(-1); - case RGB_SAI: + case RGB_SAI_CMD: return zmk_rgb_underglow_change_sat(1); - case RGB_SAD: + case RGB_SAD_CMD: return zmk_rgb_underglow_change_sat(-1); - case RGB_BRI: + case RGB_BRI_CMD: return zmk_rgb_underglow_change_brt(1); - case RGB_BRD: + case RGB_BRD_CMD: return zmk_rgb_underglow_change_brt(-1); - case RGB_SPI: + case RGB_SPI_CMD: return zmk_rgb_underglow_change_spd(1); - case RGB_SPD: + case RGB_SPD_CMD: return zmk_rgb_underglow_change_spd(-1); - case RGB_EFF: + case RGB_EFF_CMD: return zmk_rgb_underglow_cycle_effect(1); - case RGB_EFR: + case RGB_EFR_CMD: return zmk_rgb_underglow_cycle_effect(-1); + case RGB_COLOR_HSB_CMD: + return zmk_rgb_underglow_set_hsb((binding->param2 >> 16) & 0xFFFF, + (binding->param2 >> 8) & 0xFF, binding->param2 & 0xFF); } return -ENOTSUP; diff --git a/app/src/rgb_underglow.c b/app/src/rgb_underglow.c index 73a5c5e9..a2c02ed8 100644 --- a/app/src/rgb_underglow.c +++ b/app/src/rgb_underglow.c @@ -346,6 +346,19 @@ int zmk_rgb_underglow_toggle() { return zmk_rgb_underglow_save_state(); } +int zmk_rgb_underglow_set_hsb(uint16_t hue, uint8_t saturation, uint8_t brightness) { + if (hue > 360 || saturation > 100 || brightness > 100) { + return -ENOTSUP; + } + + state.hue = hue; + state.saturation = saturation; + state.brightness = brightness; + state.current_effect = UNDERGLOW_EFFECT_SOLID; + + return 0; +} + int zmk_rgb_underglow_change_hue(int direction) { if (!led_strip) return -ENODEV; From 79b4a0ea6fdda3bd65cadd40106518ac20914cf5 Mon Sep 17 00:00:00 2001 From: KemoNine Date: Tue, 15 Dec 2020 11:13:02 +0000 Subject: [PATCH 52/59] Add RGB_COLOR_HSB to lighting documentation --- docs/docs/behaviors/lighting.md | 58 +++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/docs/docs/behaviors/lighting.md b/docs/docs/behaviors/lighting.md index 2d4f532e..2a204e52 100644 --- a/docs/docs/behaviors/lighting.md +++ b/docs/docs/behaviors/lighting.md @@ -21,19 +21,20 @@ This will allow you to reference the actions defined in this header such as `RGB Here is a table describing the action for each define: -| Define | Action | -| --------- | --------------------------------------------------------- | -| `RGB_TOG` | Toggles the RGB feature on and off | -| `RGB_HUI` | Increases the hue of the RGB feature | -| `RGB_HUD` | Decreases the hue of the RGB feature | -| `RGB_SAI` | Increases the saturation of the RGB feature | -| `RGB_SAD` | Decreases the saturation of the RGB feature | -| `RGB_BRI` | Increases the brightness of the RGB feature | -| `RGB_BRD` | Decreases the brightness of the RGB feature | -| `RGB_SPI` | Increases the speed of the RGB feature effect's animation | -| `RGB_SPD` | Decreases the speed of the RGB feature effect's animation | -| `RGB_EFF` | Cycles the RGB feature's effect forwards | -| `RGB_EFR` | Cycles the RGB feature's effect reverse | +| Define | Action | +| --------------- | ---------------------------------------------------------------------------------------------- | +| `RGB_TOG` | Toggles the RGB feature on and off | +| `RGB_HUI` | Increases the hue of the RGB feature | +| `RGB_HUD` | Decreases the hue of the RGB feature | +| `RGB_SAI` | Increases the saturation of the RGB feature | +| `RGB_SAD` | Decreases the saturation of the RGB feature | +| `RGB_BRI` | Increases the brightness of the RGB feature | +| `RGB_BRD` | Decreases the brightness of the RGB feature | +| `RGB_SPI` | Increases the speed of the RGB feature effect's animation | +| `RGB_SPD` | Decreases the speed of the RGB feature effect's animation | +| `RGB_EFF` | Cycles the RGB feature's effect forwards | +| `RGB_EFR` | Cycles the RGB feature's effect reverse | +| `RGB_COLOR_HSB` | Sets a specific [HSB (HSV)](https://en.wikipedia.org/wiki/HSL_and_HSV) value for the underglow | ## RGB Underglow @@ -42,10 +43,31 @@ The "RGB underglow" behavior completes an RGB action given on press. ### Behavior Binding - Reference: `&rgb_ug` -- Parameter: The RGB action define, e.g. `RGB_TOG` or `RGB_BRI` +- Parameter #1: The RGB action define, e.g. `RGB_TOG` or `RGB_BRI` +- Parameter #1: Only applies to `RGB_COLOR_HSB` and is the HSB values of the color to set within parenthesis and separated by a common (see below for an example) -Example: +:::note HSB Values -``` -&rgb_ug RGB_TOG -``` +When specifying HSB values you'll need to use `RGB_COLOR_HSB(h, s, b)` in your keymap file. See below for an example. + +Value Limits: + +- Hue values can _not_ exceed 360 (degrees) +- Saturation values can _not_ exceed 100 (percent) +- Brightness values can _not_ exceed 100 (percent) + +::: + +### Examples + +1. Toggle underglow on/off + + ``` + &rgb_ug RGB_TOG + ``` + +1. Set a specific HSB color (green) + + ``` + &rgb_ug RGB_COLOR_HSB(128,100,100) + ``` From 6345bd54688a20cb054e061db3b3c7102bd0a0d4 Mon Sep 17 00:00:00 2001 From: KemoNine Date: Tue, 15 Dec 2020 11:19:52 +0000 Subject: [PATCH 53/59] Remove setting the animation/effect when setting hsv ; some of the effects like glowing will use the hsv color specified --- app/src/rgb_underglow.c | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/rgb_underglow.c b/app/src/rgb_underglow.c index a2c02ed8..f3bd7a9d 100644 --- a/app/src/rgb_underglow.c +++ b/app/src/rgb_underglow.c @@ -354,7 +354,6 @@ int zmk_rgb_underglow_set_hsb(uint16_t hue, uint8_t saturation, uint8_t brightne state.hue = hue; state.saturation = saturation; state.brightness = brightness; - state.current_effect = UNDERGLOW_EFFECT_SOLID; return 0; } From af563e9dbcad8ca4c06f956c342fae79e3706ff7 Mon Sep 17 00:00:00 2001 From: KemoNine Date: Wed, 30 Dec 2020 21:10:18 +0000 Subject: [PATCH 54/59] Fix parameter number --- docs/docs/behaviors/lighting.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/behaviors/lighting.md b/docs/docs/behaviors/lighting.md index 2a204e52..6e6732be 100644 --- a/docs/docs/behaviors/lighting.md +++ b/docs/docs/behaviors/lighting.md @@ -44,7 +44,7 @@ The "RGB underglow" behavior completes an RGB action given on press. - Reference: `&rgb_ug` - Parameter #1: The RGB action define, e.g. `RGB_TOG` or `RGB_BRI` -- Parameter #1: Only applies to `RGB_COLOR_HSB` and is the HSB values of the color to set within parenthesis and separated by a common (see below for an example) +- Parameter #2: Only applies to `RGB_COLOR_HSB` and is the HSB values of the color to set within parenthesis and separated by a common (see below for an example) :::note HSB Values From 002a89765f27fc295cf14af1648348c3bc0032ae Mon Sep 17 00:00:00 2001 From: Nick Winans Date: Fri, 8 Jan 2021 15:32:55 -0600 Subject: [PATCH 55/59] refactor(Kconfig): Set USB default based on hardware capabilities Removes the USB default under every split right half in favor of a default based on hardware capabilities in the main app Kconfig. --- app/Kconfig | 3 +++ app/boards/shields/bfo9000/Kconfig.defconfig | 3 --- app/boards/shields/corne/Kconfig.defconfig | 3 --- app/boards/shields/cradio/Kconfig.defconfig | 3 --- app/boards/shields/helix/Kconfig.defconfig | 3 --- app/boards/shields/iris/Kconfig.defconfig | 3 --- app/boards/shields/jian/Kconfig.defconfig | 3 --- app/boards/shields/jorne/Kconfig.defconfig | 3 --- app/boards/shields/kyria/Kconfig.defconfig | 3 --- app/boards/shields/lily58/Kconfig.defconfig | 3 --- app/boards/shields/microdox/Kconfig.defconfig | 3 --- app/boards/shields/quefrency/Kconfig.defconfig | 3 --- app/boards/shields/sofle/Kconfig.defconfig | 3 --- app/boards/shields/splitreus62/Kconfig.defconfig | 3 --- 14 files changed, 3 insertions(+), 39 deletions(-) diff --git a/app/Kconfig b/app/Kconfig index f4860210..f5d92a88 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -361,6 +361,9 @@ config KERNEL_BIN_NAME config REBOOT default y +config USB + default y if HAS_HW_NRF_USBD + module = ZMK module-str = zmk source "subsys/logging/Kconfig.template.log_config" diff --git a/app/boards/shields/bfo9000/Kconfig.defconfig b/app/boards/shields/bfo9000/Kconfig.defconfig index 1251113f..a8584886 100644 --- a/app/boards/shields/bfo9000/Kconfig.defconfig +++ b/app/boards/shields/bfo9000/Kconfig.defconfig @@ -16,9 +16,6 @@ if SHIELD_BFO9000_RIGHT config ZMK_KEYBOARD_NAME default "BFO9000 Right" -config USB - default y - endif if SHIELD_BFO9000_LEFT || SHIELD_BFO9000_RIGHT diff --git a/app/boards/shields/corne/Kconfig.defconfig b/app/boards/shields/corne/Kconfig.defconfig index 6cf60b18..ef4817b5 100644 --- a/app/boards/shields/corne/Kconfig.defconfig +++ b/app/boards/shields/corne/Kconfig.defconfig @@ -12,9 +12,6 @@ if SHIELD_CORNE_RIGHT config ZMK_KEYBOARD_NAME default "Corne Right" - -config USB - default y endif diff --git a/app/boards/shields/cradio/Kconfig.defconfig b/app/boards/shields/cradio/Kconfig.defconfig index 25bb4331..5e826bf0 100644 --- a/app/boards/shields/cradio/Kconfig.defconfig +++ b/app/boards/shields/cradio/Kconfig.defconfig @@ -16,9 +16,6 @@ if SHIELD_CRADIO_RIGHT config ZMK_KEYBOARD_NAME default "cradio right" -config USB - default y - endif if SHIELD_CRADIO_LEFT || SHIELD_CRADIO_RIGHT diff --git a/app/boards/shields/helix/Kconfig.defconfig b/app/boards/shields/helix/Kconfig.defconfig index f58684a8..f0a4f880 100644 --- a/app/boards/shields/helix/Kconfig.defconfig +++ b/app/boards/shields/helix/Kconfig.defconfig @@ -16,9 +16,6 @@ if SHIELD_HELIX_RIGHT config ZMK_KEYBOARD_NAME default "Helix Right" -config USB - default y - endif if SHIELD_HELIX_LEFT || SHIELD_HELIX_RIGHT diff --git a/app/boards/shields/iris/Kconfig.defconfig b/app/boards/shields/iris/Kconfig.defconfig index a43c0073..57b8c1ee 100644 --- a/app/boards/shields/iris/Kconfig.defconfig +++ b/app/boards/shields/iris/Kconfig.defconfig @@ -16,9 +16,6 @@ if SHIELD_IRIS_RIGHT config ZMK_KEYBOARD_NAME default "Iris Right" -config USB - default y - endif if SHIELD_IRIS_LEFT || SHIELD_IRIS_RIGHT diff --git a/app/boards/shields/jian/Kconfig.defconfig b/app/boards/shields/jian/Kconfig.defconfig index 07023a24..fc1f1995 100644 --- a/app/boards/shields/jian/Kconfig.defconfig +++ b/app/boards/shields/jian/Kconfig.defconfig @@ -14,9 +14,6 @@ if SHIELD_JIAN_RIGHT config ZMK_KEYBOARD_NAME default "Jian Right" - -config USB - default y endif diff --git a/app/boards/shields/jorne/Kconfig.defconfig b/app/boards/shields/jorne/Kconfig.defconfig index 18dcabe1..860cb12f 100644 --- a/app/boards/shields/jorne/Kconfig.defconfig +++ b/app/boards/shields/jorne/Kconfig.defconfig @@ -14,9 +14,6 @@ if SHIELD_JORNE_RIGHT config ZMK_KEYBOARD_NAME default "Jorne Right" - -config USB - default y endif diff --git a/app/boards/shields/kyria/Kconfig.defconfig b/app/boards/shields/kyria/Kconfig.defconfig index d0c17105..99e47bfe 100644 --- a/app/boards/shields/kyria/Kconfig.defconfig +++ b/app/boards/shields/kyria/Kconfig.defconfig @@ -15,9 +15,6 @@ if SHIELD_KYRIA_RIGHT config ZMK_KEYBOARD_NAME default "Kyria Right" -config USB - default y - endif if SHIELD_KYRIA_LEFT || SHIELD_KYRIA_RIGHT diff --git a/app/boards/shields/lily58/Kconfig.defconfig b/app/boards/shields/lily58/Kconfig.defconfig index ebcfa7b7..915cc70e 100644 --- a/app/boards/shields/lily58/Kconfig.defconfig +++ b/app/boards/shields/lily58/Kconfig.defconfig @@ -14,9 +14,6 @@ if SHIELD_LILY58_RIGHT config ZMK_KEYBOARD_NAME default "Lily58 Right" -config USB - default y - endif if SHIELD_LILY58_LEFT || SHIELD_LILY58_RIGHT diff --git a/app/boards/shields/microdox/Kconfig.defconfig b/app/boards/shields/microdox/Kconfig.defconfig index 0afd7491..be39c9f8 100644 --- a/app/boards/shields/microdox/Kconfig.defconfig +++ b/app/boards/shields/microdox/Kconfig.defconfig @@ -17,9 +17,6 @@ if SHIELD_MICRODOX_RIGHT config ZMK_KEYBOARD_NAME default "Microdox Right" -config USB - default y - endif if SHIELD_MICRODOX_LEFT || SHIELD_MICRODOX_RIGHT diff --git a/app/boards/shields/quefrency/Kconfig.defconfig b/app/boards/shields/quefrency/Kconfig.defconfig index 5a7d964a..de44702f 100644 --- a/app/boards/shields/quefrency/Kconfig.defconfig +++ b/app/boards/shields/quefrency/Kconfig.defconfig @@ -17,9 +17,6 @@ if SHIELD_QUEFRENCY_RIGHT config ZMK_KEYBOARD_NAME default "Quefrency Right" -config USB - default y - endif if SHIELD_QUEFRENCY_LEFT || SHIELD_QUEFRENCY_RIGHT diff --git a/app/boards/shields/sofle/Kconfig.defconfig b/app/boards/shields/sofle/Kconfig.defconfig index 765afea4..6a580bfe 100644 --- a/app/boards/shields/sofle/Kconfig.defconfig +++ b/app/boards/shields/sofle/Kconfig.defconfig @@ -16,9 +16,6 @@ if SHIELD_SOFLE_RIGHT config ZMK_KEYBOARD_NAME default "Sofle Right" -config USB - default y - endif if SHIELD_SOFLE_LEFT || SHIELD_SOFLE_RIGHT diff --git a/app/boards/shields/splitreus62/Kconfig.defconfig b/app/boards/shields/splitreus62/Kconfig.defconfig index 26c2e937..fdaa3779 100644 --- a/app/boards/shields/splitreus62/Kconfig.defconfig +++ b/app/boards/shields/splitreus62/Kconfig.defconfig @@ -18,9 +18,6 @@ if SHIELD_SPLITREUS62_RIGHT config ZMK_KEYBOARD_NAME default "Splitreus62 Right" -config USB - default y - endif if SHIELD_SPLITREUS62_LEFT || SHIELD_SPLITREUS62_RIGHT From 0c6686f6e8ccb23465655458a2837081c3eda5e9 Mon Sep 17 00:00:00 2001 From: Nick Winans Date: Thu, 7 Jan 2021 12:36:49 -0600 Subject: [PATCH 56/59] docs(split): Remove USB configuration on right half --- docs/docs/development/new-shield.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/docs/development/new-shield.md b/docs/docs/development/new-shield.md index ceb81d10..6fac2075 100644 --- a/docs/docs/development/new-shield.md +++ b/docs/docs/development/new-shield.md @@ -111,9 +111,6 @@ if SHIELD_MY_BOARD_RIGHT config ZMK_KEYBOARD_NAME default "My Awesome Keyboard Right" -config USB - default y - endif if SHIELD_MY_BOARD_LEFT || SHIELD_MY_BOARD_RIGHT From 4cfe7885a09917ec267577ed49b9c807144c6cb1 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Mon, 4 Jan 2021 13:44:57 -0500 Subject: [PATCH 57/59] chore: Initial simple CODEOWNERS. --- CODEOWNERS | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 CODEOWNERS diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 00000000..d9bf0d44 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,5 @@ +* @zmkfirmware/core + +/app/boards @zmkfirmware/boards-shields + +/docs @zmkfirmware/docs \ No newline at end of file From 90c2c6672fbf7fb575b61dd9f5a482e1ffc5dbcd Mon Sep 17 00:00:00 2001 From: innovaker <66737976+innovaker@users.noreply.github.com> Date: Fri, 8 Jan 2021 16:02:24 +0000 Subject: [PATCH 58/59] fix(setup.sh): rename BF0-9000 to BFO-9000 Replaces BF0 (zero) with BFO. Refs: dcd665999a5ee04372559d56fc22b9a2d0784bf2 PR: #595 --- docs/static/setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/static/setup.sh b/docs/static/setup.sh index 8ac39435..34f0f054 100644 --- a/docs/static/setup.sh +++ b/docs/static/setup.sh @@ -91,7 +91,7 @@ echo "" echo "Keyboard Shield Selection:" prompt="Pick an keyboard:" -options=("Kyria" "Lily58" "Corne" "Splitreus62" "Sofle" "Iris" "Reviung41" "RoMac" "RoMac+" "makerdiary M60" "Microdox" "TG4X" "QAZ" "NIBBLE" "Jorne" "Jian" "CRBN" "Tidbit" "Eek!" "BF0-9000" "Helix") +options=("Kyria" "Lily58" "Corne" "Splitreus62" "Sofle" "Iris" "Reviung41" "RoMac" "RoMac+" "makerdiary M60" "Microdox" "TG4X" "QAZ" "NIBBLE" "Jorne" "Jian" "CRBN" "Tidbit" "Eek!" "BFO-9000" "Helix") PS3="$prompt " # TODO: Add support for "Other" and linking to docs on adding custom shields in user config repos. From feb0d5b90cbbb1a1026bf356afd788c860824ccf Mon Sep 17 00:00:00 2001 From: Okke Formsma Date: Fri, 11 Dec 2020 23:24:44 +0100 Subject: [PATCH 59/59] feat(combos): initial implementation closes #45 --- app/CMakeLists.txt | 1 + app/Kconfig | 17 + app/dts/bindings/zmk,combos.yaml | 22 + app/src/combo.c | 466 ++++++++++++++++++ .../combos-and-holdtaps-0/events.patterns | 2 + .../keycode_events.snapshot | 4 + .../combos-and-holdtaps-0/native_posix.keymap | 47 ++ .../combos-and-holdtaps-1/events.patterns | 2 + .../keycode_events.snapshot | 4 + .../combos-and-holdtaps-1/native_posix.keymap | 42 ++ .../combos-and-holdtaps-2/events.patterns | 2 + .../keycode_events.snapshot | 2 + .../combos-and-holdtaps-2/native_posix.keymap | 45 ++ .../combo/multiple-timeouts/events.patterns | 1 + .../multiple-timeouts/keycode_events.snapshot | 4 + .../multiple-timeouts/native_posix.keymap | 40 ++ .../overlapping-combos-0/events.patterns | 2 + .../keycode_events.snapshot | 20 + .../overlapping-combos-0/native_posix.keymap | 117 +++++ .../overlapping-combos-1/events.patterns | 2 + .../keycode_events.snapshot | 8 + .../overlapping-combos-1/native_posix.keymap | 65 +++ .../overlapping-combos-2/events.patterns | 2 + .../keycode_events.snapshot | 4 + .../overlapping-combos-2/native_posix.keymap | 52 ++ .../overlapping-combos-3/events.patterns | 2 + .../keycode_events.snapshot | 4 + .../overlapping-combos-3/native_posix.keymap | 53 ++ .../events.patterns | 1 + .../keycode_events.snapshot | 16 + .../native_posix.keymap | 84 ++++ app/tests/combo/press-release/events.patterns | 1 + .../press-release/keycode_events.snapshot | 8 + .../combo/press-release/native_posix.keymap | 51 ++ app/tests/combo/press-timeout/events.patterns | 1 + .../press-timeout/keycode_events.snapshot | 4 + .../combo/press-timeout/native_posix.keymap | 35 ++ .../events.patterns | 2 + .../keycode_events.snapshot | 4 + .../native_posix.keymap | 45 ++ .../events.patterns | 2 + .../keycode_events.snapshot | 4 + .../native_posix.keymap | 46 ++ .../events.patterns | 2 + .../keycode_events.snapshot | 4 + .../native_posix.keymap | 46 ++ .../slowrelease-disabled/events.patterns | 1 + .../keycode_events.snapshot | 4 + .../slowrelease-disabled/native_posix.keymap | 38 ++ .../combo/slowrelease-enabled/events.patterns | 1 + .../keycode_events.snapshot | 4 + .../slowrelease-enabled/native_posix.keymap | 38 ++ docs/docs/behaviors/combos.md | 52 ++ docs/docs/intro.md | 2 +- docs/sidebars.js | 1 + 55 files changed, 1528 insertions(+), 1 deletion(-) create mode 100644 app/dts/bindings/zmk,combos.yaml create mode 100644 app/src/combo.c create mode 100644 app/tests/combo/combos-and-holdtaps-0/events.patterns create mode 100644 app/tests/combo/combos-and-holdtaps-0/keycode_events.snapshot create mode 100644 app/tests/combo/combos-and-holdtaps-0/native_posix.keymap create mode 100644 app/tests/combo/combos-and-holdtaps-1/events.patterns create mode 100644 app/tests/combo/combos-and-holdtaps-1/keycode_events.snapshot create mode 100644 app/tests/combo/combos-and-holdtaps-1/native_posix.keymap create mode 100644 app/tests/combo/combos-and-holdtaps-2/events.patterns create mode 100644 app/tests/combo/combos-and-holdtaps-2/keycode_events.snapshot create mode 100644 app/tests/combo/combos-and-holdtaps-2/native_posix.keymap create mode 100644 app/tests/combo/multiple-timeouts/events.patterns create mode 100644 app/tests/combo/multiple-timeouts/keycode_events.snapshot create mode 100644 app/tests/combo/multiple-timeouts/native_posix.keymap create mode 100644 app/tests/combo/overlapping-combos-0/events.patterns create mode 100644 app/tests/combo/overlapping-combos-0/keycode_events.snapshot create mode 100644 app/tests/combo/overlapping-combos-0/native_posix.keymap create mode 100644 app/tests/combo/overlapping-combos-1/events.patterns create mode 100644 app/tests/combo/overlapping-combos-1/keycode_events.snapshot create mode 100644 app/tests/combo/overlapping-combos-1/native_posix.keymap create mode 100644 app/tests/combo/overlapping-combos-2/events.patterns create mode 100644 app/tests/combo/overlapping-combos-2/keycode_events.snapshot create mode 100644 app/tests/combo/overlapping-combos-2/native_posix.keymap create mode 100644 app/tests/combo/overlapping-combos-3/events.patterns create mode 100644 app/tests/combo/overlapping-combos-3/keycode_events.snapshot create mode 100644 app/tests/combo/overlapping-combos-3/native_posix.keymap create mode 100644 app/tests/combo/partially-overlapping-combos/events.patterns create mode 100644 app/tests/combo/partially-overlapping-combos/keycode_events.snapshot create mode 100644 app/tests/combo/partially-overlapping-combos/native_posix.keymap create mode 100644 app/tests/combo/press-release/events.patterns create mode 100644 app/tests/combo/press-release/keycode_events.snapshot create mode 100644 app/tests/combo/press-release/native_posix.keymap create mode 100644 app/tests/combo/press-timeout/events.patterns create mode 100644 app/tests/combo/press-timeout/keycode_events.snapshot create mode 100644 app/tests/combo/press-timeout/native_posix.keymap create mode 100644 app/tests/combo/press1-press2-release1-release2/events.patterns create mode 100644 app/tests/combo/press1-press2-release1-release2/keycode_events.snapshot create mode 100644 app/tests/combo/press1-press2-release1-release2/native_posix.keymap create mode 100644 app/tests/combo/press1-press2-release2-release1/events.patterns create mode 100644 app/tests/combo/press1-press2-release2-release1/keycode_events.snapshot create mode 100644 app/tests/combo/press1-press2-release2-release1/native_posix.keymap create mode 100644 app/tests/combo/press1-release1-press2-release2/events.patterns create mode 100644 app/tests/combo/press1-release1-press2-release2/keycode_events.snapshot create mode 100644 app/tests/combo/press1-release1-press2-release2/native_posix.keymap create mode 100644 app/tests/combo/slowrelease-disabled/events.patterns create mode 100644 app/tests/combo/slowrelease-disabled/keycode_events.snapshot create mode 100644 app/tests/combo/slowrelease-disabled/native_posix.keymap create mode 100644 app/tests/combo/slowrelease-enabled/events.patterns create mode 100644 app/tests/combo/slowrelease-enabled/keycode_events.snapshot create mode 100644 app/tests/combo/slowrelease-enabled/native_posix.keymap create mode 100644 docs/docs/behaviors/combos.md diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 5fb3827c..b217a1a1 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -52,6 +52,7 @@ if ((NOT CONFIG_ZMK_SPLIT) OR CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) target_sources(app PRIVATE src/behaviors/behavior_none.c) target_sources(app PRIVATE src/behaviors/behavior_sensor_rotate_key_press.c) target_sources_ifdef(CONFIG_ZMK_EXT_POWER app PRIVATE src/behaviors/behavior_ext_power.c) + target_sources(app PRIVATE src/combo.c) target_sources(app PRIVATE src/keymap.c) endif() target_sources_ifdef(CONFIG_ZMK_RGB_UNDERGLOW app PRIVATE src/behaviors/behavior_rgb_underglow.c) diff --git a/app/Kconfig b/app/Kconfig index f5d92a88..0aa291d6 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -251,6 +251,23 @@ config ZMK_EXT_POWER #Power Management endmenu +menu "Combo options" + +config ZMK_COMBO_MAX_PRESSED_COMBOS + int "Maximum number of currently pressed combos" + default 4 + +config ZMK_COMBO_MAX_COMBOS_PER_KEY + int "Maximum number of combos per key" + default 5 + +config ZMK_COMBO_MAX_KEYS_PER_COMBO + int "Maximum number of keys per combo" + default 4 + +#Display/LED Options +endmenu + menu "Advanced" menu "Initialization Priorities" diff --git a/app/dts/bindings/zmk,combos.yaml b/app/dts/bindings/zmk,combos.yaml new file mode 100644 index 00000000..75eaa3e1 --- /dev/null +++ b/app/dts/bindings/zmk,combos.yaml @@ -0,0 +1,22 @@ +# Copyright (c) 2020, The ZMK Contributors +# SPDX-License-Identifier: MIT + +description: Combos container + +compatible: "zmk,combos" + +child-binding: + description: "A combo" + + properties: + bindings: + type: phandle-array + required: true + key-positions: + type: array + required: true + timeout-ms: + type: int + default: 50 + slow-release: + type: boolean diff --git a/app/src/combo.c b/app/src/combo.c new file mode 100644 index 00000000..49638703 --- /dev/null +++ b/app/src/combo.c @@ -0,0 +1,466 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#define DT_DRV_COMPAT zmk_combos + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); + +#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) + +struct combo_cfg { + int32_t key_positions[CONFIG_ZMK_COMBO_MAX_KEYS_PER_COMBO]; + int32_t key_position_len; + struct zmk_behavior_binding behavior; + int32_t timeout_ms; + // if slow release is set, the combo releases when the last key is released. + // otherwise, the combo releases when the first key is released. + bool slow_release; + // the virtual key position is a key position outside the range used by the keyboard. + // it is necessary so hold-taps can uniquely identify a behavior. + int32_t virtual_key_position; +}; + +struct active_combo { + struct combo_cfg *combo; + // key_positions_pressed is filled with key_positions when the combo is pressed. + // The keys are removed from this array when they are released. + // Once this array is empty, the behavior is released. + struct position_state_changed *key_positions_pressed[CONFIG_ZMK_COMBO_MAX_KEYS_PER_COMBO]; +}; + +struct combo_candidate { + struct combo_cfg *combo; + // the time after which this behavior should be removed from candidates. + // by keeping track of when the candidate should be cleared there is no + // possibility of accidental releases. + int64_t timeout_at; +}; + +// set of keys pressed +struct position_state_changed *pressed_keys[CONFIG_ZMK_COMBO_MAX_KEYS_PER_COMBO] = {NULL}; +// the set of candidate combos based on the currently pressed_keys +struct combo_candidate candidates[CONFIG_ZMK_COMBO_MAX_COMBOS_PER_KEY]; +// the last candidate that was completely pressed +struct combo_cfg *fully_pressed_combo = NULL; +// a lookup dict that maps a key position to all combos on that position +struct combo_cfg *combo_lookup[ZMK_KEYMAP_LEN][CONFIG_ZMK_COMBO_MAX_COMBOS_PER_KEY] = {NULL}; +// combos that have been activated and still have (some) keys pressed +// this array is always contiguous from 0. +struct active_combo active_combos[CONFIG_ZMK_COMBO_MAX_PRESSED_COMBOS] = {NULL}; +int active_combo_count = 0; + +struct k_delayed_work timeout_task; +int64_t timeout_task_timeout_at; + +// Store the combo key pointer in the combos array, one pointer for each key position +// The combos are sorted shortest-first, then by virtual-key-position. +static int initialize_combo(struct combo_cfg *new_combo) { + for (int i = 0; i < new_combo->key_position_len; i++) { + int32_t position = new_combo->key_positions[i]; + if (position >= ZMK_KEYMAP_LEN) { + LOG_ERR("Unable to initialize combo, key position %d does not exist", position); + return -EINVAL; + } + + struct combo_cfg *insert_combo = new_combo; + bool set = false; + for (int j = 0; j < CONFIG_ZMK_COMBO_MAX_COMBOS_PER_KEY; j++) { + struct combo_cfg *combo_at_j = combo_lookup[position][j]; + if (combo_at_j == NULL) { + combo_lookup[position][j] = insert_combo; + set = true; + break; + } + if (combo_at_j->key_position_len < insert_combo->key_position_len || + (combo_at_j->key_position_len == insert_combo->key_position_len && + combo_at_j->virtual_key_position < insert_combo->virtual_key_position)) { + continue; + } + // put insert_combo in this spot, move all other combos up. + combo_lookup[position][j] = insert_combo; + insert_combo = combo_at_j; + } + if (!set) { + LOG_ERR("Too many combos for key position %d, CONFIG_ZMK_COMBO_MAX_COMBOS_PER_KEY %d.", + position, CONFIG_ZMK_COMBO_MAX_COMBOS_PER_KEY); + return -ENOMEM; + } + } + return 0; +} + +static int setup_candidates_for_first_keypress(int32_t position, int64_t timestamp) { + for (int i = 0; i < CONFIG_ZMK_COMBO_MAX_COMBOS_PER_KEY; i++) { + struct combo_cfg *combo = combo_lookup[position][i]; + if (combo == NULL) { + return i; + } + candidates[i].combo = combo; + candidates[i].timeout_at = timestamp + combo->timeout_ms; + // LOG_DBG("combo timeout %d %d %d", position, i, candidates[i].timeout_at); + } + return CONFIG_ZMK_COMBO_MAX_COMBOS_PER_KEY; +} + +static int filter_candidates(int32_t position) { + // this code iterates over candidates and the lookup together to filter in O(n) + // assuming they are both sorted on key_position_len, virtal_key_position + int matches = 0, lookup_idx = 0, candidate_idx = 0; + while (lookup_idx < CONFIG_ZMK_COMBO_MAX_COMBOS_PER_KEY && + candidate_idx < CONFIG_ZMK_COMBO_MAX_COMBOS_PER_KEY) { + struct combo_cfg *candidate = candidates[candidate_idx].combo; + struct combo_cfg *lookup = combo_lookup[position][lookup_idx]; + if (candidate == NULL || lookup == NULL) { + break; + } + if (candidate->virtual_key_position == lookup->virtual_key_position) { + candidates[matches] = candidates[candidate_idx]; + matches++; + candidate_idx++; + lookup_idx++; + } else if (candidate->key_position_len > lookup->key_position_len) { + lookup_idx++; + } else if (candidate->key_position_len < lookup->key_position_len) { + candidate_idx++; + } else if (candidate->virtual_key_position > lookup->virtual_key_position) { + lookup_idx++; + } else if (candidate->virtual_key_position < lookup->virtual_key_position) { + candidate_idx++; + } + } + // clear unmatched candidates + for (int i = matches; i < CONFIG_ZMK_COMBO_MAX_COMBOS_PER_KEY; i++) { + candidates[i].combo = NULL; + } + // LOG_DBG("combo matches after filter %d", matches); + return matches; +} + +static int64_t first_candidate_timeout() { + int64_t first_timeout = LONG_MAX; + for (int i = 0; i < CONFIG_ZMK_COMBO_MAX_COMBOS_PER_KEY; i++) { + if (candidates[i].combo == NULL) { + break; + } + if (candidates[i].timeout_at < first_timeout) { + first_timeout = candidates[i].timeout_at; + } + } + return first_timeout; +} + +static inline bool candidate_is_completely_pressed(struct combo_cfg *candidate) { + // this code assumes set(pressed_keys) <= set(candidate->key_positions) + // this invariant is enforced by filter_candidates + // the only thing we need to do is check if len(pressed_keys) == len(combo->key_positions) + return pressed_keys[candidate->key_position_len - 1] != NULL; +} + +static void cleanup(); + +static int filter_timed_out_candidates(int64_t timestamp) { + int num_candidates = 0; + for (int i = 0; i < CONFIG_ZMK_COMBO_MAX_COMBOS_PER_KEY; i++) { + struct combo_candidate *candidate = &candidates[i]; + if (candidate->combo == NULL) { + break; + } + if (candidate->timeout_at > timestamp) { + // reorder candidates so they're contiguous + candidates[num_candidates].combo = candidate->combo; + candidates[num_candidates].timeout_at = candidates->timeout_at; + num_candidates++; + } else { + candidate->combo = NULL; + } + } + return num_candidates; +} + +static int clear_candidates() { + for (int i = 0; i < CONFIG_ZMK_COMBO_MAX_COMBOS_PER_KEY; i++) { + if (candidates[i].combo == NULL) { + return i; + } + candidates[i].combo = NULL; + } + return CONFIG_ZMK_COMBO_MAX_COMBOS_PER_KEY; +} + +static int capture_pressed_key(struct position_state_changed *ev) { + for (int i = 0; i < CONFIG_ZMK_COMBO_MAX_COMBOS_PER_KEY; i++) { + if (pressed_keys[i] != NULL) { + continue; + } + pressed_keys[i] = ev; + return ZMK_EV_EVENT_CAPTURED; + } + return 0; +} + +const struct zmk_listener zmk_listener_combo; + +static void release_pressed_keys() { + // release the first key that was pressed + if (pressed_keys[0] == NULL) { + return; + } + ZMK_EVENT_RELEASE(pressed_keys[0]) + pressed_keys[0] = NULL; + + // reprocess events (see tests/combo/fully-overlapping-combos-3 for why this is needed) + for (int i = 1; i < CONFIG_ZMK_COMBO_MAX_COMBOS_PER_KEY; i++) { + if (pressed_keys[i] == NULL) { + return; + } + struct position_state_changed *captured_event = pressed_keys[i]; + pressed_keys[i] = NULL; + ZMK_EVENT_RAISE(captured_event); + } +} + +static inline int press_combo_behavior(struct combo_cfg *combo, int32_t timestamp) { + struct zmk_behavior_binding_event event = { + .position = combo->virtual_key_position, + .timestamp = timestamp, + }; + + return behavior_keymap_binding_pressed(&combo->behavior, event); +} + +static inline int release_combo_behavior(struct combo_cfg *combo, int32_t timestamp) { + struct zmk_behavior_binding_event event = { + .position = combo->virtual_key_position, + .timestamp = timestamp, + }; + + return behavior_keymap_binding_released(&combo->behavior, event); +} + +static void move_pressed_keys_to_active_combo(struct active_combo *active_combo) { + int combo_length = active_combo->combo->key_position_len; + for (int i = 0; i < combo_length; i++) { + active_combo->key_positions_pressed[i] = pressed_keys[i]; + pressed_keys[i] = NULL; + } + // move any other pressed keys up + for (int i = 0; i + combo_length < CONFIG_ZMK_COMBO_MAX_KEYS_PER_COMBO; i++) { + if (pressed_keys[i + combo_length] == NULL) { + return; + } + pressed_keys[i] = pressed_keys[i + combo_length]; + pressed_keys[i + combo_length] = NULL; + } +} + +static struct active_combo *store_active_combo(struct combo_cfg *combo) { + for (int i = 0; i < CONFIG_ZMK_COMBO_MAX_PRESSED_COMBOS; i++) { + if (active_combos[i].combo == NULL) { + active_combos[i].combo = combo; + active_combo_count++; + return &active_combos[i]; + } + } + LOG_ERR("Unable to store combo; already %d active. Increase " + "CONFIG_ZMK_COMBO_MAX_PRESSED_COMBOS", + CONFIG_ZMK_COMBO_MAX_PRESSED_COMBOS); + return NULL; +} + +static void activate_combo(struct combo_cfg *combo) { + struct active_combo *active_combo = store_active_combo(combo); + if (active_combo == NULL) { + // unable to store combo + release_pressed_keys(); + return; + } + move_pressed_keys_to_active_combo(active_combo); + press_combo_behavior(combo, active_combo->key_positions_pressed[0]->timestamp); +} + +static void deactivate_combo(int active_combo_index) { + active_combo_count--; + if (active_combo_index != active_combo_count) { + memcpy(&active_combos[active_combo_index], &active_combos[active_combo_count], + sizeof(struct active_combo)); + } + active_combos[active_combo_count].combo = NULL; + active_combos[active_combo_count] = (struct active_combo){0}; +} + +/* returns true if a key was released. */ +static bool release_combo_key(int32_t position, int64_t timestamp) { + for (int combo_idx = 0; combo_idx < active_combo_count; combo_idx++) { + struct active_combo *active_combo = &active_combos[combo_idx]; + + bool key_released = false; + bool all_keys_pressed = true; + bool all_keys_released = true; + for (int i = 0; i < active_combo->combo->key_position_len; i++) { + if (active_combo->key_positions_pressed[i] == NULL) { + all_keys_pressed = false; + } else if (active_combo->key_positions_pressed[i]->position != position) { + all_keys_released = false; + } else { // not null and position matches + k_free(active_combo->key_positions_pressed[i]); + active_combo->key_positions_pressed[i] = NULL; + key_released = true; + } + } + + if (key_released) { + if ((active_combo->combo->slow_release && all_keys_released) || + (!active_combo->combo->slow_release && all_keys_pressed)) { + release_combo_behavior(active_combo->combo, timestamp); + } + if (all_keys_released) { + deactivate_combo(combo_idx); + } + return true; + } + } + return false; +} + +static void cleanup() { + k_delayed_work_cancel(&timeout_task); + clear_candidates(); + if (fully_pressed_combo != NULL) { + activate_combo(fully_pressed_combo); + fully_pressed_combo = NULL; + } + release_pressed_keys(); +} + +static void update_timeout_task() { + int64_t first_timeout = first_candidate_timeout(); + if (timeout_task_timeout_at == first_timeout) { + return; + } + if (first_timeout == LLONG_MAX) { + timeout_task_timeout_at = 0; + k_delayed_work_cancel(&timeout_task); + return; + } + if (k_delayed_work_submit(&timeout_task, K_MSEC(first_timeout - k_uptime_get())) == 0) { + timeout_task_timeout_at = first_timeout; + } +} + +static int position_state_down(struct position_state_changed *ev) { + int num_candidates; + if (candidates[0].combo == NULL) { + num_candidates = setup_candidates_for_first_keypress(ev->position, ev->timestamp); + if (num_candidates == 0) { + return 0; + } + } else { + filter_timed_out_candidates(ev->timestamp); + num_candidates = filter_candidates(ev->position); + } + update_timeout_task(); + + struct combo_cfg *candidate_combo = candidates[0].combo; + int ret = capture_pressed_key(ev); + switch (num_candidates) { + case 0: + cleanup(); + return ret; + case 1: + if (candidate_is_completely_pressed(candidate_combo)) { + fully_pressed_combo = candidate_combo; + cleanup(); + } + return ret; + default: + if (candidate_is_completely_pressed(candidate_combo)) { + fully_pressed_combo = candidate_combo; + } + return ret; + } +} + +static int position_state_up(struct position_state_changed *ev) { + cleanup(); + if (release_combo_key(ev->position, ev->timestamp)) { + return ZMK_EV_EVENT_HANDLED; + } else { + return 0; + } +} + +static void combo_timeout_handler(struct k_work *item) { + if (timeout_task_timeout_at == 0 || k_uptime_get() < timeout_task_timeout_at) { + // timer was cancelled or rescheduled. + return; + } + if (filter_timed_out_candidates(timeout_task_timeout_at) < 2) { + cleanup(); + } + update_timeout_task(); +} + +static int position_state_changed_listener(const struct zmk_event_header *eh) { + if (!is_position_state_changed(eh)) { + return 0; + } + + struct position_state_changed *ev = cast_position_state_changed(eh); + if (ev->state) { // keydown + return position_state_down(ev); + } else { // keyup + return position_state_up(ev); + } +} + +ZMK_LISTENER(combo, position_state_changed_listener); +ZMK_SUBSCRIPTION(combo, position_state_changed); + +// todo: remove this once #506 is merged and #include +#define KEY_BINDING_TO_STRUCT(idx, drv_inst) \ + { \ + .behavior_dev = DT_LABEL(DT_PHANDLE_BY_IDX(drv_inst, bindings, idx)), \ + .param1 = COND_CODE_0(DT_PHA_HAS_CELL_AT_IDX(drv_inst, bindings, idx, param1), (0), \ + (DT_PHA_BY_IDX(drv_inst, bindings, idx, param1))), \ + .param2 = COND_CODE_0(DT_PHA_HAS_CELL_AT_IDX(drv_inst, bindings, idx, param2), (0), \ + (DT_PHA_BY_IDX(drv_inst, bindings, idx, param2))), \ + } + +#define COMBO_INST(n) \ + static struct combo_cfg combo_config_##n = { \ + .timeout_ms = DT_PROP(n, timeout_ms), \ + .key_positions = DT_PROP(n, key_positions), \ + .key_position_len = DT_PROP_LEN(n, key_positions), \ + .behavior = KEY_BINDING_TO_STRUCT(0, n), \ + .virtual_key_position = ZMK_KEYMAP_LEN + __COUNTER__, \ + .slow_release = DT_PROP(n, slow_release), \ + }; + +#define INITIALIZE_COMBO(n) initialize_combo(&combo_config_##n); + +DT_INST_FOREACH_CHILD(0, COMBO_INST) + +static int combo_init() { + k_delayed_work_init(&timeout_task, combo_timeout_handler); + DT_INST_FOREACH_CHILD(0, INITIALIZE_COMBO); + return 0; +} + +SYS_INIT(combo_init, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); + +#endif \ No newline at end of file diff --git a/app/tests/combo/combos-and-holdtaps-0/events.patterns b/app/tests/combo/combos-and-holdtaps-0/events.patterns new file mode 100644 index 00000000..b90d7863 --- /dev/null +++ b/app/tests/combo/combos-and-holdtaps-0/events.patterns @@ -0,0 +1,2 @@ +s/.*hid_listener_keycode_//p +s/.*combo//p \ No newline at end of file diff --git a/app/tests/combo/combos-and-holdtaps-0/keycode_events.snapshot b/app/tests/combo/combos-and-holdtaps-0/keycode_events.snapshot new file mode 100644 index 00000000..ad86b269 --- /dev/null +++ b/app/tests/combo/combos-and-holdtaps-0/keycode_events.snapshot @@ -0,0 +1,4 @@ +pressed: usage_page 0x07 keycode 0xe0 mods 0x00 +pressed: usage_page 0x07 keycode 0x1c mods 0x00 +released: usage_page 0x07 keycode 0xe0 mods 0x00 +released: usage_page 0x07 keycode 0x1c mods 0x00 diff --git a/app/tests/combo/combos-and-holdtaps-0/native_posix.keymap b/app/tests/combo/combos-and-holdtaps-0/native_posix.keymap new file mode 100644 index 00000000..d35c7277 --- /dev/null +++ b/app/tests/combo/combos-and-holdtaps-0/native_posix.keymap @@ -0,0 +1,47 @@ +#include +#include +#include + +&mt { + flavor = "hold-preferred"; +}; + +/* +This test fails if the order of event handlers for hold-taps +and combos is wrong. Hold-taps need to process key position events +first so the decision to hold or tap can be made. +*/ +/ { + combos { + compatible = "zmk,combos"; + + combo_two { + timeout-ms = <100>; + key-positions = <1 2>; + bindings = <&kp Y>; + }; + }; + + keymap { + compatible = "zmk,keymap"; + label ="Default keymap"; + + default_layer { + bindings = < + &mt LEFT_CONTROL A &kp B + &kp C &none + >; + }; + }; +}; + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_PRESS(0,1,10) + ZMK_MOCK_PRESS(0,2,10) + ZMK_MOCK_RELEASE(0,0,10) + ZMK_MOCK_RELEASE(0,1,10) + ZMK_MOCK_RELEASE(0,2,10) + >; +}; \ No newline at end of file diff --git a/app/tests/combo/combos-and-holdtaps-1/events.patterns b/app/tests/combo/combos-and-holdtaps-1/events.patterns new file mode 100644 index 00000000..b90d7863 --- /dev/null +++ b/app/tests/combo/combos-and-holdtaps-1/events.patterns @@ -0,0 +1,2 @@ +s/.*hid_listener_keycode_//p +s/.*combo//p \ No newline at end of file diff --git a/app/tests/combo/combos-and-holdtaps-1/keycode_events.snapshot b/app/tests/combo/combos-and-holdtaps-1/keycode_events.snapshot new file mode 100644 index 00000000..dc4dbb49 --- /dev/null +++ b/app/tests/combo/combos-and-holdtaps-1/keycode_events.snapshot @@ -0,0 +1,4 @@ +pressed: usage_page 0x07 keycode 0x1c mods 0x00 +pressed: usage_page 0x07 keycode 0x06 mods 0x00 +released: usage_page 0x07 keycode 0x1c mods 0x00 +released: usage_page 0x07 keycode 0x06 mods 0x00 diff --git a/app/tests/combo/combos-and-holdtaps-1/native_posix.keymap b/app/tests/combo/combos-and-holdtaps-1/native_posix.keymap new file mode 100644 index 00000000..a99c15d9 --- /dev/null +++ b/app/tests/combo/combos-and-holdtaps-1/native_posix.keymap @@ -0,0 +1,42 @@ +#include +#include +#include + +&mt { + flavor = "hold-preferred"; +}; + +/* this test checks if hold-taps can be part of a combo */ +/ { + combos { + compatible = "zmk,combos"; + combo_two { + timeout-ms = <100>; + key-positions = <0 1>; + bindings = <&kp Y>; + }; + }; + + keymap { + compatible = "zmk,keymap"; + label ="Default keymap"; + + default_layer { + bindings = < + &mt LEFT_CONTROL A &kp B + &kp C &none + >; + }; + }; +}; + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_PRESS(0,1,10) + ZMK_MOCK_PRESS(0,2,10) + ZMK_MOCK_RELEASE(0,0,10) + ZMK_MOCK_RELEASE(0,1,10) + ZMK_MOCK_RELEASE(0,2,10) + >; +}; \ No newline at end of file diff --git a/app/tests/combo/combos-and-holdtaps-2/events.patterns b/app/tests/combo/combos-and-holdtaps-2/events.patterns new file mode 100644 index 00000000..b90d7863 --- /dev/null +++ b/app/tests/combo/combos-and-holdtaps-2/events.patterns @@ -0,0 +1,2 @@ +s/.*hid_listener_keycode_//p +s/.*combo//p \ No newline at end of file diff --git a/app/tests/combo/combos-and-holdtaps-2/keycode_events.snapshot b/app/tests/combo/combos-and-holdtaps-2/keycode_events.snapshot new file mode 100644 index 00000000..a6508804 --- /dev/null +++ b/app/tests/combo/combos-and-holdtaps-2/keycode_events.snapshot @@ -0,0 +1,2 @@ +pressed: usage_page 0x07 keycode 0xe0 mods 0x00 +pressed: usage_page 0x07 keycode 0xe4 mods 0x00 diff --git a/app/tests/combo/combos-and-holdtaps-2/native_posix.keymap b/app/tests/combo/combos-and-holdtaps-2/native_posix.keymap new file mode 100644 index 00000000..f8dbe450 --- /dev/null +++ b/app/tests/combo/combos-and-holdtaps-2/native_posix.keymap @@ -0,0 +1,45 @@ +#include +#include +#include + +&mt { + flavor = "hold-preferred"; +}; + +/* This test verifies that hold-tap keys can observe + * events which were released from combos. + */ +/ { + combos { + compatible = "zmk,combos"; + combo_one { + timeout-ms = <100>; + key-positions = <0 2>; + bindings = <&kp Y>; + }; + combo_two { + timeout-ms = <100>; + key-positions = <1 3>; + bindings = <&kp Z>; + }; + }; + + keymap { + compatible = "zmk,keymap"; + label ="Default keymap"; + + default_layer { + bindings = < + &mt LEFT_CONTROL A &mt RIGHT_CONTROL B + &none &none + >; + }; + }; +}; + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,0) + ZMK_MOCK_PRESS(0,1,300) + >; +}; \ No newline at end of file diff --git a/app/tests/combo/multiple-timeouts/events.patterns b/app/tests/combo/multiple-timeouts/events.patterns new file mode 100644 index 00000000..b1342af4 --- /dev/null +++ b/app/tests/combo/multiple-timeouts/events.patterns @@ -0,0 +1 @@ +s/.*hid_listener_keycode_//p diff --git a/app/tests/combo/multiple-timeouts/keycode_events.snapshot b/app/tests/combo/multiple-timeouts/keycode_events.snapshot new file mode 100644 index 00000000..c5bdd6e0 --- /dev/null +++ b/app/tests/combo/multiple-timeouts/keycode_events.snapshot @@ -0,0 +1,4 @@ +pressed: usage_page 0x07 keycode 0x04 mods 0x00 +pressed: usage_page 0x07 keycode 0x05 mods 0x00 +released: usage_page 0x07 keycode 0x04 mods 0x00 +released: usage_page 0x07 keycode 0x05 mods 0x00 diff --git a/app/tests/combo/multiple-timeouts/native_posix.keymap b/app/tests/combo/multiple-timeouts/native_posix.keymap new file mode 100644 index 00000000..91bf5235 --- /dev/null +++ b/app/tests/combo/multiple-timeouts/native_posix.keymap @@ -0,0 +1,40 @@ +#include +#include +#include + +/ { + combos { + compatible = "zmk,combos"; + combo_one { + timeout-ms = <30>; + key-positions = <0 1>; + bindings = <&kp C>; + }; + combo_two { + timeout-ms = <120>; + key-positions = <0 1 2>; + bindings = <&kp C>; + }; + }; + + keymap { + compatible = "zmk,keymap"; + label ="Default keymap"; + + default_layer { + bindings = < + &kp A &kp B + &none &none + >; + }; + }; +}; + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,100) + ZMK_MOCK_PRESS(0,1,10) + ZMK_MOCK_RELEASE(0,0,10) + ZMK_MOCK_RELEASE(0,1,10) + >; +}; \ No newline at end of file diff --git a/app/tests/combo/overlapping-combos-0/events.patterns b/app/tests/combo/overlapping-combos-0/events.patterns new file mode 100644 index 00000000..b90d7863 --- /dev/null +++ b/app/tests/combo/overlapping-combos-0/events.patterns @@ -0,0 +1,2 @@ +s/.*hid_listener_keycode_//p +s/.*combo//p \ No newline at end of file diff --git a/app/tests/combo/overlapping-combos-0/keycode_events.snapshot b/app/tests/combo/overlapping-combos-0/keycode_events.snapshot new file mode 100644 index 00000000..ec63b77f --- /dev/null +++ b/app/tests/combo/overlapping-combos-0/keycode_events.snapshot @@ -0,0 +1,20 @@ +pressed: usage_page 0x07 keycode 0x1b mods 0x00 +released: usage_page 0x07 keycode 0x1b mods 0x00 +pressed: usage_page 0x07 keycode 0x1b mods 0x00 +released: usage_page 0x07 keycode 0x1b mods 0x00 +pressed: usage_page 0x07 keycode 0x1b mods 0x00 +released: usage_page 0x07 keycode 0x1b mods 0x00 +pressed: usage_page 0x07 keycode 0x1b mods 0x00 +released: usage_page 0x07 keycode 0x1b mods 0x00 +pressed: usage_page 0x07 keycode 0x1b mods 0x00 +released: usage_page 0x07 keycode 0x1b mods 0x00 +pressed: usage_page 0x07 keycode 0x1b mods 0x00 +released: usage_page 0x07 keycode 0x1b mods 0x00 +pressed: usage_page 0x07 keycode 0x1c mods 0x00 +released: usage_page 0x07 keycode 0x1c mods 0x00 +pressed: usage_page 0x07 keycode 0x1c mods 0x00 +released: usage_page 0x07 keycode 0x1c mods 0x00 +pressed: usage_page 0x07 keycode 0x1c mods 0x00 +released: usage_page 0x07 keycode 0x1c mods 0x00 +pressed: usage_page 0x07 keycode 0x1c mods 0x00 +released: usage_page 0x07 keycode 0x1c mods 0x00 diff --git a/app/tests/combo/overlapping-combos-0/native_posix.keymap b/app/tests/combo/overlapping-combos-0/native_posix.keymap new file mode 100644 index 00000000..e3cbf437 --- /dev/null +++ b/app/tests/combo/overlapping-combos-0/native_posix.keymap @@ -0,0 +1,117 @@ +#include +#include +#include + +/* + combo 0 timeout inf + combo 01 timeout inf + combo 0123 timeout inf + press 012 in any combination, release any of those keys + expected: combo 012 on key-release + */ + +/* it is useful to set timeout to a large value when attaching a debugger. */ +#define TIMEOUT (60*60*1000) + +/ { + combos { + compatible = "zmk,combos"; + combo_one { + timeout-ms = ; + key-positions = <0 1 2>; + bindings = <&kp X>; + }; + + combo_two { + timeout-ms = ; + key-positions = <0 2>; + bindings = <&kp Y>; + }; + + combo_three { + timeout-ms = ; + key-positions = <1>; + bindings = <&kp Z>; + }; + }; + + keymap { + compatible = "zmk,keymap"; + label ="Default keymap"; + + default_layer { + bindings = < + &kp A &kp B + &kp C &none + >; + }; + }; +}; +&kscan { + events = < + /* all permutations of combo one press, combo triggered by release */ + /* while debugging these, you may want to set the release_timer to a high number */ + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_PRESS(0,1,10) + ZMK_MOCK_PRESS(0,2,10) + ZMK_MOCK_RELEASE(0,0,10) + ZMK_MOCK_RELEASE(0,1,10) + ZMK_MOCK_RELEASE(0,2,10) + + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_PRESS(0,2,10) + ZMK_MOCK_PRESS(0,1,10) + ZMK_MOCK_RELEASE(0,0,10) + ZMK_MOCK_RELEASE(0,2,10) + ZMK_MOCK_RELEASE(0,1,10) + + ZMK_MOCK_PRESS(0,1,10) + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_PRESS(0,2,10) + ZMK_MOCK_RELEASE(0,1,10) + ZMK_MOCK_RELEASE(0,0,10) + ZMK_MOCK_RELEASE(0,2,10) + + ZMK_MOCK_PRESS(0,1,10) + ZMK_MOCK_PRESS(0,2,10) + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_RELEASE(0,1,10) + ZMK_MOCK_RELEASE(0,2,10) + ZMK_MOCK_RELEASE(0,0,10) + + ZMK_MOCK_PRESS(0,2,10) + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_PRESS(0,1,10) + ZMK_MOCK_RELEASE(0,2,10) + ZMK_MOCK_RELEASE(0,0,10) + ZMK_MOCK_RELEASE(0,1,10) + + ZMK_MOCK_PRESS(0,2,10) + ZMK_MOCK_PRESS(0,1,10) + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_RELEASE(0,2,10) + ZMK_MOCK_RELEASE(0,1,10) + ZMK_MOCK_RELEASE(0,0,10) + + /* all permutations of combo two press and release, combo triggered by release */ + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_PRESS(0,2,10) + ZMK_MOCK_RELEASE(0,0,10) + ZMK_MOCK_RELEASE(0,2,10) + + ZMK_MOCK_PRESS(0,2,10) + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_RELEASE(0,2,10) + ZMK_MOCK_RELEASE(0,0,10) + + ZMK_MOCK_PRESS(0,2,10) + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_RELEASE(0,0,10) + ZMK_MOCK_RELEASE(0,2,10) + + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_PRESS(0,2,10) + ZMK_MOCK_RELEASE(0,2,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/combo/overlapping-combos-1/events.patterns b/app/tests/combo/overlapping-combos-1/events.patterns new file mode 100644 index 00000000..b90d7863 --- /dev/null +++ b/app/tests/combo/overlapping-combos-1/events.patterns @@ -0,0 +1,2 @@ +s/.*hid_listener_keycode_//p +s/.*combo//p \ No newline at end of file diff --git a/app/tests/combo/overlapping-combos-1/keycode_events.snapshot b/app/tests/combo/overlapping-combos-1/keycode_events.snapshot new file mode 100644 index 00000000..daf72478 --- /dev/null +++ b/app/tests/combo/overlapping-combos-1/keycode_events.snapshot @@ -0,0 +1,8 @@ +pressed: usage_page 0x07 keycode 0x1c mods 0x00 +released: usage_page 0x07 keycode 0x1c mods 0x00 +pressed: usage_page 0x07 keycode 0x1c mods 0x00 +released: usage_page 0x07 keycode 0x1c mods 0x00 +pressed: usage_page 0x07 keycode 0x1c mods 0x00 +released: usage_page 0x07 keycode 0x1c mods 0x00 +pressed: usage_page 0x07 keycode 0x1c mods 0x00 +released: usage_page 0x07 keycode 0x1c mods 0x00 diff --git a/app/tests/combo/overlapping-combos-1/native_posix.keymap b/app/tests/combo/overlapping-combos-1/native_posix.keymap new file mode 100644 index 00000000..c228c475 --- /dev/null +++ b/app/tests/combo/overlapping-combos-1/native_posix.keymap @@ -0,0 +1,65 @@ +#include +#include +#include + +/* + combo 01 timeout 50 + combo 012 timeout 100 + AB is pressed within 50ms, C is never pressed. + expected outcome: AB after 100ms +*/ +/ { + combos { + compatible = "zmk,combos"; + combo_two { + timeout-ms = <50>; + key-positions = <0 1>; + bindings = <&kp Y>; + }; + + combo_three { + timeout-ms = <100>; + key-positions = <0 1 2>; + bindings = <&kp X>; + }; + }; + + keymap { + compatible = "zmk,keymap"; + label ="Default keymap"; + + default_layer { + bindings = < + &kp A &kp B + &kp C &none + >; + }; + }; +}; + +&kscan { + events = < + /* if you're debugging these, remember that the timer can be triggered between + events while stepping through code. */ + /* all permutations of combo two press and release, combo triggered by timeout */ + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_PRESS(0,1,100) + ZMK_MOCK_RELEASE(0,0,10) + ZMK_MOCK_RELEASE(0,1,10) + + ZMK_MOCK_PRESS(0,1,10) + ZMK_MOCK_PRESS(0,0,100) + ZMK_MOCK_RELEASE(0,1,10) + ZMK_MOCK_RELEASE(0,0,10) + + ZMK_MOCK_PRESS(0,1,10) + ZMK_MOCK_PRESS(0,0,100) + ZMK_MOCK_RELEASE(0,0,10) + ZMK_MOCK_RELEASE(0,1,10) + + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_PRESS(0,1,100) + ZMK_MOCK_RELEASE(0,1,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/combo/overlapping-combos-2/events.patterns b/app/tests/combo/overlapping-combos-2/events.patterns new file mode 100644 index 00000000..b90d7863 --- /dev/null +++ b/app/tests/combo/overlapping-combos-2/events.patterns @@ -0,0 +1,2 @@ +s/.*hid_listener_keycode_//p +s/.*combo//p \ No newline at end of file diff --git a/app/tests/combo/overlapping-combos-2/keycode_events.snapshot b/app/tests/combo/overlapping-combos-2/keycode_events.snapshot new file mode 100644 index 00000000..dc4dbb49 --- /dev/null +++ b/app/tests/combo/overlapping-combos-2/keycode_events.snapshot @@ -0,0 +1,4 @@ +pressed: usage_page 0x07 keycode 0x1c mods 0x00 +pressed: usage_page 0x07 keycode 0x06 mods 0x00 +released: usage_page 0x07 keycode 0x1c mods 0x00 +released: usage_page 0x07 keycode 0x06 mods 0x00 diff --git a/app/tests/combo/overlapping-combos-2/native_posix.keymap b/app/tests/combo/overlapping-combos-2/native_posix.keymap new file mode 100644 index 00000000..3d364213 --- /dev/null +++ b/app/tests/combo/overlapping-combos-2/native_posix.keymap @@ -0,0 +1,52 @@ +#include +#include +#include + +/* + combo 01 timeout 100 + combo 0123 timeout 100 + press 012, wait until timeout runs out + expected: combo 01 after 100ms, immediately followed by key 2. + */ +/ { + combos { + compatible = "zmk,combos"; + combo_two { + timeout-ms = <100>; + key-positions = <0 1>; + bindings = <&kp Y>; + }; + + combo_four { + timeout-ms = <100>; + key-positions = <0 1 2 3>; + bindings = <&kp W>; + }; + + }; + + keymap { + compatible = "zmk,keymap"; + label ="Default keymap"; + + default_layer { + bindings = < + &kp A &kp B + &kp C &none + >; + }; + }; +}; + +&kscan { + events = < + /* if you're debugging these, remember that the timer can be triggered between + events while stepping through code. */ + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_PRESS(0,1,10) + ZMK_MOCK_PRESS(0,2,100) + ZMK_MOCK_RELEASE(0,0,10) + ZMK_MOCK_RELEASE(0,1,10) + ZMK_MOCK_RELEASE(0,2,100) + >; +}; \ No newline at end of file diff --git a/app/tests/combo/overlapping-combos-3/events.patterns b/app/tests/combo/overlapping-combos-3/events.patterns new file mode 100644 index 00000000..b90d7863 --- /dev/null +++ b/app/tests/combo/overlapping-combos-3/events.patterns @@ -0,0 +1,2 @@ +s/.*hid_listener_keycode_//p +s/.*combo//p \ No newline at end of file diff --git a/app/tests/combo/overlapping-combos-3/keycode_events.snapshot b/app/tests/combo/overlapping-combos-3/keycode_events.snapshot new file mode 100644 index 00000000..e0cb655e --- /dev/null +++ b/app/tests/combo/overlapping-combos-3/keycode_events.snapshot @@ -0,0 +1,4 @@ +pressed: usage_page 0x07 keycode 0x04 mods 0x00 +pressed: usage_page 0x07 keycode 0x1c mods 0x00 +released: usage_page 0x07 keycode 0x04 mods 0x00 +released: usage_page 0x07 keycode 0x1c mods 0x00 diff --git a/app/tests/combo/overlapping-combos-3/native_posix.keymap b/app/tests/combo/overlapping-combos-3/native_posix.keymap new file mode 100644 index 00000000..0622dcd0 --- /dev/null +++ b/app/tests/combo/overlapping-combos-3/native_posix.keymap @@ -0,0 +1,53 @@ +#include +#include +#include + +/* + combo 12 timeout 100 + combo 0123 timeout 100 + press 012, release 2 + expected: key pos 0 followed by combo 12 + */ +/ { + combos { + compatible = "zmk,combos"; + combo_two { + timeout-ms = <100>; + key-positions = <1 2>; + bindings = <&kp Y>; + }; + + + combo_four { + timeout-ms = <100>; + key-positions = <0 1 2 3>; + bindings = <&kp W>; + }; + + }; + + keymap { + compatible = "zmk,keymap"; + label ="Default keymap"; + + default_layer { + bindings = < + &kp A &kp B + &kp C &none + >; + }; + }; +}; + +&kscan { + events = < + /* if you're debugging these, remember that the timer can be triggered between + events while stepping through code. */ + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_PRESS(0,1,10) + ZMK_MOCK_PRESS(0,2,100) + ZMK_MOCK_RELEASE(0,0,10) + ZMK_MOCK_RELEASE(0,1,10) + ZMK_MOCK_RELEASE(0,2,100) + >; +}; \ No newline at end of file diff --git a/app/tests/combo/partially-overlapping-combos/events.patterns b/app/tests/combo/partially-overlapping-combos/events.patterns new file mode 100644 index 00000000..b1342af4 --- /dev/null +++ b/app/tests/combo/partially-overlapping-combos/events.patterns @@ -0,0 +1 @@ +s/.*hid_listener_keycode_//p diff --git a/app/tests/combo/partially-overlapping-combos/keycode_events.snapshot b/app/tests/combo/partially-overlapping-combos/keycode_events.snapshot new file mode 100644 index 00000000..adaa64bc --- /dev/null +++ b/app/tests/combo/partially-overlapping-combos/keycode_events.snapshot @@ -0,0 +1,16 @@ +pressed: usage_page 0x07 keycode 0x1b mods 0x00 +released: usage_page 0x07 keycode 0x1b mods 0x00 +pressed: usage_page 0x07 keycode 0x1b mods 0x00 +released: usage_page 0x07 keycode 0x1b mods 0x00 +pressed: usage_page 0x07 keycode 0x1b mods 0x00 +released: usage_page 0x07 keycode 0x1b mods 0x00 +pressed: usage_page 0x07 keycode 0x1b mods 0x00 +released: usage_page 0x07 keycode 0x1b mods 0x00 +pressed: usage_page 0x07 keycode 0x1c mods 0x00 +released: usage_page 0x07 keycode 0x1c mods 0x00 +pressed: usage_page 0x07 keycode 0x1c mods 0x00 +released: usage_page 0x07 keycode 0x1c mods 0x00 +pressed: usage_page 0x07 keycode 0x1c mods 0x00 +released: usage_page 0x07 keycode 0x1c mods 0x00 +pressed: usage_page 0x07 keycode 0x1c mods 0x00 +released: usage_page 0x07 keycode 0x1c mods 0x00 diff --git a/app/tests/combo/partially-overlapping-combos/native_posix.keymap b/app/tests/combo/partially-overlapping-combos/native_posix.keymap new file mode 100644 index 00000000..4e68105f --- /dev/null +++ b/app/tests/combo/partially-overlapping-combos/native_posix.keymap @@ -0,0 +1,84 @@ +#include +#include +#include + +/ { + combos { + compatible = "zmk,combos"; + combo_one { + timeout-ms = <30>; + key-positions = <0 1>; + bindings = <&kp X>; + }; + + combo_two { + timeout-ms = <30>; + key-positions = <0 2>; + bindings = <&kp Y>; + }; + + combo_three { + timeout-ms = <30>; + key-positions = <3>; + bindings = <&kp Z>; + }; + }; + + keymap { + compatible = "zmk,keymap"; + label ="Default keymap"; + + default_layer { + bindings = < + &kp A &kp B + &kp C &none + >; + }; + }; +}; + +&kscan { + events = < + /* all permutations of combo one press and release */ + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_PRESS(0,1,10) + ZMK_MOCK_RELEASE(0,0,10) + ZMK_MOCK_RELEASE(0,1,10) + + ZMK_MOCK_PRESS(0,1,10) + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_RELEASE(0,1,10) + ZMK_MOCK_RELEASE(0,0,10) + + ZMK_MOCK_PRESS(0,1,10) + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_RELEASE(0,0,10) + ZMK_MOCK_RELEASE(0,1,10) + + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_PRESS(0,1,10) + ZMK_MOCK_RELEASE(0,1,10) + ZMK_MOCK_RELEASE(0,0,10) + + /* all permutations of combo two press and release */ + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_PRESS(0,2,10) + ZMK_MOCK_RELEASE(0,0,10) + ZMK_MOCK_RELEASE(0,2,10) + + ZMK_MOCK_PRESS(0,2,10) + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_RELEASE(0,2,10) + ZMK_MOCK_RELEASE(0,0,10) + + ZMK_MOCK_PRESS(0,2,10) + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_RELEASE(0,0,10) + ZMK_MOCK_RELEASE(0,2,10) + + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_PRESS(0,2,10) + ZMK_MOCK_RELEASE(0,2,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; diff --git a/app/tests/combo/press-release/events.patterns b/app/tests/combo/press-release/events.patterns new file mode 100644 index 00000000..b1342af4 --- /dev/null +++ b/app/tests/combo/press-release/events.patterns @@ -0,0 +1 @@ +s/.*hid_listener_keycode_//p diff --git a/app/tests/combo/press-release/keycode_events.snapshot b/app/tests/combo/press-release/keycode_events.snapshot new file mode 100644 index 00000000..01718e71 --- /dev/null +++ b/app/tests/combo/press-release/keycode_events.snapshot @@ -0,0 +1,8 @@ +pressed: usage_page 0x07 keycode 0x06 mods 0x00 +released: usage_page 0x07 keycode 0x06 mods 0x00 +pressed: usage_page 0x07 keycode 0x06 mods 0x00 +released: usage_page 0x07 keycode 0x06 mods 0x00 +pressed: usage_page 0x07 keycode 0x06 mods 0x00 +released: usage_page 0x07 keycode 0x06 mods 0x00 +pressed: usage_page 0x07 keycode 0x06 mods 0x00 +released: usage_page 0x07 keycode 0x06 mods 0x00 diff --git a/app/tests/combo/press-release/native_posix.keymap b/app/tests/combo/press-release/native_posix.keymap new file mode 100644 index 00000000..0f45792d --- /dev/null +++ b/app/tests/combo/press-release/native_posix.keymap @@ -0,0 +1,51 @@ +#include +#include +#include + +/ { + combos { + compatible = "zmk,combos"; + combo_one { + timeout-ms = <30>; + key-positions = <0 1>; + bindings = <&kp C>; + }; + }; + + keymap { + compatible = "zmk,keymap"; + label ="Default keymap"; + + default_layer { + bindings = < + &kp A &kp B + &none &none + >; + }; + }; +}; + +&kscan { + events = < + /* all different combinations of press and release order */ + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_PRESS(0,1,10) + ZMK_MOCK_RELEASE(0,0,10) + ZMK_MOCK_RELEASE(0,1,10) + + ZMK_MOCK_PRESS(0,1,10) + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_RELEASE(0,0,10) + ZMK_MOCK_RELEASE(0,1,10) + + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_PRESS(0,1,10) + ZMK_MOCK_RELEASE(0,1,10) + ZMK_MOCK_RELEASE(0,0,10) + + ZMK_MOCK_PRESS(0,1,10) + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_RELEASE(0,1,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/combo/press-timeout/events.patterns b/app/tests/combo/press-timeout/events.patterns new file mode 100644 index 00000000..b1342af4 --- /dev/null +++ b/app/tests/combo/press-timeout/events.patterns @@ -0,0 +1 @@ +s/.*hid_listener_keycode_//p diff --git a/app/tests/combo/press-timeout/keycode_events.snapshot b/app/tests/combo/press-timeout/keycode_events.snapshot new file mode 100644 index 00000000..c5bdd6e0 --- /dev/null +++ b/app/tests/combo/press-timeout/keycode_events.snapshot @@ -0,0 +1,4 @@ +pressed: usage_page 0x07 keycode 0x04 mods 0x00 +pressed: usage_page 0x07 keycode 0x05 mods 0x00 +released: usage_page 0x07 keycode 0x04 mods 0x00 +released: usage_page 0x07 keycode 0x05 mods 0x00 diff --git a/app/tests/combo/press-timeout/native_posix.keymap b/app/tests/combo/press-timeout/native_posix.keymap new file mode 100644 index 00000000..ff0b7493 --- /dev/null +++ b/app/tests/combo/press-timeout/native_posix.keymap @@ -0,0 +1,35 @@ +#include +#include +#include + +/ { + combos { + compatible = "zmk,combos"; + combo_one { + timeout-ms = <30>; + key-positions = <0 1>; + bindings = <&kp C>; + }; + }; + + keymap { + compatible = "zmk,keymap"; + label ="Default keymap"; + + default_layer { + bindings = < + &kp A &kp B + &none &none + >; + }; + }; +}; + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,100) + ZMK_MOCK_PRESS(0,1,10) + ZMK_MOCK_RELEASE(0,0,10) + ZMK_MOCK_RELEASE(0,1,10) + >; +}; \ No newline at end of file diff --git a/app/tests/combo/press1-press2-release1-release2/events.patterns b/app/tests/combo/press1-press2-release1-release2/events.patterns new file mode 100644 index 00000000..5f3e4cf7 --- /dev/null +++ b/app/tests/combo/press1-press2-release1-release2/events.patterns @@ -0,0 +1,2 @@ +s/.*hid_listener_keycode_//p +s/.*combo/combo/p \ No newline at end of file diff --git a/app/tests/combo/press1-press2-release1-release2/keycode_events.snapshot b/app/tests/combo/press1-press2-release1-release2/keycode_events.snapshot new file mode 100644 index 00000000..cfa02de2 --- /dev/null +++ b/app/tests/combo/press1-press2-release1-release2/keycode_events.snapshot @@ -0,0 +1,4 @@ +pressed: usage_page 0x07 keycode 0x06 mods 0x00 +pressed: usage_page 0x07 keycode 0x07 mods 0x00 +released: usage_page 0x07 keycode 0x06 mods 0x00 +released: usage_page 0x07 keycode 0x07 mods 0x00 diff --git a/app/tests/combo/press1-press2-release1-release2/native_posix.keymap b/app/tests/combo/press1-press2-release1-release2/native_posix.keymap new file mode 100644 index 00000000..2518bbc9 --- /dev/null +++ b/app/tests/combo/press1-press2-release1-release2/native_posix.keymap @@ -0,0 +1,45 @@ +#include +#include +#include + +/ { + combos { + compatible = "zmk,combos"; + combo_one { + timeout-ms = <30>; + key-positions = <0 1>; + bindings = <&kp C>; + }; + + combo_two { + timeout-ms = <30>; + key-positions = <2 3>; + bindings = <&kp D>; + }; + }; + + keymap { + compatible = "zmk,keymap"; + label ="Default keymap"; + + default_layer { + bindings = < + &kp A &kp B + &kp Z &kp Y + >; + }; + }; +}; + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_PRESS(0,1,10) + ZMK_MOCK_PRESS(1,0,10) + ZMK_MOCK_PRESS(1,1,10) + ZMK_MOCK_RELEASE(0,0,10) + ZMK_MOCK_RELEASE(0,1,10) + ZMK_MOCK_RELEASE(1,0,10) + ZMK_MOCK_RELEASE(1,1,10) + >; +}; \ No newline at end of file diff --git a/app/tests/combo/press1-press2-release2-release1/events.patterns b/app/tests/combo/press1-press2-release2-release1/events.patterns new file mode 100644 index 00000000..b54b66b6 --- /dev/null +++ b/app/tests/combo/press1-press2-release2-release1/events.patterns @@ -0,0 +1,2 @@ +s/.*hid_listener_keycode_//p +s/.*combo/combo/p diff --git a/app/tests/combo/press1-press2-release2-release1/keycode_events.snapshot b/app/tests/combo/press1-press2-release2-release1/keycode_events.snapshot new file mode 100644 index 00000000..b55f09ba --- /dev/null +++ b/app/tests/combo/press1-press2-release2-release1/keycode_events.snapshot @@ -0,0 +1,4 @@ +pressed: usage_page 0x07 keycode 0x06 mods 0x00 +pressed: usage_page 0x07 keycode 0x07 mods 0x00 +released: usage_page 0x07 keycode 0x07 mods 0x00 +released: usage_page 0x07 keycode 0x06 mods 0x00 diff --git a/app/tests/combo/press1-press2-release2-release1/native_posix.keymap b/app/tests/combo/press1-press2-release2-release1/native_posix.keymap new file mode 100644 index 00000000..4895636e --- /dev/null +++ b/app/tests/combo/press1-press2-release2-release1/native_posix.keymap @@ -0,0 +1,46 @@ +#include +#include +#include + +/ { + combos { + compatible = "zmk,combos"; + combo_one { + timeout-ms = <30>; + key-positions = <0 1>; + bindings = <&kp C>; + }; + + combo_two { + timeout-ms = <30>; + key-positions = <2 3>; + bindings = <&kp D>; + }; + }; + + keymap { + compatible = "zmk,keymap"; + label ="Default keymap"; + + default_layer { + bindings = < + &kp A &kp B + &kp Z &kp Y + >; + }; + }; +}; + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_PRESS(0,1,10) + ZMK_MOCK_PRESS(1,0,10) + ZMK_MOCK_PRESS(1,1,10) + + ZMK_MOCK_RELEASE(1,0,10) + ZMK_MOCK_RELEASE(1,1,10) + ZMK_MOCK_RELEASE(0,0,10) + ZMK_MOCK_RELEASE(0,1,10) + >; +}; \ No newline at end of file diff --git a/app/tests/combo/press1-release1-press2-release2/events.patterns b/app/tests/combo/press1-release1-press2-release2/events.patterns new file mode 100644 index 00000000..5f3e4cf7 --- /dev/null +++ b/app/tests/combo/press1-release1-press2-release2/events.patterns @@ -0,0 +1,2 @@ +s/.*hid_listener_keycode_//p +s/.*combo/combo/p \ No newline at end of file diff --git a/app/tests/combo/press1-release1-press2-release2/keycode_events.snapshot b/app/tests/combo/press1-release1-press2-release2/keycode_events.snapshot new file mode 100644 index 00000000..c41dee8c --- /dev/null +++ b/app/tests/combo/press1-release1-press2-release2/keycode_events.snapshot @@ -0,0 +1,4 @@ +pressed: usage_page 0x07 keycode 0x06 mods 0x00 +released: usage_page 0x07 keycode 0x06 mods 0x00 +pressed: usage_page 0x07 keycode 0x07 mods 0x00 +released: usage_page 0x07 keycode 0x07 mods 0x00 diff --git a/app/tests/combo/press1-release1-press2-release2/native_posix.keymap b/app/tests/combo/press1-release1-press2-release2/native_posix.keymap new file mode 100644 index 00000000..0c4a698c --- /dev/null +++ b/app/tests/combo/press1-release1-press2-release2/native_posix.keymap @@ -0,0 +1,46 @@ +#include +#include +#include + +/ { + combos { + compatible = "zmk,combos"; + combo_one { + timeout-ms = <30>; + key-positions = <0 1>; + bindings = <&kp C>; + }; + + combo_two { + timeout-ms = <30>; + key-positions = <2 3>; + bindings = <&kp D>; + }; + }; + + keymap { + compatible = "zmk,keymap"; + label ="Default keymap"; + + default_layer { + bindings = < + &kp A &kp B + &kp Z &kp Y + >; + }; + }; +}; + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_PRESS(0,1,10) + ZMK_MOCK_RELEASE(0,0,10) + ZMK_MOCK_RELEASE(0,1,10) + + ZMK_MOCK_PRESS(1,0,10) + ZMK_MOCK_PRESS(1,1,10) + ZMK_MOCK_RELEASE(1,0,10) + ZMK_MOCK_RELEASE(1,1,10) + >; +}; \ No newline at end of file diff --git a/app/tests/combo/slowrelease-disabled/events.patterns b/app/tests/combo/slowrelease-disabled/events.patterns new file mode 100644 index 00000000..b1342af4 --- /dev/null +++ b/app/tests/combo/slowrelease-disabled/events.patterns @@ -0,0 +1 @@ +s/.*hid_listener_keycode_//p diff --git a/app/tests/combo/slowrelease-disabled/keycode_events.snapshot b/app/tests/combo/slowrelease-disabled/keycode_events.snapshot new file mode 100644 index 00000000..c41dee8c --- /dev/null +++ b/app/tests/combo/slowrelease-disabled/keycode_events.snapshot @@ -0,0 +1,4 @@ +pressed: usage_page 0x07 keycode 0x06 mods 0x00 +released: usage_page 0x07 keycode 0x06 mods 0x00 +pressed: usage_page 0x07 keycode 0x07 mods 0x00 +released: usage_page 0x07 keycode 0x07 mods 0x00 diff --git a/app/tests/combo/slowrelease-disabled/native_posix.keymap b/app/tests/combo/slowrelease-disabled/native_posix.keymap new file mode 100644 index 00000000..3bacb886 --- /dev/null +++ b/app/tests/combo/slowrelease-disabled/native_posix.keymap @@ -0,0 +1,38 @@ +#include +#include +#include + +/ { + combos { + compatible = "zmk,combos"; + combo_one { + timeout-ms = <30>; + key-positions = <0 1>; + bindings = <&kp C>; + /* no slow-release! */ + }; + }; + + keymap { + compatible = "zmk,keymap"; + label = "Default keymap"; + + default_layer { + bindings = < + &kp A &kp B + &kp D &none + >; + }; + }; +}; + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_PRESS(0,1,10) + ZMK_MOCK_RELEASE(0,0,10) /* this should release the combo */ + ZMK_MOCK_PRESS(1,0,10) + ZMK_MOCK_RELEASE(0,1,10) + ZMK_MOCK_RELEASE(1,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/combo/slowrelease-enabled/events.patterns b/app/tests/combo/slowrelease-enabled/events.patterns new file mode 100644 index 00000000..b1342af4 --- /dev/null +++ b/app/tests/combo/slowrelease-enabled/events.patterns @@ -0,0 +1 @@ +s/.*hid_listener_keycode_//p diff --git a/app/tests/combo/slowrelease-enabled/keycode_events.snapshot b/app/tests/combo/slowrelease-enabled/keycode_events.snapshot new file mode 100644 index 00000000..cfa02de2 --- /dev/null +++ b/app/tests/combo/slowrelease-enabled/keycode_events.snapshot @@ -0,0 +1,4 @@ +pressed: usage_page 0x07 keycode 0x06 mods 0x00 +pressed: usage_page 0x07 keycode 0x07 mods 0x00 +released: usage_page 0x07 keycode 0x06 mods 0x00 +released: usage_page 0x07 keycode 0x07 mods 0x00 diff --git a/app/tests/combo/slowrelease-enabled/native_posix.keymap b/app/tests/combo/slowrelease-enabled/native_posix.keymap new file mode 100644 index 00000000..8ac8316b --- /dev/null +++ b/app/tests/combo/slowrelease-enabled/native_posix.keymap @@ -0,0 +1,38 @@ +#include +#include +#include + +/ { + combos { + compatible = "zmk,combos"; + combo_one { + timeout-ms = <30>; + key-positions = <0 1>; + bindings = <&kp C>; + slow-release; + }; + }; + + keymap { + compatible = "zmk,keymap"; + label ="Default keymap"; + + default_layer { + bindings = < + &kp A &kp B + &kp D &none + >; + }; + }; +}; + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_PRESS(0,1,10) + ZMK_MOCK_RELEASE(0,0,10) /* this should not release the combo yet */ + ZMK_MOCK_PRESS(1,0,10) + ZMK_MOCK_RELEASE(0,1,10) + ZMK_MOCK_RELEASE(1,0,10) + >; +}; \ No newline at end of file diff --git a/docs/docs/behaviors/combos.md b/docs/docs/behaviors/combos.md new file mode 100644 index 00000000..e9b01761 --- /dev/null +++ b/docs/docs/behaviors/combos.md @@ -0,0 +1,52 @@ +--- +title: Combo Behavior +sidebar_label: Combos +--- + +## Summary + +Combo keys are a way to combine multiple keypresses to output a different key. For example, you can hit the Q and W keys on your keyboard to output escape. + +### Configuration + +Combos are specified like this: + +``` +/ { + combos { + compatible = "zmk,combos"; + combo_esc { + timeout-ms = <50>; + key-positions = <0 1>; + bindings = <&kp ESC>; + }; + }; +}; +``` + +- The name of the combo doesn't really matter, but convention is to start the node name with `combo_`. +- The `compatible` property should always be `"zmk,combos"` for combos. +- `timeout-ms` is the number of milliseconds that all keys of the combo must be pressed. +- `key-positions` is an array of key positions. See the info section below about how to figure out the positions on your board. +- `bindings` is the behavior that is activated when the behavior is pressed. +- (advanced) you can specify `slow-release` if you want the combo binding to be released when all key-positions are released. The default is to release the combo as soon as any of the keys in the combo is released. + +:::info + +Key positions are numbered like the keys in your keymap, starting at 0. So, if the first key in your keymap is `Q`, this key is in position `0`. The next key (possibly `W`) will have position 1, etcetera. + +::: + +### Advanced usage + +- Partially overlapping combos like `0 1` and `0 2` are supported. +- Fully overlapping combos like `0 1` and `0 1 2` are supported. +- You are not limited to `&kp` bindings. You can use all ZMK behaviors there, like `&mo`, `&bt`, `&mt`, `<` etc. + +### Advanced configuration + +There are three global combo parameters which are set through KConfig. You can set them in the `.conf` file in the same directory as your keymap file. + +- `CONFIG_ZMK_COMBO_MAX_PRESSED_COMBOS` is the number of combos that can be active at the same time. Default 4. +- `CONFIG_ZMK_COMBO_MAX_COMBOS_PER_KEY` is the maximum number of combos that can be active on a key position. Defaults to 5. (So you can have 5 separate combos that use position `3` for example) +- `CONFIG_ZMK_COMBO_MAX_KEYS_PER_COMBO` is the maximum number of keys that need to be pressed to activate a combo. Default 4. If you want a combo that triggers when pressing 5 keys, you'd set this to 5 for example. diff --git a/docs/docs/intro.md b/docs/docs/intro.md index 57670ea0..2215291c 100644 --- a/docs/docs/intro.md +++ b/docs/docs/intro.md @@ -26,7 +26,7 @@ ZMK is currently missing some features found in other popular firmware. This tab | [Display Support](features/displays)[^2] | 🚧 | 🚧 | ✅ | | [RGB Underglow](features/underglow) | ✅ | ✅ | ✅ | | One Shot Keys | ✅ | ✅ | ✅ | -| [Combo Keys](https://github.com/zmkfirmware/zmk/pull/504) | 🚧 | | ✅ | +| [Combo Keys](behaviors/combos) | ✅ | | ✅ | | Macros | 🚧 | ✅ | ✅ | | Mouse Keys | 💡 | ✅ | ✅ | | Low Active Power Usage | ✅ | | | diff --git a/docs/sidebars.js b/docs/sidebars.js index 8fc1dc54..d095a47e 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -20,6 +20,7 @@ module.exports = { "behaviors/misc", "behaviors/hold-tap", "behaviors/mod-tap", + "behaviors/combos", "behaviors/reset", "behaviors/bluetooth", "behaviors/outputs",