Commit graph

1770 commits

Author SHA1 Message Date
Davide Depau
5feaa5f00c evdev: don't suspend keyboard on ThinkPad X1 Yoga 1st in tablet mode
When the X1 Yoga is in tablet mode, one capacitative touch button (windows
key, sends KEY_LEFTMETA) and two side volume buttons are accessible on the
front. The key event comes through the internal keyboard that we disabled in
tablet mode so it stops working.

Luckily the Yoga physically disables the "main" keyboard when in tablet mode,
so all we have to do is skip our code to disable the keyboard and the keys are
working again.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-18 14:36:31 +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
b0a0627ae2 evdev: add a run-time check to avoid re-using model flags
Only runs on the LIBINPUT_MODEL_* flags, the ID_INPUT_TRACKBALL flag is an
exception.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-13 09:31:45 +10:00
Peter Hutterer
f37c1dc66a evdev: remove duplicate MODEL entry in the model parsing
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-13 09:30:33 +10:00
Peter Hutterer
23614f7551 debounce: disable debouncing on the Logitech K400
This is an external keyboard+touchpad but not recognised as touchpad by the
kernel so it's in mouse emulation mode. Double-taps are sent with impossibly
close timestamps and filtered out by the debouncing code. Since this isn't a
real button that can wear out anyway, let's just disable debouncing on this
device.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-13 09:29:36 +10:00
Peter Hutterer
7525aea272 evdev: return an error if the profile change failed
If we get to this point, we've already ruled out invalid arguments and this
shouldn't really fail, so let's reply with UNSUPPORTED instead.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-12 11:45:58 +10:00
Peter Hutterer
fde4255f29 evdev: break up a long line
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-12 11:45:55 +10:00
Tim Richardson
dd6059aefc evdev: fix duplicated flag value
edit: Luckily there's no overlap between the users of those two flags so this
didn't trigger any bugs.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-12 08:48:22 +10:00
Peter Hutterer
8eb41b432e doc: axis overrides need to go to systemd, not libinput
And remove the double-slash in the error message pointing here.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-10 08:00:35 +10:00
Peter Hutterer
24963d4e45 Fix a doxygen link for the get_default_matrix call
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-06 08:18:33 +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
794391cb51 touchpad: log the touch size thresholds if we're using them
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-05 11:05:14 +10:00
Nandor Han
23d543b711 udev: validate input devices during cold-plug
During libinput initialization a list of existing input devices is
retrieved from udev. This can lead to a situation where libinput can
end up processing un-configured devices because of the race generated
by udev events and libinput startup.
Sequence example:
weston - start
udev - device 1 added
weston - get a list of input devices
weston - process device 1 -- undefined behavior
udev - device 1 added - finalized

The problem was found because of incorrect touchscreen association
when in a dual monitor system the secondary touchscreen was
incorrectly associated with output one since udev didn't finish the
device initialization and WL_OUTPUT was missing.

To avoid this situation we skip un-configured devices during libinput
initialization, relying on udev to send events when devices are
fully configured.

Note: due to the peculiarities of udev_device_get_is_initialized(), the
input device is still processed if the call fails. If there are no udev
rules defined for the device, it will never be reported as initialized,
but this is not a problem, because all input devices handled by libinput
must have some udev properties set, therefore they always have rules.

