Commit graph

370 commits

Author SHA1 Message Date
Peter Hutterer
d557a649fd Add a public plugin system to libinput
This patch adds a new API for enabling public "plugins" in libinput, in
addition to the exisitng internal ones. The API is currently limited to
specifying which paths should be loaded and whether to load them.
Public plugins are static, they are loaded before the context is initialized
and do not update after that.

If plugins are to be loaded, libinput will then run through those paths,
look up files and pass them to (future) plugins to load the actual
files.

Our debugging tools have an --enable-plugins and
--disable-plugins option that load from the default data paths
(/etc/libinput/plugins and /usr/lib{64}/libinput/plugins) and from
the $builddir/plugins directory.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1192>
2025-08-01 15:38:39 +10:00
Peter Hutterer
936cee2242 libinput 1.29.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2025-07-31 15:26:54 +10:00
Peter Hutterer
b8651d798c tools: add a debug-tablet-pad tool
A simple tool to check the evdev and libinput events from a tablet pad.
This is near-identical to the existing debug-tablet tool but adjusted
for tablet pad events.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1280>
2025-07-28 23:40:33 +00:00
Peter Hutterer
cfec80582e meson.build: change from config.set10() and #if to config.set() and #ifdef
config.set10 is much more convenient and nicer to read but can provide
false positive if the value is 0 and #ifdef is used instead of #if. So
let's switch everything to use #ifdef instead, that way we cannot get
false positives if the value is unset.

Closes #1162

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1277>
2025-07-28 12:04:09 +10:00
Peter Hutterer
36b2afae82 plugin: ignore high-resolution wheel events from disabled wheels
Make sure we drop any potential high-resolution wheel events from a
device that isn't supposed to have them.

Where the device's axes were disabled due to a quirk, re-enabling the
axes means the device's events won't be filtered anymore. Our wheel
emulation plugin thus emulates high-resolution wheel events in addition
to the hardware events.

Fix this by simply filtering out any high-resolution wheel events on any
device that uses this plugin.

Closes #1160

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1279>
2025-07-24 09:13:12 +10:00
Peter Hutterer
6aefc2f166 libinput 1.28.903
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2025-07-21 13:34:46 +10:00
Peter Hutterer
abd5989ee8 plugin: prevent potential keycode leakage to the logs
Mixup of #if vs #ifdef caused this condition to always be treated as
true, resulting in leakage of key codes to the logs if the libinput log
level was set to debug.

Fixes: 7137eb9702 ("plugin: add ability to queue more events in the evdev_frame callback")

Closes #1163

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1276>
2025-07-21 13:02:20 +10:00
Peter Hutterer
013ed167a4 libinput 1.28.902
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2025-07-17 11:29:06 +10:00
Peter Hutterer
eed4f84508 test: add a typical PS/2 wheel mouse
Notably without a high-resoulution wheel to ensure we run the tests on
those devices too.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1275>
2025-07-17 00:36:52 +00:00
Peter Hutterer
18b34d0bc0 test: split some tablet tests into new groups
Our CI pipeline fails 9 times out of 10 on the valgrind tests. The tests
seem to finish in either 35 min or exceed the 60 min timeout limit, with
nothing in between. To avoid this let's split into more groups so we can
a) run those more in parallel and b) are less likely to hit the
timeout when run slowly.

Analysis of recent logs shows the eraser button tests to be the worst
offender, taking 752s (due to the combinatorial explosion) alone. The
various tip and proximity tests together also take some time so let's
group those out.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1274>
2025-07-17 00:16:02 +00:00
Peter Hutterer
c24ad64d18 meson.build: drop the timeouts to fit into the CI's 60 min limit
The vm tests had a 20 min timeout and a multiplier of 100. Our CI will
kill us (without logs) after 60 minutes.

Let's drop this to ~18min and a multiplier of 3 which gives us a few
minutes for setup before the CI terminates us. Ideally this means
we get some meson logs on timeout failures.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1274>
2025-07-17 00:16:02 +00:00
Peter Hutterer
1dec6f98b0 plugins: add a plugin to emulate high-resolution wheel events
Fixes a regression causing missing scroll events on devices where the
kernel only sets REL_WHEEL/REL_HWHEEL but not the corresponding
hires events. On those devices we would get the legacy axis events but
no longer the new ones.

The mouse wheel plugin will correctly emulate missing hires events
but it doesn't attach to devices where the hires bit is never set.

This plugin can be very simple - since we know we enabled the code on
this device we don't need to keep any extra state around. If our frame
handler is called for this device we want to add the hi-res events.

Theoretically this breaks if the device has only one hi-res axis enabled
but not the other one (i.e. REL_WHEEL_HI_RES but only REL_HWHEEL) but
that's too theoretical to worry about.

Closes #1156

Fixes: 31854a829a ("plugin: only register the wheel plugin on devices that have a wheel")
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1268>
2025-07-14 11:14:15 +10:00
Peter Hutterer
7716954365 libinput 1.28.901
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2025-07-10 11:51:28 +10:00
Peter Hutterer
48d6e959ff test: add a test device for a pressureless tablet
See https://gitlab.freedesktop.org/libinput/libinput/-/issues/1152

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1263>
2025-07-09 21:21:32 +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
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
José Expósito
d1800a76fe evdev: Handle scroll wheel with a plugin
Transform the code present in evdev-wheel.c into a internal plugin.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1235>
2025-06-25 00:43:29 +00:00
Peter Hutterer
2c6fa261a3 evdev: replace the debounce handler with a plugin
Same functionality but run as a plugin on the evdev stream instead.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1230>
2025-06-24 12:01:51 +10:00
Jan Engelhardt
d67d45a8fd Teach meson about pkgconfig Requires.private
Fixes: ed87c6dbb0 ("Add libudev and -lm to Requires.private")
added Requires.private, 4f4bfae2a1 ("Add meson.build file")
forgot to transplant the logic to meson.build.

Fixes: 4f4bfae2a1 ("Add meson.build file")

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1232>
2025-06-19 13:05:26 +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
905b4c6a4c evdev: implement our evdev device dispatch as plugin
This makes event handling easier where plugins queue other event frames
per frame. Our initialization guarantees that our evdev code is alway
the last plugin in the series so in the no-plugin case we just pass on
to that.

The effective event flow is now:
    evdev.c -> plugin1 -> plugin2 -> evdev-plugin.c -> evdev.c
except that no plugins exist yet.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1217>
2025-06-18 06:18:54 +00:00
Peter Hutterer
3958ba44c2 Add an internal plugin system to libinput
This adds the scaffolding for an internal plugin architecture. No such
plugin currently exists and any plugin implemented against this
architecture merely is plugin-like in the event flow, not actually
external to libinput.

The goal of this architecture is to have more segmented processing
of the event stream from devices to modify that stream before libinput
ever sees it. Right now libinput looks at e.g. a tablet packet and then
determines whether the tool was correctly in proximity, etc.
With this architecture we can have a plugin that modifies the event
stream that the tool is *always* correctly in proximity and the tablet
backend itself merely needs to handle the correct case.

The event flow will thus logically change from:
   evdev device -> backend dispatch
to
   evdev device -> plugin1 -> plugin2 -> backend dispatch

The plugin API is more expansive than we will use immediately, it is the
result of several different implementation branches that all require
different functionality.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1217>
2025-06-18 06:18:53 +00:00
Peter Hutterer
76f88deb24 touchpad: remove a workaround for an old libevdev bug
Require libevdev 1.9, released in 2020.

Reverts commit 1e1b9c0e60 ("touchpad: never reduce the slot count to 0")

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1224>
2025-06-16 17:11:14 +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
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
efea8463fe util: add a helper to find files in a set of directories
Returns a number of paths for files with a given suffix in a
priority-sorted list of directories.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1204>
2025-05-26 05:22:33 +00:00
Peter Hutterer
66d32803d3 meson.build: don't error on deprecated declarations with -Werror
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1203>
2025-05-16 20:45:49 +10:00
Peter Hutterer
8177a685c2 meson.build: fix detection of C23 auto
Sadly, this detection was broken because in C everything defaults to
type int. Casting a const char* to int is permitted but generates a
warning which was promptly ignored by meson.

This result in HAVE_C23_AUTO being set on compilers that don't by
default have -Werror=implicit-int and "auto" ended up being just an
"int".

Change the detection to use gmtime() which returns a struct, and add a
basic test using one of our struct-returning utility functions, just to
be sure.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1198>
2025-05-08 23:06:58 +00:00
Peter Hutterer
ecd4ea3053 util: add a wrapper for the C23 auto keyword
C23 auto is basically __auto_type so let's wrap it if our compiler
doesn't provide it (yet).

This lets us use `auto` as type specifier, e.g. compare
   enum libinput_config_status status = libinput_device_config_set(...)
   auto status = libinput_device_config_set(...)

