Commit graph

448 commits

Author SHA1 Message Date
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
Peter Hutterer
b519ea4ab5 tablet: add touch arbitration
So far we've relied on the wacom kernel module to do touch arbitration for us
but that won't be the case in upcoming kernels. Implement touch arbitration in
userspace by pairing the two devices and suspending the touch device whenever
a tool comes into proximity.

In the future more sophisticated arbitration can be done (e.g. only touches
which are close to the pen) but let's burn that bridge when we have to cross
it.

Note that touch arbitration is "device suspend light", i.e. we leave the
device enabled and the fd is active. Tablet interactions are comparatively
short-lived, so closing the fd and asking logind for a new one every time the
pen changes proximity is suboptimal. Instead, we just keep a boolean around
and discard all events while it is set.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
2016-09-07 11:17:03 +10:00
Peter Hutterer
aa87d2b25b touchpad: always reset the motion history on finger changes
We've already been doing this for semi-mt devices and for non-clickpads but
let's do it for clickpads as well. On Synaptics touchpads (PS/2 and RMI4)
we see slot jumps where two slots are active, slot X ends but slot Y continues
with the other slot's positional data. This causes a cursor jump on finger
lift after a two-finger scrolling motion. Simply resetting the motion history fixes it.

The only multi-finger interaction where a user could expect perfect fluid
motion is when using a second finger to touch cone of the software button
areas. Let's see if we have complaints first before we implement something
more complex.

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

Signed-off-by:Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-08-29 20:10:50 +10:00
Peter Hutterer
3cb60130c1 touchpad: on a non-clickpad, reset the motion history on nfingers change
The only reason to have more than one finger on a non-clickpad is to tap,
scroll or gesture. In all cases resetting the motion history is a good idea to
avoid jumps moving from 2 to 1 finger.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-08-19 10:45:07 +10:00
Peter Hutterer
fbadb1ad3e touchpad: implement configurable button mapping for tapping
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-08-15 09:05:57 +10:00
Peter Hutterer
5af236a022 evdev: switch three ints to booleans
And a minor rename to make it more obvious

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-08-11 19:56:16 +10:00
Peter Hutterer
1ea9fbfd4c touchpad: ignore modifier key combos for dwt
Inspired by the syndaemon -K switch and Anton Lindqvist's patch.
https://patchwork.freedesktop.org/patch/102417/

We already ignored modifiers for dwt. Now we also ignore modifier + key
combinations, i.e. hitting Ctrl+s to save does not trigger dwt, the touchpad
remains immediately usable.

However, if dwt is already active and a modifier combination is pressed, dwt
remains active, i.e. while typing, a shift + key does not disable dwt.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-08-05 07:35:10 +10:00
Peter Hutterer
64e3941189 touchpad: use the udev ID_INPUT_TOUCHPAD_INTEGRATION property if available
udev now labels touchpads as "internal" or "external" for us, use that value
where available and only fall back onto our own labelling if it's missing or
unknown.

systemd commit: https://github.com/systemd/systemd/pull/3638

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-08-01 14:33:35 +10:00
Peter Hutterer
c543b4a91a touchpad: change manual calculations of dimensions to helper functions
Wherever we use an absolute size in mm on the touchpad, switch to the new
helper functions. In a few cases we only need one coordinate so just leave the
other one as 0 in those cases.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-08-01 07:11:20 +10:00
Peter Hutterer
a5066edaaf touchpad: change the sanity check function to a bool
And rename to make the return value more obvious

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2016-07-20 11:43:45 +10:00
Peter Hutterer
bc84245ec3 touchpad: change palm detection trigger functions to bools
And rename to make it more obvious what the return value means.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2016-07-20 11:43:45 +10:00
Peter Hutterer
271dc496dc Switch a bunch of internal functions from int to bool
All these effectively returned bools anyway, switch the signature over to be
less ambiguous.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2016-07-20 11:43:45 +10:00
Peter Hutterer
2f0d0b9f63 Change a few functions that only ever returned 0 to voids
These are internal functions, if we need them to return an error code we can
change that at any time. Meanwhile, if we only ever return 0 anyway we might
as well just make them voids to save on error paths.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2016-07-20 11:43:40 +10:00