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(mouse): Add mouse move and scroll support #2477

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

petejohanson
Copy link
Contributor

Summary

  • 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.

This is the planned successor to #2027 that integrates a more flexible input processing system inspired by the work by badjeff. I will leave #2027 alone for now, but this PR is intended to be the version that's targeted to actually merge.

WARNING The work in this PR is subject to ZERO API/code/config stability guarantees. If you want something that won't randomly break on you, keep using #2027. Only use the branch from this PR if you are willing to accept that, follow the PR closely for any changes, and are technical enough to solve any problems that occur from using it.

Input Processors

All the options for scaling, swapping X/Y values, etc are now accomplished with input processors, that can be set on a given listener, and overridden for a set of given layers:

I've implemented input processors with the following compatible values:

  • zmk,input-processor-code-mapper - For translating input codes to other values. Useful for enabling a "scroll layer" that makes a pointer send scroll events instead of X/Y move events.
  • zmk,input-processor-scaler - For scaling values, using a passed in multiplier and divisor. Useful for "precision layer". Example &xy_scaler 1 4 to scale values by 1/4, for fine grained movements.
  • zmk,input-processor-temp-layer - For enabling a layer until a certain time period of no input events from the device. Useful for a "mouse layer" with mouse keys when using an integrated trackpad/ball/whatever.
  • zmk,input-processor-transform - For swapping X/Y values, inverting a given Y or X value. Useful when a given input driver doesn't support these transforms and it may be installed rotated 90deg, etc.

Input processors are tied to input listeners, with layer overrides, e.g.:

&mmv_input_listener {
	input-processors = <&xy_scaler 3 2>, <&input_proc_temp_layer MOUSE_L 2000>;

	wheelie {
		layers = <WHEEL_L>;
		input-processors = <&mouse_to_wheel_mapper>;
	};

	fine {
		layers = <FINE_L>;
		input-processors = <&xy_scaler 1 3>;
	};
};

Smooth Scrolling

This also adds "smooth scrolling" support, by using HID "resolution multipliers", which appears to be supported in Linux and Windows, but not macOS. On macOS, we should be properly falling back to normal behavior here even with CONFIG_ZMK_MOUSE_SMOOTH_SCROLLING=y. More testing needed here.

Testing

So far, I've tested with mouse keys/scroll/move, and with a Cirque device. More testing all around! Existing generic Zephyr input devices should still "just work" with this PR.

To Do

  • Add "out of the box" input processors you can use, that are tagged with /omit-if-no-ref/.
  • Document input listener config
  • Document available input processors
  • Testing, more testing.

* 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.

Co-authored-by: Alexander Krikun <[email protected]>
Co-authored-by: Robert U <[email protected]>
Co-authored-by: Shawn Meier <[email protected]>
@petejohanson petejohanson added enhancement New feature or request core Core functionality/behavior of ZMK pointers Pointer related functionality labels Sep 13, 2024
@petejohanson petejohanson self-assigned this Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core functionality/behavior of ZMK enhancement New feature or request pointers Pointer related functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants