forked from kofal.net/zmk
feat(mouse): Add mouse move and scroll support (#2477)
* feat(mouse): Add mouse move and scroll support
* Use Zephyr input subsystem for all pointers.
* Input processors for modifying events, e.g. scaling, swapping
codes, temporary (mouse) layers, etc.
* Mouse move/scroll behaviors.
* Infrastructure in place for physical pointer input devices.
* feat: Add input split support.
* docs: Add initial pointer docs.
---------
Co-authored-by: Cem Aksoylar <caksoylar@users.noreply.github.com>
Co-authored-by: Alexander Krikun <krikun98@gmail.com>
Co-authored-by: Robert U <urob@users.noreply.github.com>
Co-authored-by: Shawn Meier <ftc@users.noreply.github.com>
Co-authored-by: Chris Andreae <chris@andreae.gen.nz>
Co-authored-by: Anant Thazhemadam <47104651+thazhemadam@users.noreply.github.com>
Co-authored-by: Erik Tollerud <erik.tollerud@gmail.com>
Co-authored-by: Nicolas Munnich <98408764+Nick-Munnich@users.noreply.github.com>
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2024 The ZMK Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <behaviors/key_press.dtsi>
|
||||
#include <behaviors/key_toggle.dtsi>
|
||||
#include <behaviors/transparent.dtsi>
|
||||
@@ -19,6 +25,6 @@
|
||||
#include <behaviors/key_repeat.dtsi>
|
||||
#include <behaviors/backlight.dtsi>
|
||||
#include <behaviors/macros.dtsi>
|
||||
#include <behaviors/mouse_key_press.dtsi>
|
||||
#include <behaviors/soft_off.dtsi>
|
||||
#include <behaviors/studio_unlock.dtsi>
|
||||
#include <behaviors/mouse_keys.dtsi>
|
||||
|
||||
@@ -16,4 +16,9 @@
|
||||
#binding-cells = <1>;
|
||||
};
|
||||
};
|
||||
|
||||
mkp_input_listener: mkp_input_listener {
|
||||
compatible = "zmk,input-listener";
|
||||
device = <&mkp>;
|
||||
};
|
||||
};
|
||||
|
||||
9
app/dts/behaviors/mouse_keys.dtsi
Normal file
9
app/dts/behaviors/mouse_keys.dtsi
Normal file
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2024 The ZMK Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include "mouse_key_press.dtsi"
|
||||
#include "mouse_move.dtsi"
|
||||
#include "mouse_scroll.dtsi"
|
||||
25
app/dts/behaviors/mouse_move.dtsi
Normal file
25
app/dts/behaviors/mouse_move.dtsi
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) 2024 The ZMK Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <zephyr/dt-bindings/input/input-event-codes.h>
|
||||
|
||||
/ {
|
||||
behaviors {
|
||||
/omit-if-no-ref/ mmv: mouse_move {
|
||||
compatible = "zmk,behavior-input-two-axis";
|
||||
#binding-cells = <1>;
|
||||
x-input-code = <INPUT_REL_X>;
|
||||
y-input-code = <INPUT_REL_Y>;
|
||||
time-to-max-speed-ms = <300>;
|
||||
acceleration-exponent = <1>;
|
||||
};
|
||||
};
|
||||
|
||||
mmv_input_listener: mmv_input_listener {
|
||||
compatible = "zmk,input-listener";
|
||||
device = <&mmv>;
|
||||
};
|
||||
};
|
||||
26
app/dts/behaviors/mouse_scroll.dtsi
Normal file
26
app/dts/behaviors/mouse_scroll.dtsi
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
/*
|
||||
* Copyright (c) 2024 The ZMK Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <zephyr/dt-bindings/input/input-event-codes.h>
|
||||
|
||||
/ {
|
||||
behaviors {
|
||||
/omit-if-no-ref/ msc: mouse_scroll {
|
||||
compatible = "zmk,behavior-input-two-axis";
|
||||
#binding-cells = <1>;
|
||||
x-input-code = <INPUT_REL_HWHEEL>;
|
||||
y-input-code = <INPUT_REL_WHEEL>;
|
||||
time-to-max-speed-ms = <300>;
|
||||
acceleration-exponent = <0>;
|
||||
};
|
||||
};
|
||||
|
||||
msc_input_listener: msc_input_listener {
|
||||
compatible = "zmk,input-listener";
|
||||
device = <&msc>;
|
||||
};
|
||||
};
|
||||
28
app/dts/bindings/behaviors/zmk,behavior-input-two-axis.yaml
Normal file
28
app/dts/bindings/behaviors/zmk,behavior-input-two-axis.yaml
Normal file
@@ -0,0 +1,28 @@
|
||||
# Copyright (c) 2024 The ZMK Contributors
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
description: Two axis input behavior
|
||||
|
||||
compatible: "zmk,behavior-input-two-axis"
|
||||
|
||||
include: one_param.yaml
|
||||
|
||||
properties:
|
||||
x-input-code:
|
||||
type: int
|
||||
required: true
|
||||
y-input-code:
|
||||
type: int
|
||||
required: true
|
||||
trigger-period-ms:
|
||||
type: int
|
||||
default: 16
|
||||
description: The time (in ms) between generated inputs when an input has non-zero speed.
|
||||
delay-ms:
|
||||
type: int
|
||||
time-to-max-speed-ms:
|
||||
type: int
|
||||
required: true
|
||||
acceleration-exponent:
|
||||
type: int
|
||||
default: 1
|
||||
6
app/dts/bindings/input_processors/ip_common.yaml
Normal file
6
app/dts/bindings/input_processors/ip_common.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
# Copyright (c) 2024 The ZMK Contributors
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
properties:
|
||||
track-remainders:
|
||||
type: boolean
|
||||
13
app/dts/bindings/input_processors/ip_one_param.yaml
Normal file
13
app/dts/bindings/input_processors/ip_one_param.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
# Copyright (c) 2024 The ZMK Contributors
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
include: ip_common.yaml
|
||||
|
||||
properties:
|
||||
"#input-processor-cells":
|
||||
type: int
|
||||
required: true
|
||||
const: 1
|
||||
|
||||
input-processor-cells:
|
||||
- param1
|
||||
14
app/dts/bindings/input_processors/ip_two_param.yaml
Normal file
14
app/dts/bindings/input_processors/ip_two_param.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
# Copyright (c) 2024 The ZMK Contributors
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
include: ip_common.yaml
|
||||
|
||||
properties:
|
||||
"#input-processor-cells":
|
||||
type: int
|
||||
required: true
|
||||
const: 2
|
||||
|
||||
input-processor-cells:
|
||||
- param1
|
||||
- param2
|
||||
10
app/dts/bindings/input_processors/ip_zero_param.yaml
Normal file
10
app/dts/bindings/input_processors/ip_zero_param.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
# Copyright (c) 2024 The ZMK Contributors
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
include: ip_common.yaml
|
||||
|
||||
properties:
|
||||
"#input-processor-cells":
|
||||
type: int
|
||||
required: true
|
||||
const: 0
|
||||
@@ -0,0 +1,16 @@
|
||||
# Copyright (c) 2024, The ZMK Contributors
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
description: Input Processor for remapping certain input codes to other codes
|
||||
|
||||
compatible: "zmk,input-processor-code-mapper"
|
||||
|
||||
include: ip_zero_param.yaml
|
||||
|
||||
properties:
|
||||
type:
|
||||
type: int
|
||||
required: true
|
||||
map:
|
||||
type: array
|
||||
required: true
|
||||
@@ -0,0 +1,16 @@
|
||||
# Copyright (c) 2024, The ZMK Contributors
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
description: Input Processor for scaling values
|
||||
|
||||
compatible: "zmk,input-processor-scaler"
|
||||
|
||||
include: ip_two_param.yaml
|
||||
|
||||
properties:
|
||||
type:
|
||||
type: int
|
||||
required: true
|
||||
codes:
|
||||
type: array
|
||||
required: true
|
||||
@@ -0,0 +1,21 @@
|
||||
# Copyright (c) 2024, The ZMK Contributors
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
description: Input Processor for temporarily enabling a layer after input events
|
||||
|
||||
compatible: "zmk,input-processor-temp-layer"
|
||||
|
||||
include: ip_two_param.yaml
|
||||
|
||||
properties:
|
||||
require-prior-idle-ms:
|
||||
type: int
|
||||
required: false
|
||||
default: 0
|
||||
description: Time in milliseconds that must pass after the last keystroke before the layer can be toggled
|
||||
|
||||
excluded-positions:
|
||||
type: array
|
||||
required: false
|
||||
default: []
|
||||
description: Array of key positions that will NOT trigger layer deactivation when pressed
|
||||
@@ -0,0 +1,18 @@
|
||||
# Copyright (c) 2024, The ZMK Contributors
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
description: Input Processor for transforming values in various ways
|
||||
|
||||
compatible: "zmk,input-processor-transform"
|
||||
|
||||
include: ip_one_param.yaml
|
||||
|
||||
properties:
|
||||
type:
|
||||
type: int
|
||||
x-codes:
|
||||
type: array
|
||||
required: true
|
||||
y-codes:
|
||||
type: array
|
||||
required: true
|
||||
26
app/dts/bindings/zmk,input-listener.yaml
Normal file
26
app/dts/bindings/zmk,input-listener.yaml
Normal file
@@ -0,0 +1,26 @@
|
||||
# Copyright (c) 2024 The ZMK Contributors
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
description: |
|
||||
Listener to subscribe to input events and send HID updates after processing
|
||||
|
||||
compatible: "zmk,input-listener"
|
||||
|
||||
properties:
|
||||
device:
|
||||
type: phandle
|
||||
required: true
|
||||
input-processors:
|
||||
type: phandle-array
|
||||
|
||||
child-binding:
|
||||
description: "Listener overrides for certain layers"
|
||||
|
||||
properties:
|
||||
layers:
|
||||
type: array
|
||||
required: true
|
||||
process-next:
|
||||
type: boolean
|
||||
input-processors:
|
||||
type: phandle-array
|
||||
18
app/dts/bindings/zmk,input-split.yaml
Normal file
18
app/dts/bindings/zmk,input-split.yaml
Normal file
@@ -0,0 +1,18 @@
|
||||
# Copyright (c) 2024 The ZMK Contributors
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
include: [base.yaml]
|
||||
|
||||
compatible: "zmk,input-split"
|
||||
|
||||
description: Device to wire up an input device for split use.
|
||||
|
||||
properties:
|
||||
reg:
|
||||
required: true
|
||||
|
||||
device:
|
||||
type: phandle
|
||||
|
||||
input-processors:
|
||||
type: phandle-array
|
||||
10
app/dts/input/processors.dtsi
Normal file
10
app/dts/input/processors.dtsi
Normal file
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) 2024 The ZMK Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <input/processors/scaler.dtsi>
|
||||
#include <input/processors/code_mapper.dtsi>
|
||||
#include <input/processors/transform.dtsi>
|
||||
#include <input/processors/temp_layer.dtsi>
|
||||
29
app/dts/input/processors/code_mapper.dtsi
Normal file
29
app/dts/input/processors/code_mapper.dtsi
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2024 The ZMK Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <zephyr/dt-bindings/input/input-event-codes.h>
|
||||
|
||||
/ {
|
||||
/omit-if-no-ref/ zip_xy_swap_mapper: zip_xy_swap_mapper {
|
||||
compatible = "zmk,input-processor-code-mapper";
|
||||
#input-processor-cells = <0>;
|
||||
type = <INPUT_EV_REL>;
|
||||
map
|
||||
= <INPUT_REL_Y INPUT_REL_X>
|
||||
, <INPUT_REL_X INPUT_REL_Y>
|
||||
;
|
||||
};
|
||||
|
||||
/omit-if-no-ref/ zip_xy_to_scroll_mapper: zip_xy_to_scroll_mapper {
|
||||
compatible = "zmk,input-processor-code-mapper";
|
||||
#input-processor-cells = <0>;
|
||||
type = <INPUT_EV_REL>;
|
||||
map
|
||||
= <INPUT_REL_Y INPUT_REL_WHEEL>
|
||||
, <INPUT_REL_X INPUT_REL_HWHEEL>
|
||||
;
|
||||
};
|
||||
};
|
||||
33
app/dts/input/processors/scaler.dtsi
Normal file
33
app/dts/input/processors/scaler.dtsi
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2024 The ZMK Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <zephyr/dt-bindings/input/input-event-codes.h>
|
||||
|
||||
/ {
|
||||
/omit-if-no-ref/ zip_x_scaler: zip_x_scaler {
|
||||
compatible = "zmk,input-processor-scaler";
|
||||
#input-processor-cells = <2>;
|
||||
type = <INPUT_EV_REL>;
|
||||
codes = <INPUT_REL_X>;
|
||||
track-remainders;
|
||||
};
|
||||
|
||||
/omit-if-no-ref/ zip_y_scaler: zip_y_scaler {
|
||||
compatible = "zmk,input-processor-scaler";
|
||||
#input-processor-cells = <2>;
|
||||
type = <INPUT_EV_REL>;
|
||||
codes = <INPUT_REL_Y>;
|
||||
track-remainders;
|
||||
};
|
||||
|
||||
/omit-if-no-ref/ zip_xy_scaler: zip_xy_scaler {
|
||||
compatible = "zmk,input-processor-scaler";
|
||||
#input-processor-cells = <2>;
|
||||
type = <INPUT_EV_REL>;
|
||||
codes = <INPUT_REL_X INPUT_REL_Y>;
|
||||
track-remainders;
|
||||
};
|
||||
};
|
||||
14
app/dts/input/processors/temp_layer.dtsi
Normal file
14
app/dts/input/processors/temp_layer.dtsi
Normal file
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (c) 2024 The ZMK Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <zephyr/dt-bindings/input/input-event-codes.h>
|
||||
|
||||
/ {
|
||||
/omit-if-no-ref/ zip_temp_layer: zip_temp_layer {
|
||||
compatible = "zmk,input-processor-temp-layer";
|
||||
#input-processor-cells = <2>;
|
||||
};
|
||||
};
|
||||
25
app/dts/input/processors/transform.dtsi
Normal file
25
app/dts/input/processors/transform.dtsi
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) 2024 The ZMK Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <zephyr/dt-bindings/input/input-event-codes.h>
|
||||
|
||||
/ {
|
||||
/omit-if-no-ref/ zip_xy_transform: zip_xy_transform {
|
||||
compatible = "zmk,input-processor-transform";
|
||||
#input-processor-cells = <1>;
|
||||
type = <INPUT_EV_REL>;
|
||||
y-codes = <INPUT_REL_Y>;
|
||||
x-codes = <INPUT_REL_X>;
|
||||
};
|
||||
|
||||
/omit-if-no-ref/ zip_scroll_transform: zip_scroll_transform {
|
||||
compatible = "zmk,input-processor-transform";
|
||||
#input-processor-cells = <1>;
|
||||
type = <INPUT_EV_REL>;
|
||||
y-codes = <INPUT_REL_WHEEL>;
|
||||
x-codes = <INPUT_REL_HWHEEL>;
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user