Commit graph

360 commits

Author SHA1 Message Date
Peter Hutterer
1cfa1f64cf evdev: read LIBINPUT_ATTR_KEYBOARD_INTEGRATION property
We have heuristics for detecting whether a keyboard is internal or external,
but in some cases (e.g. Surface 3) these heuristics fail. Add a udev property
that we can apply to these cases so we have something that's reliable.

This will likely eventually become ID_INPUT_KEYBOARD_INTEGRATION as shipped by
systemd, similar to the touchpad property.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-05-23 15:10:10 +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
9d1fdb0c6d touchpad: remove the lid switch listener on device_removed
Sequence triggered by the xorg driver, but basically: if the touchpad is
destroyed before the lid switch, the event listener wasn't removed and an
assertion was triggered.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-05-05 12:50:04 +10:00
Peter Hutterer
fc470291f1 Merge branch 'wip/touchpad-tap-timestamps' 2017-05-04 11:51:36 +10:00
Marcos Paulo de Souza
8584c044da touchpad: make use of use tp_for_each_touch
Instead of reimplementing a for loop every time.

Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-05-03 12:38:15 +10:00
Peter Hutterer
ea4332a6cf touchpad: add touch state debugging helper
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-04-28 15:37:00 +10:00
Peter Hutterer
3ecdab130a Merge branch 'wip/touchpad-custom-pressure-values' 2017-04-26 12:38:28 +10:00
Peter Hutterer
8d5f4decb4 touchpad: move the pressure range to a hwdb entry
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-04-26 12:38:15 +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
7d1a047b7c touchpad: add helper function for stopping current actions
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-04-21 10:03:16 +10:00
Peter Hutterer
76fce6cddd touchpad: move edge palm init to separate helper
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-04-21 10:03:16 +10:00
Peter Hutterer
160d60eb85 touchpad: always enable trackpoint palm detection
Trackpoints are situated so that a user is pretty much guaranteed to trigger
some palm interaction, even if on a small touchpad. Always enable trackpoint
monitoring on touchpads where required.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-04-21 10:03:16 +10:00
Peter Hutterer
5a63c82822 touchpad: make palm detection logging a bit easier
Nested trinary conditions are fun, but...

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-04-21 10:03:16 +10:00
Peter Hutterer
ddcf1f61bf touchpad: move edge palm detection into a helper too
Just code cleanup, no changes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-04-21 10:03:16 +10:00
Peter Hutterer
b4bb28caeb touchpad: don't try to unhover touches in NONE state
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-03-29 11:13:23 +10:00
Peter Hutterer
3afe8bc914 touchpad: add touchpad pressure state debugging to debug output
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-03-23 10:17:07 +10:00
Peter Hutterer
25b14e1335 evdev: mark the new log functions as printf-style functions
And fix up the one buggy call we had

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-03-23 07:30:08 +10:00
Peter Hutterer
17e9dfd0d1 touchpad: add pressure ranges for cyapa touchpads
https://bugs.freedesktop.org/show_bug.cgi?id=100122

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2017-03-23 07:29:36 +10:00
Peter Hutterer
957f8ec2f1 touchpad: add elantech-specific pressure values
https://bugs.freedesktop.org/show_bug.cgi?id=99975

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2017-03-08 06:49:38 +10:00
Peter Hutterer
6181adbdcd evdev: standardize log messsages
Prefix device log messages with the device's sysname so it's more obvious
where the messages are coming from. This makes it much easier to grep for a
specific device's messages but also adds some identifier to messages that
were previously without any identifier (e.g. all the state machine debugging)

All info and error messages also automatically prefix the device name, so
those messages are standardised too, e.g

an info message now:
  event4  - SynPS/2 Synaptics TouchPad: is tagged by udev as: Touchpad
a debug message now:
  event4  - using pressure-based touch detection

