Commit graph

89 commits

Author SHA1 Message Date
Peter Hutterer
ba603ea192 touchpad: improve finger counting for synaptics serial touchpads
A three-finger touch may cause slot N to end, in a frame after the
BTN_TOOL_TRIPLETAP. This causes tp->nfinger_down to be decremented to 2 as the
touch switches to MAYBE_END - which happens to be our num_slots. We exit early
and never restore the touch correctly.

Fix this by checking that the number of fake touches is equal to the slots, if
it is higher then we need to check for recovery.

Fixes https://gitlab.freedesktop.org/libinput/libinput/issues/99

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-03 15:01:55 +10:00
Peter Hutterer
708b3f0d8e test: properly release a few leaking litest device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-07-26 11:51:26 +10:00
Peter Hutterer
237ebb7cc4 touchpad: don't disable tapping on MT_TOOL_PALM
The tapping code can handle palm states now, so there is no need to disable
tapping altogether when a tool-based palm is detected.

Fixes https://gitlab.freedesktop.org/libinput/libinput/issues/65

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-06-26 01:37:28 +00:00
Peter Hutterer
6adb336829 touchpad: remember the suspend reason
There are 4 possible cases why a touchpad suspends right now: lid switch,
tablet mode switch, sendevents disabled and sendevents disabled when an
external mouse is present.

But these reasons can stack up, e.g. a lid switch may happen while send events
is disabled, disabling one should not re-enable the touchpad. This patch adds
a bitmask to remember the reasons we're current suspended, resuming only
happens once all reasons are back to 0.

https://bugs.freedesktop.org/show_bug.cgi?id=106498

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-18 12:05:02 +10:00
Friedrich Schöller
af86152370 touchpad: fix tapping that happens after a moving thumb
When finger movement exceeded the motion threshold before the finger was
recognized as a thumb, it would never be regarded as a thumb by the tap system.
This prohibited tapping until the thumb was lifted.

This is fixed by moving the check for the thumb state up such that it
happens before the motion threshold check.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-10 14:35:54 +10:00
Peter Hutterer
cfa921250d touchpad: ignore palm touches when handling clickfingers
https://bugs.freedesktop.org/show_bug.cgi?id=104188

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-20 09:04:13 +10:00
Peter Hutterer
928bad9104 touchpad: don't process state for a touch in TOUCH_NONE
If a touch is in TOUCH_NONE, there is nothing to see here, please move along.

In the case of bug 105696, we were accessing the speed.exceeded_count of a
touch that was released previously, erroneously detecting a speed-based thumb.
The sequence was:
- touch down in slot 0, speed.exceeded_count is reset to 0
- move touch until exceeded_count is greater than our threshold
- touch up in slot 0
- touch down in slot 1 [1]
- touch down in slot 2 (more than 25mm away)
- we counted the slot 0 speed.exceeded_count, labeling the slot 2 touch as
  speed-based thumb

[1] peculiar behavior only observed on this device, usually slots get re-used
at the first opportunity so having an inactive slot followed by higher slots
being used is unusual.

https://bugs.freedesktop.org/show_bug.cgi?id=105696

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-05 13:59:12 +10:00
Peter Hutterer
ce80e40006 test: move all the _setup() functions into a special section
This way we can loop through them instead of having to add them manually.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-23 10:17:52 +10:00
Peter Hutterer
3f5ff113a8 touchpad: only keep low-pressure fingers alive for 2+-slot touchpads
Regression introduced by 3979b9e16a, bug 105258.
With that commit, we only ended real touches when we had less than nslots fake
fingers down. i.e. tripletap on a 2 slot touchpad would not end the
first/second touch even if the pressure goes below the threshold. e.g. Lenovo
x270 needs this, see https://bugs.freedesktop.org/attachment.cgi?id=137672, it
dips below the pressure threshold for the first slot and ends the second slot
in the same frame as the third finger is detected. Fun times.

Anyway, this breaks semi-mt touchpads, another fine category of devices,
because some of those can detect hovering fingers at low pressure, see bug
105535. Because semi-mt devices are generally garbage, we treat them as
single-touch devices instead. So whenever two fingers are down, we treat both
as above the pressure threshold, even when they're physicall hovering.

Fix this by making the x270 fix conditional on at least 2 slots.

https://bugs.freedesktop.org/show_bug.cgi?id=105535

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-21 14:08:06 +10:00
Peter Hutterer
d786b55daa touchpad: don't enable top palm detection on touchpads <= 55mm high
Tiny enough as it is, let's not take usable space away.

https://bugs.freedesktop.org/show_bug.cgi?id=105434

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-13 10:04:02 +10:00
Peter Hutterer
6ccd8e934f touchpad: add a TOUCH_MAYBE_END state
This state is used by the pre-processing of the touch states to indicate that
the touch point has ended and is changed to TOUCH_END as soon as that
pre-processing is finished.

