Testing: split input test (#2762)

test(pointing): Add mock input device.

New mock input device to generate input events for tests.

test(split): Add peripheral input test.

Test event propagation from peripheral input devices.

fix(split): Proper scoping for local within switch.

Minor compile fix.

chore: Fix up test snapshots after logging changes.

Adjust the test snapshots after logging changes to the central.

fix(kscan): Don't fire last mock event twice.

Fix a bug where the kscan mock would raise the last mock event
twice before halting processing.
This commit is contained in:
Pete Johanson
2025-01-13 13:15:16 -07:00
committed by GitHub
parent 022603ec16
commit 8dddb1d9d7
25 changed files with 332 additions and 21 deletions

View File

@@ -13,6 +13,9 @@ profile 0 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 23
profile 0 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 28
profile 0 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 30
profile 0 <dbg> ble_central: discover_func: [SUBSCRIBED]
profile 0 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 32
profile 0 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 34
profile 0 <dbg> ble_central: discover_func: [CONSUMER SUBSCRIBED]
profile 0 <dbg> ble_central: notify_func: payload
profile 0 00 00 04 00 00 00 00 00 |........
profile 0 <dbg> ble_central: notify_func: payload

View File

@@ -13,6 +13,9 @@ profile 0 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 23
profile 0 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 28
profile 0 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 30
profile 0 <dbg> ble_central: discover_func: [SUBSCRIBED]
profile 0 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 32
profile 0 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 34
profile 0 <dbg> ble_central: discover_func: [CONSUMER SUBSCRIBED]
profile 0 <dbg> ble_central: notify_func: payload
profile 0 00 00 05 00 00 00 00 00 |........
profile 0 <dbg> ble_central: notify_func: payload

View File

@@ -13,6 +13,9 @@ profile 0 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 23
profile 0 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 28
profile 0 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 30
profile 0 <dbg> ble_central: discover_func: [SUBSCRIBED]
profile 0 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 32
profile 0 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 34
profile 0 <dbg> ble_central: discover_func: [CONSUMER SUBSCRIBED]
profile 0 <dbg> ble_central: notify_func: payload
profile 0 00 00 04 00 00 00 00 00 |........
profile 0 <dbg> ble_central: notify_func: payload

View File

@@ -0,0 +1 @@
s/^d_02: @[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9][0-9][0-9][0-9] .{19}/profile 0 /p

View File

@@ -0,0 +1,2 @@
CONFIG_ZMK_SPLIT=y
CONFIG_ZMK_POINTING=y

View File

@@ -0,0 +1,27 @@
#include <behaviors.dtsi>
#include <dt-bindings/zmk/bt.h>
#include <dt-bindings/zmk/keys.h>
#include "shared.dtsi"
&kscan {
/delete-property/ exit-after;
events = <>;
};
&split_listener {
status = "okay";
};
/ {
keymap {
compatible = "zmk,keymap";
default_layer {
bindings = <
&kp A &kp B
&bt BT_SEL 0 &bt BT_CLR>;
sensor-bindings = <&inc_dec_kp A B>;
};
};
};

View File

@@ -0,0 +1,31 @@
#include <dt-bindings/zmk/kscan_mock.h>
#include <zephyr/dt-bindings/input/input-event-codes.h>
#include "shared.dtsi"
&kscan {
events = <>;
/delete-property/ exit-after;
};
/ {
mock_input: mock_input {
compatible = "zmk,input-mock";
status = "okay";
event-startup-delay = <4000>;
event-period = <2000>;
events
= <INPUT_EV_REL INPUT_REL_X 100 0>
, <INPUT_EV_REL INPUT_REL_Y 100 1>
, <INPUT_EV_REL INPUT_REL_X 40 0>
, <INPUT_EV_REL INPUT_REL_Y 50 1>
;
exit-after;
};
};
&split_input {
device = <&mock_input>;
};

View File

@@ -0,0 +1,16 @@
/ {
splits {
#address-cells = <1>;
#size-cells = <0>;
split_input: split_input@0 {
compatible = "zmk,input-split";
reg = <0>;
};
};
split_listener: split_listener {
compatible = "zmk,input-listener";
status = "disabled";
device = <&split_input>;
};
};

View File

@@ -0,0 +1,2 @@
./ble_test_central.exe -d=2 -subscribe_to_pointer_report
./tests_ble_split_peripheral-input_peripheral.exe -d=3

View File

@@ -0,0 +1,25 @@
profile 0 <wrn> bt_id: No static addresses stored in controller
profile 0 <dbg> ble_central: main: [Bluetooth initialized]
profile 0 <dbg> ble_central: start_scan: [Scanning successfully started]
profile 0 <dbg> ble_central: device_found: [DEVICE]: FD:9E:B2:48:47:39 (random), AD evt type 0, AD data len 15, RSSI -56
profile 0 <dbg> ble_central: eir_found: [AD]: 25 data_len 2
profile 0 <dbg> ble_central: eir_found: [AD]: 1 data_len 1
profile 0 <dbg> ble_central: eir_found: [AD]: 2 data_len 4
profile 0 <dbg> ble_central: connected: [Connected]: FD:9E:B2:48:47:39 (random)
profile 0 <dbg> ble_central: connected: [Setting the security for the connection]
profile 0 <dbg> ble_central: pairing_complete: Pairing complete
profile 0 <dbg> ble_central: discover_conn: [Discovery started for conn]
profile 0 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 23
profile 0 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 28
profile 0 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 30
profile 0 <dbg> ble_central: discover_func: [SUBSCRIBED]
profile 0 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 32
profile 0 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 34
profile 0 <dbg> ble_central: discover_func: [CONSUMER SUBSCRIBED]
profile 0 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 36
profile 0 <dbg> ble_central: discover_func: [ATTRIBUTE] handle 38
profile 0 <dbg> ble_central: discover_func: [MOUSE SUBSCRIBED]
profile 0 <dbg> ble_central: notify_func: payload
profile 0 00 64 00 64 00 00 00 00 00 |.d.d.... .
profile 0 <dbg> ble_central: notify_func: payload
profile 0 00 28 00 32 00 00 00 00 00 |.(.2.... .