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

Input Listener: Auto Layer Toggle on mouse movement #2122

Closed

Conversation

infused-kim
Copy link
Contributor

@infused-kim infused-kim commented Jan 18, 2024

This PR adds a way to toggle a layer whenever a mouse moves.

It was designed for the PS/2 Mouse & Trackpoint PR, but since it's using the new input listener system, it can be used with any mouse driver that's using the new zephyr 3.5 input system.

Configuration

In your shield.dtsi:

/ {
    mouse_ps2_input_listener: mouse_ps2_input_listener {
        compatible = "zmk,input-listener";
        status = "disabled";

        device = <&mouse_ps2>;
    };
};

As you can see the input config is disabled by default. Enable it only on the central half of your keyboard (such as shield_right.overlay:

&mouse_ps2_input_listener {
    status = "okay";
};

And then in your actual keymap:

&mouse_ps2_input_listener {
  xy-swap;
  x-invert;
  y-invert;

  // Set the layer that should automatically activate when the mouse is
  // moving.
  layer-toggle = <MOUSE_TP>;

  // How long the mouse needs to move for before the layer is activated (to
  // avoid accidental activations while typing) (Default: 250)
  layer-toggle-delay-ms = <250>;

  // How long to wait, after the last mouse movement, before deactivating
  // the layer (Default: 250)
  layer-toggle-timeout-ms = <250>;
};

@infused-kim infused-kim requested a review from a team as a code owner January 18, 2024 02:48
caksoylar and others added 11 commits February 23, 2024 13:04
Co-authored-by: Alexander Krikun <[email protected]>
Co-authored-by: Robert U <[email protected]>
Co-authored-by: Shawn Meier <[email protected]>
* Add ability to swap X/Y, invert X and Y values, and apply a
  scalar multiplier/divisor.
* Remove now-unused mouse work queue and related mouse main file.
* Move ticks config into a DTS property on the two axis input behavior.
* Corrected logging for two-axis input timestamps.
* Buffer data from input devices and only surface to HID once synd'd.
Input Listener: Added logging

Auto Layer Toggle: Added initial version

Auto Layer Toggle: Changed how config is retrieved

Auto Layer Toggle: Adjust logging
@infused-kim infused-kim force-pushed the pr/input_config_auto_layer branch from 3b16ddb to a81da31 Compare February 26, 2024 04:36
@infused-kim infused-kim changed the title Input Config - Auto Layer Toggle on mouse movement Input Listener: Auto Layer Toggle on mouse movement Feb 26, 2024
@infused-kim
Copy link
Contributor Author

I updated the code to the new input listener system and updated the PR description with the new config.

@Nick-Munnich
Copy link
Contributor

This has been made obsolete by the input processors PR I believe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants