Commit graph

5731 commits

Author SHA1 Message Date
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
Peter Hutterer
7d8fac2868 quirks: add a helper function for returning quirks for a device
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1230>
2025-06-24 12:01:51 +10:00
Peter Hutterer
6f403a0cc9 evdev: replace get_key_type with evdev_usage_is_button/key
Makes this easier to use from other areas and we never cared about the
key type NONE anyway.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1230>
2025-06-24 12:01:51 +10:00
Borui Wang
9b28e7fd35 quirks: disable BTN_RIGHT on MS Surface Pro Flex Keyboard
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1236>
2025-06-23 23:21:12 +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
Peter Hutterer
0678ef2b98 util: add white to the ansi color escape codes
Can't be used because it's near invisible on white backgrounds
but have it for completeness.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1240>
2025-06-23 12:52:57 +00:00
Peter Hutterer
28a681932c wheel: match the state debug prefix with our other debug logs
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1240>
2025-06-23 12:52:56 +00:00
José Expósito
3a3e292d43 wheel: Rename scroll timeout callback function
The function name doesn't represent what the function really does.

Rename it and be consistent with the naming of other related functions
like wheel_set_scroll_timer() or wheel_cancel_scroll_timer().

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1241>
2025-06-23 02:18:24 +00:00
José Expósito
2461cdf497 wheel: Use libinput_device_has_capability()
Use this helper instead of checking manually.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1241>
2025-06-23 02:18:24 +00:00
José Expósito
35598db1ce wheel: Remove unused argument from fallback_wheel_process_relative()
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1241>
2025-06-23 02:18:24 +00:00
José Expósito
973d5ea587 wheel: Remove unused argument from fallback_rotate_wheel()
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1241>
2025-06-23 02:18:23 +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
fca5154d1d touchpad: fix a debug message "released" -> "is no longer palm"
The touch itself remains down and is now considered a finger again, so
let's make this message less ambiguous.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1239>
2025-06-23 10:40:37 +10:00
Peter Hutterer
29bb231114 plugin: require plugins to enable the frame callback for a device
The vast majority of plugins are only interested in a single or a few
devices. Require that they enable the frame callback for those devices
and don't notify them for any other frames.

Give each plugin a unique index and use that for a bitmask to check if
the plugin wants events for a particular device. If not, skip it.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1229>
2025-06-20 09:06:45 +00:00
Peter Hutterer
b31326dd02 plugin: log a debug message when a plugin terminates the event frame list
Our last plugin is our own evdev handling code so if the event queue
is empty before then that means a plugin has discarded the frame(s).

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1229>
2025-06-20 09:06:45 +00:00
Peter Hutterer
a6f7f55178 plugin: only load the plugin system once
This got lost during one of the many rebases, see
https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1217#note_2961314

It is required even without public-facing plugins so we don't end up
with duplicated plugins for every device added with
libinput_path_add_device().

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1229>
2025-06-20 09:06:45 +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
8f132481b3 zsh: add shell completion for the eraser button
Plus a note in tools/shared.h so we don't keep forgetting about this.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1234>
2025-06-20 10:01:20 +10:00
Peter Hutterer
4336c0456f zsh: fix shell completion for set-area
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1234>
2025-06-20 10:01:20 +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
b1bc500e0d Remove unused pc.in files
These have not been used since the switch to meson.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1232>
2025-06-19 13:05:26 +00:00
Peter Hutterer
f6c4a361c0 tools: disable GTK's deprecated warnings
I'd be surprised if those get removed before the whole X11 support is
removed - and in that case we can remove the x11 support as well.
So let's disable the warnings and deal with it when it truly breaks -
there are no replacements for what we want to do here after all.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1233>
2025-06-19 14:50:25 +10:00
Peter Hutterer
56f0524115 tablet: always allow BTN_STYLUS* for eraser button configuration
If the button we want to map to isn't enabled by the kernel allow
setting the button nonetheless. On some tablets we only get the
actual number of button codes (e.g. BTN_STYLUS only on an Inspiroy 2S)
so not being able to map the eraser button to some other button makes
this whole feature a bit pointless.

