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:
Pete Johanson
2024-12-09 17:45:41 -07:00
committed by GitHub
parent 7e8c542c94
commit 6b40bfda53
119 changed files with 4223 additions and 229 deletions

View File

@@ -282,3 +282,23 @@ Applies to: `compatible = "zmk,behavior-tap-dance"`
| `#binding-cells` | int | Must be `<0>` | |
| `bindings` | phandle array | A list of behaviors from which to select | |
| `tapping-term-ms` | int | The maximum time (in milliseconds) between taps before an item from `bindings` is triggered. | 200 |
## Two Axis Input
This behavior is part of the core [pointing devices](../features/pointing.md) feature, and is used to generate X/Y and scroll input events. It is the underlying behavior used for the mouse [move](../keymaps/behaviors/mouse-emulation.md#mouse-move) and [scroll](../keymaps/behaviors/mouse-emulation.md#mouse-scroll) behaviors.
### Devicetree
Definition file: [zmk/app/dts/bindings/behaviors/zmk,behavior-input-two-axis.yaml](https://github.com/zmkfirmware/zmk/blob/main/app/dts/bindings/behaviors/zmk%2Cbehavior-input-two-axis.yaml)
Applies to: `compatible = "zmk,behavior-input-two-axis"`
| Property | Type | Description | Default |
| ----------------------- | ---- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| `#binding-cells` | int | Must be `<1>` | |
| `x-input-code` | int | The [relative event code](https://github.com/zmkfirmware/zephyr/blob/v3.5.0%2Bzmk-fixes/include/zephyr/dt-bindings/input/input-event-codes.h#L245) for generated input events for the X-axis. | |
| `y-input-code` | int | The [relative event code](https://github.com/zmkfirmware/zephyr/blob/v3.5.0%2Bzmk-fixes/include/zephyr/dt-bindings/input/input-event-codes.h#L245) for generated input events for the Y-axis. | |
| `trigger-period-ms` | int | How many milliseconds between generated input events based on the current speed/direction. | 16 |
| `delay-ms` | int | How many milliseconds to delay any processing or event generation when first pressed. | 0 |
| `time-to-max-speed-ms` | int | How many milliseconds it takes to accelerate to the curren max speed. | 0 |
| `acceleration-exponent` | int | The acceleration exponent to apply: `0` - uniform speed, `1` - uniform acceleration, `2` - linear acceleration | 1 |

View File

@@ -0,0 +1,67 @@
---
title: Pointing Device Configuration
sidebar_label: Pointing
---
These are settings related to the pointing device/mouse support in ZMK.
See [Configuration Overview](index.md) for instructions on how to change these settings.
## Kconfig
Definition file: [zmk/app/pointing/Kconfig](https://github.com/zmkfirmware/zmk/blob/main/app/pointing/Kconfig)
### General
| Config | Type | Description | Default |
| -------------------------------------- | ---- | -------------------------------------------------------------------------- | ------- |
| `CONFIG_ZMK_POINTING` | bool | Enable the general pointing/mouse functionality | n |
| `CONFIG_ZMK_POINTING_SMOOTH_SCROLLING` | bool | Enable smooth scrolling HID functionality (via HID Resolution Multipliers) | n |
### Advanced Settings
The following settings are from Zephyr and should be defaulted to sane values, but can be adjusted if you encounter problems.
| Config | Type | Description | Default |
| -------------------------------- | ---- | ---------------------------------------------------------- | ------------------------------- |
| `CONFIG_INPUT_THREAD_STACK_SIZE` | int | Stack size for the dedicated input event processing thread | 512 (1024 on split peripherals) |
## Input Listener
The following documents settings related to [input listeners](../features/pointing.md#input-listeners).
### Devicetree
Applies to: `compatible = "zmk,input-listener"`
Definition file: [zmk/app/dts/bindings/zmk,input-listener.yaml](https://github.com/zmkfirmware/zmk/blob/main/app/dts/bindings/zmk%2Cinput-listener.yaml)
| Property | Type | Description |
| ------------------ | ------------- | ------------------------------------------------------------------- |
| `device` | phandle | Input device handle |
| `input-processors` | phandle-array | List of input processors (with parameters) to apply to input events |
#### Child Properties
Additional properties can be set on child nodes, which allows changing the settings when certain layers are enabled:
| Property | Type | Description |
| ------------------ | ------------- | ------------------------------------------------------------------------------------------ |
| `layers` | array | List of layer indexes. This config will apply if any layer in the list is active. |
| `input-processors` | phandle-array | List of input processors (with parameters) to apply to input events |
| `process-next` | bool | Whether to continue applying other input processors after this override if it takes effect |
## Input Split
Input splits are used for [pointing devices on split peripherals](../development/hardware-integration/pointing.mdx#split).
### Devicetree
Applies to: `compatible = "zmk,input-split"`
Definition file: [zmk/app/dts/bindings/zmk,input-split.yaml](https://github.com/zmkfirmware/zmk/blob/main/app/dts/bindings/zmk%2Cinput-split.yaml)
| Property | Type | Description |
| ------------------ | ------------- | ------------------------------------------------------------------- |
| `device` | handle | Input device handle |
| `input-processors` | phandle-array | List of input processors (with parameters) to apply to input events |