Commit graph

1460 commits

Author SHA1 Message Date
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
Peter Hutterer
2d11182689 test: assume Wacom devices are external touchpads
Same as the code itself does.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-16 11:58:14 +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
a1ab4757a4 test: don't use ck_assert_ptr_null
Breaks the build on Ubuntu which ships check 0.10.0 from pre-Dec 2016.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-03 15:16:33 +10:00
Peter Hutterer
1e4c5a93a8 util: add a strv_join() helper function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-03 12:31:30 +10:00
Peter Hutterer
4277d63bc6 Merge branch 'wip/custom-pointer-acceleration-function-v2' 2018-05-02 10:53:08 +10:00
Peter Hutterer
63e5372190 Add libinput_device_touch_get_touch_count()
This makes it possible for callers to detect whether a touch device is
single or multitouch (or even check for things like dual-touch vs real
multi-touch) and adjust the interface accordingly.

Note that this is for touch devices only, not touchpads that are just pointer
devices.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-01 09:38:24 +10:00
Peter Hutterer
59eb10e593 util: allow for palm pressure > 255
https://bugs.freedesktop.org/show_bug.cgi?id=105753

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-30 11:18:07 +10:00
Peter Hutterer
c0fd857def touchpad: fix the trackpoint event counter for the T460s
Introduced in 416fa44d80 but there was a logic
error: we claimed to require 3 events from a trackpoint before stopping the
touchpad but the timer was only set when we actually stopped the touchpad. So
if a trackpoint sends a single event every second, we'd disable the touchpad
after 3 seconds for the duration of the timeout, then again 3 seconds later,
etc.

Fix this by always setting the timeout and resetting the event counter if no
activity happened.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-27 16:37:10 +10:00
Peter Hutterer
f6d61dc314 touchpad: allow custom profiles on touchpads
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-26 14:48:37 +10:00
Peter Hutterer
bd04826aa4 util: add a helper function to split a key-value pair string
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-26 14:48:37 +10:00
Peter Hutterer
25d309bde7 test: print the device name for a wrong event
So we can rule out any between device race conditions

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-20 14:25:57 +10:00
Peter Hutterer
dec1b4f93c test: print the full event in case of a mismatch
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-20 14:25:54 +10:00
Peter Hutterer
80c3a100de touchpad: ignore any semi-mt movement in the same frame as a finger release
Semi-MT devices provide a bounding box of the fingers, and internally we don't
treat them as real MT device. Depending which finger currently provides
ABS_X/Y we may get a large jump when the other finger is released.
Basic sequence is finger 1 down, finger 2 down, finger 1 up.
On the last interaction, the ABS_X/Y which was on finger 1's coordinates now
jumps to finger 2's coordinates. This is interpreted as movement by the
tapping code, resulting in missed two-finger taps.

Ignore these movements on semi-mt devices.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-20 09:41:21 +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
2857cfe87d test: use a udev monitor to wait for a device to disappear
Reduces potential race conditions.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-18 14:36:31 +10:00
Peter Hutterer
fb8a5b040a test: replace a strcmp with streq
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-18 14:36:31 +10:00
Peter Hutterer
358acb5747 test: remove double check for empty queue
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-18 14:36:31 +10:00
Peter Hutterer
08d85350cb test: add a test for a touchscreen with out-of-range axes
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-16 17:04:46 +10:00
Peter Hutterer
b2fb2adefa Remove some duplicate empty lines
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-16 15:14:23 +10:00
Peter Hutterer
1531c9dc88 test: call K_OFF when run on the vt
Slight disadvantage: this breaks Ctrl+C to cancel the test suite. Still
potentially better than injecting random events into your vt.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2018-04-06 10:35:36 +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
75aee30919 test: add a script to check for leftover litest rules
An aborted test run can sometimes leave udev rules as detritus. Test for that
so we don't get test case failures triggered by those rules.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-23 12:41:23 +10:00
Peter Hutterer
1e9925735a test: reliably sort the udev rules
This guarantees the device rules have a static order between test runs.
Previously and in some cases, the temporary file name could affect the order
of the udev rules - let's not do that.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-23 10:17:52 +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
4937f63a1d test: drop the * from the Lid Switch test device udev rule match
This is the cause of the random test case failures. Because the rule for this
device would also match on the Surface3 lid switch test device it comes down
to whatever mkstemps() picked as the unique characters. When the Surface3
sorted later, everything worked, otherwise it would fail.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-21 14:08:06 +10:00
Peter Hutterer
ab59264bb3 test: fix vert axis printing on error
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-21 10:18:45 +10:00
Peter Hutterer
fd1cb049da test: disable the second-finger-move test for semi-mt devices
Having only one finger move (and the second finger at that) in semi-mt device
is not something we can realistically support. We disable the mt axes and
treat semi-mts as single-touch devices, so we don't actually get those events.

The only reason this test passed is because we release the first touch first
here, causing a ABS_X/Y shift that exceeded the motion threshold.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-15 19:06:44 +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
2ab233857d touchpad: handle a palm down in the tapped state
We expected the first event after TAPPED to be a finger down. If that finger
has been recognised as palm, the finger state isn't TOUCH_BEGIN so we get an
invalid state in our FSM.

  libinput bug: 0: invalid tap event TAP_EVENT_PALM in state TAP_STATE_TAPPED

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-07 11:07:54 +10:00
Peter Hutterer
96fd84ebc9 pad: use libwacom to get the evdev to button number mapping
Some of wacom's tablets, notably the Bamboo series, have a non-predictable
scheme of mapping the buttons to numeric button numbers in libwacom. Since we
promise sequential button numbers, we need to have those identical to
libwacom, otherwise it's impossible to map the two together.