And since this required changing a lot of the strings in messages anyway,
polish a few minor things too.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Hans de Goede <hdegoede@redhat.com>
2017-02-24 16:04:44 +10:00
Peter Hutterer
7c3279346d touchpad: drop 'is blacklisted' check for dwt pairing
dwt is needed on internal touchpads only and those external ones that are a
combo device. This also now gives us the same check for palm detect and dwt.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2017-02-13 08:29:20 +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
00d6b908d3 Merge branch 'touchpad-pressure-based-v2' 2017-02-03 11:41:06 +10:00
Peter Hutterer
45d7794de2 Merge branch 'wip/switch-interface' 2017-02-01 13:56:32 +10:00
Peter Hutterer
92ce7b2f1f touchpad: remove unnecessary return statement
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-31 12:46:51 +10:00
Peter Hutterer
2dc6534ec0 evdev: add a wrapper to get the evdev device from a libinput device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-31 08:00:58 +10:00
Peter Hutterer
60de087e65 evdev: improve type-safety on dispatch switches
Set the dispatch type on creation, then check that whenever we try to get the
dispatch struct. This avoids a potential mismatch between the backends.

Plus, use of container_of means we're not dependent on the exact layout
anymore.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-31 07:36:12 +10:00
Peter Hutterer
568d527caa touchpad: use pressure values for touch is-down decision
Don't rely on BTN_TOUCH for "finger down", the value for that is hardcoded in
the kernel and not always suitable. Some devices need a different value to
avoid reacting to accidental touches or hovering fingers.

Implement a basic Schmitt trigger, same as we have in the synaptics driver. We
also take the default values from there but these will likely see some
updates.

A special case is when we have more fingers down than slots. Since we can't
detect the pressure on fake fingers (we only get a bit for 'is down') we
assume that *all* fingers are down with sufficient pressure. It's too much of
a niche case to have this work any other way.

This patch drops the handling of ABS_DISTANCE because it's simply not needed
anymore.

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
87f3ea760c touchpad: check for a switch type before handling the event
Don't call get_switch_event immediately, doing so for non-switch events is
documented as a bug. Check the event type instead, if that one is correct then
we can assume the rest works.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-26 14:44:04 +10:00
James Ye
f1cf83425e Pair touchpad and lid_switch for disable
Add listener for lid switch events, disable touchpad on switch event.

Signed-off-by: James Ye <jye836@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-26 14:44:04 +10:00
Peter Hutterer
b2109ca535 touchpad: use a helper function for the libinput context
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-25 17:08:51 +10:00
Peter Hutterer
a64f9df5ce Drop normalized_get_direction, use physical distances instead
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2017-01-23 10:43:04 +10:00
Peter Hutterer
33d708e2de touchpad: convert normalized_length to physical coordinates
Now that the acceleration code doesn't use dpi-normalized coordinates anymore,
we don't need to use them in the touchpad code. Switch to physical distances
instead, it makes debugging a lot saner.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2017-01-23 10:37:08 +10:00
Peter Hutterer
43352590f7 touchpad: mask out ABS_MT if we don't have or disable MT
Make sure the events we deal with are the ones we actually honor. This reduces
the chance that we accidentally process events we weren't event supposed to
get based on some earlier device decision.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2017-01-23 10:00:48 +10:00
Peter Hutterer
acbbe882a2 Merge branch 'touchpad-pointer-accel-revamp' 2016-12-21 11:34:37 +10:00
Peter Hutterer
bdd4264d61 filter: change the filter functions to take raw device coordinates
We used to normalize all deltas to equivalents of a 1000dpi mouse before
passing it into the acceleration functions. This has a bunch of drawbacks, not
least that we already have to un-normalize back into device units for a few
devices already (trackpoints, tablet, low-dpi mice).

Switch the filter code over to use device units, relying on the dpi set
earlier during filter creation to convert to normalized. To make things easy,
the output of the filter code is still normalized data, i.e. data ready to be
handed to the libinput caller.

No effective functional changes. For touchpads, we still send normalized
coordinates (for now, anyway). For the various filter methods, we either drop
the places where we unnormalized before or we normalize where needed.

