Commit graph

1909 commits

Author SHA1 Message Date
Peter Hutterer
ca6b82841c plugin/wheel: tighten the wheel debouncing code
The previous approach had a fixed threshold of 60 (half a detent)
below which scroll events were ignored. Reduce this threshold to have a
threshold of one device-specific delta. That threshold adjusts over time
to the device's individual minimum delta so after a few scroll event it
should settle on the lowest value possible.

The result is that fine-grained scrolling is possible on those devices
and only the very first scroll event is held back/swallowed, two events
in the same direction release scrolling.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1258>
2025-07-09 01:29:57 +00:00
Peter Hutterer
b347cc8691 pre-commit: bump to latest ruff-format
And update our python files according to latest ruff format output.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1259>
2025-07-09 00:13:00 +00:00
Peter Hutterer
a635176632 test: parametrize a test instead of in-test looping
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1260>
2025-07-08 04:02:50 +00:00
Peter Hutterer
9a9466b6a9 evdev: discard any frame with EV_SYN SYN_REPORT 1
When the kernel inserts a repeat frame it does that with EV_KEY code
value of 2 and the frame itself is a SYN_REPORT with value 1. Nothing in
libinput wants those repeat values, so let's discard them here before
anything tries to process them.

This inserted frame causes bugs on touchpads with EV_REP (rare enough)
because while the key event itself is dropped, the timestamp of the
frame still causes the next real frame's delta time to shorten,
resulting in wrong acceleration values.

Closes #1149

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1255>
2025-07-02 23:32:32 +00:00
Peter Hutterer
06d8750504 test: write pad events with a SYN_REPORT 0
The previous loop wrote whatever ring/strip value into the SYN_REPORT
event, causing frames with e.g. EV_SYN SYN_REPORT 7.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1255>
2025-07-02 23:32:32 +00:00
Peter Hutterer
dc48d28d74 test: de-duplicate some pad event handling with a helper
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1255>
2025-07-02 23:32:32 +00:00
Peter Hutterer
ce23e644aa test: keep waiting for a udev device on EAGAIN
This shouldn't happen because we turn off O_NONBLOCK on the udev
monitor's fd but sometimes this call fails with EAGAIN. If that happens,
keep busy-looping until we get some other error or success.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1257>
2025-07-02 12:46:50 +00:00
Peter Hutterer
6104fe44f1 test: if we fail to receive our udev device, abort with a useful error
This frequently fails when the runners are busy, so let's at least print
the errno to have *some* idea of what is failing.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1257>
2025-07-02 12:46:50 +00:00
Peter Hutterer
27f4b0ae74 Move mtdev into a plugin
mtdev is used only for MT Protocol A device of which there are quite
few. But that protocol is also a perfect example for event frames in ->
different event frame out so let's move this into the plugin pipeline.

Because the plugin doesn't really have full access to the device's
internals we set up mtdev base on the libevdev information rather than
just handing it the fd and letting it extract the right info.

A minor functionality change: previously mtdev-backed devices returned
zero on libinput_device_touch_get_touch_count(). Now it is hardcoded to
10 - the number of callers that care about this is likely near zero.

Because it's now neatly factored out into a plugin we can also make
mtdev no longer a strict requirement.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1245>
2025-07-02 06:53:05 +00:00
Peter Hutterer
8141159beb Add evdev_frame_append_one()
This is the most common usage, let's add a helper.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1245>
2025-07-02 06:53:05 +00:00
Peter Hutterer
d458b86240 test: correct two capability checks
We have one test device that only has a horizontal scroll wheel but not
a vertical one, causing these tests to run unexpectedly.