Signed-off-by: Nandor Han <nandor.han@ge.com>
[Pekka: change log to debug, unref device]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-05 09:38:36 +10:00
Peter Hutterer
f2b1eed976 evdev: point users to the trackpoint documentation for missing ranges
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-23 13:38:07 +10:00
Peter Hutterer
8dff0dfe02 evdev: add another debug message for the trackpoint sensitivity
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-23 13:38:07 +10:00
Peter Hutterer
419db83dad tablet: add missing space in an error message
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
5883ac7d98 touchpad: make sure we compare only the last 3 events for wobble
We're left-shifting the bits but weren't comparing against the l_r_l mask
itself. So if we get a sequence of [1, 1, 0, 1] we didn't detect a wobble
because 0b1101 != 0b101 (what we're looking for).

Fix this by turning it into a right shift, that way the bits fall off
the mask automatic
                  al
                    ly
                      y
                      y
                      y
                      y
                     .  .
                   _._v.___

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-13 10:04:02 +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
d8db6b5927 touchpad: end hovering touches in maybe_end_touch
Otherwise a hovering touch stays around forever even after the finger has
discontinued. This doesn't matter on slots, but for fake fingers the finger
may suddenly end up being forced down/up as a result of the pressure changes
on the real fingers.

So when in maybe_end_touch, switch them back to NONE immediately - hovering
touches do not need to trigger a TOUCH_END event.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-12 11:41:14 +10:00
Peter Hutterer
49a8bd3ca7 Merge branch 'wip/hysteresis-wobbles' 2018-03-09 10:17:43 +10:00
Peter Hutterer
1523d8bb2e Extract and reset the abs fuzz value for the x/y axes
The kernel fuzz handling is buggy, especially when we want to rely on the fuzz
value for our hysteresis. But since this is a hw property and (at least
sometimes) set by the driver, we can't make this a pure libinput hwdb set
either.

So our workaround is:
* extract the (non-zero) fuzz into a udev property so we don't lose it
* set the fuzz to 0 to disable the in-kernel hysteresis
* overwrite our internal absinfo with the property fuzz

This way we get to use the hw-specified fuzz without having the kernel muck
around with it. We also get to use the EVDEV_ABS_ values in 60-evdev.hwdb to
override a driver-set fuzz.

Two drawbacks:
- we're resetting the kernel fuzz to 0, this affects any other users of the
  device node. That's probably a minor impact only.
- we can only save this in a udev property there's a risk of this information
  getting lost when playing around with udev rules. That too should be a minor
  issue.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-09 09:49:54 +10:00
Peter Hutterer
1b64888a22 touchpad: enable hysteresis based on a 0 fuzz value
If the fuzz is 0, assume we don't need hysteresis and use the wobble detection
code instead. If the fuzz is non-zero, enable it by default.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-09 09:49:54 +10:00
Peter Hutterer
ea7498ef97 touchpad: use the fuzz value (if any) for the hysteresis margin
We currently used 0.5mm on touchpads as hysteresis value. This causes pointer
movement delays, it is likely too high. Reduce it to a kernel-set fuzz value
(if any) and see how we go with that. On many touchpads, the fuzz is 8 which
would be closer to 0.2mm on e.g. a T440.

Note that the does some defuzzing anyway, but the response of that function is
nonlinear, e.g. for a fuzz of 8, the physical deltas map to:

phys 0..3  → delta 0
phys 4..7  → delta 1
phys 8..15 → delta 4, 5, 6, 7
phys 16..N → delta 16..N

In other words, we never see some logical deltas 2 and 3. While this shouldn't
matter given the average touchpad resolution, reducing the hysteresis margin
is likely to provide some better response. We never see values 8-15 either
which could be the cause of some pointer jumps we've been seeing.

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

Devices with a fuzz of 0 have the hysteresis margin reduced to 0.25mm (from
0.5mm).

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-09 09:49:54 +10:00
Peter Hutterer
50418a0153 fallback: fix touchscreen defuzzing
The hysteresis-returned point always differs from the current point, even if
the hysteresis kicks in. We need to compare to the hysteresis center.

And the returned point is only the new center if we exceed the margin,
otherwise the center stays as-is.

The touch_fuzz() test only succeeded for this because for the values we were
introducing jitter by, the kernel filtered out all the actual movement so
these paths weren't hit.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-09 09:49:54 +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
cd63ba2cc0 tools: add the git version in the libinput-record output
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-06 14:22:30 +10:00
Peter Hutterer
a437d9374b touchpad: enable palm detection on tablets' touchpads
https://bugs.freedesktop.org/show_bug.cgi?id=104986

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-05 15:51:17 +10:00
Peter Hutterer
b1ddd1effe touchpad: init touch size range based on the udev property
No need to hardcode Apple here, if we have a udev property for this, let's use
it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-05 15:22:13 +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
Daniel van Vugt
6936a15558 Introduce omnidirectional (elliptical) hysteresis
This changes the hysteresis region to an ellipse (usually a circle), where
previously it was a rectangle (usually square).

Using an ellipse means the algorithm is no longer more sensitive in some
directions than others. It is now omnidirectional, which solves a few
problems:
  * Moving a finger in small circles now creates circles, not squares.
  * Moving a finger in a curve no longer snaps the cursor to vertical
    or horizontal lines. The cursor now follows a similar curve to the
    finger.

https://bugs.freedesktop.org/page.cgi?id=splinter.html&bug=105306

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-05 10:40:48 +10:00
Peter Hutterer
440d94be57 Merge branch 'wip/touchpad-maybe-end-state' 2018-03-05 08:26:47 +10:00
Konstantin Kharlamov
400aadd53a touchpad: add wobbling detection
The details are explained in comment in the code. That aside, I shall
mention the check is so light, that it shouldn't influence CPU
performance even a bit, and can blindly be kept always enabled.

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

Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
2018-03-02 08:58:36 +10:00
Konstantin Kharlamov
e8dffbd73a touchpad: remove the code for disabling hysteresis
Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
2018-03-01 16:35:13 +10:00
Peter Hutterer
e43bd4ae3a touchpad: move the hysteresis into its own substruct
Prep work for the wobbling detection patch

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
2018-03-01 16:34:24 +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
85e5d80cd4 touchpad: add the pressure thresholds to the debugging output
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-01 12:23:45 +10:00
Peter Hutterer
39b806089c touchpad: don't do speed-based thumb detection on single-touch or semi-mts
Because life is too short for this

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-01 11:23:07 +10:00
Peter Hutterer
601a18a602 Whitespace fix
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-27 14:36:08 +10:00
Peter Hutterer
3e77f2e9f5 evdev: remove excessive debugging output
Accidentally committed in 2a378beab0

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-23 10:47:08 +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
56fd071412 evdev: pass the time down to toggle_touch
Currently unused, will be used in later patches

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-21 15:13:08 +10:00
Peter Hutterer
da74aab7f7 touchpad: change the stylus palm arbitration to process touches
Previously, on touch toggle (invoked by the tablet when a pen goes in
proximity) the touchpad cleared the state and ignored any events. Since we
ignore touches that we didn't see the touch begin for, this handled the cases
of a touch remaining after proximity out.

This code pre-dates palm detection, so let's take the bluetack off and instead
integrate it with proper palm detectino.
2018-02-21 15:13:08 +10:00
Peter Hutterer
402b179bc7 touchpad: reset the palm state to NONE on a new touch
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-21 15:13:08 +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
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
6020ce7c9f touchpad: compress a statement
Having this initialized and then changed later is more confusing that having
the trinary here in one line
2018-02-20 13:00:24 +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
075e998b07 Don't leak when realloc fails
Found by coverity

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-16 16:57:30 +10:00