Sometimes we have to resurrect a touch point that has physically or logically
ended but needs to be kept around to keep the BTN_TOOL_* fake finger count
happy. Particularly on Synaptics touchpads, where a BTN_TOOL_TRIPLETAP can
cause a touch point to end (i.e. 1 touch down + TRIPLETAP) but that touch
restarts in the next sequence. We had a quirk for this in place already, but
if we end the touch and then re-instate it with tp_begin_touch(), we may lose
some information about thumb/palm/etc. states that touch already had. As a
result, the state machines can get confused and a touch that was previously
ignored as thumb suddenly isn't one anymore and triggers assertions.

The specific sequence in bug 10528 is:
* touch T1 down
* touch T2 down, detected as speed-based thumb, tap state machine ignores
  it
* frame F: TRIPLETAP down, touch T2 up
* frame F+1: touch T2 down in next frame, but without the thumb bit
* frame F+n: touch T2 ends, tap state machine gets confused because
  that touch should not trigger a release

https://bugs.freedesktop.org/show_bug.cgi?id=105258

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-01 12:24:48 +10:00
Peter Hutterer
21b83dfd0b test: don't run the 2fg pressure test on single-touch touchpads
Only the appletouch has pressure and thus executed that code path

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-01 12:23:45 +10:00
Peter Hutterer
f5a9e38c90 touchpad: don't disable the hysteresis unless a finger is down
On the very first event, the last_motion_time set by tp_begin_touch is not yet
set because we are called before the pressure-based touch detection takes
effect. And any event timestamp is more than 80ms after a zero timestamp,
causing the hysteresis to always be disabled.

https://bugs.freedesktop.org/show_bug.cgi?id=98839#c74

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-01-09 13:47:42 +10:00
Peter Hutterer
3fea53c3a9 test: restore the non-debounced litest_button_click()
8cf6893 removed it to make search/replace easier, restore it for the tests
where we don't want debouncing to automatically be handled.

Still left in place are the various top software button cases. Because of the
button re-routing through the fallback interface we need those to be
debounced.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-11-20 11:31:56 +10:00
Peter Hutterer
8cf6893f6d test: replace litest_button_click with a debounced version
This is via a simple search & replace. Later auditing is needed to switch
clicks that should not be debounced (e.g. touchpads) back to a non-debounced
version.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-11-20 09:55:05 +10:00
Peter Hutterer
4d7592066a touchpad: allow for multiple paired keyboards
needed for the razer blade keybard which provides multiple event nodes for
one physical device but it's hard/impossible to identify which one is the real
event node we care about.

