Commit graph

56 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
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
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
0ecd08c134 tools: use __attribute__(cleanup)
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1184>
2025-04-16 17:04:58 +10:00
Peter Hutterer
546debe926 Remove empty lines between closing braces
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1190>
2025-04-16 11:44:09 +10:00
Peter Hutterer
9f98e6d573 tools/debug-events: print all available options
They're still without explanation but better than just printing
"[options]" without even pointing to the man page.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1162>
2025-03-26 11:26:25 +10: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
28e896916a tools/debug-events: separate event handling from event printing
Move the big switch statement into a helper function and reduce it to a
statement that only does that bits that weren't related to printing.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1156>
2025-03-13 06:13:38 +00:00
Peter Hutterer
1dd8a8965c tools/debug-events: make the print_ functions return the printed string
Two advantages here: fewer actual printf() calls making the output
slightly more coherent if there are other things writing to stdout but
also better re-usability since we can now move the print functions to
shared code.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1156>
2025-03-13 06:13:38 +00:00
Peter Hutterer
33612fb37c tools/debug-events: move the event type str to a helper function
This isn't really necessary for the code as-is it makes debugging things
easier.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1044>
2024-09-12 00:59:13 +00:00
Peter Hutterer
dc249b0ffe tools/debug-events: add ability to compress motion events
If --compress-motion-events is given (and stdout is a tty) reduce
the output printed to one line per repeated motion/axis/scroll sequence
(with a count). Example output:
 event6   POINTER_MOTION          108 +1.912s	 1.00/ -1.00 ( +1.00/ -1.00))
 event6   POINTER_BUTTON              +2.008s	BTN_LEFT (272) pressed, seat count: 1
 event6   POINTER_BUTTON              +2.074s	BTN_LEFT (272) released, seat count: 0
 event6   POINTER_MOTION           39 +5.249s	 0.00/  0.99 ( +0.00/ +1.00)
 event6   POINTER_BUTTON              +5.385s	BTN_LEFT (272) pressed, seat count: 1
 event6   POINTER_MOTION           66 +6.031s	-1.00/  0.00 ( -1.00/ +0.00)
 event6   POINTER_BUTTON              +6.401s	BTN_LEFT (272) released, seat count: 0

The event count (108, 39 and 66) is only printed for more than one event
in sequence so the output is otherwise identical (but 4 spaces wider
now)

If stdout is not a tty the event count is printed but no compression
happens since we rely on a ansi escape sequence for that. Could be fixed
by changing the current print statements to print a \n before the
current event instead of at the end of the current line.

This makes debugging events easier as button events and similar are no
longer obscured by pages of motion events in between.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1041>
2024-09-11 12:49:28 +10:00
Peter Hutterer
09fd1cdd98 tools/debug-events: ignore old-style pointer axis events completely
Since they're interleaved with the more modern finger/wheel/continuous
events they mess up our repeate count, preventing compression for those
events.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1041>
2024-09-09 15:41:45 +10:00
Peter Hutterer
1725b7d606 Add support for --set-pressure-range to the debugging tools
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1009>
2024-06-10 15:09:19 +00:00
Joshua Goins
beca998122 tablet: add API for relative dials
Some tablets such as those in the XP-PEN PRO series use "dials" which
are actually scrollwheels and emit EV_REL events. These should not be
emulated as rings (which are absolute) so we must expose them as a new
tablet event.

Adds LIBINPUT_EVENT_TABLET_PAD_DIAL that work largely identical as our
high-resolution wheel events (i.e. the values are in multiples or
fractions of of 120). Currently supports two dials.

This is a lot of copy/paste from the ring axes because the interface is
virtually identical. The main difference is that dials give us a v120
value in the same manner as our scroll axes.

Notes:
- REL_DIAL is mutually exclusive with REL_WHEEL, we assume the kernel
  doesn't (at this point) give us devices with both. If this changes for
  devices with three dials (wheel + hwheel + dial) we need to add code
  for that.
- REL_DIAL does not have a high-resolution axis and we assume that any
  device with REL_WHEEL_HI_RES will also have REL_HWHEEL_HI_RES (if the
  second wheel exists).
- With dials being REL_DIAL or REL_WHEEL there is no possibility of
  detecting a finger release (the kernel does not route EV_RELs with a
  value of zero). Unless this is implemented via a side-channel - and it
  doesn't look like any hardware that supports dials does that - we
  cannot forward any information here. So unlike absolute rings we
  cannot provide a source information here.

Closes #600

Co-authored-by: Peter Hutterer <peter.hutterer@who-t.net>
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/967>
2024-02-20 02:49:05 +00:00
Peter Hutterer
c1ab44c566 tools: fix a few scan-build dead store warnings
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-04-20 09:51:49 +10:00
Peter Hutterer
0266428c93 tools: fflush the output in debug-events after each set of events
Fixes e.g. the case where debug-events is used to get the initial device
list but no more. Since we never flush, the content is stuck in the
buffers and gets lost.

