Commit graph

4681 commits

Author SHA1 Message Date
Peter Hutterer
bfbcf1737b tablet: require a minimum pressure before we process pressure events
Tools default to 1% lower threshold (tip up) and 5% upper threshold (tip
down). But our distance vs pressure exclusion would reset the distance
for *any* pressure value, regardless how low that value was and how high
distance was in comparison.

A very low pressure value of less than 1% would then result in a
normalized pressure of 0, so we'd effectively just reset the distance to
zero and do nothing with the pressure. This can cause distance jumps
when the tool arbitrarily sends low pressure values while hovering as
seen in https://github.com/libsdl-org/SDL/pull/5481#issuecomment-1118969064

Commit 61bdc05fb0 from Dec 2017
  "tablet: set the tip-up pressure threshold to 1%"
was presumably to address this but no longer (?) works.

Fix this by addressing multiple issues at the same time:
- anything under that 1% threshold is now considered as zero pressure
  and any distance value is kept as-is. Once pressure reaches 1%,
  distance is always zero.
- axis normalization is now from 1% to 100% (previously: upper threshold
  to 100%). So a tip down event should always have ~4% pressure and we
  may get tablet motion events with nonzero pressure before the tip down
  event.
  From memory, this was always intended anyway since a tip event should
  require some significant pressure, maybe too high compared to e.g.
  pressure-sensitive painting
- where a tablet has an offset, add the same 1%/5% thresholds, on top of
  that offset. And keep adjusting those thresholds as we change the
  offset. Assuming that the offset is the absolute minimum a worn-out
  pen can reach, this gives us the same behaviour as a new pen. The
  calculation here uses a simple approach so the actual range is
  slightly larger than 5% but it'll do.

  Previously, the lower threshold for an offset pen was the axis minimum
  but that can never be reached. So there was probably an undiscovered
  bug in there.

And fix a bunch of comments that were either wrong, confusing or
incomplete, e.g. the pressure thresholds were already in device
coordinates.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-05-23 05:43:18 +00:00
Peter Hutterer
988329d5d9 tablet: use a helper variable to make the code more readable
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-05-23 05:43:18 +00:00
Peter Hutterer
393442fd3a test: rename a test function to make it easier to select
Because --filter-test does substring matching it's easier to have it
with a unique name rather than one that is a prefix of another.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-05-23 05:43:18 +00:00
Peter Hutterer
374d32c6be tablet: remove an always-true part of an if condition
A few lines north of here we return early if neither bit is set. If we
get to this point, at least one bit is set so this part of the condition
always evaluates to true.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-05-23 05:43:18 +00:00
José Expósito
a9e6cd03d0 Remove "device-" file
The file was unintentional added in a merge request:
https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/771

Fixes: 4d26736e ("Quirk all StarLabs trackpads")
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2022-05-18 23:17:35 +02:00
Sean Rhodes
4d26736e20 Quirk all StarLabs trackpads
Quirk all the StarLabs trackpads as they are all the same design,
a clickpad with physical buttons that act as one button.

Fixes #771.

Signed-off-by: Sean Rhodes <sean@starlabs.systems>
2022-05-16 05:10:10 +00:00
Peter Hutterer
e0e0e3aa8f quirks: remove an unused quirk
Removed in b925a0878b
   quirks: switch the models with missing buttonpad to use the new attr

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-05-16 12:24:16 +10:00
Peter Hutterer
8cb2b47b7b quirks: move the canvas quirk enum to the right order
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-05-16 12:23:57 +10:00
Sean Rhodes
a6fa862c00 quirks: Add quirk for StarLite Mk IV
Signed-off-by: Sean Rhodes <sean@starlabs.systems>
2022-05-09 18:26:05 +02:00
Peter Hutterer
5dd751a3d0 test: install libinput-test-utils as part of install-tests
This tests a bunch of internal utility functions that may work
differently depending on compiler flags, etc. Let's make that test
available so it can be verified on an installed system.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-05-09 05:03:00 +00:00
Peter Hutterer
43a8d769ac tools: add a libinput test tool as entry point for our test suites
We already install libinput-test-suite if the meson option install-tests
is set, see
  commit be7045cdc7
  test: make the test suite runner available as installed binary

To make other tests easily available and more discoverable, add a new
tool "libinput test" with the matching man page. This will also help us
to enforce some of the namespacing a bit better.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-05-09 05:03:00 +00:00
Peter Hutterer
d48c7e72f7 tools/analyze-recording: improve the repeated-events line printing
When redirecting to a file, we don't want lines like this:
   .. +2 ... +5 ... +9

