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,50 @@
/*
* Copyright (c) 2024 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#include <zmk/ble.h>
#include <zmk/endpoints.h>
#include <zmk/pointing/resolution_multipliers.h>
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
static struct zmk_pointing_resolution_multipliers multipliers[ZMK_ENDPOINT_COUNT];
struct zmk_pointing_resolution_multipliers
zmk_pointing_resolution_multipliers_get_current_profile(void) {
return zmk_pointing_resolution_multipliers_get_profile(zmk_endpoints_selected());
}
struct zmk_pointing_resolution_multipliers
zmk_pointing_resolution_multipliers_get_profile(struct zmk_endpoint_instance endpoint) {
const int profile = zmk_endpoint_instance_to_index(endpoint);
return multipliers[profile];
}
void zmk_pointing_resolution_multipliers_set_profile(struct zmk_pointing_resolution_multipliers m,
struct zmk_endpoint_instance endpoint) {
int profile = zmk_endpoint_instance_to_index(endpoint);
// This write is not happening on the main thread. To prevent potential data races, every
// operation involving hid_indicators must be atomic. Currently, each function either reads
// or writes only one entry at a time, so it is safe to do these operations without a lock.
multipliers[profile] = m;
}
void zmk_pointing_resolution_multipliers_process_report(
struct zmk_hid_mouse_resolution_feature_report_body *report,
struct zmk_endpoint_instance endpoint) {
struct zmk_pointing_resolution_multipliers vals = {
.wheel = report->wheel_res,
.hor_wheel = report->hwheel_res,
};
zmk_pointing_resolution_multipliers_set_profile(vals, endpoint);
LOG_DBG("Update resolution multipliers: endpoint=%d, wheel=%d, hor_wheel=%d",
endpoint.transport, vals.wheel, vals.hor_wheel);
}