Easy way to reproduce: `libinput debug-events | cat`, then ctrl+c and see
nothing show up (before this patch, anyway).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-01-13 09:28:32 +10:00
Peter Hutterer
a5dd45e8ce Remove duplicate empty lines in our source
We only touch src and tools, imported headers from include are not ours
to change.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-11-25 10:08:20 +10:00
pudiva chip líquida
1f1ddbc6df touchpad: new option dwtp (disable-while-trackpointing)
Add option to control whether the touchpad should be disabled while the
trackpoint is in use.

Fix #731

Signed-off-by: pudiva chip líquida <pudiva@skylittlesystem.org>
2022-03-08 01:33:40 +00:00
Peter Hutterer
6bb02aaf30 High-resolution scroll wheel support
Starting with kernel v5.0 two new axes are available for high-resolution wheel
scrolling: REL_WHEEL_HI_RES and REL_HWHEEL_HI_RES. Both axes send data in
fractions of 120 where each multiple of 120 amounts to one logical scroll
event. Fractions of 120 indicate a wheel movement less than one detent.

This commit adds a new API for scroll events. Three new event types that encode
the axis source in the event type name and a new API to get a normalized-to-120
value that also used by Windows and the kernel (each multiple of 120 represents
a logical scroll click).

This addresses a main shortcoming with the existing API - it was unreliable to
calculate the click angle based on the axis value+discrete events and thus any
caller using the axis value alone would be left with some ambiguity. With the
v120 API it's now possible to (usually) calculate the click angle, but more
importantly it provides the simplest hw-independent way of scrolling by a
click or a fraction of a click.

A new event type is required, the only way to integrate the v120 value
otherwise was to start sending events with a discrete value of 0. This
would break existing xf86-input-libinput (divide by zero, fixed in 0.28.2) and
weston (general confusion). mutter, kwin are unaffected.

With the new API, the old POINTER_AXIS event are deprecated - callers should use
the new API where available and discard any POINTER_AXIS events.

Notable: REL_WHEEL/REL_HWHEEL are emulated by the kernel but there's no
guarantee that they'll come every accumulated 120 values, e.g. Logitech mice
often send events that don't add up to 120 per detent.

We use the kernel's wheel click emulation instead of doing our own.