Let's not print anything until we have collected all those lines and
then print the final result, we don't need a live update here.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-05-06 14:25:50 +10:00
Peter Hutterer
4ac5fd9e24 tools/analyze-recording: add --print-state to always print values
Helpful in comparing values that update frequently - without this the
last printed value may be way off the page when some other value comes
in that it needs to be compared to.

Values not seen yet default to zero - we can't query those from a
recording but it'll be good enough this way.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-05-06 14:05:13 +10:00
Peter Hutterer
200bc920ac tools/record: fix indentation for libinput events
Commit 0cdf459643
  tools/record: get rid of indent push/pop, replace with fixed indents

Introduced some magic to detect if there's a '-' at the start of the
format string to fix the identation. This only works if the format
string is constant though, leading to an indentation error when record
is run with --with-libinput.

Fixes 0cdf459643

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-05-06 14:04:59 +10:00
Peter Hutterer
f22d193879 tools: don't print a carriage return if we're not on a tty
Otherwise redirecting the output to a file leaves us with ugly ^M

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-05-04 17:32:27 +00:00
Peter Hutterer
509747c01b tools: allow limiting the axes in libinput analyse recording
Use --ignore ABS_X,ABS_Y or --only ABS_X,ABS_Y to ignore or limit to
only a specific axis set. Especially for tablet devices with their
multitudes of axes this makes analysing a particular set easier.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-05-04 17:32:27 +00:00
Alexander Courtis
e0813f4825 AttrLidSwitchReliability quirk default unreliable->reliable 2022-04-26 01:55:22 +00:00
Peter Hutterer
a423d7d326 evdev: strip the device name of format directives
This fixes a format string vulnerabilty.

evdev_log_message() composes a format string consisting of a fixed
prefix (including the rendered device name) and the passed-in format
buffer. This format string is then passed with the arguments to the
actual log handler, which usually and eventually ends up being printf.

If the device name contains a printf-style format directive, these ended
up in the format string and thus get interpreted correctly, e.g. for a
device "Foo%sBar" the log message vs printf invocation ends up being:
  evdev_log_message(device, "some message %s", "some argument");
  printf("event9 - Foo%sBar: some message %s", "some argument");

This can enable an attacker to execute malicious code with the
privileges of the process using libinput.

To exploit this, an attacker needs to be able to create a kernel device
with a malicious name, e.g. through /dev/uinput or a Bluetooth device.

To fix this, convert any potential format directives in the device name
by duplicating percentages.

Pre-rendering the device to avoid the issue altogether would be nicer
but the current log level hooks do not easily allow for this. The device
name is the only user-controlled part of the format string.

A second potential issue is the sysname of the device which is also
sanitized.

This issue was found by Albin Eldstål-Ahrens and Benjamin Svensson from
Assured AB, and independently by Lukas Lamster.

Fixes #752

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-04-20 13:32:31 +10:00
Peter Hutterer
a6ec596467 tools/record: fix the indentation of the system: section
Fixes 0cdf459643

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-04-07 14:46:57 +10:00
Tom Stellard
bdd2c9b76f Update valgrind.h to a newer version
This updates valgrind.h to the version that was packaged in
valgrind-devel-3.18.1-9.fc36.  This new version contains a fix for a
build failure with clang.

Signed-off-by: Tom Stellard <tstellar@redhat.com>
2022-04-05 17:22:42 -07:00
Peter Hutterer
3d064a07f8 doc/user: add a page to troubleshoot right-click Clickpads
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-03-28 23:25:26 +00:00
Peter Hutterer
423bb6455f meson: replace a meson.source_root() with the explicit directory
Removes the warning that source_root() has been deprecated since 0.56.0

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-03-28 21:41:58 +00:00
Peter Hutterer
f917661980 meson: fix a meson warning
run_command() wants a check kwarg now:

WARNING: You should add the boolean check kwarg to the run_command call.
         It currently defaults to false,
         but it will default to true in future releases of meson.
         See also: https://github.com/mesonbuild/meson/issues/9300

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-03-28 21:41:58 +00:00
José Expósito
321458576d test: disable hold gestures when are not required
Certain tests that make use of verify_left_handed_touch_motion can fail
depending on how quick they are executed, specially when using Valgrind.

