Commit graph

2958 commits

Author SHA1 Message Date
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
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
Mario Di Raimondo
f47eb2d796 Fix Apple Magic Trackpad sensitivity
https://bugs.freedesktop.org/show_bug.cgi?id=103572

Signed-off-by: Mario Di Raimondo <mario.diraimondo@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-02 14:24:59 +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
223c914847 tools: remove a stray perror() in libinput-record
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-01 12:51:27 +10:00
Peter Hutterer
f1c0f28bca tools: fix two scan-build errors in libinput-record
division by 0 and an unused variable

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-01 12:48:48 +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
21b83dfd0b test: don't run the 2fg pressure test on single-touch touchpads
Only the appletouch has pressure and thus executed that code path

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-01 12:23:45 +10:00
Peter Hutterer
990da54aa6 test: don't run the MT pressure test on devices without MT pressure
This test worked because on devices that don't use pressure the touches were
reset when BTN_TOUCH when to 0, triggering the 'ignore fake fingers when no
real fingers are down' behavior. But this is a different code path than the
pressure handling, so let's separate those tests.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-01 12:21:21 +10:00
Peter Hutterer
d25aa301b1 doc: more references to libinput-record
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-01 12:19:44 +10:00
Peter Hutterer
b02579121b tools: add --all to libinput-record
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-01 11:50:46 +10:00
Peter Hutterer
4072db4c38 doc: add a section to the tools page for record/replay
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-01 11:50:46 +10:00
Peter Hutterer
578151da61 tools: add a libinput-replay tool
Similar in style to evemu-play but parses the YAML printed by
libinput-record. Note that this tool requires python-libevdev which is a new
package and may not be packaged by your distribution. Install with pip3 or
alternatively, just ignore libinput-replay, it's a developer tool only anyway.

User-visible differences to evemu-play:
* supports replaying multiple devices at the same time.
* no replaying on a specific device, we can add this if we ever need it
* --verbose prints the event to stdout as we are replaying them. This is
  particularly useful on long recordings - once the bug occurs we can ctrl+c
  and match up the last few lines with the recordings file. This allows us to
  e.g. drop the rest of the file.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-01 11:50:46 +10:00
Peter Hutterer
576f2ed2a7 tools: add a libinput-record tool
This is a tool that does effectively the same job as evemu-record.
evemu has two disadvantages: its API is clunky and hard to extend even for
simple features. And it has a custom file format that requires special
processing but is difficult to extend and hard to write manually. e.g. the
bitmasks require keeping a line number state to know which bit an entry refers
to.

libinput-record records the same data but the output is YAML. That can be
processed easier and extended in the future without breaking the parsing. We
can (in the future) also interleave the evemu output with libinput's debug
output, thus having a single file where the events can be compared and
analysed without the need for replaying.  Likewise, we can easily annotate the
file with parsable bits of information without having to shove all that into a
comment (like version numbers of libinput, kernel, etc).

User-visible differences to evemu-record:
* the output file requires an explicit -o or --output-file argument
* no evemu-describe equivalent, if you just want the description simply cancel
  before any events are sent
* to see key codes, a --show-keycodes flag must be supplied, otherwise all
  'normal' keys end up as KEY_A. This protects against inadvertent information
  leakage
* supports a --multiple option to record multiple devices simultaneously. All
  recordings have the same time offset, it is thus possible to reproduce bugs
  that depend on the interaction of more than one device.

And to answer the question of: why a printf-approach to writing out yaml
instead of a library, it's simply that we want to be able to have real-time
output of the recording.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-01 11:50:46 +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
4eb420b16e test: fix an incomplete comment
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-28 17:43:30 +10:00
Peter Hutterer
4b10af94a8 meson.build: bump to 1.10.900
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-28 17:43:30 +10:00
Peter Hutterer
5b29be3998 tools: fix inverse up/down threshold handling in measure touch-size
https://bugs.freedesktop.org/show_bug.cgi?id=105264

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-27 15:17:39 +10:00
Peter Hutterer
f1b740022a udev: fix flake8-3 complaint in parse_hwdb.py
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-27 14:36:08 +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
Konstantin Kharlamov
d133dc9440 indentation: add .dir-locals.el for emacs
It's pretty basic as compared to e.g. one of Mesa, but I don't see what
else could be needed, and if anything, it can be added later.

Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-26 18:44:00 +10:00
Peter Hutterer
59550ed21c tools: fix option parsing in libinput measure
Missing '+' in the optstring caused it to evaluate all options. If any
argument was passed to a subcommand, libinput-measure would throw an error and
exit.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-26 13:53:40 +10:00
Peter Hutterer
963a7600f1 tools: remove pressure copy/paste leftovers from measure touch-size
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-26 13:53:40 +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
8353eeb5a8 meson: add the 221 version to the libsystemd dependency
The sd-bus interface we're using wasn't public until 221.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-21 13:56: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
8f71cb40fe test: send major/minor for the wacom intous 5 finger device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
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
Maxin B. John
920debffd7 libinput-measure-touchpad-tap: use /usr/bin/env to invoke python3
Tweak this python scripts to use '/usr/bin/env python3'

Signed-off-by: Maxin B. John <maxin.john@intel.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-20 11:11:08 +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
Peter Hutterer
da94e4e603 Silence coverity warning about uninitialized entry
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-16 16:57:30 +10:00
Quentin Glidic
b2b5cdaf61 meson: Fix absolute libdir case in install script
If libdir is an absolute path (which means it’s outside of prefix) we
would wrongly add the prefix to it in the install script. Just pass the
correct libdir from Meson directly thanks to join_paths() magic.

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-16 16:57:30 +10:00
Quentin Glidic
0843fa8e5e meson: Fix bindir usage in install script
Since the install script cannot know the correct bindir, just pass it
from Meson directly.

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-16 16:57:30 +10:00
Peter Hutterer
582e3c00b7 Add a test device for aiptek tablets
This tablet advertises tilt but doesn't actually have it. Let's rule out tilt
for all aiptek devices until someone complains.

Recording from: https://bugzilla.redhat.com/show_bug.cgi?id=1535755
Related to: https://bugs.freedesktop.org/show_bug.cgi?id=104911

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-13 16:04:58 +10:00
Peter Hutterer
2191ed6cc0 tablet: fake a BTN_TOOL_PEN on the first event if needed
Some (?) Aiptek tablets have BTN_TOOL_PEN but aren't inclined to actually send
this on proximity in. This means we don't have a tool assigned and ignore the
events.

This patch piggy-backs on the already-existing proximity-out quirks. On the
first EV_SYN and if the tool is still NONE (i.e. no BTN_TOOL_* was received), we
pretend that we've earlier forced a proximity-out event for this tablet. This
causes the proximity-out quirk code to emulate a proximity in and we're off.
Hooray.

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

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-13 16:04:08 +10:00
Peter Hutterer
ee2b58a66f tablet: disable BTN_TOOL_MOUSE/LENS for non-Wacom tablets
Mouse and lens cursor tools are rare and the rotation calculation is quirky to
say the least. I don't have access to a non-Wacom mouse tool, so
until this changes, just disable those tools and wait for someone to shout.

This is a much easier fix than trying to figure out the correct generic
rotation calculation that may not be correct anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-13 16:04:08 +10:00
Peter Hutterer
26705762e2 tablet: skip tablet_flush() if our current tool type is none
If a tablet never sends a BTN_TOOL_foo, we never update the tool and we remain
on the 'none' tool.

Somewhat related to:
https://bugzilla.redhat.com/show_bug.cgi?id=1535755
https://bugs.freedesktop.org/show_bug.cgi?id=104911

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