zmk icon indicating copy to clipboard operation
zmk copied to clipboard

Feature Request: Send mouse scroll events from encoder rotations, instead of page up/down

Open petejohanson opened this issue 4 years ago • 7 comments

Sending page up/down on encoder rotation only supports scrolling the actively focused content on most OSes. If we instead were to expose a HID mouse/trackpad, and send vertical scroll events, the experience may be improved for many scenarios.

  1. Add an additional HID report to the descriptor for mouse events.
  2. Add API to send mouse report updates.
  3. Hook those to a new behavior you could bind to the encoder sensor location.

petejohanson avatar Aug 05 '20 00:08 petejohanson

Would this feature also include general implementation of mouse keys?

tominabox1 avatar Sep 22 '20 18:09 tominabox1

Would this feature also include general implementation of mouse keys?

This and mouse keys would both rely on some of the same underlying HID changes needed, but would be implemented slightly differently, likely.

However, there is distinct API for behaviours reacting to key positions versus sensor events, so we could choice to use one behavior for both if we wanted.

petejohanson avatar Sep 22 '20 19:09 petejohanson

Hi all, are there any advances on this request? If there is some test code I would like to try it.

el-oso avatar Dec 09 '21 22:12 el-oso

I was able to leverage what was in Nick's repo: compatible = "zmk,behavior-sensor-rotate-var" to make my own behavior that will let me use &mwh and &mmv on a rotary encoder. Got mouse scroll wheel working well on my Rollow's thumb horizontal encoders. You are more than welcome to review it in my zmk-config.

Happy to try to submit a PR but I have very limited knowledge here and don't want to mess something up

t4corun avatar Jan 20 '23 05:01 t4corun

Trying to make this work on the new PR (https://github.com/zmkfirmware/zmk/pull/2027) as well as on top of Nick's repo (linked by @t4corun above), but the scroll wheel binding does not seem to work for me..

Here's the behavior I'm using

scroll_up_down: behavior_sensor_rotate_mouse_wheel_up_down {
	compatible = "zmk,behavior-sensor-rotate";
	#sensor-binding-cells = <0>;
        bindings = <&msc SCRL_UP>, <&msc SCRL_DOWN>;
};

then it's defined in the keymap:

sensor-bindings = <&scroll_up_down>;

I'm obviously missing something, as the scroll works when mapped to a key, but does not work when mapped to the encoder.

pmalecka avatar Apr 28 '24 20:04 pmalecka

It is probable that the scrolling signal sent isn't enough for the computer to translate to an actual scroll, since the duration that encoder sends a tap event is very short by default. You should add tap-ms to the sensor rotate behavior with a larger value, see https://zmk.dev/docs/config/behaviors#sensor-rotation

If that isn't enough to scroll, you might want to increase the max speed of the scroll behavior; e.g. define a larger ZMK_MOUSE_DEFAULT_SCRL_VAL before #includeing the mouse header or use MOVE_Y(...) (see https://github.com/zmkfirmware/zmk/pull/2027/files#diff-96b6a313b7b2d798a719c2c62671b1244ad8a8830f1b716c7612dc4c92462dc3R47)

caksoylar avatar Apr 28 '24 23:04 caksoylar

Thanks for the help!

Had to both to make it work: tap-ms = <20>; and #define ZMK_MOUSE_SCRL_VAL 140

pmalecka avatar Apr 29 '24 12:04 pmalecka