Skip to content

Commit

Permalink
feat(pointing): Add pre-defined scroll scaler and mouse scroll tests (#…
Browse files Browse the repository at this point in the history
…2759)

feat(pointing): Add pre-defined scroll scaler

tests(pointing): Add mouse scroll tests
  • Loading branch information
caksoylar authored Feb 4, 2025
1 parent 8e065d5 commit 0f7c112
Show file tree
Hide file tree
Showing 23 changed files with 299 additions and 17 deletions.
10 changes: 9 additions & 1 deletion app/dts/input/processors/scaler.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,12 @@
codes = <INPUT_REL_X INPUT_REL_Y>;
track-remainders;
};
};

/omit-if-no-ref/ zip_scroll_scaler: zip_scroll_scaler {
compatible = "zmk,input-processor-scaler";
#input-processor-cells = <2>;
type = <INPUT_EV_REL>;
codes = <INPUT_REL_WHEEL INPUT_REL_HWHEEL>;
track-remainders;
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
s/.*hid_mouse_//p
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
scroll_set: Mouse scroll set to -1/1
scroll_set: Mouse scroll set to 0/0
movement_set: Mouse movement set to 0/0
scroll_set: Mouse scroll set to -1/1
scroll_set: Mouse scroll set to 0/0
movement_set: Mouse movement set to 0/0
scroll_set: Mouse scroll set to -1/1
scroll_set: Mouse scroll set to 0/0
movement_set: Mouse movement set to 0/0
scroll_set: Mouse scroll set to -1/1
scroll_set: Mouse scroll set to 0/0
movement_set: Mouse movement set to 0/0
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CONFIG_GPIO=n
CONFIG_ZMK_BLE=n
CONFIG_LOG=y
CONFIG_LOG_BACKEND_SHOW_COLOR=n
CONFIG_ZMK_LOG_LEVEL_DBG=y
CONFIG_ZMK_POINTING=y
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <behaviors.dtsi>
#include <behaviors/mouse_move.dtsi>
#include <dt-bindings/zmk/keys.h>
#include <dt-bindings/zmk/kscan_mock.h>
#include <dt-bindings/zmk/pointing.h>

/ {
keymap {
compatible = "zmk,keymap";

default_layer {
bindings = <
&msc SCRL_LEFT &msc SCRL_UP
&none &none
>;
};
};
};


&kscan {
events = <
ZMK_MOCK_PRESS(0,0,10)
ZMK_MOCK_PRESS(0,1,500)
ZMK_MOCK_RELEASE(0,0,10)
ZMK_MOCK_RELEASE(0,1,10)
>;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
s/.*hid_mouse_//p
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
scroll_set: Mouse scroll set to 1/0
scroll_set: Mouse scroll set to 0/0
movement_set: Mouse movement set to 0/0
scroll_set: Mouse scroll set to 1/0
scroll_set: Mouse scroll set to 0/0
movement_set: Mouse movement set to 0/0
scroll_set: Mouse scroll set to 1/0
scroll_set: Mouse scroll set to 0/0
movement_set: Mouse movement set to 0/0
scroll_set: Mouse scroll set to 1/0
scroll_set: Mouse scroll set to 0/0
movement_set: Mouse movement set to 0/0
scroll_set: Mouse scroll set to -1/0
scroll_set: Mouse scroll set to 0/0
movement_set: Mouse movement set to 0/0
scroll_set: Mouse scroll set to -1/0
scroll_set: Mouse scroll set to 0/0
movement_set: Mouse movement set to 0/0
scroll_set: Mouse scroll set to -1/0
scroll_set: Mouse scroll set to 0/0
movement_set: Mouse movement set to 0/0
scroll_set: Mouse scroll set to -1/0
scroll_set: Mouse scroll set to 0/0
movement_set: Mouse movement set to 0/0
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CONFIG_GPIO=n
CONFIG_ZMK_BLE=n
CONFIG_LOG=y
CONFIG_LOG_BACKEND_SHOW_COLOR=n
CONFIG_ZMK_LOG_LEVEL_DBG=y
CONFIG_ZMK_POINTING=y
28 changes: 28 additions & 0 deletions app/tests/pointing/mouse-scroll/move_hwheel/native_posix_64.keymap
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <behaviors.dtsi>
#include <behaviors/mouse_move.dtsi>
#include <dt-bindings/zmk/keys.h>
#include <dt-bindings/zmk/kscan_mock.h>
#include <dt-bindings/zmk/pointing.h>

/ {
keymap {
compatible = "zmk,keymap";

default_layer {
bindings = <
&msc SCRL_RIGHT &msc SCRL_LEFT
&none &none
>;
};
};
};


&kscan {
events = <
ZMK_MOCK_PRESS(0,0,500)
ZMK_MOCK_RELEASE(0,0,10)
ZMK_MOCK_PRESS(0,1,500)
ZMK_MOCK_RELEASE(0,1,10)
>;
};
1 change: 1 addition & 0 deletions app/tests/pointing/mouse-scroll/move_wheel/events.patterns
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
s/.*hid_mouse_//p
24 changes: 24 additions & 0 deletions app/tests/pointing/mouse-scroll/move_wheel/keycode_events.snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
scroll_set: Mouse scroll set to 0/1
scroll_set: Mouse scroll set to 0/0
movement_set: Mouse movement set to 0/0
scroll_set: Mouse scroll set to 0/1
scroll_set: Mouse scroll set to 0/0
movement_set: Mouse movement set to 0/0
scroll_set: Mouse scroll set to 0/1
scroll_set: Mouse scroll set to 0/0
movement_set: Mouse movement set to 0/0
scroll_set: Mouse scroll set to 0/1
scroll_set: Mouse scroll set to 0/0
movement_set: Mouse movement set to 0/0
scroll_set: Mouse scroll set to 0/-1
scroll_set: Mouse scroll set to 0/0
movement_set: Mouse movement set to 0/0
scroll_set: Mouse scroll set to 0/-1
scroll_set: Mouse scroll set to 0/0
movement_set: Mouse movement set to 0/0
scroll_set: Mouse scroll set to 0/-1
scroll_set: Mouse scroll set to 0/0
movement_set: Mouse movement set to 0/0
scroll_set: Mouse scroll set to 0/-1
scroll_set: Mouse scroll set to 0/0
movement_set: Mouse movement set to 0/0
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CONFIG_GPIO=n
CONFIG_ZMK_BLE=n
CONFIG_LOG=y
CONFIG_LOG_BACKEND_SHOW_COLOR=n
CONFIG_ZMK_LOG_LEVEL_DBG=y
CONFIG_ZMK_POINTING=y
28 changes: 28 additions & 0 deletions app/tests/pointing/mouse-scroll/move_wheel/native_posix_64.keymap
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <behaviors.dtsi>
#include <behaviors/mouse_move.dtsi>
#include <dt-bindings/zmk/keys.h>
#include <dt-bindings/zmk/kscan_mock.h>
#include <dt-bindings/zmk/pointing.h>

/ {
keymap {
compatible = "zmk,keymap";

default_layer {
bindings = <
&msc SCRL_UP &msc SCRL_DOWN
&none &none
>;
};
};
};


&kscan {
events = <
ZMK_MOCK_PRESS(0,0,500)
ZMK_MOCK_RELEASE(0,0,10)
ZMK_MOCK_PRESS(0,1,500)
ZMK_MOCK_RELEASE(0,1,10)
>;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
s/.*hid_mouse_//p
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
scroll_set: Mouse scroll set to -3/3
scroll_set: Mouse scroll set to 0/0
movement_set: Mouse movement set to 0/0
scroll_set: Mouse scroll set to -3/3
scroll_set: Mouse scroll set to 0/0
movement_set: Mouse movement set to 0/0
scroll_set: Mouse scroll set to -3/3
scroll_set: Mouse scroll set to 0/0
movement_set: Mouse movement set to 0/0
scroll_set: Mouse scroll set to -3/3
scroll_set: Mouse scroll set to 0/0
movement_set: Mouse movement set to 0/0
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CONFIG_GPIO=n
CONFIG_ZMK_BLE=n
CONFIG_LOG=y
CONFIG_LOG_BACKEND_SHOW_COLOR=n
CONFIG_ZMK_LOG_LEVEL_DBG=y
CONFIG_ZMK_POINTING=y
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

#include <dt-bindings/zmk/input_transform.h>
#include <zephyr/dt-bindings/input/input-event-codes.h>

#include <behaviors.dtsi>
#include <input/processors.dtsi>
#include <dt-bindings/zmk/keys.h>
#include <dt-bindings/zmk/kscan_mock.h>
#include <dt-bindings/zmk/pointing.h>

&msc_input_listener {
input-processors = <&zip_scroll_scaler 6 2>;
};

/ {
keymap {
compatible = "zmk,keymap";

default_layer {
bindings = <
&msc SCRL_LEFT &msc SCRL_UP
&none &none
>;
};
};
};


&kscan {
events = <
ZMK_MOCK_PRESS(0,0,10)
ZMK_MOCK_PRESS(0,1,500)
ZMK_MOCK_RELEASE(0,0,10)
ZMK_MOCK_RELEASE(0,1,10)
>;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
s/.*hid_mouse_//p
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
scroll_set: Mouse scroll set to 1/-1
scroll_set: Mouse scroll set to 0/0
movement_set: Mouse movement set to 0/0
scroll_set: Mouse scroll set to 1/-1
scroll_set: Mouse scroll set to 0/0
movement_set: Mouse movement set to 0/0
scroll_set: Mouse scroll set to 1/-1
scroll_set: Mouse scroll set to 0/0
movement_set: Mouse movement set to 0/0
scroll_set: Mouse scroll set to 1/-1
scroll_set: Mouse scroll set to 0/0
movement_set: Mouse movement set to 0/0
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CONFIG_GPIO=n
CONFIG_ZMK_BLE=n
CONFIG_LOG=y
CONFIG_LOG_BACKEND_SHOW_COLOR=n
CONFIG_ZMK_LOG_LEVEL_DBG=y
CONFIG_ZMK_POINTING=y
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <input/processors.dtsi>
#include <behaviors.dtsi>
#include <dt-bindings/zmk/keys.h>
#include <dt-bindings/zmk/kscan_mock.h>
#include <dt-bindings/zmk/pointing.h>
#include <dt-bindings/zmk/input_transform.h>

&msc_input_listener {
input-processors = <&zip_scroll_transform (INPUT_TRANSFORM_X_INVERT | INPUT_TRANSFORM_Y_INVERT)>;
};

/ {
keymap {
compatible = "zmk,keymap";

default_layer {
bindings = <
&msc SCRL_LEFT &msc SCRL_UP
&none &none
>;
};
};
};


&kscan {
events = <
ZMK_MOCK_PRESS(0,0,10)
ZMK_MOCK_PRESS(0,1,500)
ZMK_MOCK_RELEASE(0,0,10)
ZMK_MOCK_RELEASE(0,1,10)
>;
};
23 changes: 12 additions & 11 deletions docs/docs/keymaps/input-processors/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,18 @@ A set of predefined input processors is available by adding the following at the

Once included, you can use the following:

| Binding | Processor | Description |
| -------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------------- |
| `&zip_xy_scaler` | [XY Scaler](scaler.md#pre-defined-instances) | Scale a the X/Y input events using a multiplier and divisor |
| `&zip_x_scaler` | [X Scaler](scaler.md#pre-defined-instances) | Scale a the X input events using a multiplier and divisor |
| `&zip_y_scaler` | [Y Scaler](scaler.md#pre-defined-instances) | Scale a the Y input events using a multiplier and divisor |
| `&zip_xy_transform` | [XY Transform](transformer.md#pre-defined-instances) | Transform X/Y values, e.g. inverting or swapping |
| `&zip_scroll_transform` | [Scroll Transform](transformer.md#pre-defined-instances) | Transform wheel/horizontal wheel values, e.g. inverting or swapping |
| `&zip_xy_to_scroll_mapper` | [XY To Scroll Mapper](code-mapper.md#pre-defined-instances) | Map X/Y values to scroll wheel/horizontal wheel events |
| `&zip_xy_swap_mapper` | [XY Swap Mapper](code-mapper.md#pre-defined-instances) | Swap X/Y values |
| `&zip_temp_layer` | [Temporary Layer](temp-layer.md#pre-defined-instances) | Temporarily enable a layer during pointer use |
| `&zip_button_behaviors` | [Mouse Button Behaviors](behaviors.md#pre-defined-instances) | Trigger behaviors when certain mouse buttons are pressed |
| Binding | Processor | Description |
| -------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------------------ |
| `&zip_xy_scaler` | [XY Scaler](scaler.md#pre-defined-instances) | Scale the X/Y input events using a multiplier and divisor |
| `&zip_x_scaler` | [X Scaler](scaler.md#pre-defined-instances) | Scale the X input events using a multiplier and divisor |
| `&zip_y_scaler` | [Y Scaler](scaler.md#pre-defined-instances) | Scale the Y input events using a multiplier and divisor |
| `&zip_scroll_scaler` | [Scroll Scaler](scaler.md#pre-defined-instances) | Scale wheel/horizontal wheel input events using a multiplier and divisor |
| `&zip_xy_transform` | [XY Transform](transformer.md#pre-defined-instances) | Transform X/Y values, e.g. inverting or swapping |
| `&zip_scroll_transform` | [Scroll Transform](transformer.md#pre-defined-instances) | Transform wheel/horizontal wheel values, e.g. inverting or swapping |
| `&zip_xy_to_scroll_mapper` | [XY To Scroll Mapper](code-mapper.md#pre-defined-instances) | Map X/Y values to scroll wheel/horizontal wheel events |
| `&zip_xy_swap_mapper` | [XY Swap Mapper](code-mapper.md#pre-defined-instances) | Swap X/Y values |
| `&zip_temp_layer` | [Temporary Layer](temp-layer.md#pre-defined-instances) | Temporarily enable a layer during pointer use |
| `&zip_button_behaviors` | [Mouse Button Behaviors](behaviors.md#pre-defined-instances) | Trigger behaviors when certain mouse buttons are pressed |

### User-Defined Processors

Expand Down
11 changes: 6 additions & 5 deletions docs/docs/keymaps/input-processors/scaler.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ A maximum value of `16` should be used for the multiplier and divisor parameters

Three pre-defined instance of the scaler input processor are available:

| Reference | Description |
| ---------------- | --------------------------------------------- |
| `&zip_xy_scaler` | Scale X- and Y-axis values by the same amount |
| `&zip_x_scaler` | Scale X-axis values |
| `&zip_y_scaler` | Scale Y-axis values |
| Reference | Description |
| -------------------- | --------------------------------------------- |
| `&zip_xy_scaler` | Scale X- and Y-axis values by the same amount |
| `&zip_x_scaler` | Scale X-axis values |
| `&zip_y_scaler` | Scale Y-axis values |
| `&zip_scroll_scaler` | Scale wheel and horizontal wheel values |

## User-Defined Instances

Expand Down

0 comments on commit 0f7c112

Please sign in to comment.