Skip to content

Commit

Permalink
fix(behaviors): make tap dances work on a combo
Browse files Browse the repository at this point in the history
* Tap dance event handler goes after combos
* Add test
  • Loading branch information
okke-formsma authored Nov 1, 2022
1 parent d393247 commit a61eac9
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions app/tests/tap-dance/6-combo-tap2/events.patterns
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
s/.*hid_listener_keycode/kp/p
s/.*on_tap_dance_binding/td_binding/p
7 changes: 7 additions & 0 deletions app/tests/tap-dance/6-combo-tap2/keycode_events.snapshot
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions app/tests/tap-dance/6-combo-tap2/native_posix_64.keymap
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <dt-bindings/zmk/keys.h>
#include <behaviors.dtsi>
#include <dt-bindings/zmk/kscan_mock.h>
#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)
>;
};
30 changes: 20 additions & 10 deletions app/tests/tap-dance/behavior_keymap.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <dt-bindings/zmk/kscan_mock.h>

/ {
behaviors {
behaviors {
ht: hold_tap {
compatible = "zmk,behavior-hold-tap";
label = "HOLD_TAP";
Expand Down Expand Up @@ -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>;
};
};
};

0 comments on commit a61eac9

Please # to comment.