Commit graph

89 commits

Author SHA1 Message Date
Peter Hutterer
61e41df901 touchpad: disable the pressure axes wherever the resolution is nonzero
The kernel/udev set the pressure resolution to nonzero to indicate the value
is in a known scale (units/g). We use that information to disable the
pressure axis on such devices - real pressure cannot be translated to
contact size.

For the kernel patch see:
https://www.spinics.net/lists/linux-input/msg71237.html

Fixes #569

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-08 03:38:26 +00:00
Peter Hutterer
53595cb232 quirks: disable pressure on the Lenovo Yoga 9i touchpad
This touchpad is a true pressurepad and the pressure axis gives us physical
pressure down. Using it as contact size gives flaky touch detection, so let's
just disable the axis until we do something with that value.

Fixes #562

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-01-14 13:42:59 +10:00
Peter Hutterer
2e25741061 test: grab the device before any lid or tablet mode switches
Putting an EVIOCGRAB on the device before sending those events means no-one
else sees those events - particularly upower. This means no-one else knows the
lid is on or off and thus we never blank the screen (or suspend/shut down but
those are inhibited anyway).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-07 18:51:33 +10:00
Peter Hutterer
52d6398753 test: use litest_destroy_context() for test-suite contexts
Symmetrical to litest_create_context(), this allows us to store special data
in that context that we have access to during the tests.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-07 18:51:33 +10:00
Peter Hutterer
6e9477a86d test: move the check for edge palms on devices to litest proper
We'll need this in other files soon

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-03 21:50:44 +00:00
Peter Hutterer
6d173f890a test: disable a bunch of tests relying on libwacom
Some of these may have a non-libwacom solution but let's be honest, you
shouldn't be skipping libwacom if you rely on tablets to be precise.

Fixes #436

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-02-24 06:45:01 +00:00
Peter Hutterer
2bfbdfaf6b test: remove double-assignment to a variable
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-02-24 01:53:21 +00:00
Peter Hutterer
06591e5913 touchpad: sync the initial tracking id state to the touchpad
Where fingers are down during startup we need to sync them to the known state
of the device so our slot count is correct. Otherwise, when the fingers are
lifted we will trigger the new assert for nactive_slots being less than 0.

Regression introduced in eb6ef9fe70

Fixes #429

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-02-18 17:11:35 +10:00
Peter Hutterer
1e1b9c0e60 touchpad: never reduce the slot count to 0
Where a user releases all touches during a SYN_DROPPED and then puts more than
one finger back down before we sync, we end up with nonzero fake touches but
a zero slot count. This is caused by a wrong event sequences provided by
libevdev in that case.

This really needs to be fixed in libevdev, see
https://gitlab.freedesktop.org/libevdev/libevdev/merge_requests/19

In the meantime, put a check in to ignore that case and never reduce the slot
count to 0. It still leaves us open for some issues where 3fg gestures may
stop working if the right sequences are triggered during SYN_DROPPED but
updating libevdev will eventually make that go away too.

Fixes #422

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-02-18 06:26:56 +00:00
Peter Hutterer
c5f5a0fa7b test: fix a pressure test to movement during tap
The motion event here was intended to offset the light pressure from the
extended touch down. This also causes motion past the tap threshold and won't
work with a future patch.

Make the touch "real" by simply plaing a normal movement in the current
position - the kernel will filter and we'll just update the pressure.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-11-15 00:24:00 +00:00
Peter Hutterer
2b33445bc9 touchpad: use the same speed for scrolling as the baseline of the accel curve
Scrolling and gestures use unaccelerated motion. The idea behind it was that
at least for the default speed setting of 0, the accelerated speed and
unaccelerated speed are identical where meaningful.

The touchpad speed curve has a plateau for 'normal' speeds (i.e. not very slow
and not very fast) where the acceleration factor is constant. This is the
reference factor that the unaccelerated motion should use as well.

Since the touchpad acceleration rework in d6e5313497 the reference factor is
0.9 * TP_MAGIC_SLOWDOWN (previously the factor was 1.0 * TP_MAGIC_SLOWDOWN)
and scroll motion is thus 10% faster than the pointer movement at the default
speeds. Let's fix this and let the two match up.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-10-14 02:57:48 +00:00
Matt Mayfield
4536b5b38f touchpad: revamp thumb detection
Instead of a simple yes/no/maybe for thumbs, have a more extensive state
machine that keeps track of the thumb. Since we only support one thumb anyway,
the tracking moves to the tp_dispatch struct.

Test case changes:
touchpad_clickfinger_3fg_tool_position:
  with better thumb detection we can now handle this properly and expect a
  right button (2fg) press for the test case
