platform/upstream/libinput.git
3 years agogitlab CI: add a comment to explain how to actually edit the CI
Peter Hutterer [Thu, 17 Jun 2021 06:10:53 +0000 (16:10 +1000)]
gitlab CI: add a comment to explain how to actually edit the CI

We tell users not to edit it, but don't tell them how to change it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agousing secure functions safe_strdup
luokai [Tue, 15 Jun 2021 03:27:29 +0000 (11:27 +0800)]
using secure functions safe_strdup

Signed-off-by: luokai <l18674732394.com>
3 years agomeson.build: bump to 1.18.900
Peter Hutterer [Wed, 9 Jun 2021 23:46:17 +0000 (09:46 +1000)]
meson.build: bump to 1.18.900

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agogestures: improve one finger hold detection
José Expósito [Mon, 31 May 2021 15:58:39 +0000 (17:58 +0200)]
gestures: improve one finger hold detection

When one finger is used to hold, tiny pointer movement deltas can easily
end the gesture.

Add a movement threshold to avoid small movement, before or after the hold
timeout, ending the gesture and make the hold-to-interact user
interaction more reliable.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
3 years agogestures: move first_moved and first_mm up
José Expósito [Mon, 31 May 2021 15:58:11 +0000 (17:58 +0200)]
gestures: move first_moved and first_mm up

Move the calculation of first_moved and first_mm up inside
tp_gesture_detect_motion_gestures in order to be able to use their
values in the one finger code path.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
3 years agogestures: always save touch information
José Expósito [Mon, 31 May 2021 15:57:44 +0000 (17:57 +0200)]
gestures: always save touch information

When a single touch is used to hold or to move the pointer, save
information about the touch.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
3 years agodoc: update draw.io URL
José Expósito [Wed, 9 Jun 2021 07:03:15 +0000 (09:03 +0200)]
doc: update draw.io URL

The tool used to generate diagrams (draw.io) is now diagrams.net.

Update the URL in the comments.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
3 years agodoc: add touchpad gestures state machine diagram
José Expósito [Wed, 9 Jun 2021 06:57:55 +0000 (08:57 +0200)]
doc: add touchpad gestures state machine diagram

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
3 years agodoc: add docs for hold gestures
Peter Hutterer [Fri, 20 Sep 2019 03:49:34 +0000 (13:49 +1000)]
doc: add docs for hold gestures

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agodoc: note that gestures may be cancelled
Peter Hutterer [Mon, 23 Sep 2019 04:15:43 +0000 (14:15 +1000)]
doc: note that gestures may be cancelled

This has been in place forever, so let's note it in the docs.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agogestures: add quick hold implementation
José Expósito [Thu, 27 May 2021 17:20:37 +0000 (19:20 +0200)]
gestures: add quick hold implementation

When 1 or 2 fingers are used to hold, use a faster timer to make the
"hold to stop kinetic scrolling" user interaction feel more immediate.

Also handle double tap and tap and drag interations to send only one
hold gesture instead of two.

Holding with 3 or 4 fingers remains the same to try to avoid callers
missusing hold gestures to build their own tap implementation.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
3 years agotests: add hold gesture tests
José Expósito [Thu, 27 May 2021 17:20:31 +0000 (19:20 +0200)]
tests: add hold gesture tests

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
3 years agotests: optionally hold in gesture test functions
José Expósito [Thu, 27 May 2021 17:20:23 +0000 (19:20 +0200)]
tests: optionally hold in gesture test functions

Add an extra parameter to the common gesture test functions to allow to hold
before performing the gesture.

This parameter will be used by the hold tests allowing to share the code.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
3 years agotests: move existing gesture tests to functions to be able to reuse them
José Expósito [Thu, 27 May 2021 17:20:11 +0000 (19:20 +0200)]
tests: move existing gesture tests to functions to be able to reuse them

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
3 years agogestures: add hold gesture implementation
José Expósito [Thu, 27 May 2021 17:20:03 +0000 (19:20 +0200)]
gestures: add hold gesture implementation

Hold gestures are notifications about fingers on the touchpad.
There is no coordinate attached to a hold gesture, merely the number of fingers.
A hold gesture starts when the user places a finger on the touchpad and
ends when all fingers are lifted. It is cancelled when the finger(s) move
past applicable thresholds and trigger some other interaction like pointer
movement or scrolling.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
3 years agogesutures: allow to configure hold gestures
José Expósito [Thu, 27 May 2021 17:19:49 +0000 (19:19 +0200)]
gesutures: allow to configure hold gestures

Valgrind can be too slow to run some time based tests. In those cases, we
need to disable hold gestures.

Add the required functions to configure hold gestures: enable, disable,
get default state and get current state.

Keep them private as they are intended to be used only from the tests.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
3 years agolibinput: add hold gesture public API and tool support
José Expósito [Thu, 27 May 2021 17:19:38 +0000 (19:19 +0200)]
libinput: add hold gesture public API and tool support

Add hold gestures to the public API and the private functions to notify them.
Also add hold gestures to debug-events and debug-gui.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
3 years agogestures: filter motion inside the gesture state machine
José Expósito [Thu, 27 May 2021 17:19:21 +0000 (19:19 +0200)]
gestures: filter motion inside the gesture state machine

At the moment, every gesture is triggered by motion. In order to implement
gestures not based on motion, like hold, it is required to filter the unwanted
motion inside the gesture state machine so it transits to the correct states.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
3 years agogestures: use events to change between states
José Expósito [Thu, 27 May 2021 17:19:12 +0000 (19:19 +0200)]
gestures: use events to change between states

Refactor the gesture state machine to emit events to change between states.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
3 years agogestures: handle pointer motion as an extra state
José Expósito [Thu, 27 May 2021 17:18:54 +0000 (19:18 +0200)]
gestures: handle pointer motion as an extra state

Refactor the gesture state machine to integrate pointer motion as an extra state
of the state machine.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
3 years agogestures: refactor gesture enabled
José Expósito [Tue, 1 Jun 2021 17:11:19 +0000 (19:11 +0200)]
gestures: refactor gesture enabled

Move the condition to check if gestures are enabled to its own function.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
3 years agogestures: add a function to know if there is pending pointer motion
José Expósito [Thu, 27 May 2021 17:18:16 +0000 (19:18 +0200)]
gestures: add a function to know if there is pending pointer motion

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
3 years agolibinput 1.18.0 1.18.0
Peter Hutterer [Wed, 2 Jun 2021 03:06:37 +0000 (13:06 +1000)]
libinput 1.18.0

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agoUpdate 50-system-asus.quirks to include Asus G15 Zephyrus quirk.
Neev Parikh [Mon, 31 May 2021 16:24:43 +0000 (16:24 +0000)]
Update 50-system-asus.quirks to include Asus G15 Zephyrus quirk.

Signed-off-by: Neev Parikh <neev.v.parikh@gmail.com>
3 years agolibinput 1.17.901 1.17.901
Peter Hutterer [Wed, 26 May 2021 03:17:59 +0000 (13:17 +1000)]
libinput 1.17.901

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agogitlab CI: use FDO_CI_CONCURRENT in our meson build script
Peter Hutterer [Tue, 18 May 2021 23:49:39 +0000 (09:49 +1000)]
gitlab CI: use FDO_CI_CONCURRENT in our meson build script

Always prefix the ninja args with the FDO_CI_CONCURRENT values (i.e. how many
jobs the runner tells us).

Note that this variable is currently not passed through to the qemu jobs, so
inside the VM we'll still use the ninja default values.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agodoc/user: #wayland is now on oftc
Peter Hutterer [Tue, 25 May 2021 01:03:44 +0000 (11:03 +1000)]
doc/user: #wayland is now on oftc

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agotest: cleanup: remove fallthrough followed by break
José Expósito [Sun, 23 May 2021 17:32:33 +0000 (19:32 +0200)]
test: cleanup: remove fallthrough followed by break

Remove fallthrough comments followed by a break statement.
No functional changes.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
3 years agouse more safety list_for_each_safe when remove element in traversing list
weizhixiang [Wed, 19 May 2021 12:48:34 +0000 (21:48 +0900)]
use more safety list_for_each_safe when remove element in traversing list

Signed-off-by: weizhixiang <weizhixiang@uniontech.com>
3 years agouse ARRAY_FOR_EACH when traverse array
weizhixiang [Wed, 19 May 2021 12:09:30 +0000 (21:09 +0900)]
use ARRAY_FOR_EACH when traverse array

Signed-off-by: weizhixiang <weizhixiang@uniontech.com>
3 years agoevdev: restart debouncing timers after every event
satrmb [Wed, 19 May 2021 08:13:06 +0000 (10:13 +0200)]
evdev: restart debouncing timers after every event

