summaryrefslogtreecommitdiff
path: root/app/tests
diff options
context:
space:
mode:
authorPeter Johanson <peter@peterjohanson.com>2021-11-29 04:26:22 +0000
committerPete Johanson <peter@peterjohanson.com>2022-01-30 22:47:34 -0500
commit70bb7c93349344e0990f12282abfcd8d00ba7208 (patch)
treeeeb47ee39ec4a887ef6d1edf809b88709e6269bb /app/tests
parentac3c3170bd70f5186544495cb5ced7bfbf3f6764 (diff)
feat(behaviors): `&key_repeat` behavior + tests.
* Add new `&key_repeat` behavior that captures and re-sends the most recently triggered keycode. Closes: #853
Diffstat (limited to 'app/tests')
-rw-r--r--app/tests/key-repeat/behavior_keymap.dtsi17
-rw-r--r--app/tests/key-repeat/ignore-other-usage-page-events/events.patterns2
-rw-r--r--app/tests/key-repeat/ignore-other-usage-page-events/keycode_events.snapshot12
-rw-r--r--app/tests/key-repeat/ignore-other-usage-page-events/native_posix.keymap15
-rw-r--r--app/tests/key-repeat/press-and-release-after-key-usage/events.patterns2
-rw-r--r--app/tests/key-repeat/press-and-release-after-key-usage/keycode_events.snapshot8
-rw-r--r--app/tests/key-repeat/press-and-release-after-key-usage/native_posix.keymap13
-rw-r--r--app/tests/key-repeat/send-nothing-if-no-keys-pressed-yet/events.patterns2
-rw-r--r--app/tests/key-repeat/send-nothing-if-no-keys-pressed-yet/keycode_events.snapshot0
-rw-r--r--app/tests/key-repeat/send-nothing-if-no-keys-pressed-yet/native_posix.keymap11
10 files changed, 82 insertions, 0 deletions
diff --git a/app/tests/key-repeat/behavior_keymap.dtsi b/app/tests/key-repeat/behavior_keymap.dtsi
new file mode 100644
index 0000000..93b6d06
--- /dev/null
+++ b/app/tests/key-repeat/behavior_keymap.dtsi
@@ -0,0 +1,17 @@
+#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 = <
+ &key_repeat &kp A
+ &kp B &kp C_VOL_UP
+ >;
+ };
+ };
+};
diff --git a/app/tests/key-repeat/ignore-other-usage-page-events/events.patterns b/app/tests/key-repeat/ignore-other-usage-page-events/events.patterns
new file mode 100644
index 0000000..7947192
--- /dev/null
+++ b/app/tests/key-repeat/ignore-other-usage-page-events/events.patterns
@@ -0,0 +1,2 @@
+s/.*hid_listener_keycode_//p
+s/.*hid_implicit_modifiers_//p \ No newline at end of file
diff --git a/app/tests/key-repeat/ignore-other-usage-page-events/keycode_events.snapshot b/app/tests/key-repeat/ignore-other-usage-page-events/keycode_events.snapshot
new file mode 100644
index 0000000..c06d94a
--- /dev/null
+++ b/app/tests/key-repeat/ignore-other-usage-page-events/keycode_events.snapshot
@@ -0,0 +1,12 @@
+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
+pressed: usage_page 0x0c keycode 0xe9 implicit_mods 0x00 explicit_mods 0x00
+press: Modifiers set to 0x00
+released: usage_page 0x0c keycode 0xe9 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/key-repeat/ignore-other-usage-page-events/native_posix.keymap b/app/tests/key-repeat/ignore-other-usage-page-events/native_posix.keymap
new file mode 100644
index 0000000..b042e8e
--- /dev/null
+++ b/app/tests/key-repeat/ignore-other-usage-page-events/native_posix.keymap
@@ -0,0 +1,15 @@
+#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_RELEASE(0,1,10)
+ ZMK_MOCK_PRESS(1,1,10)
+ ZMK_MOCK_RELEASE(1,1,10)
+ ZMK_MOCK_PRESS(0,0,10)
+ ZMK_MOCK_RELEASE(0,0,10)
+ >;
+}; \ No newline at end of file
diff --git a/app/tests/key-repeat/press-and-release-after-key-usage/events.patterns b/app/tests/key-repeat/press-and-release-after-key-usage/events.patterns
new file mode 100644
index 0000000..7947192
--- /dev/null
+++ b/app/tests/key-repeat/press-and-release-after-key-usage/events.patterns
@@ -0,0 +1,2 @@
+s/.*hid_listener_keycode_//p
+s/.*hid_implicit_modifiers_//p \ No newline at end of file
diff --git a/app/tests/key-repeat/press-and-release-after-key-usage/keycode_events.snapshot b/app/tests/key-repeat/press-and-release-after-key-usage/keycode_events.snapshot
new file mode 100644
index 0000000..d568d37
--- /dev/null
+++ b/app/tests/key-repeat/press-and-release-after-key-usage/keycode_events.snapshot
@@ -0,0 +1,8 @@
+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
+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/key-repeat/press-and-release-after-key-usage/native_posix.keymap b/app/tests/key-repeat/press-and-release-after-key-usage/native_posix.keymap
new file mode 100644
index 0000000..98c8f6f
--- /dev/null
+++ b/app/tests/key-repeat/press-and-release-after-key-usage/native_posix.keymap
@@ -0,0 +1,13 @@
+#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_RELEASE(0,1,10)
+ ZMK_MOCK_PRESS(0,0,10)
+ ZMK_MOCK_RELEASE(0,0,10)
+ >;
+}; \ No newline at end of file
diff --git a/app/tests/key-repeat/send-nothing-if-no-keys-pressed-yet/events.patterns b/app/tests/key-repeat/send-nothing-if-no-keys-pressed-yet/events.patterns
new file mode 100644
index 0000000..7947192
--- /dev/null
+++ b/app/tests/key-repeat/send-nothing-if-no-keys-pressed-yet/events.patterns
@@ -0,0 +1,2 @@
+s/.*hid_listener_keycode_//p
+s/.*hid_implicit_modifiers_//p \ No newline at end of file
diff --git a/app/tests/key-repeat/send-nothing-if-no-keys-pressed-yet/keycode_events.snapshot b/app/tests/key-repeat/send-nothing-if-no-keys-pressed-yet/keycode_events.snapshot
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/app/tests/key-repeat/send-nothing-if-no-keys-pressed-yet/keycode_events.snapshot
diff --git a/app/tests/key-repeat/send-nothing-if-no-keys-pressed-yet/native_posix.keymap b/app/tests/key-repeat/send-nothing-if-no-keys-pressed-yet/native_posix.keymap
new file mode 100644
index 0000000..9ff6446
--- /dev/null
+++ b/app/tests/key-repeat/send-nothing-if-no-keys-pressed-yet/native_posix.keymap
@@ -0,0 +1,11 @@
+#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_RELEASE(0,0,10)
+ >;
+}; \ No newline at end of file