touchpad_thumb_no_doublethumb_with_timeout:
  two thumbs are now always two fingers, so let's switch to axis events here

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-07-17 09:33:14 +10:00
Peter Hutterer
dda6f733af test: make the touchpad size the only check for thumb detection
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-07-15 13:08:47 +10:00
Peter Hutterer
8e4d820efd test: only run the speed finger tests when the touchpad has thumb detection 2019-07-15 13:08:47 +10:00
Peter Hutterer
181f8d2ab5 test: only run the speed tests for clickpads
We don't need speed detection for non-clickpads - the only reason to ever drop
a second finger on those is to either scroll or trigger a gesture. Unlike
clickpads, where a dropped finger may be a thumb to click.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-07-15 13:08:47 +10:00
Peter Hutterer
8d3788fa8c evdev: when the kernel fuzz is nonzero, set ours to zero
Our udev callout is supposed to reset the kernel fuzz to 0 and move the value
to the LIBINPUT_FUZZ property. This is to stop the kernel from applying its
own hysteresis-like approach.

Where the kernel fuzz is nonzero, something has gone wrong with that approach.
Complain about it and set our fuzz to zero, we are in the hands of the kernel
now. If we leave our fuzz as nonzero, we'll apply our own hysteresis on top of
the kernel's and that leads to unresponsive behavior.

Fixes #313

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-27 11:17:28 +10:00
Peter Hutterer
015af5f3dc test: fix the slot swap test again
The previous movement was one finger still, the second finger moving. This may
cause axis events to trigger when a 2fg scroll gesture was detected. Those
axis events will stop after the gesture timeout but generate one more axis
stop event.

Make two changes here: first, move the fingers like a proper 2fg scroll
motion. And shuffle around the litest_drain_events() calls to ignore any axis
event immediately after the timeout.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-24 12:30:05 +10:00
Peter Hutterer
1796fd92e7 test: avoid a pointer jump when testing for the slot continuation
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-20 22:16:15 +00:00
Peter Hutterer
8b4c040bfb test: fix the slot swap test
This test worked because no gesture was detected in the initial movement.
If that happens though, releasing one finger triggers the gesture timeout
during which we suppress events, thus failing the test. Fix this by moving,
waiting, moving - that will definitely generate an event.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-20 22:16:15 +00:00
Peter Hutterer
996270d1a1 test: fix button area scroll test to not be a pinch
Second finger's x coordinate was wrong. That we didn't pick this up as pinch
is quite telling too.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-20 22:16:15 +00:00
Peter Hutterer
160d3f2b66 test: move the fingers closer together for the empty-slot test
If we're testing for this, let's not try to get it picked up as pinch
gestures. Only an issue on the wacom and magic trackpads because of their
physical size.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-20 22:16:15 +00:00
Peter Hutterer
5bcfbfe9dc test: change touchpad 2fg no-motion test to move both fingers simultaneously
In the future we may allow motion with one finger on the touchpad.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-20 22:16:15 +00:00
Peter Hutterer
b40149f5cb test: fix initial coordinates for synaptics tripletap quirk
I don't think there was a specific reason for the second touch point to jump
around here either and the comment indicates it was just to avoid the
clickfinger distance trigger. So let's just move the first touchpoint.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-19 11:08:40 +10:00
Peter Hutterer
c3c3c4b2ae test: add another test for thumb movements
Small movements mustn't trigger events, large movements should.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-18 18:29:19 +10:00
Peter Hutterer
84872fa35b test: fix the clickfinger thumb test
This test was putting both fingers down in the thumb area. That's not
representative, it's more likely that a thumb is in the area and the second
finger clicks elsewhere. So let's test for that instead.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-18 18:29:19 +10:00
Peter Hutterer
1d9e32c91f test: rename/fix/move thumb tests
These were supposed to test the thumb area, but the pressure exceeded the
threshold for most devices, thus ending up testing the palm detection instead.

Fix to use a timeout where possible, otherwise move them to the palm detection
code instead.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-18 14:18:47 +10:00
Peter Hutterer
164a6a8159 test: fix an intermitted failing test
The touchpad_2fg_scroll_initially_diagonal test would semi-reliably fail under
valgrind but succeed otherwise. Cause was that on some devices, the initial
diagonal movement wasn't diagonal enough and closer to a horizontal movement.
This was fine on normal runs, but under valgrind we'd hit the "active
threshold" time limit and lock to horizontal scrolling, ditching the remaining
events and failing the test.

Fix this by calculating the scroll vector based on the device's width/height
ratio and go "more diagonal" on the initial vector.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-11 15:49:02 +10:00
Peter Hutterer
64df646658 test: split a test up into events vs processing
Running under valgrind, this test often fails when the machine is under load.
Split it up so the events are all processed in one go, reducing the chance of
getting a timeout while processing a previous event.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-05-27 21:02:33 +10:00
Peter Hutterer
6229df184e touchpad: rotate the touch part of tablets
Tablets in left-handed mode are rotated, so we need to rotate the touchpad
part of them too. This doesn't affect all tablets though, some of them are
symmetrical and the left-handed mode merely changes the button order around
(some of the earlier Bamboos). So we rely on libwacom to tell us which device
must be rotated.