Signed-off-by: satrmb <10471-satrmb@users.noreply.gitlab.freedesktop.org>
3 years agoIncrease pinch grace period to 300ms
novenary [Sun, 4 Apr 2021 15:44:36 +0000 (18:44 +0300)]
Increase pinch grace period to 300ms

Windows allows "about a third of a second" to trigger a two-finger
pinch.

https://gitlab.freedesktop.org/libinput/libinput/-/issues/550#implementation-in-other-systems

Signed-off-by: novenary <streetwalkermc@gmail.com>
3 years agoAllow reviving a thumb that moves sufficiently
novenary [Sun, 4 Apr 2021 15:40:09 +0000 (18:40 +0300)]
Allow reviving a thumb that moves sufficiently

When pinching, the thumb tends to move slower than the finger, so we may
suppress it too early.

Add a grace period during which it may be revived.

Signed-off-by: novenary <streetwalkermc@gmail.com>
3 years agoImprove disambiguation between two-finger pinch and scroll
novenary [Sun, 4 Apr 2021 15:30:41 +0000 (18:30 +0300)]
Improve disambiguation between two-finger pinch and scroll

A pinch is defined as two fingers moving in different directions, and a
scroll as two fingers moving in the same direction.

Often enough when the user is trying to pinch, we may initially see both
fingers moving in the same direction and decide that they want to
scroll.

Add a grace period during which we may transition to a pinch in those
situations.

Test fix: touchpad_trackpoint_buttons_2fg_scroll emits movements that
change the distance between fingers, which triggers this new transition
and makes the test fail; correct this.

Signed-off-by: novenary <streetwalkermc@gmail.com>
3 years agoquirks: add palm rejection support for all Razer Blade models
dan g [Sat, 10 Apr 2021 15:45:01 +0000 (17:45 +0200)]
quirks: add palm rejection support for all Razer Blade models

Generated with a script to scrape the openrazer project for Razer Blade
internal keyboard VIDs, see `razer_quirk_util.py` [1]

This allows us to potentially bulk-add all Razer Blade models to benefit from
palm rejection, rather than processing individual requests and merges.

[1] https://gist.github.com/danryu/ee0c24ac50af40321550462bbf9ab594

Signed-off-by: dan g <dan.garton@gmail.com>
3 years agotools/record: narrow down the obfuscation range
Peter Hutterer [Mon, 17 May 2021 07:56:14 +0000 (17:56 +1000)]
tools/record: narrow down the obfuscation range

Let a few obvious modifiers through, including the F-key range. Especially
left control is useful to know if it's down.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agotools/replay: do not replay key repeat events
Peter Hutterer [Mon, 17 May 2021 06:09:35 +0000 (16:09 +1000)]
tools/replay: do not replay key repeat events

The kernel emulates key events on its own anyway, replaying key events with
libinput replay as well just duplicates the events. Turning kernel
repeat off is not an option, it  makes the device look different (EV_REP
changes). So let's just not replay those events.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agogitlab CI: add a JUnit XML report for scan-build
Peter Hutterer [Tue, 11 May 2021 04:26:27 +0000 (14:26 +1000)]
gitlab CI: add a JUnit XML report for scan-build

Use a scan-build wrapper to generate plist files, then parse those into a
JUnit xml format. This makes the errors appear on the main MR page as opposed
to being hidden in the artifacts somewhere.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agoeditorconfig: add settings for python files
Peter Hutterer [Wed, 12 May 2021 01:41:05 +0000 (11:41 +1000)]
editorconfig: add settings for python files

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agogitlab CI: bump from Fedora 32 to 34
Peter Hutterer [Tue, 11 May 2021 21:39:05 +0000 (07:39 +1000)]
gitlab CI: bump from Fedora 32 to 34

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agotools/record: add support for hidraw recording
Peter Hutterer [Thu, 18 Feb 2021 04:20:22 +0000 (14:20 +1000)]
tools/record: add support for hidraw recording

New commandline switch --with-hidraw. This will open all hidraw devices
associated with this device and add any reports to the output in the
form:

  events:
    - hid:
        time: [0, 0]
        hidraw1: [0x01, 0x02, 0x03, 0x05, 0x06]
hidraw2: [0x07, 0x08, 0x09, 0x0a, 0x0b]
    - evdev:
      ...

i.e. there's a nesting of `hid` with a list of reports, each with the hidraw
node as dictionary entry.

