fix(behaviors): Make multiple sticky keys work on same key position (#2758)

test(behaviors): Add same position sticky key tests

fix(behaviors): Make multiple sticky keys work on same key position

refactor(behaviors): Remove unused param2 in sticky keys
This commit is contained in:
Cem Aksoylar
2025-02-26 14:54:08 -08:00
committed by GitHub
parent 9406d39d14
commit 7186528f77
10 changed files with 153 additions and 10 deletions

View File

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

View File

@@ -0,0 +1,4 @@
pressed: usage_page 0x07 keycode 0xE0 implicit_mods 0x00 explicit_mods 0x00
pressed: usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00
released: usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00
released: usage_page 0x07 keycode 0xE0 implicit_mods 0x00 explicit_mods 0x00

View File

@@ -0,0 +1,36 @@
#include <dt-bindings/zmk/keys.h>
#include <behaviors.dtsi>
#include <dt-bindings/zmk/kscan_mock.h>
/ {
behaviors {
ZMK_MACRO(sk_sl, wait-ms = <1>; tap-ms = <1>; bindings = <&sk LEFT_CONTROL &sl 1>;)
};
keymap {
compatible = "zmk,keymap";
default_layer {
bindings = <
&sk_sl &mo 1
&kp Y &kp B>;
};
upper_layer {
bindings = <
&kp T &kp X
&kp A &kp Z>;
};
};
};
&kscan {
events = <
/* tap sk_sl */
ZMK_MOCK_PRESS(0,0,10)
ZMK_MOCK_RELEASE(0,0,10)
/* tap A */
ZMK_MOCK_PRESS(1,0,10)
ZMK_MOCK_RELEASE(1,0,10)
>;
};

View File

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

View File

@@ -0,0 +1,6 @@
pressed: usage_page 0x07 keycode 0xE0 implicit_mods 0x00 explicit_mods 0x00
pressed: usage_page 0x07 keycode 0xE1 implicit_mods 0x00 explicit_mods 0x00
pressed: usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00
released: usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00
released: usage_page 0x07 keycode 0xE0 implicit_mods 0x00 explicit_mods 0x00
released: usage_page 0x07 keycode 0xE1 implicit_mods 0x00 explicit_mods 0x00

View File

@@ -0,0 +1,39 @@
#include <dt-bindings/zmk/keys.h>
#include <behaviors.dtsi>
#include <dt-bindings/zmk/kscan_mock.h>
/ {
keymap {
compatible = "zmk,keymap";
default_layer {
bindings = <
&sk LEFT_CONTROL &mo 1
&kp A &kp B>;
};
lower_layer {
bindings = <
&sk LEFT_SHIFT &kp X
&kp Y &kp Z>;
};
};
};
&kscan {
events = <
/* tap sk LEFT_CONTROL */
ZMK_MOCK_PRESS(0,0,10)
ZMK_MOCK_RELEASE(0,0,10)
/* switch to lower layer */
ZMK_MOCK_PRESS(0,1,10)
/* tap sk LEFT_SHIFT */
ZMK_MOCK_PRESS(0,0,10)
ZMK_MOCK_RELEASE(0,0,10)
/* deactivate lower layer */
ZMK_MOCK_RELEASE(0,1,10)
/* tap A */
ZMK_MOCK_PRESS(1,0,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 0xE0 implicit_mods 0x00 explicit_mods 0x00
pressed: usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00
released: usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00
released: usage_page 0x07 keycode 0xE0 implicit_mods 0x00 explicit_mods 0x00

View File

@@ -0,0 +1,45 @@
#include <dt-bindings/zmk/keys.h>
#include <behaviors.dtsi>
#include <dt-bindings/zmk/kscan_mock.h>
/ {
keymap {
compatible = "zmk,keymap";
default_layer {
bindings = <
&sk LEFT_CONTROL &mo 1
&kp A &kp B>;
};
lower_layer {
bindings = <
&sl 2 &kp X
&kp Y &kp Z>;
};
upper_layer {
bindings = <
&kp T &kp X
&kp A &kp Z>;
};
};
};
&kscan {
events = <
/* tap sk LEFT_CONTROL */
ZMK_MOCK_PRESS(0,0,10)
ZMK_MOCK_RELEASE(0,0,10)
/* switch to lower layer */
ZMK_MOCK_PRESS(0,1,10)
/* tap sl upper_layer */
ZMK_MOCK_PRESS(0,0,10)
ZMK_MOCK_RELEASE(0,0,10)
/* tap A */
ZMK_MOCK_PRESS(1,0,10)
ZMK_MOCK_RELEASE(1,0,10)
/* deactivate lower layer */
ZMK_MOCK_RELEASE(0,1,10)
>;
};