From cd5774201abd56bc9746a7050e0c030ceac74c4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Rodr=C3=ADguez=20P=C3=A9rez?= Date: Sat, 22 Nov 2025 03:37:17 +0000 Subject: [PATCH] input mouse mm: Introduce helper funtions for finger handling It fixes devices that do not store finger flags on fingerWith field such as Elantech touchpad devices. I think only Synaptic touchpad use those. Added are TODO items to change the inner working of these funtions after a future refactorisation of input devices to handle those flags and efective finger width values as separate entities. Commented is "nFingers" with meating of number of fingers which is expeted to be different from "fingers" which is a finger bitmap where each bit represent an identified finger. Change-Id: I5af5d5f86a5ea4f4f06169849afe99395a5e952b Reviewed-on: https://review.haiku-os.org/c/haiku/+/9913 Reviewed-by: Adrien Destugues --- .../devices/mouse/movement_maker.cpp | 50 ++++++++++++++++++- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/src/add-ons/input_server/devices/mouse/movement_maker.cpp b/src/add-ons/input_server/devices/mouse/movement_maker.cpp index f101071502..9a68213501 100644 --- a/src/add-ons/input_server/devices/mouse/movement_maker.cpp +++ b/src/add-ons/input_server/devices/mouse/movement_maker.cpp @@ -60,6 +60,52 @@ make_small(float value) return (int32)truncf(value); } +static inline bool +two_fingers(const touchpad_movement* event) { + // TODO: Replace fingerWith related conditions when drivers are adjusted. + // They seem to be taken from specifics of Synaptics device driver values + // for w where 0 means 2 fingers and 1 is means 3 or more fingers. + return count_set_bits(event->fingers) == 2 +// || event->nFingers == 2 + || event->fingerWidth == 0; +} + + +static inline bool +two_or_more_fingers(const touchpad_movement* event) { + // TODO: Replace fingerWith related conditions when drivers are adjusted. + // They seem to be taken from specifics of Synaptics device driver values + // for w where 0 means 2 fingers and 1 is means 3 or more fingers. + return count_set_bits(event->fingers) >= 2 +// || event->nFingers >= 2 + || event->fingerWidth == 0 || event->fingerWidth == 1; +} + + +static inline bool +three_fingers(const touchpad_movement* event) { + // TODO: Replace fingerWith related conditions when drivers are adjusted. + // They seem to be taken from specifics of Synaptics device driver values + // for w where 0 means 2 fingers and 1 is means 3 or more fingers. + return count_set_bits(event->fingers) == 3 +// || event->nFingers = 3 + || event->fingerWidth == 1; // This is 3 or more fingers for Synaptic +} + + +static inline bool +three_or_more_fingers(const touchpad_movement* event) { + // TODO: Replace fingerWith related conditions when drivers are adjusted. + // They seem to be taken from specifics of Synaptics device driver values + // for w where 0 means 2 fingers and 1 is means 3 or more fingers. + return count_set_bits(event->fingers) > 2 +// || event->nFingers > 2 + || event->fingerWidth == 1; +} + + +// #pragma mark - + void MovementMaker::SetSettings(const touchpad_settings& settings) @@ -326,7 +372,7 @@ TouchpadMovement::EventToMovement(const touchpad_movement* event, mouse_movement if (event->zPressure >= fSpecs.minPressure && event->zPressure < fSpecs.maxPressure && ((event->fingerWidth >= 4 && event->fingerWidth <= 7) - || event->fingerWidth == 0 || event->fingerWidth == 1) + || two_or_more_fingers(event)) && (event->xPosition != 0 || event->yPosition != 0)) { // The touch pad is in touch with at least one finger if (!_CheckScrollingToMovement(event, movement)) @@ -574,7 +620,7 @@ TouchpadMovement::_CheckScrollingToMovement(const touchpad_movement *event, || fSettings.scroll_bottomrange > 0.999999) { isSideScrollingH = true; } - if ((event->fingerWidth == 0 || event->fingerWidth == 1) + if (two_or_more_fingers(event) && fSettings.scroll_twofinger) { // two finger scrolling is enabled isSideScrollingV = true;