One test needs both enabled (not strictly so but let's not bother) and
the other one only needs the vertical wheel.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1251>
2025-07-01 09:20:57 +00:00
Peter Hutterer
e77239f0c7 test: update a test for current kernels
This device was added before high-res scroll events existing in the
kernel and it's used in a test to verify that a device that has
ABS_MT_POSITION_X but not _Y doesn't get automatically ignored.

Said test (device_quirks_no_abs_mt_y) uses a wheel event to verify that
we do get events from this device.

Since then we've long had kernels that support hi-res scrolling and the
kernel takes care of those events for us. So let's update the device
description and the events we send to include the high-resolution
events. That doesn't change the validity of the test but stops it from
becoming a false positive.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1251>
2025-07-01 09:20:57 +00:00
Peter Hutterer
2a1095924b Run clang-format over the code
This uses the .clang-format file in the follow-up commit, but committed
prior to that to ease review of said file and various integrations.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1246>
2025-07-01 16:42:44 +10:00
Peter Hutterer
490084569d test: add missing libevdev and util-mem includes
This only worked because of the include order.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1246>
2025-07-01 16:39:46 +10:00
Peter Hutterer
ed29a4f200 test: disable clang-format in test collections
It's too much effort fighting clang-format for these snippets which
all don't really do much anyway but are important to be read easily.

Let's categorically disable all formatting in the test collections and
move on.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1246>
2025-07-01 16:36:14 +10:00
Peter Hutterer
aebf3cd491 Add trailing commas to prevent clang-format oddities
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1246>
2025-07-01 16:36:14 +10:00
Peter Hutterer
784312a494 test: add clang-format directives to prevent formatting
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1246>
2025-07-01 16:36:14 +10:00
Peter Hutterer
4295c9bc1f test: switch more tests to litest_with_parameters
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1246>
2025-07-01 16:36:14 +10:00
Peter Hutterer
45ab542cc3 test: move a comment to avoid confusing clang-format
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1246>
2025-07-01 16:36:14 +10:00
Peter Hutterer
c83bd808ae test: add missing NULL for a test device's udev properties
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1246>
2025-07-01 16:23:04 +10:00
Peter Hutterer
d6f081730a test: replace some litest_test_param_fetch with getters
The _fetch() api isn't very friendly to clang-format so let's use the
one that results in better formatting.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1246>
2025-07-01 16:23:04 +10:00
Peter Hutterer
3df080513a test: fix automatic -j0 in debugger
If we're running in a debugger we want -j0 set by default so we don't
have to follow forks. This was traditionally JOBS_SINGLE but with
the drop of the check framework it's now -j0.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1253>
2025-06-30 05:58:46 +00:00
Peter Hutterer
2b22a0b4ba meson.build: require libevdev 1.10
Released in 2020, that's plenty old enough now to get rid of an ifdef.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1250>
2025-06-27 08:21:13 +00:00
Peter Hutterer
2e0c3c4af4 test: only check error messages for bugs
The use of the bug log handler should be replaced with the captured logs
now but meanwhile: don't abort if we're running in --verbose mode and
something prints a debug message before our expected bug error message.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1250>
2025-06-27 08:21:13 +00:00
Peter Hutterer
fc70dc90f0 test: replace two goto outs with _unref_
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1250>
2025-06-27 08:21:13 +00:00
Peter Hutterer
b61a896407 util: fix the ANSI escape codes for bright colors, add some more
The previous incarnations of BRIGHT_FOO were actually bold foo. Change
the colors over to use the actual bright colors and make bold a separate
set of defines.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1240>
2025-06-23 12:52:57 +00:00
cptpcrd
84085edc04 pad: honor send-events mode
The custom implementation of the send-events mode for tablet pads does
not actually suspend and resume the device, so events continue to be
sent despite the device being theoretically disabled. Fix this by
removing the custom send-events implementation in favor of
evdev_dispatch's implementation.

Also add a simple test to ensure the send-events mode works.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1238>
2025-06-23 01:58:29 +00:00
Peter Hutterer
b3cbc6053f test: handle plugin bugs and log messages in the test suite
For the bug log handler check we need to print our message to search for
the "plugin bug:" prefix. And since we have that message printed now
anyway we might as well add it to the abort message.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1229>
2025-06-20 09:06:44 +00:00
Peter Hutterer
c48aff86d7 tablet: implement eraser button disabling
This adds a new (internal) plugin that is responsible for eraser button
disabling.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1218>
2025-06-18 19:38:14 +10:00
Peter Hutterer
2d23d7f4aa tablet: implement the tablet proximity timer as plugin
Together with the "forced-tool" quirk (that enforces BTN_TOOL_PEN to be
set even if the tablet doesn't) since those two go hand-in-hand.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1218>
2025-06-18 19:38:14 +10:00
Peter Hutterer
e5e28ea7e6 tablet: implement the tablet double tool quirk as plugin
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1218>
2025-06-18 19:38:14 +10:00
Peter Hutterer
8974a15178 util: add a bitmask_t type for bit masks
Previously we used uint32_t for bitmasks but having a custom type means
we're less likely to confuse an int value with a mask type.

Two types of API here, the u32 api for passing in masks and a bit API
for passing in single bits.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1218>
2025-06-18 19:38:14 +10:00
Peter Hutterer
7e6a9f322f test: restore prefix search in the format
Otherwise we get false positives for "pressure:" since that may also
show up in the "Queuing ... " message for tablet events.

Fixes: 9f6b294e36 ("test: print the log message to a buffer, then print the whole lot")
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1228>
2025-06-18 05:32:39 +00:00
Peter Hutterer
471912aacf test: add litest_assert_strv_substring
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1226>
2025-06-17 13:50:58 +10:00
Peter Hutterer
a0a2416d11 test: add logcapturing to litest
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1226>
2025-06-17 13:50:58 +10:00
Peter Hutterer
1850ea18f4 util: add safe_atou64 for 64-bit values
Copy/paste from safe_atou

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1226>
2025-06-17 13:50:58 +10:00
Peter Hutterer
9f6b294e36 test: print the log message to a buffer, then print the whole lot
This reduces the number of actual printf calls to one and makes it
easier to search for a string in the message for highlighting.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1226>
2025-06-17 13:50:57 +10:00
Peter Hutterer
ef15d7ed08 test: fix the valgrind/debugger check
First condition was always false since we never run gdb and valgrind at
the same time.

Fixes: bd7b91065b ("evdev: warn if our event processing lags by 10ms or more")
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1221>
2025-06-13 09:39:11 +10:00
Peter Hutterer
24c84a65b4 test: insert libinput_dispatch() on the secondary context to avoid timeouts
In these tests we have a secondary context but didn't call
libinput_dispatch() regularly so we're guaranteed to hit timeout errors
on the secondary context for any event sequence longer than e.g. our
hold gesture timeout.

litest_touch_move_to() waits 10ms between movements and calls
libinput_dispatch() but obviously not for the secondary context so we
need to do this manually.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1221>
2025-06-13 09:39:11 +10:00
Peter Hutterer
41e988c99e Introduce our own evdev_event struct
In addition to the evdev_frame this struct is what contains our actual
events instead of a struct input_event. The goal of this is twofold:
slightly better memory usage per frame since we can skip the timestamp
and refer to the evdev frame's timestamp only. This also improves
handling a frame since we no longer need to care about updating
all events when the timestamp changes during appending events.

Secondly it merges the evdev type + code into a single "usage"
(term obviously and shamelessly stolen from HID). Those usages
are the same as the code names but with an extra EVDEV_ prepended,
i.e.  EV_SYN / SYN_REPORT becomes EVDEV_SYN_REPORT.

And they are wrapped in a newtype so passing it around provides
some typesafety.

This only switches one part of the processing over, the dispatch
interfaces still use a struct input_event

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1215>
2025-06-12 18:20:40 +10:00
Peter Hutterer
9f00f77bc4 Add an evdev_frame wrapper struct
The kernel only ever gives us a frame of events in one go (it flushes on
SYN_REPORT). We then need to look at that frame as a single state change
(keyboards excepted for historical reasons) so let's push this into a
proper struct we can pass around.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1215>
2025-06-12 18:20:40 +10:00
Ryan Hendrickson
8a95c0e3c8 wheel: add and use ignore_small_hi_res_movements
ignore_small_hi_res_movements is set to true if the underlying device is
not virtual.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1213>
2025-06-08 23:55:10 +00:00
Peter Hutterer
46950de903 util: return early when listing files from a NULL directory list
For consistency with "no matching file found" return a single-null-entry
array.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1212>
2025-06-05 00:49:57 +00:00
Peter Hutterer
d5761547da test: add litest_log_group() for easier test log grouping
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1210>
2025-06-04 04:07:26 +00:00
Peter Hutterer
669bc620aa test: add helpers for private data handling in tests
Our litest context needs the libinput user_data but it does provide
a `private` pointer for our test data - let's reduce the boilerplate
to access that.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1211>
2025-06-03 09:32:42 +00:00
Peter Hutterer
ec9c39da18 util: add a number of list helpers
The list_debug function is ifdef'd out, it'll be useful to debug
whenever we have some list corruption.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1209>
2025-06-03 09:10:15 +00:00
Peter Hutterer
ea50e1a92c test: add litest_assert_str_in/not_in() helpers
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1204>
2025-05-26 05:22:33 +00:00
Peter Hutterer
14c4667980 test: add litest_assert_not_reached()
Simpler than a specific litest_abort_msg() everywhere

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1204>
2025-05-26 05:22:33 +00:00
Peter Hutterer
e91e1c3111 util: add a tmpdir helper
With the __attribute__(cleanup) helper this makes it simple
enough to provide a tempdir inside a function that is (recursively)
automatically deleted when the variable is deleted.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1204>
2025-05-26 05:22:33 +00:00
Peter Hutterer
91d4f9e58e util: add an rmdir_r helper function
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1204>
2025-05-26 05:22:33 +00:00