Instead of ignoring the hold end event, use the existing mechanism to
disable hold gestures where we are not interested in them.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2022-03-28 12:44:55 +02:00
Peter Hutterer
395d12d634 util: auto-declare the element variable in ARRAY_FOR_EACH
All cases we have in our code base have an otherwise unused variable to
loop through the array. Let's auto-declare this as part of the loop.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-03-09 10:16:07 +10:00
pudiva chip líquida
1f1ddbc6df touchpad: new option dwtp (disable-while-trackpointing)
Add option to control whether the touchpad should be disabled while the
trackpoint is in use.

Fix #731

Signed-off-by: pudiva chip líquida <pudiva@skylittlesystem.org>
2022-03-08 01:33:40 +00:00
José Expósito
602e8dcb99 coding style: allow C99 variable declaration
Allow to declare variables before they are used in new written code.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2022-03-02 11:01:14 +00:00
José Expósito
5664007013 evdev: modernize variable declaration in evdev_device_is_joystick_or_gamepad
Declare the variables used to keep track of joystick buttons and
keyboard keys right before they are used for better readability and
consistency.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2022-03-02 08:35:23 +01:00
José Expósito
ea568a7bcb evdev: check well-known keyboard keys on joystick/gamepad detection
Create a list of well-known keyboard keys containing one the most
representative key(s) of a group.
The rule is based on the assumption that if the representative key is
present, other keys of the group should be present as well.

The groups are:

 - Modifiers group: KEY_LEFTCTRL.
 - Character group: KEY_CAPSLOCK.
 - Numeric group: KEY_NUMLOCK.
 - Editing keys: KEY_INSERT.
 - Multimedia keys: KEY_MUTE, KEY_CALC, KEY_FILE, KEY_MAIL,
   KEY_PLAYPAUSE and KEY_BRIGHTNESSDOWN.

When 4 of these keys are found, the device is tagged as a keyboard.

Fix #745

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2022-03-02 08:21:49 +01:00
Peter Hutterer
2e7dd3f84e gitlab CI: fail the sanity check stage if the fork is not public
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-02-24 10:21:53 +10:00
José Expósito
7850e4aecd libinput 1.20.0
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2022-02-19 13:32:09 +01:00
Markus Wall
4d5d6e7b4e quirks: add lenovo legion slim 7
This makes disable-when-typing for the touchpad work properly
on the Lenovo Legion Slim 7.

Signed-off-by: Markus Wall <markuswall@yahoo.se>
2022-02-15 20:02:38 +01:00
Markus Wall
e3b99fb394 Add quirks for Lenovo Legion Y740
This makes disable-when-typing for the touchpad work properly
on the Lenovo Legion Y740.

Tested on Lenovo Legion Y740-15IRHg.

Signed-off-by: Markus Wall <markuswall@yahoo.se>
2022-02-15 06:34:55 +00:00
José Expósito
dc86d66a32 doc/user: clarify fork visibility
Clarify that when forking libinput the public visibility level should be
selected. Otherwise, CI pipelines will fail on merge requests.

Also, update the fork URL.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2022-02-14 19:30:34 +01:00
Peter Hutterer
6914b41de5 doc: correct the documentation for reporting trackpoint bugs
libinput measure trackpoint-range was removed in 1.12

Fixes #734

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-02-11 07:45:40 +00:00
Alberto Fanjul
748280f9de pad: load libwacom device by path, not by usbid
to avoid conflicts with vendors reusing vid:pid try to find first by path

Signed-off-by: Alberto Fanjul <albertofanjul@gmail.com>
2022-02-07 21:26:47 +01:00
José Expósito
8e41089584 libinput 1.19.901
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2022-02-03 07:56:40 +01:00
Tiger Kaovilai
232c99341d Update 50-system-hp.quirks with 15-bl000 volume button quirks
https://bugzilla.redhat.com/show_bug.cgi?id=2048628

Signed-off-by: Passawit Kaovilai <passawit.kaovilai@gmail.com>
2022-02-03 01:28:55 +00:00
José Expósito
e9ccd4f402 doc: document disambiguation between two finger pinch and scroll
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2022-01-27 08:35:30 +01:00
José Expósito
8f53377680 gestures: fix disambiguation between two finger pinch and scroll
The changes introduced in b5b6f835af to
add support for hold gestures introduced a regression:

The mechanism that was in place to improve the disambiguation between
two finger pinch and scroll during the beginning of the gesture stopped
working and instead a bug warning was printed on the log.

