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(-)
@@ -60,6 +60,52 @@
return (int32)truncf(value);
}
static inline bool
two_fingers(const touchpad_movement* event) {
return count_set_bits(event->fingers) == 2
|| event->fingerWidth == 0;
}
static inline bool
two_or_more_fingers(const touchpad_movement* event) {
return count_set_bits(event->fingers) >= 2
|| event->fingerWidth == 0 || event->fingerWidth == 1;
}
static inline bool
three_fingers(const touchpad_movement* event) {
return count_set_bits(event->fingers) == 3
|| event->fingerWidth == 1;
}
static inline bool
three_or_more_fingers(const touchpad_movement* event) {
return count_set_bits(event->fingers) > 2
|| event->fingerWidth == 1;
}
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)) {
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) {
isSideScrollingV = true;