Commit graph

2059 commits

Author SHA1 Message Date
Peter Hutterer
a71d091e59 tablet: add a comment explaining why we adjust the pressure offset downwards
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-08 12:54:52 +10:00
Peter Hutterer
c5865f3ef0 tablet: point the pressure offset log messages to the right URL
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-08 12:54:52 +10:00
Brian Ashworth
801485afda evdev: always store user calibration matrix
In evdev_device_calibrate, the user matrix was not being stored when it
was the identity matrix. This resulted in
libinput_device_config_calibration_get_matrix not providing the correct
matrix. Instead of giving the identity matrix, the last non-identity
matrix set was given.

This just moves the storage of the user matrix in
evdev_device_calibrate to be above the identity matrix early return so
that it always get stored.

Signed-off-by: Brian Ashworth <bosrsf04@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-05 09:58:06 +10:00
Matt Mayfield
c284d4aaf0 touchpad: stricter thumb detection if no pressure/size 2019-07-17 09:33:14 +10:00
Matt Mayfield
35fd6e6c4e touchpad: don't detect speed-based thumbs if there's already a thumb 2019-07-17 09:33:14 +10:00
Matt Mayfield
4536b5b38f touchpad: revamp thumb detection
Instead of a simple yes/no/maybe for thumbs, have a more extensive state
machine that keeps track of the thumb. Since we only support one thumb anyway,
the tracking moves to the tp_dispatch struct.

Test case changes:
touchpad_clickfinger_3fg_tool_position:
  with better thumb detection we can now handle this properly and expect a
  right button (2fg) press for the test case
touchpad_thumb_no_doublethumb_with_timeout:
  two thumbs are now always two fingers, so let's switch to axis events here

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-07-17 09:33:14 +10:00
Peter Hutterer
8e4d820efd test: only run the speed finger tests when the touchpad has thumb detection 2019-07-15 13:08:47 +10:00
Peter Hutterer
f140826c86 touchpad: only log edge scroll state changes when the state actually changes
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-07-15 13:08:47 +10:00
Peter Hutterer
282979558e touchpad: add a helper function for supressing a thumb
Only sets the state to YES at the moment, will do more in the future.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-07-15 13:08:47 +10:00
Matt Mayfield
15c8613a65 gestures: Improve thumb detection, allow one finger scroll
Check if there's a thumb if we have two touches. If one finger moves but
the thumb remains still, we assume that one is really a thumb. But if the
thumb moves while the finger is still, let's assume this is a 2-finger scroll.

Extracted from Matt Mayfield's thumb detection patchset
2019-07-15 13:08:47 +10:00
Peter Hutterer
1dae79c833 gestures: fast-track scroll/swipe detection when gestures are off
We can't detect pinch when gestures are off anyway, so we don't need to check
the finger distances.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-07-15 13:08:47 +10:00
Matt Mayfield
93ab2f964a gestures: improvements to pinch detection
Only bias towards scrolling if the fingers are in the position past the
timeout.
2019-07-15 13:08:47 +10:00
Matt Mayfield
e97f054917 gestures: improve scroll responsiveness for vertically aligned touches
Put some basic location checks in, if the fingers are next to each other and
vertically close, assume scroll over swipe.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>:
2019-07-15 13:08:47 +10:00
Matt Mayfield
7b9a6a94a3 touchpad: basic thumb detection within gestures
When a touchpad has thumb detection enabled, avoid false-positive gestures
involving a resting thumb by using two thresholds: inner and outer.

While both touches remain inside their inner thresholds, remain in UNKNOWN
state to allow for accurate gesture detection even with no timeout.

If both touches move outside their inner thresholds, start a pinch or
swipe/scroll gesture according to direction, as usual.

If one touch moves outside its outer threshold while the other has not yet
exceeded its inner threshold, and thumb detection is enabled, then if one
touch is >20mm lower, mark it as a thumb and cancel the gesture.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-07-15 13:08:47 +10:00
Peter Hutterer
7fbfb14419 touchpad: rename the thumb detection methods
No functional changes, just prep work for a later patch where the thumbs will
dynamically update their state (instead of just using yes/no/maybe).

Extracted from Matt Mayfield's thumb detection patches.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-07-15 13:08:47 +10:00
Peter Hutterer
47d8f05d3b touchpad: extract some bits of thumb detection into helper functions
No functional changes

Extracted from Matt Mayfield's thumb detection patches.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-07-15 13:08:47 +10:00
Peter Hutterer
93a754c41c touchpad: move the speed-thumb detection code to the thumb helper file
Extracted from Matt Mayfield's thumb detection patches.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-07-15 13:08:47 +10:00
Peter Hutterer
117ef65087 touchpad: add helper function to reset a thumb's state
Extracted from Matt Mayfield's thumb detection patches.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-07-15 13:08:47 +10:00
Peter Hutterer
c2331ae11e touchpad: explicitly start with detect_thumbs as false
Not needed because we zalloc() anyway, but this makes it grep-able.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-07-15 13:08:47 +10:00
Peter Hutterer
d232e44c9f touchpad: add helper function for setting the thumb state
This moves the thumb state logging directly into that helper function too.