Fix the regression by allowing to go from the scroll state to the pinch
state.

Fix #726

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2022-01-27 08:35:30 +01:00
Peter Hutterer
e9aba30a78 gitlab CI: update to latest CI templates
This include ci-templates commit 0c312d9c7255f which hopefully fixes our
current headaches with the one non-signed-off commit that somehow
managed to find its way into the repo.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-01-27 09:16:46 +10:00
spacefreak86
7d309cc101 quirks: Add Asus ROG Strix G15 2021 keyboard quirk 2022-01-20 04:44:07 +00:00
José Expósito
c8d75da26d tools: remove hardcoded value for boolean quirks
When a boolean quirk was displayed its real value was ignored and
instead a hardcoded value of 1 was always used.

Get the quirk real value and display it.

Fix #725

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2022-01-15 13:45:48 +01:00
José Expósito
cf6c97119f wheel: allow to scroll while middle button is pressed
Since cd4f2f32b5 ("fallback: disable mouse scroll wheel while middle
button is pressed") the mouse wheel is inhibited while the mouse wheel
is pressed.

The original intention of this feature was to avoid unintended scroll
while pressing the scroll wheel. However, now that high-resolution
scroll is fully integrated in libinput we can improve this feature and
filter unintended scroll (below half a detent) and allow it when it is
intended (over half a detent).

Remove the "WHEEL_STATE_PRESSED" state from the wheel state machine and
let the general heuristics handle this case.

Also, remove the specific tests for this feature as now it is covered
by the general test cases.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-12-30 08:32:40 +01:00
José Expósito
cddf956990 quirks: Remove Lenovo Trackpoint Keyboard II quirk
The device sends its own scroll events when its trackpoint is moved
while the middle button is pressed.

Because scroll events are not going to be inhibited after a certain
amount of scroll is detected in a follow up commit, remove the quirk.

This reverts 53bd70f4c7 ("quirks: Lenovo Trackpoint Keyboard II")

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-12-29 18:11:55 +01:00
Peter Hutterer
e4548f5805 meson.build: disable -Wunused when building the litest selftest
We use check directly to test the various litest bits, so if ifdef out
the litest main() and a few other bits. This results in compiler
warnings that aren't worth fixing - a lot of moving code around for no
real benefit.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-12-23 08:18:06 +10:00
Peter Hutterer
5a568cfaf0 evdev: silence a clang compiler warning
Signed-off-by:Peter Hutterer <peter.hutterer@who-t.net>
2021-12-22 15:07:56 +10:00
Peter Hutterer
57a592e2df tablet: handle a BTN_TOOL_PEN on top of BTN_TOOL_RUBBER
The Wacom 524C device triggers a kernel bug in the InRange and Invert
handling. Every time BTN_TOUCH is set/unset the device also sets/unsets
BTN_TOOL_PEN even when we nominally have the eraser in proximity.

The event sequence effectively looks like this:

    # on prox in
    BTN_TOOL_RUBBER 1
    -- SYN_REPORT ---
    # on tip down
    BTN_TOOL_PEN 1
    BTN_TOUCH 1
    -- SYN_REPORT ---
    # on tip up
    BTN_TOUCH 0
    BTN_TOOL_PEN 0
    -- SYN_REPORT ---
    # on prox out
    BTN_TOOL_RUBBER 1
    -- SYN_REPORT ---

To work around this, bias our duplicate tool detection code towards the
eraser - if we have an eraser in-prox already and the pen goes
in-prox, ignore it and continue with the eraser. But if we have a pen
in-prox and the eraser goes in-prox as well, force a prox-out for the
pen and put the eraser in-prox.

Recording originally from
https://github.com/linuxwacom/xf86-input-wacom/issues/186

Fixes #702

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-12-14 08:09:20 +00:00
Peter Hutterer
167cebf7de test: add a test device for the Wacom 524C device
This device triggers a kernel bug in the InRange and Invert handling,
every time BTN_TOUCH is set the device also sets BTN_TOOL_PEN even when
we currently have the eraser in proximity.

Recording from https://github.com/linuxwacom/xf86-input-wacom/issues/186

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-12-14 08:09:20 +00:00
Peter Hutterer
23f5d9074b test: allow for a hold end event when verifying touch motion
Depending on how quick the test suite runs we may get a hold end event
here. Let's silently ignore that one since we aren't interested in it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-12-14 08:09:20 +00:00