Because hidraw events do not have timestamps and always occur before the evdev
events, they are in a separate frame (as shown above). We could try to figure
out how to match them with the upcoming evdev frame but it's not worth it for
now.

The timestamp itself is a special key in the hidraw with the timestamp from
clock_gettime.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agomeson.build: bump to 1.17.900
Peter Hutterer [Wed, 5 May 2021 02:46:33 +0000 (12:46 +1000)]
meson.build: bump to 1.17.900

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agodoc/user: Add instructions for using with CMake
Nicolas Fella [Tue, 4 May 2021 18:58:14 +0000 (20:58 +0200)]
doc/user: Add instructions for using with CMake

CMake provides a nice way to use libinput, let the world now.

Signed-off-by: Nicolas Fella <nicolas.fella@gmx.de>
3 years agoAdd quirk for Lenovo Legion 5 Pro.
Hans Gaiser [Thu, 29 Apr 2021 19:30:09 +0000 (21:30 +0200)]
Add quirk for Lenovo Legion 5 Pro.

Signed-off-by: Hans Gaiser <hansg91@gmail.com>
3 years agotools/record: linebreak the hid report descriptor every 16 bytes
Peter Hutterer [Thu, 29 Apr 2021 00:12:46 +0000 (10:12 +1000)]
tools/record: linebreak the hid report descriptor every 16 bytes

