feat(combos): initial implementation

closes #45
This commit is contained in:
Okke Formsma
2020-12-11 23:24:44 +01:00
committed by Pete Johanson
parent 90c2c6672f
commit feb0d5b90c
55 changed files with 1528 additions and 1 deletions

View File

@@ -0,0 +1,2 @@
s/.*hid_listener_keycode_//p
s/.*combo//p

View File

@@ -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

View File

@@ -0,0 +1,47 @@
#include <dt-bindings/zmk/keys.h>
#include <behaviors.dtsi>
#include <dt-bindings/zmk/kscan-mock.h>
&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)
>;
};

View File

@@ -0,0 +1,2 @@
s/.*hid_listener_keycode_//p
s/.*combo//p

View File

@@ -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

View File

@@ -0,0 +1,42 @@
#include <dt-bindings/zmk/keys.h>
#include <behaviors.dtsi>
#include <dt-bindings/zmk/kscan-mock.h>
&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)
>;
};

View File

@@ -0,0 +1,2 @@
s/.*hid_listener_keycode_//p
s/.*combo//p

View File

@@ -0,0 +1,2 @@
pressed: usage_page 0x07 keycode 0xe0 mods 0x00
pressed: usage_page 0x07 keycode 0xe4 mods 0x00

View File

@@ -0,0 +1,45 @@
#include <dt-bindings/zmk/keys.h>
#include <behaviors.dtsi>
#include <dt-bindings/zmk/kscan-mock.h>
&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)
>;
};

View File

@@ -0,0 +1 @@
s/.*hid_listener_keycode_//p

View File

@@ -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

View File

@@ -0,0 +1,40 @@
#include <dt-bindings/zmk/keys.h>
#include <behaviors.dtsi>
#include <dt-bindings/zmk/kscan-mock.h>
/ {
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)
>;
};

View File

@@ -0,0 +1,2 @@
s/.*hid_listener_keycode_//p
s/.*combo//p

View File

@@ -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

View File

@@ -0,0 +1,117 @@
#include <dt-bindings/zmk/keys.h>
#include <behaviors.dtsi>
#include <dt-bindings/zmk/kscan-mock.h>
/*
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 = <TIMEOUT>;
key-positions = <0 1 2>;
bindings = <&kp X>;
};
combo_two {
timeout-ms = <TIMEOUT>;
key-positions = <0 2>;
bindings = <&kp Y>;
};
combo_three {
timeout-ms = <TIMEOUT>;
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)
>;
};

View File

@@ -0,0 +1,2 @@
s/.*hid_listener_keycode_//p
s/.*combo//p

View File

@@ -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

View File

@@ -0,0 +1,65 @@
#include <dt-bindings/zmk/keys.h>
#include <behaviors.dtsi>
#include <dt-bindings/zmk/kscan-mock.h>
/*
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)
>;
};

View File

@@ -0,0 +1,2 @@
s/.*hid_listener_keycode_//p
s/.*combo//p

View File

@@ -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

View File

@@ -0,0 +1,52 @@
#include <dt-bindings/zmk/keys.h>
#include <behaviors.dtsi>
#include <dt-bindings/zmk/kscan-mock.h>
/*
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)
>;
};

View File

@@ -0,0 +1,2 @@
s/.*hid_listener_keycode_//p
s/.*combo//p

View File

@@ -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

View File

@@ -0,0 +1,53 @@
#include <dt-bindings/zmk/keys.h>
#include <behaviors.dtsi>
#include <dt-bindings/zmk/kscan-mock.h>
/*
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)
>;
};

View File

@@ -0,0 +1 @@
s/.*hid_listener_keycode_//p

View File

@@ -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

View File

@@ -0,0 +1,84 @@
#include <dt-bindings/zmk/keys.h>
#include <behaviors.dtsi>
#include <dt-bindings/zmk/kscan-mock.h>
/ {
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)
>;
};

View File

@@ -0,0 +1 @@
s/.*hid_listener_keycode_//p

View File

@@ -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

View File

@@ -0,0 +1,51 @@
#include <dt-bindings/zmk/keys.h>
#include <behaviors.dtsi>
#include <dt-bindings/zmk/kscan-mock.h>
/ {
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)
>;
};

View File

@@ -0,0 +1 @@
s/.*hid_listener_keycode_//p

View File

@@ -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

View File

@@ -0,0 +1,35 @@
#include <dt-bindings/zmk/keys.h>
#include <behaviors.dtsi>
#include <dt-bindings/zmk/kscan-mock.h>
/ {
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)
>;
};

View File

@@ -0,0 +1,2 @@
s/.*hid_listener_keycode_//p
s/.*combo/combo/p

View File

@@ -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

View File

@@ -0,0 +1,45 @@
#include <dt-bindings/zmk/keys.h>
#include <behaviors.dtsi>
#include <dt-bindings/zmk/kscan-mock.h>
/ {
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)
>;
};

View File

@@ -0,0 +1,2 @@
s/.*hid_listener_keycode_//p
s/.*combo/combo/p

View File

@@ -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

View File

@@ -0,0 +1,46 @@
#include <dt-bindings/zmk/keys.h>
#include <behaviors.dtsi>
#include <dt-bindings/zmk/kscan-mock.h>
/ {
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)
>;
};

View File

@@ -0,0 +1,2 @@
s/.*hid_listener_keycode_//p
s/.*combo/combo/p

View File

@@ -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

View File

@@ -0,0 +1,46 @@
#include <dt-bindings/zmk/keys.h>
#include <behaviors.dtsi>
#include <dt-bindings/zmk/kscan-mock.h>
/ {
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)
>;
};

View File

@@ -0,0 +1 @@
s/.*hid_listener_keycode_//p

View File

@@ -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

View File

@@ -0,0 +1,38 @@
#include <dt-bindings/zmk/keys.h>
#include <behaviors.dtsi>
#include <dt-bindings/zmk/kscan-mock.h>
/ {
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)
>;
};

View File

@@ -0,0 +1 @@
s/.*hid_listener_keycode_//p

View File

@@ -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

View File

@@ -0,0 +1,38 @@
#include <dt-bindings/zmk/keys.h>
#include <behaviors.dtsi>
#include <dt-bindings/zmk/kscan-mock.h>
/ {
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)
>;
};