Commit graph

2567 commits

Author SHA1 Message Date
Peter Hutterer
dc8f7c3671 util: allow strv_from_string() with NULL nelems
The caller may not care about the number of elements, let them be
careless.

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
José Expósito
ee35e04207 wheel: Remove unnecessary pending event
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1235>
2025-06-25 00:43:29 +00:00
José Expósito
5bc683c8dd wheel: Drop high-resolution wheel emulation workaround
Remove the workaround used to emulate high-resolution wheel scroll
events on kernels < 5.0 (~6 years old kernels).

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1235>
2025-06-25 00:43:29 +00:00
José Expósito
ed3cb9cc48 fallback: Remove fallback_init_debounce() declaration
A leftover from commit 2c6fa261a3 ("evdev: replace the debounce
handler with a plugin")

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1247>
2025-06-24 10:12:12 +02:00
Peter Hutterer
e99f0c995e evdev: rename evdev_device_dispatch_one to evdev_device_dispatch_frame
Because it now takes a frame as argument, no longer a single event.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1244>
2025-06-24 03:14:16 +00:00
Peter Hutterer
f003dbb6cb plugins: fix the timer name for the tablet proximity timer
Since every device has one of those, let's name it after the device's
system.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1244>
2025-06-24 03:14:16 +00:00
Peter Hutterer
d2316d7e93 plugins: fix some indentation in the eraser button plugin
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1244>
2025-06-24 03:14:16 +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
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
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
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
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
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
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
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
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
5d23794d53 tablet: disable smoothing for uinput devices
When a tablet was created via uinput we trust that the
tablet's events are preprocessed to the point where we
no longer need to apply smoothing to the axes.

Closes #1120

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1219>
2025-06-12 09:49:15 +00:00
Peter Hutterer
c4d0d2c09d Switch some uint32_t usage loops to use evdev_usage_next
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1215>
2025-06-12 18:20:40 +10:00
Peter Hutterer
1c5715fedf Use a newtype for the keycode, button code and pad button
This provides both some type-safety but also better readability of what
the integer we're passing around is supposed to be. In particular the
pad buttons are numeric buttons while the normal buttons are evdev
codes.

Future extension of this could be to also check for (or against) the
valid BTN_* ranges for a button code or keycode.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1215>
2025-06-12 18:20:40 +10:00
Peter Hutterer
c821bbd8e4 Drop struct input-event from dispatch->interface->process
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1215>
2025-06-12 18:20:40 +10:00
Peter Hutterer
28ee82b6f1 Switch the tablet pad backend to use struct evdev_event
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1215>
2025-06-12 18:20:40 +10:00