Extracted from Matt Mayfield's thumb detection patches.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-07-15 13:08:47 +10:00
Peter Hutterer
9e27244e6c touchpad: move tp_init_thumb and tp_thumb_detect to the thumb file
Extracted from Matt Mayfield's thumb detection patches.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-07-15 13:08:47 +10:00
Peter Hutterer
7c9ed03c42 touchpad: add a helper function for counting touches for gestures
Currently the same as tp_touch_active() but this will change.

No functional changes.

Extracted from Matt Mayfield's thumb detection patches.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-07-15 13:08:47 +10:00
Peter Hutterer
6e27a100b5 touchpad: add a helper function for checking thumb state
No functional changes

Extracted from Matt Mayfield's thumb detection patches.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-07-15 13:08:47 +10:00
Peter Hutterer
7e89e43c74 touchpad: rename the scroll timeout define, drop the pinch one
The previously 'scroll'-named timeout is also used for swipe, so let's rename
it. And the pinch one isn't used at all.

Extracted from Matt Mayfield's thumb detection patches.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-07-15 13:08:47 +10:00
Peter Hutterer
43b910b1df touchpad: reduce state debugging output by only logging changed states
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-07-15 13:08:47 +10:00
Peter Hutterer
8d3788fa8c evdev: when the kernel fuzz is nonzero, set ours to zero
Our udev callout is supposed to reset the kernel fuzz to 0 and move the value
to the LIBINPUT_FUZZ property. This is to stop the kernel from applying its
own hysteresis-like approach.

Where the kernel fuzz is nonzero, something has gone wrong with that approach.
Complain about it and set our fuzz to zero, we are in the hands of the kernel
now. If we leave our fuzz as nonzero, we'll apply our own hysteresis on top of
the kernel's and that leads to unresponsive behavior.

Fixes #313

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-27 11:17:28 +10:00
Peter Hutterer
82958a31f1 evdev: only extract the fuzz for touchpads and touchscreens
We don't have a hysteresis for tablet devices, so let's leave those as-is.

This may be a slight regression in behavior compared to pre-410b157e84 now the
kernel will apply the fuzz. Let's see if anyone notices, the fuzz is usually
so tiny on tablets that it shouldn't be noticable.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-26 18:27:36 +10:00
Peter Hutterer
82102f8599 If we never initialized the libwacom database, don't check the refcount
If the libwacom context failed to initialize for some reason, the database is
NULL and the refcount remains at zero. Calling unref should just work then.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-26 14:15:09 +10:00
Peter Hutterer
305251e633 touchpad: slightly change a debug message
Makes it clearer that thumb detection always enables area-based detection.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-18 14:18:47 +10:00
Peter Hutterer
9cb089f2b6 tablet: disable the forced proximity out for the Dell Canvas pen
This pen has random timeouts, often when a button is pressed. This causes a
forced proximity out (and the button release) and makes the whole device a
tad unusable.

Nothing we can detect by heuristics since it looks like other devices that
don't send proximity out events. And the timeout can be quite high, the
recording in #304 has over 800ms for one sequence.

Fixes #304

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-17 14:39:58 +10:00
Peter Hutterer
d13e11c24f quirk: drop the ModelTabletNoTilt quirk
This quirk is unused, use AttrEventCodeDisable instead.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-17 14:39:58 +10:00
Peter Hutterer
ffd8c71e4e tablet: fix double proximity out on slow proximity out pens
Where the proximity out event is delayed by the kernel, libinput would cause
an extra proxmity in-out after the forced proximity out event.

Event sequence is basically (k: kernel, l: libinput)

k: tablet axis events
l: tablet axis events
k: nothing for $proximity timer milliseconds
l: tablet proximity out
k: proximity out event
l: proximity in event
l: proximity out event

Fixes #306

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-17 14:39:58 +10:00
Michael Forney
9c89ab6d95 Replace one more __builtin_popcount with bitwise test
__builtin_popcount might not be available and in this case, a bitwise-and
can accomplish the same task.

Signed-off-by: Michael Forney <mforney@mforney.org>
2019-06-16 19:41:58 -07:00
Michael Forney
552d5aeba5 Don't return expression in function returning void
This is a constraint violation in ISO C[0].

[0] http://port70.net/~nsz/c/c11/n1570.html#6.8.6.4p1

