summaryrefslogtreecommitdiff
path: root/app/tests
diff options
context:
space:
mode:
authorOkke Formsma <okke@formsma.nl>2020-11-11 16:40:13 +0100
committerPete Johanson <peter@peterjohanson.com>2020-11-16 17:19:27 -0500
commite48a6b659c6da4afd56f2c3e3fa56d291ebf80e4 (patch)
treeb1d4d267a28feb380f7c28df76a006b3070a46fa /app/tests
parent2871dca9bfce2588e23da0905d7142ef5ff1c1a1 (diff)
fix momentary layer bug when top layer is not &trans
Key release events released keys on the wrong layer if the 'top layer' was not &trans above the &mo key. base <&mo 1> layer 1 <&kp B> This was caused by overwriting `zmk_keymap_active_behavior_layer[position]` after the &mo key was handled.
Diffstat (limited to 'app/tests')
-rw-r--r--app/tests/momentary-layer/1-normal/events.patterns (renamed from app/tests/momentary-layer/early-key-release/events.patterns)0
-rw-r--r--app/tests/momentary-layer/1-normal/keycode_events.snapshot4
-rw-r--r--app/tests/momentary-layer/1-normal/native_posix.keymap32
-rw-r--r--app/tests/momentary-layer/2-early-key-release/events.patterns (renamed from app/tests/momentary-layer/normal/events.patterns)0
-rw-r--r--app/tests/momentary-layer/2-early-key-release/keycode_events.snapshot (renamed from app/tests/momentary-layer/early-key-release/keycode_events.snapshot)0
-rw-r--r--app/tests/momentary-layer/2-early-key-release/native_posix.keymap32
-rw-r--r--app/tests/momentary-layer/3-covered/events.patterns3
-rw-r--r--app/tests/momentary-layer/3-covered/keycode_events.snapshot2
-rw-r--r--app/tests/momentary-layer/3-covered/native_posix.keymap33
-rw-r--r--app/tests/momentary-layer/4-nested/events.patterns3
-rw-r--r--app/tests/momentary-layer/4-nested/keycode_events.snapshot6
-rw-r--r--app/tests/momentary-layer/4-nested/native_posix.keymap39
-rw-r--r--app/tests/momentary-layer/5-nested-early-key-release/events.patterns3
-rw-r--r--app/tests/momentary-layer/5-nested-early-key-release/keycode_events.snapshot6
-rw-r--r--app/tests/momentary-layer/5-nested-early-key-release/native_posix.keymap39
-rw-r--r--app/tests/momentary-layer/behavior_keymap.dtsi12
-rw-r--r--app/tests/momentary-layer/early-key-release/native_posix.keymap8
-rw-r--r--app/tests/momentary-layer/normal/keycode_events.snapshot4
-rw-r--r--app/tests/momentary-layer/normal/native_posix.keymap8
19 files changed, 205 insertions, 29 deletions
diff --git a/app/tests/momentary-layer/early-key-release/events.patterns b/app/tests/momentary-layer/1-normal/events.patterns
index bd7b488..bd7b488 100644
--- a/app/tests/momentary-layer/early-key-release/events.patterns
+++ b/app/tests/momentary-layer/1-normal/events.patterns
diff --git a/app/tests/momentary-layer/1-normal/keycode_events.snapshot b/app/tests/momentary-layer/1-normal/keycode_events.snapshot
new file mode 100644
index 0000000..608ce09
--- /dev/null
+++ b/app/tests/momentary-layer/1-normal/keycode_events.snapshot
@@ -0,0 +1,4 @@
+mo_pressed: position 1 layer 1
+kp_pressed: usage_page 0x07 keycode 0x06 mods 0x00
+kp_released: usage_page 0x07 keycode 0x06 mods 0x00
+mo_released: position 1 layer 1
diff --git a/app/tests/momentary-layer/1-normal/native_posix.keymap b/app/tests/momentary-layer/1-normal/native_posix.keymap
new file mode 100644
index 0000000..2fc24d2
--- /dev/null
+++ b/app/tests/momentary-layer/1-normal/native_posix.keymap
@@ -0,0 +1,32 @@
+#include <dt-bindings/zmk/keys.h>
+#include <behaviors.dtsi>
+#include <dt-bindings/zmk/kscan-mock.h>
+#include "../behavior_keymap.dtsi"
+
+/ {
+ keymap {
+ compatible = "zmk,keymap";
+ label ="Default keymap";
+
+ default_layer {
+ bindings = <
+ &kp B &mo 1
+ &none &none>;
+ };
+
+ layer_1 {
+ bindings = <
+ &kp C &trans
+ &none &none>;
+ };
+ };
+};
+
+&kscan {
+ events = <
+ ZMK_MOCK_PRESS(0,1,10)
+ ZMK_MOCK_PRESS(0,0,10)
+ ZMK_MOCK_RELEASE(0,0,10)
+ ZMK_MOCK_RELEASE(0,1,10)
+ >;
+}; \ No newline at end of file
diff --git a/app/tests/momentary-layer/normal/events.patterns b/app/tests/momentary-layer/2-early-key-release/events.patterns
index bd7b488..bd7b488 100644
--- a/app/tests/momentary-layer/normal/events.patterns
+++ b/app/tests/momentary-layer/2-early-key-release/events.patterns
diff --git a/app/tests/momentary-layer/early-key-release/keycode_events.snapshot b/app/tests/momentary-layer/2-early-key-release/keycode_events.snapshot
index 82ebc67..82ebc67 100644
--- a/app/tests/momentary-layer/early-key-release/keycode_events.snapshot
+++ b/app/tests/momentary-layer/2-early-key-release/keycode_events.snapshot
diff --git a/app/tests/momentary-layer/2-early-key-release/native_posix.keymap b/app/tests/momentary-layer/2-early-key-release/native_posix.keymap
new file mode 100644
index 0000000..9ffa5f6
--- /dev/null
+++ b/app/tests/momentary-layer/2-early-key-release/native_posix.keymap
@@ -0,0 +1,32 @@
+#include <dt-bindings/zmk/keys.h>
+#include <behaviors.dtsi>
+#include <dt-bindings/zmk/kscan-mock.h>
+#include "../behavior_keymap.dtsi"
+
+/ {
+ keymap {
+ compatible = "zmk,keymap";
+ label ="Default keymap";
+
+ default_layer {
+ bindings = <
+ &kp B &mo 1
+ &none &none>;
+ };
+
+ layer_1 {
+ bindings = <
+ &kp C &none
+ &none &none>;
+ };
+ };
+};
+
+&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)
+ >;
+}; \ No newline at end of file
diff --git a/app/tests/momentary-layer/3-covered/events.patterns b/app/tests/momentary-layer/3-covered/events.patterns
new file mode 100644
index 0000000..08b1e98
--- /dev/null
+++ b/app/tests/momentary-layer/3-covered/events.patterns
@@ -0,0 +1,3 @@
+s/.*hid_listener_keycode/kp/p
+s/.*mo_keymap_binding/mo/p
+s/.*keymap_position_state_changed/kp_st/p \ No newline at end of file
diff --git a/app/tests/momentary-layer/3-covered/keycode_events.snapshot b/app/tests/momentary-layer/3-covered/keycode_events.snapshot
new file mode 100644
index 0000000..87d1281
--- /dev/null
+++ b/app/tests/momentary-layer/3-covered/keycode_events.snapshot
@@ -0,0 +1,2 @@
+mo_pressed: position 1 layer 1
+mo_released: position 1 layer 1
diff --git a/app/tests/momentary-layer/3-covered/native_posix.keymap b/app/tests/momentary-layer/3-covered/native_posix.keymap
new file mode 100644
index 0000000..2484d8b
--- /dev/null
+++ b/app/tests/momentary-layer/3-covered/native_posix.keymap
@@ -0,0 +1,33 @@
+#include <dt-bindings/zmk/keys.h>
+#include <behaviors.dtsi>
+#include <dt-bindings/zmk/kscan-mock.h>
+
+/*
+this test verifies that the correct key is released when a layer is enabled "on top"
+and the original key is "covered".
+*/
+/ {
+ keymap {
+ compatible = "zmk,keymap";
+ label ="Default keymap";
+
+ default_layer {
+ bindings = <
+ &trans &mo 1
+ &trans &trans>;
+ };
+
+ layer_1 {
+ bindings = <
+ &trans &kp A
+ &trans &trans>;
+ };
+ };
+};
+
+&kscan {
+ events = <
+ ZMK_MOCK_PRESS(0,1,10)
+ ZMK_MOCK_RELEASE(0,1,10)
+ >;
+};
diff --git a/app/tests/momentary-layer/4-nested/events.patterns b/app/tests/momentary-layer/4-nested/events.patterns
new file mode 100644
index 0000000..08b1e98
--- /dev/null
+++ b/app/tests/momentary-layer/4-nested/events.patterns
@@ -0,0 +1,3 @@
+s/.*hid_listener_keycode/kp/p
+s/.*mo_keymap_binding/mo/p
+s/.*keymap_position_state_changed/kp_st/p \ No newline at end of file
diff --git a/app/tests/momentary-layer/4-nested/keycode_events.snapshot b/app/tests/momentary-layer/4-nested/keycode_events.snapshot
new file mode 100644
index 0000000..f03e4d5
--- /dev/null
+++ b/app/tests/momentary-layer/4-nested/keycode_events.snapshot
@@ -0,0 +1,6 @@
+mo_pressed: position 1 layer 1
+mo_pressed: position 0 layer 2
+kp_pressed: usage_page 0x07 keycode 0x05 mods 0x00
+kp_released: usage_page 0x07 keycode 0x05 mods 0x00
+mo_released: position 0 layer 2
+mo_released: position 1 layer 1
diff --git a/app/tests/momentary-layer/4-nested/native_posix.keymap b/app/tests/momentary-layer/4-nested/native_posix.keymap
new file mode 100644
index 0000000..0eb77d2
--- /dev/null
+++ b/app/tests/momentary-layer/4-nested/native_posix.keymap
@@ -0,0 +1,39 @@
+#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 = <
+ &none &mo 1
+ &none &none>;
+ };
+
+ layer_1 {
+ bindings = <
+ &mo 2 &none
+ &none &none>;
+ };
+
+ layer_2 {
+ bindings = <
+ &none &none
+ &kp B &none>;
+ };
+ };
+};
+
+&kscan {
+ events = <
+ ZMK_MOCK_PRESS(0,1,10)
+ ZMK_MOCK_PRESS(0,0,10)
+ ZMK_MOCK_PRESS(1,0,10)
+ ZMK_MOCK_RELEASE(1,0,10)
+ ZMK_MOCK_RELEASE(0,0,10)
+ ZMK_MOCK_RELEASE(0,1,10)
+ >;
+}; \ No newline at end of file
diff --git a/app/tests/momentary-layer/5-nested-early-key-release/events.patterns b/app/tests/momentary-layer/5-nested-early-key-release/events.patterns
new file mode 100644
index 0000000..08b1e98
--- /dev/null
+++ b/app/tests/momentary-layer/5-nested-early-key-release/events.patterns
@@ -0,0 +1,3 @@
+s/.*hid_listener_keycode/kp/p
+s/.*mo_keymap_binding/mo/p
+s/.*keymap_position_state_changed/kp_st/p \ No newline at end of file
diff --git a/app/tests/momentary-layer/5-nested-early-key-release/keycode_events.snapshot b/app/tests/momentary-layer/5-nested-early-key-release/keycode_events.snapshot
new file mode 100644
index 0000000..15be601
--- /dev/null
+++ b/app/tests/momentary-layer/5-nested-early-key-release/keycode_events.snapshot
@@ -0,0 +1,6 @@
+mo_pressed: position 1 layer 1
+mo_pressed: position 0 layer 2
+kp_pressed: usage_page 0x07 keycode 0x05 mods 0x00
+mo_released: position 1 layer 1
+mo_released: position 0 layer 2
+kp_released: usage_page 0x07 keycode 0x05 mods 0x00
diff --git a/app/tests/momentary-layer/5-nested-early-key-release/native_posix.keymap b/app/tests/momentary-layer/5-nested-early-key-release/native_posix.keymap
new file mode 100644
index 0000000..a67035b
--- /dev/null
+++ b/app/tests/momentary-layer/5-nested-early-key-release/native_posix.keymap
@@ -0,0 +1,39 @@
+#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 = <
+ &none &mo 1
+ &none &none>;
+ };
+
+ layer_1 {
+ bindings = <
+ &mo 2 &none
+ &none &none>;
+ };
+
+ layer_2 {
+ bindings = <
+ &none &none
+ &kp B &none>;
+ };
+ };
+};
+
+&kscan {
+ events = <
+ ZMK_MOCK_PRESS(0,1,10)
+ ZMK_MOCK_PRESS(0,0,10)
+ ZMK_MOCK_PRESS(1,0,10)
+ ZMK_MOCK_RELEASE(0,1,10)
+ ZMK_MOCK_RELEASE(0,0,10)
+ ZMK_MOCK_RELEASE(1,0,10)
+ >;
+}; \ No newline at end of file
diff --git a/app/tests/momentary-layer/behavior_keymap.dtsi b/app/tests/momentary-layer/behavior_keymap.dtsi
index 6cc3140..a5b6c12 100644
--- a/app/tests/momentary-layer/behavior_keymap.dtsi
+++ b/app/tests/momentary-layer/behavior_keymap.dtsi
@@ -10,19 +10,13 @@
default_layer {
bindings = <
&kp B &mo 1
- &kp D &kp G>;
+ &trans &trans>;
};
- lower_layer {
+ layer_1 {
bindings = <
&kp C_NEXT &trans
- &kp L &kp J>;
- };
-
- raise_layer {
- bindings = <
- &kp W &kp U
- &kp X &kp M>;
+ &trans &trans>;
};
};
};
diff --git a/app/tests/momentary-layer/early-key-release/native_posix.keymap b/app/tests/momentary-layer/early-key-release/native_posix.keymap
deleted file mode 100644
index e7628c0..0000000
--- a/app/tests/momentary-layer/early-key-release/native_posix.keymap
+++ /dev/null
@@ -1,8 +0,0 @@
-#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)>;
-}; \ No newline at end of file
diff --git a/app/tests/momentary-layer/normal/keycode_events.snapshot b/app/tests/momentary-layer/normal/keycode_events.snapshot
deleted file mode 100644
index 247128f..0000000
--- a/app/tests/momentary-layer/normal/keycode_events.snapshot
+++ /dev/null
@@ -1,4 +0,0 @@
-mo_pressed: position 1 layer 1
-kp_pressed: usage_page 0x0c keycode 0xb5 mods 0x00
-kp_released: usage_page 0x0c keycode 0xb5 mods 0x00
-mo_released: position 1 layer 1
diff --git a/app/tests/momentary-layer/normal/native_posix.keymap b/app/tests/momentary-layer/normal/native_posix.keymap
deleted file mode 100644
index 7f73690..0000000
--- a/app/tests/momentary-layer/normal/native_posix.keymap
+++ /dev/null
@@ -1,8 +0,0 @@
-#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,1,10) ZMK_MOCK_PRESS(0,0,10) ZMK_MOCK_RELEASE(0,0,10) ZMK_MOCK_RELEASE(0,1,10)>;
-}; \ No newline at end of file