Skip to content

Commit

Permalink
bugfix(sticky keys): release active sticky keys properly
Browse files Browse the repository at this point in the history
  • Loading branch information
okke-formsma authored and petejohanson committed Nov 30, 2020
1 parent 7babe7f commit 3bf770a
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/src/behaviors/behavior_sticky_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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)
>;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
s/.*hid_listener_keycode_//p
Original file line number Diff line number Diff line change
@@ -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 changes: 47 additions & 0 deletions app/tests/sticky-keys/8-lsk-osk-combination/native_posix.keymap
Original file line number Diff line number Diff line change
@@ -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)
>;
};

0 comments on commit 3bf770a

Please sign in to comment.