Commit graph

1823 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
a9d78e99ea touchpad: split the switch event handlers up
Because we register the handler separately (once for lid, once for
tablet-mode) the handler is called twice for the same event. This causes a
double-suspend of the touchpad, though it doesn't seem to have any real
effect.

Split it up so that each handler function only does one thing.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-18 12:05:02 +10:00
Peter Hutterer
6dcdfdd513 evdev: add three more Logitech K400-like devices to the debouncing quirk
And rename the model flag, no point in having separate flags here, we likely
have to add more devices over time.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-17 12:37:20 +10:00
Peter Hutterer
ba922b59ef util: avoid potential integer overflow
If we need more than 1000 pairs, we have a problem...

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-16 14:23:12 +10:00
Peter Hutterer
75e4ab05e4 utils: fix leak in kv_double_from_string()
We need to free 'pairs' here, do so by jumping to the error label.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-16 14:23:12 +10:00
Peter Hutterer
3251ba2af0 touchpad: add a tool to measure the touchpad fuzz
Well, I say "measure" but really at this point it just reads the
properties/axes and then does it's best to auto-generate a hwdb entry that
matches the user's hardware and sets a fuzz value on the device. Ideally this
reduces the number of hand-holding required in bugzillas. There are plenty of
things that can go wrong, so our fallback is still to throw up our hands and
point to the documentation.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-15 13:51:33 +10:00
Peter Hutterer
2ca8d6cb08 evdev: drop the arbitrary trackpoint range maximum
ALPS SS5 devices have a range above 100.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-14 11:19:25 +10:00
Peter Hutterer
f206903823 Fix the scan-build fake leaks
We pass the event to libinput_post_event() where it is appended to the event
queue. Except in these three cases clang doesn't seem to realize what's
happening and complains about memory leaks. I tried workarounds like
g_steal_pointer() but nothing I tried helps. So let's just pretend we're
freeing it when clang looks at us.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-10 15:47:37 +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
a4036a33ca udev: copy the trackpoint sensitivity directly from sysfs
Rather than going the roundabout way of having systemd set the sensitivity
followed by us reading that udev property and hoping, just take the
sensitivity directly from sysfs. This makes us basically independent of what
systemd does (or the lack of systemd, where that is a problem).

It does remove the chance of users to trick libinput by manually adjusting the
sensitivity after the udev rules kicked in, but seriously, we should work on
fixing acceleration properly in that case.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-03 19:15:18 +10:00
Peter Hutterer
3d81f1179f touchpad: only try to detect touchpad wobbling with one finger down
https://bugs.freedesktop.org/show_bug.cgi?id=106365

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-03 19:15:00 +10:00
Peter Hutterer
5427d5ed87 Revert "touchpad: only try to detect touchpad wobbling with one finger down"
Logic inversion error from a draft version of the patch, see corrected version
coming up.

This reverts commit 30a398591b.
2018-05-03 19:13:56 +10:00
Peter Hutterer
37e8c56e2c util: remove dead assignment in strv_join
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-03 15:31:17 +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
6fe55cd0ea Allow for TABLET_TOOL_BUTTON events in the various tablet_tool_get_<foo>()
We fill in the events correctly and we already allowed the
get_transformed_x/y functions on a button event, there isn't really a reason
to prohibit these.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-03 12:28:01 +10:00
Peter Hutterer
1392c1f3ac evdev: mask out MSC_TIMESTAMP, we don't need it
Not really an issue at this point, but some HID devices like sending
MSC_TIMESTAMP. Since we don't use them in libinput, all we do is drag
ourselves out of sleep, look at the event, frown because it's not our morning
coffee, and go back to sleep. Instead, disable the code altogether, libevdev
will mask it transparently and then the kernel will let us sleep.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-03 10:03:28 +10:00
Deepa Dinamani
ee163ef63e Update struct input_event
The struct input_event is not y2038 safe.
Update the struct according to the kernel patch:
https://lkml.org/lkml/2018/1/6/324

Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-03 10:03:28 +10:00
Peter Hutterer
30a398591b touchpad: only try to detect touchpad wobbling with one finger down
Too many touches are unreliable with 2+ fingers down and we should error on
the side of not detecting wobbling.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-02 14:17:32 +10:00
Peter Hutterer
9c3a597aab touchpad: reset the wobble detection for non-pointer events
If we get an event other than a motion event we're not wobbling so we need to
reset and restart.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-02 14:17:30 +10:00
Peter Hutterer
be69bcef2c touchpad: reset the wobble detection history for y-only changes
Otherwise we may detect wobble despite having a series of valid y movements,
e.g. the following sequence was detected as wobble:
	x: 1 y: 0
	x: 0 y: 1
	x: 0 y: 2
	x: 0 y: 2
	x: 0 y: 1
	x: -1 y: 0
	x: 1 y: 0

Avoid this by resetting the history when we get a dx == 0 event. It'll take
longer for real wobble to be detected but it reduces the number of false
positives.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-02 14:17:27 +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
d8bd650540 Expose a custom acceleration profile
This adds a third profile to the available profiles to map device-specific
speed to an acceleration factor, fully defined by the caller.

