Pete Johanson
4 years ago
committed by
GitHub
47 changed files with 338 additions and 79 deletions
@ -1,9 +1,8 @@
@@ -1,9 +1,8 @@
|
||||
CONFIG_KSCAN=n |
||||
CONFIG_ZMK_KSCAN_MOCK_DRIVER=y |
||||
CONFIG_ZMK_KSCAN_COMPOSITE_DRIVER=y |
||||
CONFIG_ZMK_KSCAN_GPIO_DRIVER=n |
||||
CONFIG_GPIO=n |
||||
CONFIG_ZMK_BLE=n |
||||
CONFIG_LOG=y |
||||
CONFIG_KSCAN_LOG_LEVEL_DBG=y |
||||
CONFIG_LOG_BACKEND_SHOW_COLOR=n |
||||
CONFIG_ZMK_LOG_LEVEL_DBG=y |
||||
|
@ -1,79 +1,18 @@
@@ -1,79 +1,18 @@
|
||||
#include <dt-bindings/zmk/keys.h> |
||||
#include <behaviors.dtsi> |
||||
#include <zmk/kscan-mock.h> |
||||
#include <dt-bindings/zmk/keys.h> |
||||
#include <dt-bindings/zmk/kscan-mock.h> |
||||
|
||||
/ { |
||||
chosen { |
||||
zmk,kscan = &kscan0; |
||||
zmk,keymap = &keymap0; |
||||
}; |
||||
|
||||
kscan0: kscan_0 { |
||||
compatible = "zmk,kscan-composite"; |
||||
label = "KSCAN_COMP"; |
||||
rows = <2>; |
||||
columns = <4>; |
||||
|
||||
left: left { |
||||
kscan = <&left_hand>; |
||||
}; |
||||
|
||||
right: right { |
||||
kscan = <&right_hand>; |
||||
column-offset = <2>; |
||||
}; |
||||
zmk,kscan = &kscan; |
||||
}; |
||||
|
||||
left_hand: kscan_1 { |
||||
kscan: kscan { |
||||
compatible = "zmk,kscan-mock"; |
||||
label = "KSCAN_LEFT"; |
||||
label = "KSCAN_MOCK"; |
||||
|
||||
rows = <2>; |
||||
columns = <2>; |
||||
events = <ZMK_MOCK_PRESS(0,1,300) ZMK_MOCK_PRESS(0,0,300) ZMK_MOCK_RELEASE(0,0,300) ZMK_MOCK_RELEASE(0,1,300)>; |
||||
// events = <ZMK_MOCK_PRESS(0,0,800) ZMK_MOCK_RELEASE(0,0,800) ZMK_MOCK_PRESS(0,1,800) ZMK_MOCK_RELEASE(0,1,800)>; |
||||
}; |
||||
|
||||
right_hand: kscan_2 { |
||||
compatible = "zmk,kscan-mock"; |
||||
label = "KSCAN_RIGHT"; |
||||
|
||||
rows = <2>; |
||||
columns = <2>; |
||||
events = <ZMK_MOCK_PRESS(1,1,800) ZMK_MOCK_RELEASE(1,1,100) ZMK_MOCK_PRESS(0,1,800) ZMK_MOCK_RELEASE(0,1,100)>; |
||||
}; |
||||
|
||||
keymap0: keymap { |
||||
compatible = "zmk,keymap"; |
||||
label ="Default keymap"; |
||||
layers = <&default &lower &raise>; |
||||
}; |
||||
|
||||
layers { |
||||
compatible = "zmk,layers"; |
||||
|
||||
default: layer_0 { |
||||
label = "DEFAULT"; |
||||
|
||||
bindings = < |
||||
&kp B &mo 1 &kp C &kp E |
||||
&kp D &kp G &kp F &kp Q>; |
||||
}; |
||||
|
||||
lower: layer_1 { |
||||
label = "LOWER"; |
||||
|
||||
bindings = < |
||||
&cp M_NEXT &trans &kp O &kp Q |
||||
&kp L &kp J &kp P &kp K>; |
||||
}; |
||||
|
||||
raise: layer_2 { |
||||
label = "RAISE"; |
||||
|
||||
bindings = < |
||||
&kp W &kp U &kp I &kp N |
||||
&kp X &kp M &kp C &kp B>; |
||||
}; |
||||
exit-after; |
||||
}; |
||||
}; |
||||
|
@ -0,0 +1,40 @@
@@ -0,0 +1,40 @@
|
||||
#!/bin/sh |
||||
# |
||||
# Copyright (c) 2020 Peter Johanson; Cody McGinnis |
||||
# |
||||
# SPDX-License-Identifier: MIT |
||||
# |
||||
|
||||
if [ -z "$1" ]; then |
||||
echo "Usage: ./run-test.sh <path to testcase>" |
||||
exit 1 |
||||
elif [ "$1" = "all" ]; then |
||||
echo "" > ./build/tests/pass-fail.log |
||||
find tests -name native_posix.keymap -exec dirname \{\} \; | xargs -l -P 4 ./run-test.sh |
||||
err=$? |
||||
sort -k2 ./build/tests/pass-fail.log |
||||
exit $err |
||||
fi |
||||
|
||||
testcase="$1" |
||||
echo "Running $testcase:" |
||||
|
||||
west build -d build/$testcase -b native_posix -- -DZMK_CONFIG=$testcase > /dev/null 2>&1 |
||||
if [ $? -gt 0 ]; then |
||||
echo "FAIL: $testcase did not build" >> ./build/tests/pass-fail.log |
||||
else |
||||
./build/$testcase/zephyr/zmk.exe | sed -e "s/.*> //" | tee build/$testcase/keycode_events_full.log | sed -n -f $testcase/events.patterns > build/$testcase/keycode_events.log |
||||
diff -au $testcase/keycode_events.snapshot build/$testcase/keycode_events.log |
||||
if [ $? -gt 0 ]; then |
||||
if [ -f $testcase/pending ]; then |
||||
echo "PEND: $testcase" >> ./build/tests/pass-fail.log |
||||
exit 0 |
||||
else |
||||
echo "FAIL: $testcase" >> ./build/tests/pass-fail.log |
||||
exit 1 |
||||
fi |
||||
else |
||||
echo "PASS: $testcase" >> ./build/tests/pass-fail.log |
||||
exit 0 |
||||
fi |
||||
fi |
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
#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 = < |
||||
&kp B &mo 1 |
||||
&kp D &kp G>; |
||||
}; |
||||
|
||||
lower_layer { |
||||
bindings = < |
||||
&cp M_NEXT &trans |
||||
&kp L &kp J>; |
||||
}; |
||||
|
||||
raise_layer { |
||||
bindings = < |
||||
&kp W &kp U |
||||
&kp X &kp M>; |
||||
}; |
||||
}; |
||||
}; |
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
s/.*hid_listener_keycode_//p |
@ -0,0 +1,2 @@
@@ -0,0 +1,2 @@
|
||||
pressed: usage_page 0x0c keycode 0xb5 |
||||
released: usage_page 0x0c keycode 0xb5 |
@ -0,0 +1,5 @@
@@ -0,0 +1,5 @@
|
||||
#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)>; |
||||
}; |
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
s/.*hid_listener_keycode_//p |
@ -0,0 +1,2 @@
@@ -0,0 +1,2 @@
|
||||
pressed: usage_page 0x0c keycode 0xb5 |
||||
released: usage_page 0x0c keycode 0xb5 |
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
#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)>; |
||||
}; |
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
#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 = < |
||||
&kp B &mo 1 |
||||
&kp D &kp G>; |
||||
}; |
||||
|
||||
lower_layer { |
||||
bindings = < |
||||
&cp M_NEXT &trans |
||||
&kp L &kp J>; |
||||
}; |
||||
|
||||
raise_layer { |
||||
bindings = < |
||||
&kp W &kp U |
||||
&kp X &kp M>; |
||||
}; |
||||
}; |
||||
}; |
@ -0,0 +1,2 @@
@@ -0,0 +1,2 @@
|
||||
s/.*hid_listener_keycode/kp/p |
||||
s/.*mo_keymap_binding/mo/p |
@ -0,0 +1,4 @@
@@ -0,0 +1,4 @@
|
||||
kp_pressed: usage_page 0x07 keycode 0x05 |
||||
mo_pressed: position 1 layer 1 |
||||
kp_released: usage_page 0x07 keycode 0x05 |
||||
mo_released: position 1 layer 1 |
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
#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)>; |
||||
}; |
@ -0,0 +1,2 @@
@@ -0,0 +1,2 @@
|
||||
s/.*hid_listener_keycode/kp/p |
||||
s/.*mo_keymap_binding/mo/p |
@ -0,0 +1,4 @@
@@ -0,0 +1,4 @@
|
||||
mo_pressed: position 1 layer 1 |
||||
kp_pressed: usage_page 0x0c keycode 0xb5 |
||||
kp_released: usage_page 0x0c keycode 0xb5 |
||||
mo_released: position 1 layer 1 |
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
#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)>; |
||||
}; |
@ -0,0 +1,22 @@
@@ -0,0 +1,22 @@
|
||||
#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 |
||||
&kp A &none>; |
||||
}; |
||||
|
||||
lower_layer { |
||||
bindings = < |
||||
&none &trans |
||||
&none &kp A>; |
||||
}; |
||||
}; |
||||
}; |
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
s/.*hid_listener_keycode/kp/p |
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
#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(1,0,10) ZMK_MOCK_RELEASE(1,0,10) ZMK_MOCK_RELEASE(0,1,10)>; |
||||
}; |
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
s/.*hid_listener_keycode/kp/p |
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
#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)>; |
||||
}; |
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
#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 = < |
||||
&kp B &tog 1 |
||||
&kp D &kp G>; |
||||
}; |
||||
|
||||
lower_layer { |
||||
bindings = < |
||||
&cp M_NEXT &trans |
||||
&kp L &kp J>; |
||||
}; |
||||
|
||||
raise_layer { |
||||
bindings = < |
||||
&kp W &kp U |
||||
&kp X &kp M>; |
||||
}; |
||||
}; |
||||
}; |
@ -0,0 +1,2 @@
@@ -0,0 +1,2 @@
|
||||
s/.*hid_listener_keycode/kp/p |
||||
s/.*tog_keymap_binding/tog/p |
@ -0,0 +1,6 @@
@@ -0,0 +1,6 @@
|
||||
kp_pressed: usage_page 0x07 keycode 0x05 |
||||
tog_pressed: position 1 layer 1 |
||||
kp_released: usage_page 0x07 keycode 0x05 |
||||
tog_released: position 1 layer 1 |
||||
kp_pressed: usage_page 0x0c keycode 0xb5 |
||||
kp_released: usage_page 0x0c keycode 0xb5 |
@ -0,0 +1,9 @@
@@ -0,0 +1,9 @@
|
||||
#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) |
||||
ZMK_MOCK_PRESS(0,0,10) ZMK_MOCK_RELEASE(0,0,10)>; |
||||
}; |
@ -0,0 +1,2 @@
@@ -0,0 +1,2 @@
|
||||
s/.*hid_listener_keycode/kp/p |
||||
s/.*tog_keymap_binding/tog/p |
@ -0,0 +1,4 @@
@@ -0,0 +1,4 @@
|
||||
tog_pressed: position 1 layer 1 |
||||
tog_released: position 1 layer 1 |
||||
kp_pressed: usage_page 0x0c keycode 0xb5 |
||||
kp_released: usage_page 0x0c keycode 0xb5 |
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
#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)>; |
||||
}; |
@ -0,0 +1,22 @@
@@ -0,0 +1,22 @@
|
||||
#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 = < |
||||
&trans &mo 1 |
||||
&kp A &none>; |
||||
}; |
||||
|
||||
lower_layer { |
||||
bindings = < |
||||
&trans &trans |
||||
&trans &kp A>; |
||||
}; |
||||
}; |
||||
}; |
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
s/.*hid_listener_keycode/kp/p |
@ -0,0 +1,2 @@
@@ -0,0 +1,2 @@
|
||||
kp_pressed: usage_page 0x07 keycode 0x04 |
||||
kp_released: usage_page 0x07 keycode 0x04 |
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
#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(1,0,10) ZMK_MOCK_RELEASE(1,0,10) ZMK_MOCK_RELEASE(0,1,10)>; |
||||
}; |
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
s/.*hid_listener_keycode/kp/p |
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
#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)>; |
||||
}; |
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
--- |
||||
id: dev-tests |
||||
title: Tests |
||||
sidebar_label: Tests |
||||
--- |
||||
|
||||
Running tests requires [native posix support](./dev-posix-board). Any folder under `/app/tests` |
||||
containing `native_posix.keymap` will be selected when running `./run-test.sh all`. |
||||
|
||||
## Creating a New Test Set |
||||
1. Copy the test set that most closely resembles the tests you will be creating. |
||||
2. Rename the newly created test set to the behavior you're testing e.g, toggle-layer |
||||
3. Modify `behavior_keymap.dtsi` to create a keymap using the behavior and related behaviors |
||||
4. Modify `test_case/native_posix.keymap` for a simulated use case |
||||
5. Modify `test_case/events.patterns` to collect relevant logs to the test |
||||
- See: [sed manual](https://www.gnu.org/software/sed/manual/sed.html) and |
||||
[tutorial](https://www.digitalocean.com/community/tutorials/the-basics-of-using-the-sed-stream-editor-to-manipulate-text-in-linux) |
||||
6. Modify `test_case/keycode_events.snapshot` for to include the expected output |
||||
7. Rename the `test_case` folder to describe the test. |
||||
8. Repeat steps 4 to 7 for every test case |
Loading…
Reference in new issue