libinput guarantees high-resolution events even on pre-5.0 kernels.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-08-31 08:45:01 +02:00
José Expósito
b6b15fa304 libinput: add hold gesture public API and tool support
Add hold gestures to the public API and the private functions to notify them.
Also add hold gestures to debug-events and debug-gui.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-06-09 01:18:58 +00:00
Peter Hutterer
1ebdc60576 tools/debug-events: rework touch event printing
Previously, touch up events did not contain the slot number which makes the
logs ambiguous (e.g. see the one in #532). Fix that, and since doing so would
require extra conditions anyway get rid of the current with/without coords
function and just handle it all inside one function instead.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-21 09:09:50 +10:00
Peter Hutterer
4f282688ac tools: print the libinput_dispatch() counter for debugging messages
The messages with priority DEBUG refer to the various internal state machines
updating, so it's useful to know when they did so. Let's count up every time
we trigger libinput_dispatch() so we know how the messages group together.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-06 16:12:17 +10:00
Peter Hutterer
7244e36b50 tools: only call libinput_dispatch() once per poll
This is a closer approximation of all callers anyway, and it makes it easier
to debug which events are handled per libinput_dispatch() call.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-06 16:12:17 +10:00
weizhixiang
6e03da6344 remove extra paramenter in libinput-debug-events
Signed-off-by: weizhixiang <1138871845@qq.com>
2020-09-07 09:50:07 +00:00
Peter Hutterer
20cf83789d tools: constify the optarg handling of seats
This shuts up scan-build complaining about memory leaks in libinput
debug-events (needs the right combination of --device option and eventually
triggering usage()) and saves us a bunch of unnecessary allocations.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-02-24 01:53:21 +00:00
Peter Hutterer
acfec31103 tools: align the tool type names on proximity nicely
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-01-30 02:10:33 +00:00
Peter Hutterer
2d1bcf982a pad: add LIBINPUT_EVENT_TABLET_PAD_KEY for pad keys
The Wacom Cintiq 24HD and later tablets send specific key events for
hardware/soft buttons. KEY_PROG1..KEY_PROG3 on earlier tablets,
KEY_CONTROLPANEL, KEY_ONSCREEN_DISPLAY, and KEY_BUTTONCONFIG on later tablets.
We ignore KEY_PROG1-3 because starting with kernel 5.4 older tablets will too
use the better-named #defines.

These differ from pad buttons as the key code in itself carries semantic
information, so we should pass them on as-is instead of mapping them to
meaningless 0-indexed buttons like we do on the other buttons.

So let's add a new event, LIBINPUT_EVENT_TABLET_PAD_KEY and the associated
functions to handle that case.

Pad keys have a fixed hw-defined semantic meaning and are thus not part of
a tablet mode group.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-12-04 15:38:39 +10:00
Peter Hutterer
9696f37393 tools: debug-events: don't overrun the device array with too many arguments
Only the --device option was checked for argument count, not the rest so it's
easy to overrun the array by specifying too many devices.

Except: this was a theoretical bug only, more than 64 arguments trigger
an assertion in the argv processing in tools/shared.c anyway. Let's drop the
debug-events limit to 60 devices so we can at least have a test for this.

Found by coverity

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-12-04 12:50:11 +10:00
Peter Hutterer
47767290a7 tools: print the libinput version in debug-events
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-11-27 15:16:30 +10:00
Peter Hutterer
490131ff61 tools: make debug-events accept multiple device nodes
For interaction between devices it's necessary to look at more than one device
at a time.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-11-26 00:34:08 +00:00
Peter Hutterer
2c613feb0c tools: debug-events: expand timestamp prints to full millis
Tens of millis is not quite enough in some cases.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-11-18 22:43:48 +00:00
Peter Hutterer
558cc3f11c tools: debug-events: offset timestamps by the first normal event
Start counting the timestamps from the first time we get something off the
actual fd. This makes it easier to match up timestamps with the output from
libinput record.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-11-18 22:43:48 +00:00
Konstantin Kharlamov
476da352c0 libinput-debug-events.c: remove unused includes
Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
2019-09-13 00:07:39 +03:00
Peter Hutterer
17d792445e tablet: add a the Totem tool type to the tablet interface
This is the public API only, not the internal bits, so nothing will work just
yet.

This interface addition is for the Dell Canvas Totem tool, so let's go with
the same name because options like "Rotary" are too ambiguous.

The totem is a knob that can be placed on the surface, it provides us with
location and rotation data. The touch major/minor fields are filled in by the
current totem, but they're always the same size.

The totem exports BTN_0 as well, so let's add that to the debug-events output.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-07 01:03:21 +00:00
Peter Hutterer
1150a8442f tools: display the discrete axis steps too
Draw a second smaller scroll bar that moves with every discrete step. For that
to work, we have to accumulate the value from the normal scroll events until
we get the first discrete one, then move up.

The value per discrete event changes depending on the click wheel angle, so we
can't just use discrete on its own if we want the two scroll bars aligned.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-03-04 15:47:27 +10:00
Peter Hutterer
96a0e8ed66 tools: don't apply config options on device removed
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-12-19 15:55:42 +10:00
Peter Hutterer
4e469291b1 tools: let debug-events take a device path
This is the most common use-case other than "all from udev", so let's just
parse a device path correctly without requiring --device.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-11-07 05:03:52 +00:00
Peter Hutterer
36af7d312b tools: make the tools exit with exit code 2 on usage issues
This makes it easier to test for usage issues

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-11-07 05:03:52 +00:00
Peter Hutterer
bd52bf5421 tools: debug-events: install the signal handler before any libinput operations
On a CI container, we will time out trying to find the udev device for our
device node. This takes 2s, a SIGINT during this time should be treated the
same as one during the mainloop.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-11-07 05:03:52 +00:00
Peter Hutterer
717b57b6a2 tools: align the rotation value with 3 digits
This is a 0-360 ranged value, so let's print it aligned.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-09-27 10:27:19 +10:00
Peter Hutterer
6ed158f99d tools: add a missing space in the proximity in axis listing
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-09-27 10:27:19 +10:00
Peter Hutterer
bf9c8e06ef tools: debug-events - print axes on tablet tip events
Bit of a weird diff, print_tablet_axes() was moved up and a single call to
print_tablet_axes() was added in the tablet tip event handler.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-09-05 14:33:28 +10:00
Peter Hutterer
f78d6669e5 tools: debug-*: show unaccelerated deltas for pointer events
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-08 10:07:43 +10:00
Peter Hutterer
0a13223c39 tools: fix grab argument passing for libinput debug-events
The &grab pointer we used to pass as userdata was the address of the function
argument which goes out of scope at the end of the function. This works fine
for devices immediately opened but when a device connects later, the address
may have been re-used since and it's content is undefined. If not NULL, we
end up grabbing the device.

Instead pass the grab option in which is guaranteed to live until the end of
main.

https://gitlab.freedesktop.org/libinput/libinput/issues/26

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-06-14 09:50:29 +10:00
Peter Hutterer
795657a0a1 tools: print the number of touches for touch devices
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-02 13:51:00 +10:00
Peter Seiderer
6ed8c64e92 tools: libinput-debug-events stop variable needs volatile
The stop variable set in the signal handler needs
volatile (and use the defined sig_atomic_t instead
of unsigned int).

Signed-off-by: Peter Seiderer <ps.report@gmx.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-15 08:06:54 +10:00
Greg V
8adfac3975 Include stdarg.h where variadic functions are used
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-12-01 09:31:42 +10:00
Peter Hutterer
5acd5147a1 tools: add an extra linebreak before closing
Just puts the ^C from the Ctrl+C on a separate line to make it easier to spot

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-11-09 10:36:03 +10:00
Stefan Brüns
48fd22def7 tools: Handle LIBINPUT_SWITCH_TABLET_MODE
Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-11-06 08:45:18 +10:00
Peter Hutterer
e242ad219a tools: remove a leftover debug printf statement
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-09-06 09:24:29 +10:00