There has been a consistent call for different acceleration profiles in
libinput, but very little specifics in what actually needs to be changed.
"faster horses" and whatnot (some notable exceptions in e.g. bug 101139).
Attempts to change the actual acceleration function will likely break things
for others.

This approach opens up the profile itself to a user-specific acceleration
curve. A caller can set an acceleration curve by defining a number of points
on that curve to map input speed to an output factor. That factor is applied
to the input delta.

libinput does relatively little besides mapping the deltas to the
device-specific speed, querying the curve for that speed and applying that
factor. The curve is device-specific, the input speed is in device units/ms.

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
7d06ccc061 filter: always average the velocity of the first two events
Don't apply any velocity diff checking on the first two events, always average
them (unless the timeout is hit or the direction changes). This averages out
some of the jumps we get on slow motion.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-26 14:02:50 +10:00
Peter Hutterer
66687902d0 gestures: if two fingers are in definitive pinch position, pinch
Two fingers on the touchpad, they're 40x40mm apart, that's a pinch. But only
after a timeout because we don't want to start a 2fg gesture if the user puts
down the third/fourth finger within the next few ms.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-26 13:59:03 +10:00
Peter Hutterer
588105da31 filter: make the MAX_VELOCITY_DIFF a double
The value is 0.001 which happens to be 0 when you cast it to int.

Introduced in e3554f38f8

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-26 10:34:16 +10:00
Peter Ganzhorn
4cc2b952a2 fallback: Add IBM/Lenovo Scrollpoint mice quirk to enable smooth scrolling.
Instead of a scroll wheel these mice feature trackpoint-like sticks which
generate a huge amount of scroll events that need to be handled differently
than scroll wheel events.

Signed-off-by: Peter Ganzhorn <peter.ganzhorn@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-26 09:53:57 +10:00
Peter Hutterer
74e20e0ae0 evdev: disable ABS_MT_TOOL_PALM on the Lenovo X1 Carbon 6th gen
This device randomly decides that a touch is now a palm, based on
the moon phase, the user's starsign and possibly what the dog had for
breakfast. Since libinput assumes that a touchpad that labels a touch as palm
has reasons to do so, let's unassume this for this device by disabling that
axis altogether and relying on the touch pressure only.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2018-04-20 17:01:10 +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
1bd5869f19 filter: duplicate the pointer_accelerator struct into the bits that use it
Yeah, it's duplication. But this way it's also separation and we can't
accidentally use the wrong struct.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-18 17:10:05 +10:00
Peter Hutterer
31a21c0028 filter: namespace the various trackers_* functions
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-18 17:01:03 +10:00
Peter Hutterer
d8e8b74b06 filter: split the mouse acceleration out into a separate file
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-18 16:52:00 +10:00
Peter Hutterer
f02c9b9734 filter: drop the ntrackers argument from init_trackers
Reduces the duplication, everyone uses the same value anyway

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-18 16:42:58 +10:00
Peter Hutterer
cae84b84ae filter: tidy up the touchpad filter
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-18 16:33:56 +10:00
Peter Hutterer
6135e1d878 filter: split the low-dpi acceleration into a separate file
Plenty of duplication there from the normal filter.c, but that also makes it
less likely to break if we adjust the other one.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-18 16:24:52 +10:00
Peter Hutterer
f61adfcf9b filter: move the flat filter into a separate file
This also fixes a bug with the _noop function, because we casted to the wrong
struct the dpi value was garbage.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-18 16:15:38 +10:00
Peter Hutterer
e3554f38f8 filter: move the velocity diff to the only function we use it in
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-18 16:15:38 +10:00
Peter Hutterer
b887353ab9 filter: split the touchpad acceleration code into a separate file
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-18 16:15:38 +10:00
Peter Hutterer
40c5b64f82 filter: make the simpsons accel calculation available through the header
This is the standard approach for mice and touchpads to calculate the
acceleration based on the last two deltas, let's make that code shareable.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-18 16:15:38 +10:00
Peter Hutterer
0ead929838 filter: move the pointer_accelerator struct into the header
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-18 16:15:38 +10:00
Peter Hutterer
477f51b6bd filter: split trackpoint acceleration code into a separate file
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-18 16:15:38 +10:00
Peter Hutterer
f79b2d4df4 filter: split the tablet accel code into a separate file
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-18 16:15:38 +10:00
Peter Hutterer
d857e36c33 filter: move the x230 filter into a separate file
There's a fair bit of duplication of code from filter.c but it's not worth
disecting this and optimising it. The device is 5 years old now, we don't want
to touch this accel method so duplication is good here.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-18 16:15:38 +10:00
Peter Hutterer
228d0497b7 filter: add helper function to reset and free trackers
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-18 16:15:38 +10:00
Peter Hutterer
3f53430ea1 filter: pass trackers to calculate_velocity
So the function to calculate the velocity is easier to call from other sites.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-18 16:15:38 +10:00