Two possible changes: for trackpoints and low-dpi mice we had a max dpi factor
of 1.0 before - now we don't anymore. This was only the case if a low-dpi
mouse had more than 1000dpi (never true) or a trackpoint had a const accel
lower than 1.0 (yeah, whatever).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-12-21 10:55:57 +10:00
Peter Hutterer
db9cfc9c5c touchpad: init the device's dpi correctly
This has no real effect just yet because we don't use a touchpad's dpi
anywhere in the touchpad code. Only the acceleration code wants it but all
touchpads use the same acceleration method, and that one doesn't care about
the dpi.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-12-21 10:55:56 +10:00
Peter Hutterer
0a82d2fa39 touchpad: if an external touchpad and keyboard share a VID/PID assume dwt
This requires to expand the blacklisting to be a bit more specific so we don't
initialize dwt config on devices that won't need it.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-12-20 10:21:43 +10:00
Peter Hutterer
eacdf296a5 touchpad: convert two functions to use the device->phys helpers
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-12-14 15:19:50 +10:00
Peter Hutterer
2a16c522b9 touchpad: constify a few helper functions
May help the compiler with further optimization

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-12-14 15:19:47 +10:00
Peter Hutterer
5552a6f145 touchpad: sync BTN_TOOL_FINGER state on init
The Elantech touchpad on my Asus Vivobook doesn't release BTN_TOOL_FINGER on
up. If the touchpad was used before libinput initializes, the kernel filters
the event because its state is already set. We never receive it and keep
ignoring all events until the first switch to BTN_TOOL_DOUBLETAP and back.

On touchpad init sync the BTN_TOOL_FINGER state and set it accordingly. This
is the only event that can be legitimately down on init. We don't care about
BTN_TOUCH because ignoring an ongoing touch on init is generally a good idea
and we can ignore any multifinger gesture as well.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-12-06 07:28:15 +10:00
Peter Hutterer
996b845d68 touchpad: add a quirk for the HP Pavilion dm4
This touchpad has cursor jumps for 2-finger scrolling that also affects the
single-finger emulation. So disable any multitouch bits on this device and
disallow the 2-finger scroll method. This still allows for 2-finger
tapping/clicking.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-12-01 06:24:07 +10:00
Peter Hutterer
4bb3da4115 evdev: init axis range warnings for touch devices too
Move the code from the touchpad code into the more generic evdev code

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-11-30 08:54:00 +10:00
Peter Hutterer
cfdaaa32a7 touchpad: only use the last two coordinates for delta calculation
Taking the last 4 points means factoring in a coordinate that may be more than
40ms in the past - or even more when the finger moves slowly and we don't get
events for a while. This makes the pointer more sluggish and slower to catch up
with what the finger is actually doing.

We already have the motion hysteresis as a separate item to prevent jumps (and
thus adds some delay to the movement), the calculation over time doesn't
provide enough benefit to justify the sluggish pointer.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-11-23 10:42:57 +10:00
Peter Hutterer
3ef9b7fea5 touchpad: check for trackpoint/keyboard at the top of the helpers
No functional changes, just to filter out devices that don't match
immediately.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-10-28 15:38:29 +10:00
Peter Hutterer
a01284a6de touchpad: split the touchpad->keyboard/trackpoint pairing helpers out
No functional changes

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-10-28 15:38:29 +10:00
Peter Hutterer
1843c4aeae touchpad: switch from fabs() to abs()
silence clang warning:
evdev-mt-touchpad.c:1017:7: warning: using floating point absolute value
function 'fabs' when argument is of integer type [-Wabsolute-value]

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2016-10-25 10:00:58 +10:00
Peter Hutterer
416fa44d80 touchpad: require at least 3 events before enabling trackpoint palm detection
Some trackpoints, notably the one on the Lenovo T460s have a tendency to send
the odd event even when they're not actually used. Trackpoint events trigger
palm detection (see 0210f1fee1) and thus effectively disable the touchpad,
causing the touchpad to appear nonresponsive.

Fix this by requiring at least 3 events from a trackpoint before palm
detection is enabled. For normal use it's hard enough to trigger a single
event anyway so this should not affect the normal use-case.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-09-12 13:50:15 +10:00