New output:

 hid: [
    0x05, 0x0d, 0x09, 0x04, 0xa1, 0x01, 0x85, 0x01, 0x09, 0x22, 0xa1, 0x02, 0x09, 0x42, 0x15, 0x00,
    0x25, 0x01, 0x75, 0x01, 0x95, 0x01, 0x81, 0x02, 0x75, 0x01, 0x81, 0x03, 0x75, 0x06, 0x09, 0x51,
    0x25, 0x3f, 0x81, 0x02, 0x26, 0xff, 0x00, 0x75, 0x08, 0x09, 0x48, 0x81, 0x02, 0x09, 0x49, 0x81,
    ...

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agotools/record: print the HID report descriptor as hex
Peter Hutterer [Thu, 29 Apr 2021 00:04:46 +0000 (10:04 +1000)]
tools/record: print the HID report descriptor as hex

YAML does support hex as long as it's 0x-prefixed. The comment here (probably)
dates from an in-development version of libinput-record that used JSON.
Anyway, let's print the HID report descriptor as hex because that's the common
format for it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agotools/record: fix a strlen assumption
Peter Hutterer [Wed, 7 Apr 2021 05:26:16 +0000 (15:26 +1000)]
tools/record: fix a strlen assumption

We want to be able to print single-character strings.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agoChange various references to the master branch to main
Peter Hutterer [Thu, 29 Apr 2021 00:36:18 +0000 (10:36 +1000)]
Change various references to the master branch to main

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agodoc/user: fix a link to the system hwdb file
Peter Hutterer [Thu, 29 Apr 2021 00:30:49 +0000 (10:30 +1000)]
doc/user: fix a link to the system hwdb file

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agogitlab CI: switch to Ubuntu 21.04
Peter Hutterer [Thu, 22 Apr 2021 23:28:36 +0000 (09:28 +1000)]
gitlab CI: switch to Ubuntu 21.04

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agotouchpad: if we have a right button, let's assume it's not a clickpad
Peter Hutterer [Wed, 14 Apr 2021 05:35:07 +0000 (15:35 +1000)]
touchpad: if we have a right button, let's assume it's not a clickpad

This assumption dates back roughly a decade when INPUT_PROP_BUTTONPAD was
introduced into the kernel. To my knowledge, devices right now erroneously
advertise INPUT_PROP_BUTTONPAD when they are not a clickpad (but then they
have BTN_RIGHT) or they lack INPUT_PROP_BUTTONPAD (and only have BTN_LEFT).

So let's change our assumption here - if a clickpad has a right button log the
kernel bug and continue with the assumption the device is a touchpad with
physical buttons.

To disable that warning, fix the kernel or add an AttrInputPropDisable quirk
for the device.

Fixes #595

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agotouchpad: a touchpad with only one button is a clickpad
Peter Hutterer [Wed, 14 Apr 2021 05:18:13 +0000 (15:18 +1000)]
touchpad: a touchpad with only one button is a clickpad

There is only one touchpad with a physical left button but no right button and
that is the old Apple touchpad, discontinued in 2008. Not a huge number of
those left, I assume.

So let's change our assumptions because these days the vast majority of
touchpads are clickpads - any touchpad that only has a left button is treated
as clickpad, even where the kernel doesn't set the INPUT_PROP_BUTTONPAD.

We do need to check for BTN_LEFT as well though, because Wacom touchpads (i.e.
the touch part of non-integrated Wacom tablets) don't have a left button
either.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agotouchpad: use some helper variables to make the code easier to read
Peter Hutterer [Wed, 14 Apr 2021 06:26:21 +0000 (16:26 +1000)]
touchpad: use some helper variables to make the code easier to read

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agotouchpad: factor out clickpad assignment to a helper
Peter Hutterer [Wed, 14 Apr 2021 06:18:21 +0000 (16:18 +1000)]
touchpad: factor out clickpad assignment to a helper

No functional changes

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agoquirks: add quirk for Lenovo Yoga Slim 9 Touchpad
Udo Rader [Tue, 20 Apr 2021 02:15:03 +0000 (02:15 +0000)]
quirks: add quirk for Lenovo Yoga Slim 9 Touchpad

This touchpad is a pressure pad and needs the pressure
handling disabled.

Fixes #604

Signed-off-by: Udo Rader <udo.rader@bestsolution.at>
3 years agoquirks: add palm size quirk for the Gigabyte Aero 15
Peter Hutterer [Wed, 14 Apr 2021 05:04:39 +0000 (15:04 +1000)]
quirks: add palm size quirk for the Gigabyte Aero 15

Fixes #599

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agogestures: move the logic to detect gestures to its own function
JoseExposito [Wed, 7 Apr 2021 16:23:06 +0000 (18:23 +0200)]
gestures: move the logic to detect gestures to its own function

Move the code in used to detect motion based gestures (scroll, swipe and pinch)
to tp_gesture_detect_motion_gestures.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
3 years agogestures: move up some functions to use them later
JoseExposito [Mon, 29 Mar 2021 15:31:46 +0000 (17:31 +0200)]
gestures: move up some functions to use them later

Move tp_gesture_same_directions, tp_gesture_mm_moved and tp_gesture_init_pinch
to be able to use them in future commits.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
3 years agogestures: move the code to get raw pointer motion to its own function
JoseExposito [Wed, 7 Apr 2021 15:50:56 +0000 (17:50 +0200)]
gestures: move the code to get raw pointer motion to its own function

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
3 years agogestures: rename int filter_motion to bool ignore_motion
JoseExposito [Mon, 12 Apr 2021 16:12:25 +0000 (18:12 +0200)]
gestures: rename int filter_motion to bool ignore_motion

Use a bool instead of an int and also rename the variable to avoid ambiguity
with tp_filter_motion().

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
3 years agolibinput: change gesture notify cancel parameter from int to bool
JoseExposito [Mon, 12 Apr 2021 07:18:39 +0000 (09:18 +0200)]
libinput: change gesture notify cancel parameter from int to bool

Change the "cancel" parameter in the existing notify methods (swipe, pinch and
gesture_notify) from int to bool. It is used as boolean, the fact that it's an
int is just a historical quirkyness.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
3 years agoquirks: mark the 0x252 razer keyboard as internal
Chris Dickson [Fri, 9 Apr 2021 16:17:24 +0000 (11:17 -0500)]
quirks: mark the 0x252 razer keyboard as internal

Signed-off-by: Chris Dickson <hobochili@pm.me>
3 years agoevdev: don't truncate event time to 32 bits
Peter Hutterer [Fri, 9 Apr 2021 00:12:45 +0000 (10:12 +1000)]
evdev: don't truncate event time to 32 bits

This causes a bunch of "your system is too slow" messages in e.g. the various
gesture tests.

Fixes 95a72990
Fixes #601

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agoevdev: don't check the event time if it's higher than the dispatch time
Peter Hutterer [Mon, 22 Mar 2021 03:55:34 +0000 (13:55 +1000)]
evdev: don't check the event time if it's higher than the dispatch time

The dispatch time is taken during libinput_dispatch(), i.e. at the beginning
of an event sequence. We always read all events off the device, so where
events come in while we're inside the main dispatch loop, our event time may
be later than the saved dispatch_time. This causes an uint underflow and our
tdelta > 10 will be true for that case.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agotablet-pad-leds: Open led file with O_NONBLOCK | O_CLOEXEC
Jonas Ådahl [Tue, 6 Apr 2021 14:33:42 +0000 (16:33 +0200)]
tablet-pad-leds: Open led file with O_NONBLOCK | O_CLOEXEC

We don't want the file to be left open after any fork/exec, and we don't
want the read to be blocking; so open it as such.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
3 years agotouchpad/clickfinger: limit middle click to 3 fingers
JoseExposito [Sun, 4 Apr 2021 14:59:40 +0000 (16:59 +0200)]
touchpad/clickfinger: limit middle click to 3 fingers

Don't middle click on clickpads with click method clickfinger when more than
3 fingers are used.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
3 years agoquirk: fix sensitivity for Dell Latitude 7490 pointing-stick
Ben Weston [Sat, 3 Apr 2021 22:01:07 +0000 (23:01 +0100)]
quirk: fix sensitivity for Dell Latitude 7490 pointing-stick

Signed-off-by: Ben Weston <b.weston60@gmail.com>
3 years agotools/record: line up the "neutral state" message
Peter Hutterer [Fri, 26 Mar 2021 05:07:41 +0000 (15:07 +1000)]
tools/record: line up the "neutral state" message

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agotools/record: rework the event printing
Peter Hutterer [Fri, 26 Mar 2021 03:40:21 +0000 (13:40 +1000)]
tools/record: rework the event printing

For historical (but not very good) reasons, libinput record printed events
from the first device to the output file (or stdout) and buffered everything
else. On ctrl+c, the other devices' descriptions and the buffered events were
appended to the output file.

This makes the printing code rather complex. Simplify it by giving each device
a separate FILE* - the first device points to the real output file, the others
to a tempfile. On Ctrl+C we just append those tempfiles to the real output
file one-by-one and done.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agotools/record: rename the output file handling
Peter Hutterer [Fri, 26 Mar 2021 03:03:29 +0000 (13:03 +1000)]
tools/record: rename the output file handling

Less confusing than having output_file, out_file, and outfile.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agotools/record: remember the first device in the context
Peter Hutterer [Fri, 26 Mar 2021 02:58:11 +0000 (12:58 +1000)]
tools/record: remember the first device in the context

No functional changes since we can get this easily from the list itself, but
in the future the first device will be used more extensively.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agotools/record: append the devices in-order
Peter Hutterer [Fri, 26 Mar 2021 02:56:43 +0000 (12:56 +1000)]
tools/record: append the devices in-order

Using list_insert() here means the last device specified on the commandline is
the one that ends up in the file first - not very obvious...

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agotools/record: get rid of indent push/pop, replace with fixed indents
Peter Hutterer [Fri, 26 Mar 2021 02:46:19 +0000 (12:46 +1000)]
tools/record: get rid of indent push/pop, replace with fixed indents

Our file format is static enough that we don't need to use push/pop, we know
exactly which line is going where. So let's replace it with a static
indent instead.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agotools/record: mark the iprintf function as printf
Peter Hutterer [Fri, 26 Mar 2021 01:30:24 +0000 (11:30 +1000)]
tools/record: mark the iprintf function as printf

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agotools/record: switch the output file from an fd to a FILE*
Peter Hutterer [Fri, 26 Mar 2021 00:39:30 +0000 (10:39 +1000)]
tools/record: switch the output file from an fd to a FILE*

This is prep work to be more consistent with the use of tempfile later for
individual devices.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agotools/record: deduplicate the device opening logic
Peter Hutterer [Fri, 26 Mar 2021 00:06:47 +0000 (10:06 +1000)]
tools/record: deduplicate the device opening logic

With a new helper function strv_from_argv we can re-use the device opening
loop for all the use-cases we have.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agotools/record: free the namelist when we're done
Peter Hutterer [Thu, 25 Mar 2021 22:40:06 +0000 (08:40 +1000)]
tools/record: free the namelist when we're done

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agotools/record: localize a variable
Peter Hutterer [Thu, 25 Mar 2021 22:39:48 +0000 (08:39 +1000)]
tools/record: localize a variable

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agotools/record: de-duplicate an error message
Peter Hutterer [Thu, 25 Mar 2021 22:37:30 +0000 (08:37 +1000)]
tools/record: de-duplicate an error message

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agotools/record: factor out the output file collection
Peter Hutterer [Thu, 25 Mar 2021 22:34:50 +0000 (08:34 +1000)]
tools/record: factor out the output file collection

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agotools/code-formatting: Add EditorConfig file
JoseExposito [Fri, 19 Mar 2021 07:37:02 +0000 (08:37 +0100)]
tools/code-formatting: Add EditorConfig file

EditorConfig helps maintain consistent coding styles for multiple developers
working on the same project across various editors and IDEs:
https://editorconfig.org/

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
3 years agofallback: disable mouse scroll wheel while middle button is pressed
JoseExposito [Sat, 13 Mar 2021 19:06:06 +0000 (20:06 +0100)]
fallback: disable mouse scroll wheel while middle button is pressed

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
3 years agofallback: replace fallback_dispatch->wheel with an anonymous struct
JoseExposito [Thu, 11 Mar 2021 07:30:45 +0000 (08:30 +0100)]
fallback: replace fallback_dispatch->wheel with an anonymous struct

The current fallback_dispatch wheel struct, a device_coords, doesn't allow to
save extra information.
The new anonymous struct will allow to add a is_inhibited field to disable mouse
scroll while the middle button is pressed and, potentially, any required extra
state in the future.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
3 years agoquirks: add wildcard to HID-over-I2C names (for FreeBSD)
Greg V [Mon, 15 Mar 2021 22:11:41 +0000 (01:11 +0300)]
quirks: add wildcard to HID-over-I2C names (for FreeBSD)

The FreeBSD HID stack adds the device type to the evdev name,
so we get e.g. "ACPI0C50:00 18D1:5028 TouchPad".

(Maybe this shouldn't be matched by name at all though...)

Signed-off-by: Greg V <greg@unrelenting.technology>
3 years agoquirks: implement DMI support on FreeBSD
Greg V [Mon, 15 Mar 2021 22:06:01 +0000 (01:06 +0300)]
quirks: implement DMI support on FreeBSD

FreeBSD does not use Linux modaliases, so we have to generate these strings.
Unfortunately for us, the data in kenv has the chassis type pre-parsed into
a nice string, so we have to match these strings back into numbers.
Only relevant types are included to avoid bloating the code.

Signed-off-by: Greg V <greg@unrelenting.technology>
3 years agoquirks: add quirks for Apple SPI input devices
Greg V [Mon, 15 Mar 2021 22:17:06 +0000 (01:17 +0300)]
quirks: add quirks for Apple SPI input devices

The Linux applespi driver currently uses the Synaptics vendor ID
on the trackpad for some reason (even though, at least from bcm5974
we only know that Broadcom is involved..) but my upcoming FreeBSD driver
uses the Apple vendor ID everywhere, so add two quirks.

Signed-off-by: Greg V <greg@unrelenting.technology>
3 years agoquirks: recognize SPI bus
Greg V [Mon, 15 Mar 2021 22:02:54 +0000 (01:02 +0300)]
quirks: recognize SPI bus

Apple MacBooks (Broadwell/Skylake/Kaby Lake and Apple Silicon)
use SPI to communicate with the keyboard and trackpad.

Signed-off-by: Greg V <greg@unrelenting.technology>
3 years agotests: add a gesture test to ensure our unaccel deltas are in a sane range
Peter Hutterer [Mon, 15 Mar 2021 07:23:48 +0000 (17:23 +1000)]
tests: add a gesture test to ensure our unaccel deltas are in a sane range

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agogestures: Filter unaccelerated deltas for gestures
Alexander Mikhaylenko [Mon, 1 Mar 2021 16:09:37 +0000 (21:09 +0500)]
gestures: Filter unaccelerated deltas for gestures

Make sure the unaccelerated deltas are comparable to scroll deltas.

edit by whot:
The original intention of the unaccelerated motion data here was to provide
both accelerated and unaccelerated motion for gestures so it was possible to
have 1:1 mapping from gesture motion to screen activity.

Normalizing to 1000dpi this way would've worked for mice but touchpad
acceleration also includes the TP_MAGIC_SLOWDOWN (amongst other tricks) which
slows down motion to around 27% *before* applying the acceleration function.
On a 1000dpi touchpad (~40 units/mm) simply normalizing touchpad motion to
1000dpi results in pointer motion that is way too fast, it's lacking that
slowdown to 27% of original speed.

This results in the accelerated and unaccelerated gesture data being in
effectively two different coordinate systems with the caller having no ability
to relate the two.

Switching to the special constant acceleration applies that slowdown and
matches the data to the part of the acceleration curve where no (additional)
acceleration is applied.

It makes the gesture unaccelerated data comparable to the accelerated data
and to scroll data which uses the same process.

Fixes #582

Signed-off-by: Alexander Mikhaylenko <alexm@gnome.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agotest: push/pop event frames around three-touch movements
Peter Hutterer [Mon, 15 Mar 2021 07:08:55 +0000 (17:08 +1000)]
test: push/pop event frames around three-touch movements

Without this, each finger movement happens in a different evdev event frame.
Since we average deltas for gestures, this messes with the expected data.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agotest: simplify the helper for moving three touches at the same time
Peter Hutterer [Mon, 15 Mar 2021 06:56:23 +0000 (16:56 +1000)]
test: simplify the helper for moving three touches at the same time

There's no test case where we need to do something immediately after the last
event so we might as well do everything in the same loop.

This also fixes a bug where the first movement would usually get swallowed.
Test cases in general put the finger down at x/y, then move them to some other
position. We'd expect the first event in a loop to happen at x+n/y+n, not at
x/y again.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agotest: fix debugging messages for gesture begin event
Peter Hutterer [Mon, 15 Mar 2021 06:42:11 +0000 (16:42 +1000)]
test: fix debugging messages for gesture begin event

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agodoc/user: explain why we are doing motion normalization
Peter Hutterer [Wed, 10 Mar 2021 06:46:43 +0000 (16:46 +1000)]
doc/user: explain why we are doing motion normalization

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agofilter: correct comments about the threshold's unit
Peter Hutterer [Tue, 16 Mar 2021 04:28:31 +0000 (14:28 +1000)]
filter: correct comments about the threshold's unit

See d6e531349745ff38ae457169d5089ea61297accf for confirmation that the
threshold is intended to be in mm/s, the comment here is simply a leftover from
earlier times when the acceleration method was using device-units only.

Fixes #585

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agotest: update a few tests for more modern helpers
Peter Hutterer [Mon, 15 Mar 2021 05:40:17 +0000 (15:40 +1000)]
test: update a few tests for more modern helpers

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agotest: localize a few variables
Peter Hutterer [Fri, 12 Mar 2021 06:52:53 +0000 (16:52 +1000)]
test: localize a few variables

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agotouchpad: always push a touch's current point to the motion history
Peter Hutterer [Thu, 11 Mar 2021 04:45:17 +0000 (14:45 +1000)]
touchpad: always push a touch's current point to the motion history

The way touchpads (generally) work is that they get the position of each
finger on each scanout. The kernel filters touches that haven't moved to
reduce bandwidth so any touch that is logically down that we don't see an
update for is in the same position as during the last scanout.

Previously, touches that didn't sent events were effectively ignored, causing
our jump detection to fail:
- time t0: touch moves to position x/y, motion history time is set to t0
- time t1..t5: touch remains at position for several frames, no updates to the
  motion history
- time t6: touch jumps to position x+a/y+b
  - tp_detect_jumps() sees the last update time is t0 which is too long ago
    and exits without detecting a jump

This is fixed by pushing to the motion history any time we have *any* update -
if the touchpad notices a state change on any touch update all touches with
their current position, whether it changed or not.

This obsoletes the `time` field in the tp_touch struct, most of this patch is
passing down the current time to the few users of t->time.

Fixes #578

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agotest: add a comment to the thumb speed test
Peter Hutterer [Thu, 11 Mar 2021 06:21:28 +0000 (16:21 +1000)]
test: add a comment to the thumb speed test

Incorrect comment, the purpose of this test was to ensure that an unused slot
doesn't affect how other touches are treated, see commit 928bad9.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agotest: fix two inadvertent pointer jumps in a test
Peter Hutterer [Thu, 11 Mar 2021 05:51:47 +0000 (15:51 +1000)]
test: fix two inadvertent pointer jumps in a test

Got papered over by bugs in the implementation and didn't trigger the jump
detection or movement detection otherwise.

Related to #578

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
3 years agotools/debug-gui: draw a sprite for the unaccelerated pointer as well
Peter Hutterer [Wed, 10 Mar 2021 05:05:59 +0000 (15:05 +1000)]
tools/debug-gui: draw a sprite for the unaccelerated pointer as well

Add a second grey v-shaped (upside down triangle) pointer that moves around
with the unaccelerated deltas. This makes it easier to visualize how the
unaccelerated pointer moves around, the snake helps for some use-cases but not
all of them.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>