Signed-off-by: Michael Forney <mforney@mforney.org>
2019-06-15 15:24:10 -07:00
Michael Forney
39c0d633f7 Use bitwise test instead of __builtin_popcount
__builtin_popcount might not be available on all compilers, so using
it requires a configure check and fallback implementation. In fact
on gcc without an -march flag, it gets compiled to a function call to
libgcc. However, we only need to test whether multiple bits are set,
and this can be done easily with a bitwise and.

Signed-off-by: Michael Forney <mforney@mforney.org>
2019-06-15 15:24:10 -07:00
Michael Forney
7160db054a Avoid case ranges in switch statement
Signed-off-by: Michael Forney <mforney@mforney.org>
2019-06-15 15:24:10 -07:00
Michael Forney
9d1b43d241 Avoid unnecessary VLAs
When the array length is fixed, or bounded by a fixed upper bound,
just use that fixed length.

Signed-off-by: Michael Forney <mforney@mforney.org>
2019-06-15 15:24:10 -07:00
Michael Forney
4740ad7af6 Remove semicolons after function definitions
Signed-off-by: Michael Forney <mforney@mforney.org>
2019-06-15 15:13:41 -07:00
Peter Hutterer
9dbcc68621 test: auto-generate the udev rules
We only ever set properties in the devices, so let's make that more explicit
and auto-generate the udev rule. This way we're hopefully better protected
from the various typos that hid in those rules over the years, but also be
prepared for passing the udev property key/value pairs elsewhere.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-14 08:52:58 +10:00
Peter Hutterer
451cbce44f path: add helper function to destroy a device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-11 15:49:02 +10:00
Peter Hutterer
36284defd0 path: initialize the quirks context after error checking
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-11 15:49:02 +10:00
Peter Hutterer
03a1c496ee path: factor out the seat creation into a helper function
No functional changes

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-11 15:49:02 +10:00
Peter Hutterer
a3ea7a6808 udev: don't init the quirks until we checked all arguments
If we fail with an invalid argument, there's no need to initialize all the
quirks beforehand.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-11 15:49:02 +10:00
Peter Hutterer
90216a010a path: drop the separate header, not necessary
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-11 15:49:02 +10:00
Peter Hutterer
bf4277623f Add a new dispatch interface for the Dell Canvas Totem
This device looks similar to a MT device on the kernel side, but it's not a
MT device and it's not quite a tablet either. It uses slots to track up to 4
totems off the same device and the only hint that it's not a MT device is that
it sends ABS_MT_TOOL_TYPE / MT_TOOL_DIAL.

udev thinks it's a touchscreen and a tablet but we currently init those
devices as touchscreen (because all wacom tablet touch devices are udev
tablets+tochscreens). So we need a quirk to hook onto this device.

And we use a completely separate dispatch implementation, because adding the
behavior to the tablet interface requires so many exceptions that it's easier
to just add a separate dispatch interface.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-07 01:03:21 +00:00
Peter Hutterer
17d792445e tablet: add a the Totem tool type to the tablet interface
This is the public API only, not the internal bits, so nothing will work just
yet.

This interface addition is for the Dell Canvas Totem tool, so let's go with
the same name because options like "Rotary" are too ambiguous.

The totem is a knob that can be placed on the surface, it provides us with
location and rotation data. The touch major/minor fields are filled in by the
current totem, but they're always the same size.

The totem exports BTN_0 as well, so let's add that to the debug-events output.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-07 01:03:21 +00:00
Peter Hutterer
3b0f068eaf Warn if NDEBUG is defined
We rely on assert() too much for safety checks, let's not let the user disable
it without warning

Fixes #262

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-05-28 14:10:54 +10:00
Peter Hutterer
8dfe8c68eb quirks: add trackpoint integration attribute
Some versions [1] of the Lenovo ThinkPad Compact USB Keyboard with TrackPoint USB
have the pointing stick on an event node that has keys but is not a regular
keyboard. Thus the stick falls through the cracks and gets disabled on tablet
mode switch. Instead of adding more hacks let's do this properly: tag the
pointing stick as external and have the code in place to deal with that.

[1] This may be caused by recent kernel changes

Fixes #291

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-05-28 13:23:49 +10:00
Peter Hutterer
5e3c45780f quirks: handle ID_INPUT_KEY as udev keyboard match
We handle that as keyboard in the evdev code, let's do so here as well.

Related to #291

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-05-28 12:55:17 +10:00
Peter Hutterer
ee1bc318d5 Abstract libwacom database initialization into a single place
No real changes for the non-tablet code, but for tablets we now keep the
libwacom datbase around. The primary motivating factor here is response time
during tests - initializing the database under valgrind took longer than the
proximity timeouts and caused random test case failures when a proximity out
was triggered before we even got to process the first event.

This is unfortunately a burden on the runtime now since we keep libwacom
around whenever a tablet is connected. Not much of an impact though, I
suspect, chances are you're running a web browser and everything pales against
that anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-05-28 10:32:08 +10:00