Commit graph

385 commits

Author SHA1 Message Date
Sicelo A. Mhlongo
b3f7b4b1ea evdev: add support for SW_KEYPAD_SLIDE
A few devices have a keyboard/keypad which can be slid under the device,
leaving the device with only touch-based interaction. The corresponding kernel
event is reported as SW_KEYPAD_SLIDE [0]. Implement support in libinput.

Since the position of the switch varies across devices, it cannot always be
certain whether the keypad is usable when the switch is in the set position.
Therefore, do not automatically disable the keyboard.

[0] e68d80b13b/include/linux/linux/input-event-codes.h (L885)

Closes: #1069
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1242>
2025-12-11 13:28:41 +02:00
Peter Hutterer
11b97edcdc libinput 1.30.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2025-11-25 13:40:43 +10:00
Peter Hutterer
21e3a76bf5 libinput 1.29.902 2025-11-18 12:29:32 +10:00
Peter Hutterer
9461d1a9a1 Revert "lua: drop compatibility to 5.1 to allow for luajit"
While luajit seems to be the most popular (and fastest) lua
implementation for higher-level implementations, at the system level
it is relatively unused. Lua 5.4 on the other hand is used by other
system-level components like wireplumber and RPM. In the latter case
this means that lua is already available on every rpm-based distro
without further dependencies.

The performance of 5.4 seems to be acceptable and while luajit may be
faster the extra dependency requires more maintenance. Let's only expose
ourselves to that if absolutely needed.

This is not a strict revert because the code has changed a bit since
with several bugfixes deployed on top.

This reverts commit 2723cadaeb.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1366>
2025-11-18 01:46:53 +00:00
David Senoner
32ed3060f9 meson.build: use absolute path for callouts in udev rules
Udev rules can be put in many different directories to be found by udev
(see link #1). The callouts can be put only in one specific directory
if you want them to be found by using a relative path (only in
UDEV_LIBEXECDIR, see link #2). By passing the absolute path to the rule
you can make sure the callout will always be found.

Link 1: https://man7.org/linux/man-pages/man7/udev.7.html
Link 2: https://github.com/systemd/systemd/blob/main/src/udev/udev-spawn.c#L289

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1364>
2025-11-12 07:49:18 +01:00
Peter Hutterer
9b37ffd340 meson.build: fix indentation for the python files
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1357>
2025-11-06 23:46:42 +00:00
Peter Hutterer
b9a04e4d57 meson.build: export the plugin dir via pkgconfig
This is for the system-wide plugindir only - the only path where we'd
expect other packages to put plugins.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1357>
2025-11-06 23:46:42 +00:00
Peter Hutterer
b870abd2f3 libinput 1.29.901
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2025-11-04 11:58:29 +10:00
Peter Hutterer
eb01a4e73f plugins: add meson option to autoload plugins
Add an option to enable autoloading plugins from the default paths.
This makes testing and adoption for new users easier as they can (if
necessary) rebuild libinput with that option enabled instead of having
to wait for the compositor stack to update.

Autoloading will only use the default paths (/etc and /usr/lib) and will
only happen if the client does not modify those paths since that implies
the client wants to load plugins themselves. A client that adds a plugin
path but doesn't load the plugins is considered buggy anyway.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1347>
2025-10-31 05:25:29 +00:00
Peter Hutterer
f27fbdfa53 meson.build: change set10 to set
Follow-up to cfec80582e ("meson.build: change from config.set10() and #if to config.set() and #ifdef")
which was parallel to 9e37bc0cfa and the latter didn't get updated.

Fixes: 9e37bc0cfa ("plugins: add support for lua plugins to change evdev event streams")
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1347>
2025-10-31 05:25:29 +00:00
Zephyr Lykos
2d4482e03d meson.build: remove useless meson version checks
meson version requirement is bumped to 0.64.0 since
9e37bc0cfa ("plugins: add support for lua plugins to change evdev event streams")

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1344>
2025-10-24 00:21:12 +00:00
Zephyr Lykos
607852e66d meson.build: mark executables with install_tag
install_tag is available since meson 0.60.0:
https://mesonbuild.com/Reference-manual_functions.html#executable_install_tag

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1344>
2025-10-24 00:21:12 +00:00
Peter Hutterer
d1720d351d meson.build: bump to 1.29.900
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1338>
2025-10-23 00:06:09 +00:00
Peter Hutterer
2723cadaeb lua: drop compatibility to 5.1 to allow for luajit
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1192>
2025-08-01 16:49:00 +10:00
Peter Hutterer
9e37bc0cfa plugins: add support for lua plugins to change evdev event streams
This patch adds support for Lua scripts to modify evdev devices and
event frames before libinput sees those events.

Plugins in Lua are sandboxed and restricted in what they can do: no IO,
no network, not much of anything else.

A plugin is notified about a new device before libinput handles it and
it can thus modify that device (changes are passed through to our libevdev
context). A plugin can then also connect an evdev frame handler which
gives it access to the evdev frames before libinput processes them. The
example plugin included shows how to swap left/right mouse buttons:

    libinput:register({1})

    function frame(device, frame)
        for _, v in ipairs(frame.events) do
            if v.usage == evdev.BTN_RIGHT then
                v.usage = evdev.BTN_LEFT
            elseif v.usage == evdev.BTN_LEFT then
                v.usage = evdev.BTN_RIGHT
            end
        end
        return frame
    end

    function device_new(plugin, device)
        local usages = device:usages()
        if usages[evdev.BTN_LEFT] and usages[evdev.BTN_RIGHT] then
            device:connect("evdev-frame", frame)
        end
    end

    libinput:connect("new-evdev-device", device_new)

A few other example plugins are included in this patch

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1192>
2025-08-01 16:04:09 +10:00
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