⛏️ index : haiku.git

author Samuel Rodríguez Pérez <samuelgaliza@gmail.com> 2025-11-22 3:37:17.0 +00:00:00
committer Adrien Destugues <pulkomandy@pulkomandy.tk> 2025-12-13 14:20:38.0 +00:00:00
commit
cd5774201abd56bc9746a7050e0c030ceac74c4f [patch]
tree
b916551340c8267482b10fdc9bd56594aa27cd16
parent
4b5001248d66bec4a4d870826f0a1398ac4315ab
download
cd5774201abd56bc9746a7050e0c030ceac74c4f.tar.gz

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 <pulkomandy@pulkomandy.tk>

Diff

 src/add-ons/input_server/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 f101071..9a68213 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 @@
	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 @@
	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 @@
				|| 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;