aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/tests/keytoggle
diff options
context:
space:
mode:
authorCaleb Goates <[email protected]>2022-05-04 22:30:02 -0600
committerPete Johanson <[email protected]>2022-06-03 00:04:41 -0400
commit6dc436cb23ac361fd375725d60f638db3b1709da (patch)
treee89a3d5de4c3a683e42690d57a89fdf6af0d3956 /app/tests/keytoggle
parent0977be622a6ae2c61231f89b888c3e77f89bd477 (diff)
downloadzmk-6dc436cb23ac361fd375725d60f638db3b1709da.tar.gz
zmk-6dc436cb23ac361fd375725d60f638db3b1709da.zip
test(behavior): Add alt-tab test and modded alpha test for toggle key
Uses multiple toggles of modifier keys overlapping each other.
Diffstat (limited to 'app/tests/keytoggle')
-rw-r--r--app/tests/keytoggle/kt-alt-tab/events.patterns1
-rw-r--r--app/tests/keytoggle/kt-alt-tab/keycode_events.snapshot28
-rw-r--r--app/tests/keytoggle/kt-alt-tab/native_posix_64.keymap48
-rw-r--r--app/tests/keytoggle/kt-modded-alpha/events.patterns1
-rw-r--r--app/tests/keytoggle/kt-modded-alpha/keycode_events.snapshot12
-rw-r--r--app/tests/keytoggle/kt-modded-alpha/native_posix_64.keymap38
-rw-r--r--app/tests/keytoggle/kt-press-release-nkro/events.patterns1
-rw-r--r--app/tests/keytoggle/kt-press-release-nkro/keycode_events.snapshot2
-rw-r--r--app/tests/keytoggle/kt-press-release-nkro/native_posix_64.conf7
-rw-r--r--app/tests/keytoggle/kt-press-release-nkro/native_posix_64.keymap10
10 files changed, 148 insertions, 0 deletions
diff --git a/app/tests/keytoggle/kt-alt-tab/events.patterns b/app/tests/keytoggle/kt-alt-tab/events.patterns
new file mode 100644
index 0000000000..69eeca5afd
--- /dev/null
+++ b/app/tests/keytoggle/kt-alt-tab/events.patterns
@@ -0,0 +1 @@
+s/.*\(hid_listener_keycode_\|hid_implicit_modifiers_\)//p
diff --git a/app/tests/keytoggle/kt-alt-tab/keycode_events.snapshot b/app/tests/keytoggle/kt-alt-tab/keycode_events.snapshot
new file mode 100644
index 0000000000..3318db4236
--- /dev/null
+++ b/app/tests/keytoggle/kt-alt-tab/keycode_events.snapshot
@@ -0,0 +1,28 @@
+pressed: usage_page 0x07 keycode 0xE2 implicit_mods 0x00 explicit_mods 0x00
+press: Modifiers set to 0x04
+pressed: usage_page 0x07 keycode 0x2B implicit_mods 0x00 explicit_mods 0x00
+press: Modifiers set to 0x04
+released: usage_page 0x07 keycode 0x2B implicit_mods 0x00 explicit_mods 0x00
+release: Modifiers set to 0x04
+pressed: usage_page 0x07 keycode 0x2B implicit_mods 0x00 explicit_mods 0x00
+press: Modifiers set to 0x04
+released: usage_page 0x07 keycode 0x2B implicit_mods 0x00 explicit_mods 0x00
+release: Modifiers set to 0x04
+pressed: usage_page 0x07 keycode 0xE1 implicit_mods 0x00 explicit_mods 0x00
+press: Modifiers set to 0x06
+pressed: usage_page 0x07 keycode 0x2B implicit_mods 0x00 explicit_mods 0x00
+press: Modifiers set to 0x06
+released: usage_page 0x07 keycode 0x2B implicit_mods 0x00 explicit_mods 0x00
+release: Modifiers set to 0x06
+released: usage_page 0x07 keycode 0xE2 implicit_mods 0x00 explicit_mods 0x00
+release: Modifiers set to 0x02
+pressed: usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00
+press: Modifiers set to 0x02
+released: usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00
+release: Modifiers set to 0x02
+released: usage_page 0x07 keycode 0xE1 implicit_mods 0x00 explicit_mods 0x00
+release: Modifiers set to 0x00
+pressed: usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00
+press: Modifiers set to 0x00
+released: usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00
+release: Modifiers set to 0x00
diff --git a/app/tests/keytoggle/kt-alt-tab/native_posix_64.keymap b/app/tests/keytoggle/kt-alt-tab/native_posix_64.keymap
new file mode 100644
index 0000000000..f437989325
--- /dev/null
+++ b/app/tests/keytoggle/kt-alt-tab/native_posix_64.keymap
@@ -0,0 +1,48 @@
+#include <dt-bindings/zmk/keys.h>
+#include <behaviors.dtsi>
+#include <dt-bindings/zmk/kscan_mock.h>
+
+&kscan {
+ events = <
+ /* Toggle LALT on */
+ ZMK_MOCK_PRESS(0,0,10)
+ ZMK_MOCK_RELEASE(0,0,10)
+ /* Tap TAB twice */
+ ZMK_MOCK_PRESS(0,1,10)
+ ZMK_MOCK_RELEASE(0,1,10)
+ ZMK_MOCK_PRESS(0,1,10)
+ ZMK_MOCK_RELEASE(0,1,10)
+ /* Toggle LSHFT on */
+ ZMK_MOCK_PRESS(1,0,10)
+ ZMK_MOCK_RELEASE(1,0,10)
+ /* Tap TAB once */
+ ZMK_MOCK_PRESS(0,1,10)
+ ZMK_MOCK_RELEASE(0,1,10)
+ /* Toggle LALT off */
+ ZMK_MOCK_PRESS(0,0,10)
+ ZMK_MOCK_RELEASE(0,0,10)
+ /* Tap A */
+ ZMK_MOCK_PRESS(1,1,10)
+ ZMK_MOCK_RELEASE(1,1,10)
+ /* Toggle LSHFT off */
+ ZMK_MOCK_PRESS(1,0,10)
+ ZMK_MOCK_RELEASE(1,0,10)
+ /* Tap A */
+ ZMK_MOCK_PRESS(1,1,10)
+ ZMK_MOCK_RELEASE(1,1,10)
+ >;
+};
+
+/ {
+ keymap {
+ compatible = "zmk,keymap";
+ label ="Default keymap";
+
+ default_layer {
+ bindings = <
+ &kt LALT &kp TAB
+ &kt LSHFT &kp A
+ >;
+ };
+ };
+}; \ No newline at end of file
diff --git a/app/tests/keytoggle/kt-modded-alpha/events.patterns b/app/tests/keytoggle/kt-modded-alpha/events.patterns
new file mode 100644
index 0000000000..69eeca5afd
--- /dev/null
+++ b/app/tests/keytoggle/kt-modded-alpha/events.patterns
@@ -0,0 +1 @@
+s/.*\(hid_listener_keycode_\|hid_implicit_modifiers_\)//p
diff --git a/app/tests/keytoggle/kt-modded-alpha/keycode_events.snapshot b/app/tests/keytoggle/kt-modded-alpha/keycode_events.snapshot
new file mode 100644
index 0000000000..6fd41cb216
--- /dev/null
+++ b/app/tests/keytoggle/kt-modded-alpha/keycode_events.snapshot
@@ -0,0 +1,12 @@
+pressed: usage_page 0x07 keycode 0x04 implicit_mods 0x02 explicit_mods 0x00
+press: Modifiers set to 0x02
+released: usage_page 0x07 keycode 0x04 implicit_mods 0x02 explicit_mods 0x00
+release: Modifiers set to 0x00
+pressed: usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00
+press: Modifiers set to 0x00
+released: usage_page 0x07 keycode 0x04 implicit_mods 0x02 explicit_mods 0x00
+release: Modifiers set to 0x00
+pressed: usage_page 0x07 keycode 0x04 implicit_mods 0x02 explicit_mods 0x00
+press: Modifiers set to 0x02
+released: usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00
+release: Modifiers set to 0x00
diff --git a/app/tests/keytoggle/kt-modded-alpha/native_posix_64.keymap b/app/tests/keytoggle/kt-modded-alpha/native_posix_64.keymap
new file mode 100644
index 0000000000..3b14e416bb
--- /dev/null
+++ b/app/tests/keytoggle/kt-modded-alpha/native_posix_64.keymap
@@ -0,0 +1,38 @@
+#include <dt-bindings/zmk/keys.h>
+#include <behaviors.dtsi>
+#include <dt-bindings/zmk/kscan_mock.h>
+
+&kscan {
+ events = <
+ /* Toggle LS(A) on */
+ ZMK_MOCK_PRESS(0,0,10)
+ ZMK_MOCK_RELEASE(0,0,10)
+ /* Toggle LS(A) off */
+ ZMK_MOCK_PRESS(0,0,10)
+ ZMK_MOCK_RELEASE(0,0,10)
+ /* Press A */
+ ZMK_MOCK_PRESS(1,0,10)
+ /* Toggle LS(A) on */
+ ZMK_MOCK_PRESS(0,0,10)
+ ZMK_MOCK_RELEASE(0,0,10)
+ /* Toggle LS(A) off */
+ ZMK_MOCK_PRESS(0,0,10)
+ ZMK_MOCK_RELEASE(0,0,10)
+ /* Release A */
+ ZMK_MOCK_RELEASE(1,0,10)
+ >;
+};
+
+/ {
+ keymap {
+ compatible = "zmk,keymap";
+ label ="Default keymap";
+
+ default_layer {
+ bindings = <
+ &kt LS(A) &trans
+ &kp A &trans
+ >;
+ };
+ };
+}; \ No newline at end of file
diff --git a/app/tests/keytoggle/kt-press-release-nkro/events.patterns b/app/tests/keytoggle/kt-press-release-nkro/events.patterns
new file mode 100644
index 0000000000..833100f6ac
--- /dev/null
+++ b/app/tests/keytoggle/kt-press-release-nkro/events.patterns
@@ -0,0 +1 @@
+s/.*hid_listener_keycode_//p \ No newline at end of file
diff --git a/app/tests/keytoggle/kt-press-release-nkro/keycode_events.snapshot b/app/tests/keytoggle/kt-press-release-nkro/keycode_events.snapshot
new file mode 100644
index 0000000000..259501ba3d
--- /dev/null
+++ b/app/tests/keytoggle/kt-press-release-nkro/keycode_events.snapshot
@@ -0,0 +1,2 @@
+pressed: usage_page 0x07 keycode 0x05 implicit_mods 0x00 explicit_mods 0x00
+released: usage_page 0x07 keycode 0x05 implicit_mods 0x00 explicit_mods 0x00
diff --git a/app/tests/keytoggle/kt-press-release-nkro/native_posix_64.conf b/app/tests/keytoggle/kt-press-release-nkro/native_posix_64.conf
new file mode 100644
index 0000000000..01abac5ee1
--- /dev/null
+++ b/app/tests/keytoggle/kt-press-release-nkro/native_posix_64.conf
@@ -0,0 +1,7 @@
+CONFIG_GPIO=n
+CONFIG_LOG=y
+CONFIG_LOG_BACKEND_SHOW_COLOR=n
+CONFIG_ZMK_LOG_LEVEL_DBG=y
+CONFIG_DEBUG=y
+CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000
+CONFIG_ZMK_HID_REPORT_TYPE_NKRO=y \ No newline at end of file
diff --git a/app/tests/keytoggle/kt-press-release-nkro/native_posix_64.keymap b/app/tests/keytoggle/kt-press-release-nkro/native_posix_64.keymap
new file mode 100644
index 0000000000..644caa2629
--- /dev/null
+++ b/app/tests/keytoggle/kt-press-release-nkro/native_posix_64.keymap
@@ -0,0 +1,10 @@
+#include "../behavior_keymap.dtsi"
+
+&kscan {
+ events = <
+ ZMK_MOCK_PRESS(0,0,10)
+ ZMK_MOCK_RELEASE(0,0,10)
+ ZMK_MOCK_PRESS(0,0,10)
+ ZMK_MOCK_RELEASE(0,0,10)
+ >;
+}; \ No newline at end of file