The rotation itself is done on the input coordinate itself as we get it. This
way any software buttons, palm zones, etc. are automatically handled by rest
of the code.

Fixes #274

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-04-30 16:28:29 +10:00
Peter Hutterer
9b18adc407 test: replace != NULL checks with ck_assert_notnull
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-02-15 08:42:15 +10:00
Furkan Tokac
59dee41ba1 test: Missing test cases for palm detection based on touch size
Missing tests are written.
2019-01-29 03:19:57 +00:00
Peter Hutterer
12dc64af24 touchpad: handle a touch ending and restarting in the same frame
If a touch ends and starts again in the same frame, our touch count gets out
of whack. This later triggers an assertion when the tap touch count mismatches
the real tap count.

E: 0.105005 0003 0039 -001      # EV_ABS / ABS_MT_TRACKING_ID   -1
E: 0.105005 0003 0035 8447      # EV_ABS / ABS_MT_POSITION_X    8447
E: 0.105005 0003 0036 4479      # EV_ABS / ABS_MT_POSITION_Y    4479
E: 0.105005 0001 014a 0000      # EV_KEY / BTN_TOUCH            0
E: 0.105005 0001 0145 0000      # EV_KEY / BTN_TOOL_FINGER      0
E: 0.105005 0003 0039 0074      # EV_ABS / ABS_MT_TRACKING_ID   74
E: 0.105005 0003 0035 8388      # EV_ABS / ABS_MT_POSITION_X    8388
E: 0.105005 0003 0036 4480      # EV_ABS / ABS_MT_POSITION_Y    4480
E: 0.105005 0001 014a 0001      # EV_KEY / BTN_TOUCH            1
E: 0.105005 0001 0145 0001      # EV_KEY / BTN_TOOL_FINGER      1
E: 0.105005 0003 0000 8388      # EV_ABS / ABS_X                8388
E: 0.105005 0003 0001 4480      # EV_ABS / ABS_Y                4480
E: 0.105005 0000 0000 0000      # ------------ SYN_REPORT (0) ---------- +19ms

This is a kernel bug but let's paper over here because otherwise we crash and
that's considered impolite.

Fixes #161

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-10-15 14:46:53 +10:00
Peter Hutterer
df1f6ba40f touchpad: avoid motion events when moving one finger into AREA
If a 2fg scroll motion starts with both fingers in the bottom button area and
one finger moves into the main area before the other, we used to send motion
events for that finger. Once the second finger moved into the main area the
scroll was detected correctly but by then the cursor may have moved out of the
intended focus area.

We have two transitions where we may start sending motion events: when we move
out of the bottom area and when the finger moves by more than 5mm within the
button area. In both cases, check for any touches that are in the
bottom area and started at the 'same' time as our moving touch. Mark those as
'moved' to release them for gestures so we get the right finger count and
axis/gesture events instead of just motion events.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-10-04 10:44:55 +10:00
Peter Hutterer
655f565fba touchpad: if two fingers are within the lower thumb area, they're not thumbs
The shape of the average hand implies that two fingers down within the lower
thumb area (the bottom few mm of the touchpad) cannot be thumbs without
significant contortion. So let's not mark them as thumb.

Fixes #126

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-10-03 14:52:36 +10:00
Peter Hutterer
a8e3f4d1a5 touchpad: ignore motion speed for hovering touches
tp_detect_thumb_while_moving() assumes that of the 2 fingers down, at least
one must be in TOUCH_UPDATE, otherwise we wouldn't have a speed to analyze for
thumb.

If a touch starts in HOVERING and exceeds the speed limit, we were previously
increasing the 'exceeded count'. This later leads to an assert() in
tp_detect_thumb_while_moving() when the second finger comes down because
although we have multiple fingers, none of them are in TOUCH_UPDATE.

