From a61eac91395a7e8f2695e76c7512fb97e0e13e11 Mon Sep 17 00:00:00 2001 From: Okke Formsma Date: Tue, 1 Nov 2022 21:13:19 +0100 Subject: [PATCH] fix(behaviors): make tap dances work on a combo * Tap dance event handler goes after combos * Add test --- app/CMakeLists.txt | 2 +- .../tap-dance/6-combo-tap2/events.patterns | 2 ++ .../6-combo-tap2/keycode_events.snapshot | 7 +++++ .../6-combo-tap2/native_posix_64.keymap | 17 +++++++++++ app/tests/tap-dance/behavior_keymap.dtsi | 30 ++++++++++++------- 5 files changed, 47 insertions(+), 11 deletions(-) create mode 100644 app/tests/tap-dance/6-combo-tap2/events.patterns create mode 100644 app/tests/tap-dance/6-combo-tap2/keycode_events.snapshot create mode 100644 app/tests/tap-dance/6-combo-tap2/native_posix_64.keymap diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 4b61fc72..3da50b57 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -47,13 +47,13 @@ if ((NOT CONFIG_ZMK_SPLIT) OR CONFIG_ZMK_SPLIT_ROLE_CENTRAL) target_sources(app PRIVATE src/behaviors/behavior_momentary_layer.c) target_sources(app PRIVATE src/behaviors/behavior_mod_morph.c) target_sources(app PRIVATE src/behaviors/behavior_outputs.c) - target_sources(app PRIVATE src/behaviors/behavior_tap_dance.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) target_sources(app PRIVATE src/combo.c) + target_sources(app PRIVATE src/behaviors/behavior_tap_dance.c) target_sources(app PRIVATE src/behavior_queue.c) target_sources(app PRIVATE src/conditional_layer.c) target_sources(app PRIVATE src/endpoints.c) diff --git a/app/tests/tap-dance/6-combo-tap2/events.patterns b/app/tests/tap-dance/6-combo-tap2/events.patterns new file mode 100644 index 00000000..1768fc21 --- /dev/null +++ b/app/tests/tap-dance/6-combo-tap2/events.patterns @@ -0,0 +1,2 @@ +s/.*hid_listener_keycode/kp/p +s/.*on_tap_dance_binding/td_binding/p \ No newline at end of file diff --git a/app/tests/tap-dance/6-combo-tap2/keycode_events.snapshot b/app/tests/tap-dance/6-combo-tap2/keycode_events.snapshot new file mode 100644 index 00000000..227d9cf2 --- /dev/null +++ b/app/tests/tap-dance/6-combo-tap2/keycode_events.snapshot @@ -0,0 +1,7 @@ +td_binding_pressed: 4 created new tap dance +td_binding_pressed: 4 tap dance pressed +td_binding_released: 4 tap dance keybind released +td_binding_pressed: 4 tap dance pressed +td_binding_released: 4 tap dance keybind released +kp_pressed: usage_page 0x07 keycode 0x1F implicit_mods 0x00 explicit_mods 0x00 +kp_released: usage_page 0x07 keycode 0x1F implicit_mods 0x00 explicit_mods 0x00 diff --git a/app/tests/tap-dance/6-combo-tap2/native_posix_64.keymap b/app/tests/tap-dance/6-combo-tap2/native_posix_64.keymap new file mode 100644 index 00000000..72b6744a --- /dev/null +++ b/app/tests/tap-dance/6-combo-tap2/native_posix_64.keymap @@ -0,0 +1,17 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&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(0,0,10) + ZMK_MOCK_PRESS(0,1,10) + ZMK_MOCK_RELEASE(0,0,10) + ZMK_MOCK_RELEASE(0,1,200) + >; +}; \ No newline at end of file diff --git a/app/tests/tap-dance/behavior_keymap.dtsi b/app/tests/tap-dance/behavior_keymap.dtsi index 5e95cd50..ce80e958 100644 --- a/app/tests/tap-dance/behavior_keymap.dtsi +++ b/app/tests/tap-dance/behavior_keymap.dtsi @@ -3,7 +3,7 @@ #include / { - behaviors { + behaviors { ht: hold_tap { compatible = "zmk,behavior-hold-tap"; label = "HOLD_TAP"; @@ -47,14 +47,24 @@ }; }; - keymap { - compatible = "zmk,keymap"; - label ="Default keymap"; + combos { + compatible = "zmk,combos"; - default_layer { - bindings = < - &tdm &tds - &tdb &td2>; - }; - }; + td_combo { + bindings = <&tdb>; + key-positions = <0 1>; + timeout-ms = <50>; + }; + }; + + keymap { + compatible = "zmk,keymap"; + label = "Default keymap"; + + default_layer { + bindings = < + &tdm &tds + &tdb &td2>; + }; + }; };