Note that as of now meson will never detect this as it requires -std=c23
to be passed to the compiler. This flag is only supported by Clang 18
(released 2024) and we don't want to break things for older compilers
for what is a bit of a niche feature right now.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1181>
2025-04-07 09:00:42 +00:00
Peter Hutterer
a92d635af1 test: rename test-util-includes.c to .c.in
This way it doesn't get picked up by static analysis tools which are
then unhappy about the @FILE@ placeholder

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1175>
2025-04-04 15:47:23 +00:00
Peter Hutterer
000d9282cd test: split litest's main() into a separate file
Instead of having this ifdef'd out split the main and directly
associated functions out into a separate file.

That ifdef used to exist so we can use parts of litest in some other
files (the selftest and the utils test). Those tests care mostly
about the assertion helpers so long-term a split into
assert helpers and "rest of litest" would be better. For now, this will
do.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1174>
2025-04-04 06:28:07 +00:00
Peter Hutterer
4f7b4ef0e4 libinput 1.28.1 2025-04-01 12:46:07 +10:00
Peter Hutterer
39fa451e7e pad: fix handling of direct mode switch buttons
A tablet with multiple mode toggle buttons had each mode toggle button
merely cycle to the next mode in the sequence, removing the whole point
of having multiple toggle buttons.

Fix this by defaulting each mode toggle button to "next". Once we
have initialized all buttons we can check if we have multiple buttons -
if so we number them sequentially so that the first button maps to mode
0, the second maps to mode 1, etc.

Closes #1082

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1132>
2025-03-27 04:57:33 +00:00
Peter Hutterer
d344ae9ef6 libinput 1.28.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2025-03-24 13:54:25 +10:00
Peter Hutterer
8cd5cad1c1 meson: add option for internal event debugging
These have been behind #if 0 for ages but there are more to come, let's
make it possible to toggle those on/off with a meson option.

This is an option that must not be used in a release build, it will leak
key codes to the logs.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1156>
2025-03-13 06:13:38 +00:00
Peter Hutterer
9714253190 test: re-use the event printing in litest
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1156>
2025-03-13 06:13:38 +00:00
Peter Hutterer
6c3c2e99c0 libinput: use the shared event printing for debugging events
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1156>
2025-03-13 06:13:38 +00:00
Peter Hutterer
9907cf2eeb Move the event printing out into a utility
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1156>
2025-03-13 06:13:38 +00:00
Peter Hutterer
3aa004b964 libinput 1.27.1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2025-01-06 15:04:14 +10:00
Peter Hutterer
64d1f198fb libinput 1.27.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2024-11-19 13:41:39 +10:00
Peter Hutterer
384e946960 pad: support dial modeswitch buttons
This requires unreleased updates to libwacom [1], currently hiding
behind an ifdef so we don't require that particular version.

[1] https://github.com/linuxwacom/libwacom/pull/805

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1070>
2024-10-31 11:04:45 +10:00
Peter Hutterer
1f8a4df58c test: drop the --xml-prefix option
litest-runner outputs in YAML and no-one ever looks at the XML files
anyway. They are used to provide nice pipeline summaries but again,
no-one looks at those because they're not very useful.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
16e5bdabac test: intercept and collect valgrind errors
This works because we always invoke with --exit-errorcode=3 from the
test suite. It won't work for manual invocations but oh well.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
0cfde0f95f test: make the utils test a "pure" litest-runner test
Now that we have the runner let's use it directly for this set of simple
test.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
41c08f0816 test: add litest-runner as test suite runner
This replaces check. The code is a copy of pwtest which I wrote years
ago for pipewire but adjusted for us here the last few days.

There are a few advantages over check:
- Ability to SKIP tests or mark them as NOT_APPLICABLE, the latter
  of which is used for early checks if a device doesn't meet
  requirements.
- it captures stdout/stderr separately
- colors!
- YAML output format makes it a lot easier to read the results and
  eventually parse them for e.g. "restart failed tests"

Less abstraction: we set up the tests, pass them to the runner and run
them with the given number of forks. This is an improvement over before
where we forked into N test suites which each called check which then
forked again. Since we're now keeping track of those processes
ourselves we can also write tests that are expected to fail with
signals.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
6cac0d4d2f test: make the utils test another litest
This doesn't really gain us anything for now but it's prep work for
dropping check and the custom invocations of check.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
4fa5ea268e util: add a generic stringbuffer with a few helper functions
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
2024-10-30 23:20:42 +00:00
Peter Hutterer
e0f671126d util: add the backtrace printing function as separate util
Might as well make this easier to re-use since it doesn't do anything
specific to litest.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1066>
2024-10-23 10:08:12 +10:00