This only happens when fingers 2 and 3 come down in the same event frame,
because then we have nfingers_down at 2 (the hovering one doesn't count) but
we don't yet have a finger in TOUCH_UPDATE.

Fix this twofold, first by now calculating the speed on anything but
TOUCH_UPDATE. And second by force-resetting the speed count on
TOUCH_BEGIN/TOUCH_END so we definitely cover all the hover transitions.

Fixes #150

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-10-02 22:32:55 +00:00
Peter Hutterer
65f890a352 test: abort when we detect a touch jump during the tests
We never want to accidentally trigger this one. Where we trigger them on
purpose, we can swap the log handler out first.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-28 11:26:12 +10:00
Peter Hutterer
7768d7d981 test: drop the sleep_ms argument
This forces events for every ~10ms now. If we want a slower movement, we need
more steps - just like a real touchpad does it.

Cocinelle spatch files were variants of:
	@@
	expression A, B, C, D, E, F, G, H, I, J, K;
	@@

	- litest_touch_move_two_touches(A, B, C, D, E, F, G, H, I)
	+ litest_touch_move_two_touches(A, B, C, D, E, F, G, H)

The only test that needed a real fix was touchpad_no_palm_detect_2fg_scroll,
it used 12ms before, now it's using 10ms so on the bcm5974 touchpad the second
finger was a speed-thumb. Increasing the events and thus slowing down the
pointer means it's a normal finger and the test succeeds again.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-28 11:26:12 +10:00
Peter Hutterer
20a9c38db0 test: force 10ms intervals for touch moves, unless specified otherwise
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-28 11:26:12 +10:00
Peter Hutterer
bdc7ef8bb2 test: change a few tests to use 10ms intervals
Change a number of tests to use 10ms intervals between finger events and fix
the coordinates up accordingly to avoid pointer jumps. This is in preparation
for a test-suite wide use of 10ms intervals.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-28 11:26:08 +10:00
Peter Hutterer
35b100a2ef test: make the touchpad jump test more robust for timing errors
move_to() now uses delays, let's make this test more robust for timing errors
so we don't fall below the threshold movement we want to trigger.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-28 10:51:04 +10:00
Peter Hutterer
974425f8b7 test: don't run the 2fg pressure tap test on single-touch devices
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-28 10:50:15 +10:00
Peter Hutterer
edd336b4f8 test: fix the late tripletap test
The coordinates ended up being in the first touch detected as palm. Not
relevant for this test, but let's not do that to avoid false positives.
Also change to 10ms intervals, more realistic given the hardware.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-28 10:50:15 +10:00
Peter Hutterer
3b97de9a43 test: rename the diagonal scroll test for more clarity
This one only starts with diagonal but continues vertically. Make it clearer.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-27 17:21:45 +10:00
Peter Hutterer
f9b1875ab4 test: fix a DWT test, only worked because of timing success
This test only succeeded because all events were sent within the dwt timeout.
Change it to actually test the behavior of a touch being disabled by DWT and
staying disabled.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-27 17:21:45 +10:00
Peter Hutterer
b9b4065cda test: drop two erroneous checks in the dwt tests
These only succeeded because the test suite doesn't use frame intervals - as
soon as the time between event frames is nonzero, we may fail these.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-27 17:21:45 +10:00
Peter Hutterer
eca2f8c9c6 touchpad: improve pointer jump detection
Previously, we had a hard threshold of 20mm per event frame. That is just
about achievable by really fast movements (in which case you don't care too
much about the jumps anyway because you've already hit the edge of the screen).

Sometimes pointer jumps have lower deltas that are achievable even on slower,
more likely motions. Analysis of finger motion has shown that while a delta
>7mm per event is possible, jumping _by_ 7mm between two events is unlikely
and indicates a pointer jump. So let's diff the most recent delta and the
current delta, if it increases by 7mm between two event frames let's say it's
a pointer jump and discard it.

Helps with but does not fully resolve:
https://gitlab.freedesktop.org/libinput/libinput/issues/80
https://gitlab.freedesktop.org/libinput/libinput/issues/36

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-20 10:23:21 +10:00
Peter Hutterer
13bda5adcb touchpad: if a finger in the button area moves by more than 5mm, release it
The software button area is currently a partially-dead area. If the finger
moves into or out of the area pointer motion works. Finger motion within the
area however does not generate motion.

The main motivation for this was to avoid accidental pointer motion when a
button is pressed. This is required for stationary fingers but once you move a
significant distance, those bets are off.

So if the finger moves by more than 5mm from where it was put down, release it
and let it move the pointer.

The full impact is largely limited to horizontal movements within the button
area because:
- leaving the finger at the bottom area for 300ms without movement triggers
  the thumb identification, so it won't move anyway.
- moving the finger north is likely to go off the button area before we
  trigger this threshold.

https://gitlab.freedesktop.org/libinput/libinput/issues/86

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-13 13:36:40 +10:00
Matt Mayfield
916474b09c test: touchpad: add tests for 90 degree scroll (axis lock) 2018-08-08 11:28:30 -05:00
Peter Hutterer
28fc00b5f7 test: add a 10ms delay for scrolling tests
No touchpad gives us these events with a 0 delay, so let's not test for that.

This is required for adding timing-sensitive scroll code, see
https://gitlab.freedesktop.org/libinput/libinput/issues/101.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-07 10:29:09 +10:00
Peter Hutterer
531b1bf8de test: touchpad: swap an int for a bool
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-07 10:00:40 +10:00