aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/tests
diff options
context:
space:
mode:
authorPeter Johanson <[email protected]>2022-01-05 04:03:50 +0000
committerPete Johanson <[email protected]>2022-06-07 23:41:52 -0400
commit4af3d272fcbfa363673981fc19fc15338b2432ae (patch)
treeecaa3456ae09921d644da8afddad0d6b26cd4634 /app/tests
parent11ac8c4782a01c27268854e4289a0059b23e4a96 (diff)
downloadzmk-4af3d272fcbfa363673981fc19fc15338b2432ae.tar.gz
zmk-4af3d272fcbfa363673981fc19fc15338b2432ae.zip
fix(keymaps): Handle matching `then-layer`s.
* Proporly handle multiple conditonal layers w/ the same target `then-layer` values. * Move handling to work callback, to avoid re-entrance for cascading layers enabling other layers.
Diffstat (limited to 'app/tests')
-rw-r--r--app/tests/conditional-layer/same-layer-reached-both-ways/events.patterns3
-rw-r--r--app/tests/conditional-layer/same-layer-reached-both-ways/keycode_events.snapshot20
-rw-r--r--app/tests/conditional-layer/same-layer-reached-both-ways/native_posix_64.keymap73
-rw-r--r--app/tests/conditional-layer/same-layer-reached-differently/events.patterns3
-rw-r--r--app/tests/conditional-layer/same-layer-reached-differently/keycode_events.snapshot16
-rw-r--r--app/tests/conditional-layer/same-layer-reached-differently/native_posix_64.keymap69
-rw-r--r--app/tests/conditional-layer/tri-layer-lt/events.patterns3
-rw-r--r--app/tests/conditional-layer/tri-layer-lt/keycode_events.snapshot8
-rw-r--r--app/tests/conditional-layer/tri-layer-lt/native_posix_64.keymap56
9 files changed, 251 insertions, 0 deletions
diff --git a/app/tests/conditional-layer/same-layer-reached-both-ways/events.patterns b/app/tests/conditional-layer/same-layer-reached-both-ways/events.patterns
new file mode 100644
index 0000000000..14ded7959f
--- /dev/null
+++ b/app/tests/conditional-layer/same-layer-reached-both-ways/events.patterns
@@ -0,0 +1,3 @@
+s/.*hid_listener_keycode/kp/p
+s/.*mo_keymap_binding/mo/p
+s/.*conditional_layer/cl/p
diff --git a/app/tests/conditional-layer/same-layer-reached-both-ways/keycode_events.snapshot b/app/tests/conditional-layer/same-layer-reached-both-ways/keycode_events.snapshot
new file mode 100644
index 0000000000..49fc0f873a
--- /dev/null
+++ b/app/tests/conditional-layer/same-layer-reached-both-ways/keycode_events.snapshot
@@ -0,0 +1,20 @@
+mo_pressed: position 2 layer 1
+mo_pressed: position 3 layer 2
+cl_activate: layer 4
+mo_pressed: position 1 layer 3
+kp_pressed: usage_page 0x07 keycode 0x08 implicit_mods 0x00 explicit_mods 0x00
+kp_released: usage_page 0x07 keycode 0x08 implicit_mods 0x00 explicit_mods 0x00
+mo_released: position 1 layer 3
+mo_released: position 3 layer 2
+cl_deactivate: layer 4
+mo_released: position 2 layer 1
+mo_pressed: position 1 layer 3
+mo_pressed: position 2 layer 1
+cl_activate: layer 4
+mo_pressed: position 3 layer 2
+kp_pressed: usage_page 0x07 keycode 0x08 implicit_mods 0x00 explicit_mods 0x00
+kp_released: usage_page 0x07 keycode 0x08 implicit_mods 0x00 explicit_mods 0x00
+mo_released: position 3 layer 2
+mo_released: position 2 layer 1
+cl_deactivate: layer 4
+mo_released: position 1 layer 3
diff --git a/app/tests/conditional-layer/same-layer-reached-both-ways/native_posix_64.keymap b/app/tests/conditional-layer/same-layer-reached-both-ways/native_posix_64.keymap
new file mode 100644
index 0000000000..c94dcef219
--- /dev/null
+++ b/app/tests/conditional-layer/same-layer-reached-both-ways/native_posix_64.keymap
@@ -0,0 +1,73 @@
+#include <behaviors.dtsi>
+#include <dt-bindings/zmk/keys.h>
+#include <dt-bindings/zmk/kscan_mock.h>
+
+/ {
+ conditional_layers {
+ compatible = "zmk,conditional-layers";
+ conditional_layer_1 {
+ if-layers = <1 2>;
+ then-layer = <4>;
+ };
+ conditional_layer_2 {
+ if-layers = <1 3>;
+ then-layer = <4>;
+ };
+ };
+
+ keymap {
+ compatible = "zmk,keymap";
+ default_layer {
+ bindings = <
+ &kp A &mo 3
+ &mo 1 &mo 2
+ >;
+ };
+ layer_1 {
+ bindings = <
+ &kp B &trans
+ &trans &trans
+ >;
+ };
+ layer_2 {
+ bindings = <
+ &kp C &trans
+ &trans &trans
+ >;
+ };
+ layer_3 {
+ bindings = <
+ &kp D &trans
+ &trans &trans
+ >;
+ };
+ layer_4 {
+ bindings = <
+ &kp E &trans
+ &trans &trans
+ >;
+ };
+ };
+};
+
+&kscan {
+ events = <
+ ZMK_MOCK_PRESS(1,0,10)
+ ZMK_MOCK_PRESS(1,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_RELEASE(1,1,10)
+ ZMK_MOCK_RELEASE(1,0,10)
+
+ ZMK_MOCK_PRESS(0,1,10)
+ ZMK_MOCK_PRESS(1,0,10)
+ ZMK_MOCK_PRESS(1,1,10)
+ ZMK_MOCK_PRESS(0,0,10)
+ ZMK_MOCK_RELEASE(0,0,10)
+ ZMK_MOCK_RELEASE(1,1,10)
+ ZMK_MOCK_RELEASE(1,0,10)
+ ZMK_MOCK_RELEASE(0,1,10)
+ >;
+};
diff --git a/app/tests/conditional-layer/same-layer-reached-differently/events.patterns b/app/tests/conditional-layer/same-layer-reached-differently/events.patterns
new file mode 100644
index 0000000000..14ded7959f
--- /dev/null
+++ b/app/tests/conditional-layer/same-layer-reached-differently/events.patterns
@@ -0,0 +1,3 @@
+s/.*hid_listener_keycode/kp/p
+s/.*mo_keymap_binding/mo/p
+s/.*conditional_layer/cl/p
diff --git a/app/tests/conditional-layer/same-layer-reached-differently/keycode_events.snapshot b/app/tests/conditional-layer/same-layer-reached-differently/keycode_events.snapshot
new file mode 100644
index 0000000000..86371d2fb4
--- /dev/null
+++ b/app/tests/conditional-layer/same-layer-reached-differently/keycode_events.snapshot
@@ -0,0 +1,16 @@
+mo_pressed: position 2 layer 1
+mo_pressed: position 3 layer 2
+cl_activate: layer 4
+kp_pressed: usage_page 0x07 keycode 0x08 implicit_mods 0x00 explicit_mods 0x00
+kp_released: usage_page 0x07 keycode 0x08 implicit_mods 0x00 explicit_mods 0x00
+mo_released: position 3 layer 2
+cl_deactivate: layer 4
+mo_released: position 2 layer 1
+mo_pressed: position 1 layer 3
+mo_pressed: position 2 layer 1
+cl_activate: layer 4
+kp_pressed: usage_page 0x07 keycode 0x08 implicit_mods 0x00 explicit_mods 0x00
+kp_released: usage_page 0x07 keycode 0x08 implicit_mods 0x00 explicit_mods 0x00
+mo_released: position 2 layer 1
+cl_deactivate: layer 4
+mo_released: position 1 layer 3
diff --git a/app/tests/conditional-layer/same-layer-reached-differently/native_posix_64.keymap b/app/tests/conditional-layer/same-layer-reached-differently/native_posix_64.keymap
new file mode 100644
index 0000000000..fd127d0529
--- /dev/null
+++ b/app/tests/conditional-layer/same-layer-reached-differently/native_posix_64.keymap
@@ -0,0 +1,69 @@
+#include <behaviors.dtsi>
+#include <dt-bindings/zmk/keys.h>
+#include <dt-bindings/zmk/kscan_mock.h>
+
+/ {
+ conditional_layers {
+ compatible = "zmk,conditional-layers";
+ conditional_layer_1 {
+ if-layers = <1 2>;
+ then-layer = <4>;
+ };
+ conditional_layer_2 {
+ if-layers = <1 3>;
+ then-layer = <4>;
+ };
+ };
+
+ keymap {
+ compatible = "zmk,keymap";
+ default_layer {
+ bindings = <
+ &kp A &mo 3
+ &mo 1 &mo 2
+ >;
+ };
+ layer_1 {
+ bindings = <
+ &kp B &trans
+ &trans &trans
+ >;
+ };
+ layer_2 {
+ bindings = <
+ &kp C &trans
+ &trans &trans
+ >;
+ };
+ layer_3 {
+ bindings = <
+ &kp D &trans
+ &trans &trans
+ >;
+ };
+ layer_4 {
+ bindings = <
+ &kp E &trans
+ &trans &trans
+ >;
+ };
+ };
+};
+
+&kscan {
+ events = <
+ ZMK_MOCK_PRESS(1,0,10)
+ ZMK_MOCK_PRESS(1,1,10)
+ ZMK_MOCK_PRESS(0,0,10)
+ ZMK_MOCK_RELEASE(0,0,10)
+ ZMK_MOCK_RELEASE(1,1,10)
+ ZMK_MOCK_RELEASE(1,0,10)
+
+ ZMK_MOCK_PRESS(0,1,10)
+ ZMK_MOCK_PRESS(1,0,10)
+ ZMK_MOCK_PRESS(0,0,10)
+ ZMK_MOCK_RELEASE(0,0,10)
+ ZMK_MOCK_RELEASE(1,0,10)
+ ZMK_MOCK_RELEASE(0,1,10)
+ >;
+};
diff --git a/app/tests/conditional-layer/tri-layer-lt/events.patterns b/app/tests/conditional-layer/tri-layer-lt/events.patterns
new file mode 100644
index 0000000000..6a0e3bdc34
--- /dev/null
+++ b/app/tests/conditional-layer/tri-layer-lt/events.patterns
@@ -0,0 +1,3 @@
+s/.*hid_listener_keycode/kp/p
+s/.*mo_keymap_binding/mo/p
+s/.*conditional_layer/cl/p \ No newline at end of file
diff --git a/app/tests/conditional-layer/tri-layer-lt/keycode_events.snapshot b/app/tests/conditional-layer/tri-layer-lt/keycode_events.snapshot
new file mode 100644
index 0000000000..cb452df545
--- /dev/null
+++ b/app/tests/conditional-layer/tri-layer-lt/keycode_events.snapshot
@@ -0,0 +1,8 @@
+mo_pressed: position 2 layer 1
+mo_pressed: position 3 layer 2
+cl_activate: layer 3
+kp_pressed: usage_page 0x07 keycode 0x0A implicit_mods 0x00 explicit_mods 0x00
+kp_released: usage_page 0x07 keycode 0x0A implicit_mods 0x00 explicit_mods 0x00
+mo_released: position 3 layer 2
+cl_deactivate: layer 3
+mo_released: position 2 layer 1
diff --git a/app/tests/conditional-layer/tri-layer-lt/native_posix_64.keymap b/app/tests/conditional-layer/tri-layer-lt/native_posix_64.keymap
new file mode 100644
index 0000000000..7a091609a9
--- /dev/null
+++ b/app/tests/conditional-layer/tri-layer-lt/native_posix_64.keymap
@@ -0,0 +1,56 @@
+#include <behaviors.dtsi>
+#include <dt-bindings/zmk/keys.h>
+#include <dt-bindings/zmk/kscan_mock.h>
+
+&lt {
+ flavor = "balanced";
+};
+
+/ {
+ conditional_layers {
+ compatible = "zmk,conditional-layers";
+ tri_layer {
+ if-layers = <1 2>;
+ then-layer = <3>;
+ };
+ };
+
+ keymap {
+ compatible = "zmk,keymap";
+ default_layer {
+ bindings = <
+ &kp A &kp B
+ &lt 1 I &lt 2 J
+ >;
+ };
+ layer_1 {
+ bindings = <
+ &kp C &kp D
+ &trans &trans
+ >;
+ };
+ layer_2 {
+ bindings = <
+ &kp E &kp F
+ &trans &trans
+ >;
+ };
+ layer_3 {
+ bindings = <
+ &kp G &kp H
+ &trans &trans
+ >;
+ };
+ };
+};
+
+&kscan {
+ events = <
+ ZMK_MOCK_PRESS(1,0,10)
+ ZMK_MOCK_PRESS(1,1,10)
+ ZMK_MOCK_PRESS(0,0,10)
+ ZMK_MOCK_RELEASE(0,0,10)
+ ZMK_MOCK_RELEASE(1,1,10)
+ ZMK_MOCK_RELEASE(1,0,10)
+ >;
+};