Special-case BTN_STYLUS* because these are the ones we'll always allow.

This fixes an issue with the eraser button defaulting to BTN_STYLUS2
on some devices but it couldn't actually be set to that value by the
caller.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1231>
2025-06-19 01:51:52 +00:00
Peter Hutterer
34da27650d tablet: take an uint32_t for the eraser button
For consistency with other set_button configuration options.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1231>
2025-06-19 01:51:52 +00:00
Peter Hutterer
9c042e9620 tools: add pressure threshold support to analyze per-slot-delta
Color touches above the minimum threshold and above the down threshold
so it's easier to analyze a recording. Sometimes touches move
unexpectedly but if it's low-enough pressure this may not affect
libinput.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1225>
2025-06-19 00:00:48 +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
42c0bff29b plugin: add internal api to notify plugins of tool configuration
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1218>
2025-06-18 19:38:14 +10:00
Peter Hutterer
4ef14e14e4 Add an API for configurable eraser button behavior
This adds the public API to configure an eraser button on a tablet tool
to emulate a normal button. In DEFAULT mode the eraser button will
simply do whatever it does by default (i.e. toggle to eraser).
In BUTTON mode the eraser button will be converted to a regular tool
button event, with libinput handling the underlying proximity event
madness.

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
e7ebb1bca6 tablet: keep a ref to the last tablet in proximity for each tool
99.9% of the time the next tablet will be the same tablet it was used on
last. Having a ref means we can modify tablet settings while the tool is
out of proximity.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1218>
2025-06-18 19:38:14 +10:00
Peter Hutterer
28e50024ab tablet: move the libwacom stylus query out into the caller
Better re-usability of the WacomStylus struct in subsequent patches.

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
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
83222a0798 plugins: Add the ability for a plugin to inject evdev frames
This adds a callback for plugins (and lua plugins) to inject an evdev
frame into the event stream. Unlike the prepend/append functions
this one injects the event at the bottom of the plugin stack as if
the device had sent the frame right then and there.

There's a drawback though: the event frame isn't marked as synthetic
so it cannot be identified without having a guard in the plugin so
the same frame is not reprocessed.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1217>
2025-06-18 06:18:54 +00:00
Peter Hutterer
5698e3c12f plugin: wrap timers for use by plugins
Wrapping timers means plugins we can set up the event queue for a plugin
when the timer triggers, allowing plugins to queue events during the
timer func.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1217>
2025-06-18 06:18:54 +00:00
Peter Hutterer
e69c0b9bfb plugin: allow a prefix during event frame printing
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1217>
2025-06-18 06:18:54 +00:00
Peter Hutterer
7137eb9702 plugin: add ability to queue more events in the evdev_frame callback
This adds a event queue pointer to each plugin that is set when the
plugin's evdev_frame() callback is invoked. If the plugin calls
libinput_plugin_queue_event_frame() during the callback the given
event frame is appended to an event frame list (starting with the
current frame). Once the callback completes, that frame list is
passed to the next plugin and each frame is replayed on the next plugin.

In the case of multiple plugins queueing events this effectively builds
a tree of frames which each level of the tree representing one plugin.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1217>
2025-06-18 06:18:53 +00:00
Peter Hutterer
38d92a96b9 evdev: don't notify plugins about devices we will never add
We require ID_INPUT on any device we want to handle so let's filter any
device that is missing that property before we notify the plugins.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1217>
2025-06-18 06:18:53 +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
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
7516dddeb3 util: fix a memleak for the dwtp string
Was assigned to dwt and any device with both dwt and dwtp would leak
that string.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1227>
2025-06-18 12:22:21 +10: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
2dcfda2ebc util: add ANSI escape codes for rgb and background rgb
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
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
d67474645c doc/user: device quirk matches have to be 0x prefixed
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1223>
2025-06-16 06:39:25 +00:00
Sebastian Lövdahl
17a7ed54d7 Fix typos in index.rst
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1222>
2025-06-13 17:28:05 +00:00