Most tablets have a predictable mapping, so this does not affect the majority
of devices.

For the old-style bamboos, this swaps the buttons around with the buttons
being ordered vertically top-to-bottom in libwacom.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Jason Gerecke <jason.gerecke@wacom.com>
2018-03-05 15:00:03 +10:00
Peter Hutterer
8f688be749 test: don't use litest_is_pad_button_event for a few tests
That function requires us to know which button we're testing for. Because of
the upcoming libwacom changes, we don't know which button we're about to get,
especially on the bamboos. Use the standard libinput functions to get to the
libinput event instead, we don't care about the button numbers here anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-05 14:56:56 +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
3979b9e16a touchpad: don't end below-threshold pressure touches if nfake_fingers > nslots
If we have more BTN_TOOL_*TAP fingers down than we have slots, ignore any
below-threshold pressure changes on the slots. When a touchpad only detects
two touches, guessing whether the third touch has sufficient pressure is
unreliable. Instead, always assume that all touches have sufficient pressure
when we exceed the slot number.

Exception: if all real fingers are below the pressure threshold, the fake
fingers are ignored too.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-01 12:24:19 +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
990da54aa6 test: don't run the MT pressure test on devices without MT pressure
This test worked because on devices that don't use pressure the touches were
reset when BTN_TOUCH when to 0, triggering the 'ignore fake fingers when no
real fingers are down' behavior. But this is a different code path than the
pressure handling, so let's separate those tests.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-01 12:21:21 +10:00
Peter Hutterer
4eb420b16e test: fix an incomplete comment
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-28 17:43:30 +10:00
Peter Hutterer
2a378beab0 touchpad: delay arbitration by 90ms after touch toggle
When drawing on a tablet, the hand usually rests on the device, causing touch
events. The kernel arbitrates for us in most cases, so we get a touch up
and no events while the stylus is in proximity. When lifting the hand off in a
natural position, the hand still touches the device when the pen goes out of
proximity. This is 'immediately' followed by the hand lifting off the device.

When kernel pen/touch arbitration is active, the pen proximity out causes a
touch begin for the hand still on the pad. This is followed by a touch up when
the hand lifts which happens to look exactly like a tap-to-click.

Fix this by delaying the 'arbitration is now off' toggle, causing any touch
that starts immediately after proximity out to be detected as palm and
ignored for its lifetime.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-21 15:58:35 +10:00
Peter Hutterer
01a633b6eb touchpad: only begin fake touches when we have at least one finger down
If a single-touch touchpad drops below the pressure threshold in the same
frame where a fake finger is added, we begin a fake touch here. The subsequent
loop ends this fake touch because real_fingers_down is 0.

This causes the tapping code to have a mismatch of how many fingers are down
because it never sees the touch begin event for that finger.

https://bugs.freedesktop.org/show_bug.cgi?id=105160
2018-02-20 15:48:06 +10:00
Peter Hutterer
8f71cb40fe test: send major/minor for the wacom intous 5 finger device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-20 15:48:06 +10:00
Peter Hutterer
dd096a50fe touchpad: add a touch index for debugging
Makes debugging a bit easier when you know *which* touch was marked as palm,
etc.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-20 15:45:01 +10:00
Peter Hutterer
63880d6e1b udev: fix segfault when resuming before assigning a seat
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-16 16:57:30 +10:00
Peter Hutterer
582e3c00b7 Add a test device for aiptek tablets
This tablet advertises tilt but doesn't actually have it. Let's rule out tilt
for all aiptek devices until someone complains.

Recording from: https://bugzilla.redhat.com/show_bug.cgi?id=1535755
Related to: https://bugs.freedesktop.org/show_bug.cgi?id=104911

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-13 16:04:58 +10:00
Peter Hutterer
44426b460c tablet: release the tablet state on device delete
When the device gets deleted in a non-neutral state, we need to release all
buttons, lift the tip up and send a proximity out event.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-13 16:04:08 +10:00
Peter Hutterer
134893790e test: make the mouse tool a litest feature bit
Aiptek tablets have the BTN_TOOL_MOUSE|LENS bits but don't actually have a
mouse, at least not in libinput (see future patches). Turns out we only have
one device that really has the tool anyway, so not running the tests for the
others seems sensible.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-13 16:04:08 +10:00
Peter Hutterer
3a3fd645c4 evdev: add a quirk to disable debouncing on the MS Nano Transcievers
A set of wireless devices that can scramble the timestamps, so we get
press/release within 8ms even though I doubt the user is capable of doing
this. Since they're generally good quality anyway, let's just disable
debouncing on those until someone complains and we need something more
sophisticated.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-13 15:58:48 +10:00
Peter Hutterer
76cda659b7 test: add a missing proximity timeout in a tip up test
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-07 10:06:29 +10:00
Peter Hutterer
d4b76be18b evdev: log all evdev_msg_* on one line
So we don't have to have newline handling in the callers. This effectively
reverts 6ab2999be9 "test: detect linebreaks in log messages".

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2018-02-06 19:29:26 +10:00
Peter Hutterer
b8bef106c0 test: swap KEY_POWER for KEY_VOLUMEUP on the switch key routing test
If there's anything that listens for KEY_POWER it will likely shut down or
suspend the host. Since it doesn't matter whether we're really testing for
KEY_POWER or just any other key, let's just switch it and avoid one headache.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-05 17:49:04 +10:00