Browse Source

bugfix(sticky keys): release active sticky keys properly

see https://github.com/zmkfirmware/zmk/issues/445
xmkb
Okke Formsma 4 years ago committed by Pete Johanson
parent
commit
3bf770a364
  1. 2
      app/src/behaviors/behavior_sticky_key.c
  2. 4
      app/tests/sticky-keys/2-os-dn-up-kcdn-kcup/keycode_events.snapshot
  3. 6
      app/tests/sticky-keys/2-os-dn-up-kcdn-kcup/native_posix.keymap
  4. 1
      app/tests/sticky-keys/8-lsk-osk-combination/events.patterns
  5. 8
      app/tests/sticky-keys/8-lsk-osk-combination/keycode_events.snapshot
  6. 47
      app/tests/sticky-keys/8-lsk-osk-combination/native_posix.keymap

2
app/src/behaviors/behavior_sticky_key.c

@ -213,6 +213,8 @@ static int sticky_key_keycode_state_changed_listener(const struct zmk_event_head @@ -213,6 +213,8 @@ static int sticky_key_keycode_state_changed_listener(const struct zmk_event_head
sticky_key->modified_key_usage_page == ev->usage_page &&
sticky_key->modified_key_keycode == ev->keycode) {
release_sticky_key_behavior(sticky_key, ev->timestamp);
stop_timer(sticky_key);
clear_sticky_key(sticky_key);
}
}
}

4
app/tests/sticky-keys/2-os-dn-up-kcdn-kcup/keycode_events.snapshot

@ -2,3 +2,7 @@ pressed: usage_page 0x07 keycode 0x08 mods 0x00 @@ -2,3 +2,7 @@ pressed: usage_page 0x07 keycode 0x08 mods 0x00
pressed: usage_page 0x07 keycode 0x04 mods 0x00
released: usage_page 0x07 keycode 0x08 mods 0x00
released: usage_page 0x07 keycode 0x04 mods 0x00
pressed: usage_page 0x07 keycode 0x08 mods 0x00
pressed: usage_page 0x07 keycode 0x04 mods 0x00
released: usage_page 0x07 keycode 0x08 mods 0x00
released: usage_page 0x07 keycode 0x04 mods 0x00

6
app/tests/sticky-keys/2-os-dn-up-kcdn-kcup/native_posix.keymap

@ -9,5 +9,11 @@ @@ -9,5 +9,11 @@
ZMK_MOCK_RELEASE(0,0,10)
ZMK_MOCK_PRESS(1,0,10)
ZMK_MOCK_RELEASE(1,0,10)
/* repeat test to check if cleanup is done correctly */
ZMK_MOCK_PRESS(0,0,10)
ZMK_MOCK_RELEASE(0,0,10)
ZMK_MOCK_PRESS(1,0,10)
ZMK_MOCK_RELEASE(1,0,10)
>;
};

1
app/tests/sticky-keys/8-lsk-osk-combination/events.patterns

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

8
app/tests/sticky-keys/8-lsk-osk-combination/keycode_events.snapshot

@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
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
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

47
app/tests/sticky-keys/8-lsk-osk-combination/native_posix.keymap

@ -0,0 +1,47 @@ @@ -0,0 +1,47 @@
#include <dt-bindings/zmk/keys.h>
#include <behaviors.dtsi>
#include <dt-bindings/zmk/kscan-mock.h>
/ {
keymap {
compatible = "zmk,keymap";
label ="Default keymap";
default_layer {
bindings = <
&sk E &sl 1
&kp A &kp B>;
};
lower_layer {
bindings = <
&sk LEFT_CONTROL &kp X
&kp Y &kp Z>;
};
};
};
&kscan {
events = <
/* tap sl lower_layer */
ZMK_MOCK_PRESS(0,1,10)
ZMK_MOCK_RELEASE(0,1,10)
/* tap sk LEFT_CONTROL */
ZMK_MOCK_PRESS(0,0,10)
ZMK_MOCK_RELEASE(0,0,10)
/* tap Y */
ZMK_MOCK_PRESS(1,0,10)
ZMK_MOCK_RELEASE(1,0,10)
/* repeat */
/* tap sl */
ZMK_MOCK_PRESS(0,1,10)
ZMK_MOCK_RELEASE(0,1,10)
/* tap sk */
ZMK_MOCK_PRESS(0,0,10)
ZMK_MOCK_RELEASE(0,0,10)
/* tap Y */
ZMK_MOCK_PRESS(1,0,10)
ZMK_MOCK_RELEASE(1,0,10)
>;
};
Loading…
Cancel
Save