From 2c0e7daced1421c34a9d417b7d3e9bccbf0ebd7f Mon Sep 17 00:00:00 2001 From: Tobias Adolph <43353209+adolto@users.noreply.github.com> Date: Sun, 20 Apr 2025 10:28:51 +0200 Subject: [PATCH] fix(hid): Fix scroll value truncation (#2865) Fix 8 bit truncation of 16 bit scroll values when passed into functions `zmk_hid_mouse_scroll_set` and `zmk_hid_mouse_scroll_update`. Fixes: #2864 Co-authored-by: Tobias Adolph <43353209+adolto@users.noreply.github.comgit> --- app/include/zmk/hid.h | 4 ++-- app/src/hid.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/include/zmk/hid.h b/app/include/zmk/hid.h index 4c963be63..6f9e2ee93 100644 --- a/app/include/zmk/hid.h +++ b/app/include/zmk/hid.h @@ -377,9 +377,9 @@ int zmk_hid_mouse_button_release(zmk_mouse_button_t button); int zmk_hid_mouse_buttons_press(zmk_mouse_button_flags_t buttons); int zmk_hid_mouse_buttons_release(zmk_mouse_button_flags_t buttons); void zmk_hid_mouse_movement_set(int16_t x, int16_t y); -void zmk_hid_mouse_scroll_set(int8_t x, int8_t y); +void zmk_hid_mouse_scroll_set(int16_t x, int16_t y); void zmk_hid_mouse_movement_update(int16_t x, int16_t y); -void zmk_hid_mouse_scroll_update(int8_t x, int8_t y); +void zmk_hid_mouse_scroll_update(int16_t x, int16_t y); void zmk_hid_mouse_clear(void); #endif // IS_ENABLED(CONFIG_ZMK_POINTING) diff --git a/app/src/hid.c b/app/src/hid.c index c050f062a..cf5a557f8 100644 --- a/app/src/hid.c +++ b/app/src/hid.c @@ -445,7 +445,7 @@ void zmk_hid_mouse_movement_update(int16_t hwheel, int16_t wheel) { LOG_DBG("Mouse movement updated to %d/%d", mouse_report.body.d_x, mouse_report.body.d_y); } -void zmk_hid_mouse_scroll_set(int8_t hwheel, int8_t wheel) { +void zmk_hid_mouse_scroll_set(int16_t hwheel, int16_t wheel) { mouse_report.body.d_scroll_x = hwheel; mouse_report.body.d_scroll_y = wheel; @@ -453,7 +453,7 @@ void zmk_hid_mouse_scroll_set(int8_t hwheel, int8_t wheel) { mouse_report.body.d_scroll_y); } -void zmk_hid_mouse_scroll_update(int8_t hwheel, int8_t wheel) { +void zmk_hid_mouse_scroll_update(int16_t hwheel, int16_t wheel) { mouse_report.body.d_scroll_x += hwheel; mouse_report.body.d_scroll_y += wheel;