https://bugs.freedesktop.org/show_bug.cgi?id=103156

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-10-31 15:40:19 +10:00
Peter Hutterer
de5246dae0 touchpad: use motion speed to ignore accidental 2fg touches
Calculate the speed of the touch and compare it against a fixed speed limit.
If a touch exceeds the speed when a second touch is set down, that second
touch is marked as a thumb and ignored (unless it's right next to the other
finger, then it's likely a 2fg scroll).

The speed calculation is simple but has to lag behind by one sample - we reset
the motion history whenever a new finger is set down (to avoid pointer jumps)
so we need to know if the finger was moving fast *before* this happens. Plus,
with the pointer jumps we're more likely to get false positives if we
calculate the speed on actual finger down.

This is the simplest version for now, the speed varies greatly between
movements and should probably be averaged across the last 3-or-so samples.

https://bugs.freedesktop.org/show_bug.cgi?id=99703

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-09-01 16:06:40 +10:00
Peter Hutterer
e0c0db22e4 test: fix indentation for palm touch size test
Somehow this ended up being spaces instead of tabs

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-09-01 14:55:15 +10:00
Peter Hutterer
ca4285de66 touchpad: add touch-size-based palm detection
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-11 12:28:28 +10:00
Peter Hutterer
432fbc33cd touchpad: add touch-size based touch handling
Apple touchpads don't use ABS_MT_PRESSURE but they are multitouch touchpads,
so the current pressure-based handling code doesn't apply because it expects
slot-based pressure for mt touchpads.

Apple does however send useful data for ABS_MT_WIDTH_MAJOR/MINOR, so let's use
that instead. The data provided in those is more-or-less random, so we need a
hwdb entry to track the acceptable thresholds.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-11 12:27:54 +10:00
Peter Hutterer
9e5d1df4bb touchpad: set keyboard to non-active when the keyboard is removed
If the keyboard is removed while dwt thinks it is in active state, that state
is never reset and subsequent touches are ignored.

https://bugs.freedesktop.org/show_bug.cgi?id=101743

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-11 11:42:27 +10:00
Peter Hutterer
7b5ca6204b Fix a few things scan-build complains about
Uninitialized variables, potential NULL dereferences, dead assignments and an
unused return value.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-10 10:37:58 +10:00
Ming-Yang Lu
5dc330bdea touchpad: add upper edge into exclusion zone
This reduces unexpected cursor moves when placing the thumb near the border
of trackpoint buttons and upper edge of touchpad.

https://bugs.freedesktop.org/show_bug.cgi?id=101574

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-10 09:33:24 +10:00
Peter Hutterer
6060abc3b3 test: fix some tap palm detection tests
Without the timeout we're not guaranteed that the tap button event triggers

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-06 10:26:45 +10:00
Peter Hutterer
50550e9811 test: add missing check for an empty queue to the palm detection test
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-06 10:26:45 +10:00
Peter Hutterer
a31e4b818c test: remove failing thumb edge scroll test
Broken since the merge of palm pressure detection in
25d54b90d, not sure why the test suite succeeded on that one nonetheless.

I'm not 100% sure why the test does what it does but it seems to be testing
that a wide touch on the side still striggers edge scrolling and not the thumb
detection on the bottom of the touchpad. That is obsolete now, it's hard to
generically figure out the small gap between thumb and palm pressure, so this
test almost always triggers palm detection. It's obsolete.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-06 09:33:18 +10:00
Peter Hutterer
25d54b90db touchpad: add pressure-base palm detection
If a touch goes past the fixed pressure threshold it is labelled as a palm and
stays a palm. Default value is one that works well here on a T440 and is
virtually impossible to trigger by a normal finger or thumb. A udev property
is exposed so we can handle this in the udev hwdb and the new tool introduce a
few commits ago can help finding the palm detection threshold.

Unlike the other palm detection features, once a palm goes past the threshold
it remains a palm until the touch is released. This means palm overrides any
other palm detection features. For code simplicity, we don't combine the
states but merely check for pressure before and after the other palm detection
functions. If the pressure triggers, it will trigger before anything else. And
if something else is already active (e.g. edge where the pressure doesn't work
well) it will trigger as soon as the palm is released.

The palm threshold should thus be chosen with some room to spare between the
highest finger pressure.

https://bugs.freedesktop.org/show_bug.cgi?id=94236

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-07-03 15:58:13 +10:00
Peter Hutterer
d2054c8188 touchpad: use the "is internal keyboard" tag to enable dwt
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-06-19 15:42:43 +10:00
Peter Hutterer
211bed2c25 touchpad: pull the tap exclusion zone down to the full edge zone
This was originally left outside of the button areas in case users tap in
those zones, but we're getting false tap events in that zone.

On a 100mm touchpad, the edge zone is merely 5mm, it's acceptable to ignore
taps in that area even in the software button. We can revisit this if we see
tap detection failures in the future.

https://bugzilla.redhat.com/show_bug.cgi?id=1415796

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2017-05-11 10:30:04 +10:00
Peter Hutterer
9495713b05 touchpad: add MT_TOOL-based palm detection
If the touchpad driver tells us something is a palm, go with that.

https://bugs.freedesktop.org/show_bug.cgi?id=100243

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-04-21 10:03:58 +10:00
Peter Hutterer
c2b33f2a53 test: don't use the same mouse twice
No effect since we don't care about the mouse itself. But when running
on kernels without uinput's UI_GET_SYSNAME this can cause misdetection of
the uinput device and test case failures. Simply picking a differently named
device avoids that.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-03-14 12:33:15 +10:00
Peter Hutterer
d6379bc3f3 touchpad: reduce minimum height for horiz edge scrolling to 40mm
Introduced in commit 8e7f99c27a we only allowed horizontal edge scrolling
on devices larger than 50mm to leave enough reactive space on the touchpad.
Looking at a ruler, a 50mm high touchpad is still large enough to leave the
bottom 7mm as an horizontal edge scroll area. Reduce the minimum size to 40mm
instead, that's closer to where it starts to get a bit iffy.

https://bugzilla.redhat.com/show_bug.cgi?id=1422221

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2017-02-28 11:32:08 +10:00
Peter Hutterer
019f185107 touchpad: add a hwdb quirk for (external) touchpad/keyboard combos
Specify the layout of the combo so we know when to initialize palm detection.

This allows us to drop palm detection on external touchpads otherwise,
replacing the wacom-specific check with something more generic..

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2017-02-13 08:28:37 +10:00
Peter Hutterer
f2f616a1fc touchpad: mark the Apple onebutton touchpad as clickfinger-default
We don't initialize click methods on devices with physical buttons. This model
is a special case, it's not a clickpad but it only has one button (because one
button is all you ever need and whatnot).

https://bugs.freedesktop.org/show_bug.cgi?id=99283

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-02-09 09:26:07 +10:00
Peter Hutterer
9e8f6bd1d6 test: add touchpad pressure tests
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-30 10:50:28 +10:00
Peter Hutterer
2b3fe1a73e test: add the right pressure bits.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-30 10:50:28 +10:00
Peter Hutterer
3170b3519b touchpad: ignore hovering touches when tapping
We need to remember whether a tap was down or just hovering, otherwise we mess
up the state machine when we send tap release events for taps that never
switched to TOUCH_BEGIN. This is quick fix, really we should have a new state
here, but that's a lot harder to implement.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-26 15:43:02 +10:00
Peter Hutterer
a04ba9a276 test: check if left-handed is available for the left-handed tests
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-17 07:53:49 +10:00
Peter Hutterer
5d66edc9f4 test: prefix all test source files with "test-"
They weren't originally prefixed but the various tests were, but now that we
only have one test runner binary anyway, the prefix helps sorting the files
easily within e.g. gcov results.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-16 08:59:00 +10:00
Renamed from test/touchpad.c (Browse further)