Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pointing): Add pre-defined scroll scaler and mouse scroll tests #2759

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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)
>;
};
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 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
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
Loading