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

@@ -0,0 +1,12 @@
/*
* Copyright (c) 2024 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
#pragma once
#define ZMK_INPUT_EXPLICIT_CODE(type, code) ((type << 16) & code)
#define ZMK_INPUT_EXPLICIT_CODE_TYPE(val) ((val >> 16) & 0xFF)
#define ZMK_INPUT_EXPLICIT_CODE_CODE(val) (val & 0xFFFF)

View File

@@ -0,0 +1,11 @@
/*
* Copyright (c) 2024 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
#include <zephyr/dt-bindings/dt-util.h>
#define INPUT_TRANSFORM_XY_SWAP BIT(0)
#define INPUT_TRANSFORM_X_INVERT BIT(1)
#define INPUT_TRANSFORM_Y_INVERT BIT(2)

View File

@@ -1,24 +1,9 @@
/*
* Copyright (c) 2020 The ZMK Contributors
* Copyright (c) 2024 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
#pragma once
#include <zephyr/dt-bindings/dt-util.h>
/* Mouse press behavior */
/* Left click */
#define MB1 BIT(0)
#define LCLK (MB1)
/* Right click */
#define MB2 BIT(1)
#define RCLK (MB2)
/* Middle click */
#define MB3 BIT(2)
#define MCLK (MB3)
#define MB4 BIT(3)
#define MB5 BIT(4)
#include "pointing.h"

View File

@@ -0,0 +1,50 @@
/*
* Copyright (c) 2023 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
#pragma once
#include <zephyr/dt-bindings/dt-util.h>
/* Mouse press behavior */
/* Left click */
#define MB1 BIT(0)
#define LCLK (MB1)
/* Right click */
#define MB2 BIT(1)
#define RCLK (MB2)
/* Middle click */
#define MB3 BIT(2)
#define MCLK (MB3)
#define MB4 BIT(3)
#define MB5 BIT(4)
#ifndef ZMK_POINTING_DEFAULT_MOVE_VAL
#define ZMK_POINTING_DEFAULT_MOVE_VAL 600
#endif
#ifndef ZMK_POINTING_DEFAULT_SCRL_VAL
#define ZMK_POINTING_DEFAULT_SCRL_VAL 10
#endif
/* Mouse move behavior */
#define MOVE_Y(vert) ((vert) & 0xFFFF)
#define MOVE_Y_DECODE(encoded) (int16_t)((encoded) & 0x0000FFFF)
#define MOVE_X(hor) (((hor) & 0xFFFF) << 16)
#define MOVE_X_DECODE(encoded) (int16_t)(((encoded) & 0xFFFF0000) >> 16)
#define MOVE(hor, vert) (MOVE_X(hor) + MOVE_Y(vert))
#define MOVE_UP MOVE_Y(-ZMK_POINTING_DEFAULT_MOVE_VAL)
#define MOVE_DOWN MOVE_Y(ZMK_POINTING_DEFAULT_MOVE_VAL)
#define MOVE_LEFT MOVE_X(-ZMK_POINTING_DEFAULT_MOVE_VAL)
#define MOVE_RIGHT MOVE_X(ZMK_POINTING_DEFAULT_MOVE_VAL)
#define SCRL_UP MOVE_Y(ZMK_POINTING_DEFAULT_SCRL_VAL)
#define SCRL_DOWN MOVE_Y(-ZMK_POINTING_DEFAULT_SCRL_VAL)
#define SCRL_LEFT MOVE_X(-ZMK_POINTING_DEFAULT_SCRL_VAL)
#define SCRL_RIGHT MOVE_X(ZMK_POINTING_DEFAULT_SCRL_VAL)