Commit graph

714 commits

Author SHA1 Message Date
Peter Hutterer
54dccd66d1 Fix a few potential NULL dereferences
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1052>
2024-09-30 15:35:36 +00:00
Peter Hutterer
a4ff6d5d0b tools: add --set-calibration to the debug-events man page
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1051>
2024-09-20 21:06:15 +10: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
satrmb
910d59e836 touchpad: add sticky mode to drag-lock
Sticky mode removes the timeout from drag-lock, only a tap ends a drag.
Timeout mode remains available without changes.

Sticky mode is exposed as a new value for the existing drag-lock setting.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1037>
2024-09-05 00:47:47 +00:00
José Expósito
7d849623d5 Fix pre-commit errors
Some files had pre-commit style issues. Fix them.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1036>
2024-09-03 09:51:41 +02:00
Peter Hutterer
1b7992c31a tools: add support for setting the calibration matrix
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1018>
2024-06-20 09:32:19 +10:00
Peter Hutterer
99647b71d3 tools: add libinput analyze buttons for button state analysis
This tool helps with tracking button states and time deltas
between button events. Example output for a mouse with LMR buttons
recorded (the mouse also has BTN_SIDE and BTN_EXTRA):

  Timestamp   │  Delta   │ L │ R │ M │ S │ E
     0.596112 │      0ms │ ┬ │   │   │   │
     0.689096 │     92ms │ ┴ │   │   │   │
     1.129056 │    439ms │ ┬ │   │   │   │
     1.308178 │    179ms │ ┴ │   │   │   │
     1.469149 │      0ms │ ┬ │   │   │   │
     1.598096 │    128ms │ ┴ │   │   │   │
     1.862125 │    264ms │ ┬ │   │   │   │
     2.084234 │    222ms │ │ │ ┬ │   │   │
     2.415224 │    330ms │ │ │ ┴ │   │   │
     2.831227 │    416ms │ │ │ ┬ │   │   │
     3.215067 │    383ms │ ┴ │ │ │   │   │
     3.525230 │    310ms │ ┬ │ │ │   │   │
     3.629006 │    103ms │ ┴ │ │ │   │   │
     3.813078 │    184ms │ ┬ │ │ │   │   │
     3.909170 │     96ms │ ┴ │ │ │   │   │
     4.093180 │    184ms │ ┬ │ │ │   │   │
     4.317036 │    223ms │ ┴ │ │ │   │   │
     4.507175 │    190ms │ ┬ │ │ │   │   │
     4.587105 │     79ms │ │ │ ┴ │   │   │
     4.779211 │    192ms │ ┴ │   │   │   │
     5.075239 │    296ms │   │   │ ┬ │   │
     5.259097 │    183ms │   │   │ ┴ │   │
     5.379082 │    119ms │   │   │ ┬ │   │
     5.483044 │    103ms │   │   │ ┴ │   │

The default behavior is to highlight time deltas below 25ms
in red. 25ms is our higher debounce timeout.

Note that the delta time is the one between button events, ignoring any
e.g. motion events in between.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1010>
2024-06-18 07:43:02 +00:00
Peter Hutterer
4333845e4c tools/debug-gui: draw the evdev x/y axis with the right color
We were drawing an arc but apparently in white which made it a tad hard
to see on a white background. Draw this with the same color as the
touchpoints so we can debug single-touch and tablet devices too.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1011>
2024-06-13 05:45:19 +00:00
Peter Hutterer
4548a37511 tools: actually parse options in libinput-debug-tablets
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1009>
2024-06-10 15:09:19 +00: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
Peter Hutterer
fdb693a6ee tools/record: record the DRIVER property in the recording
So we know which kernel driver is handling the device. Quite useful,
sometimes, without having to ask for extra logs.

This of course requires that we ignore said property in libinput replay
since no uinput device will have that driver property set.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1007>
2024-06-04 16:54:28 +10:00
Tarcísio Eduardo Moreira Crocomo
46d1fff0b0 touchpad: add clickfinger button map
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/988>
2024-04-09 19:08:17 -03:00
José Expósito
f6a1f264df sparse: make some variables static
Fix warnings about variables that should be made static when compiling
with Sparse enabled:

        $ CC=cgcc meson builddir

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/987>
2024-03-18 23:35:34 +00:00
Peter Hutterer
301895685e tools: fix two black warnings
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/985>
2024-03-18 12:29:57 +10: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
Czcibor Bohusz-Dobosz
713892c162 Number the fingers by slot in debug-gui 2023-10-16 04:31:17 +00:00
José Expósito
973c461d4b tools/record: print bus name
A follow up on commit 65eaabf91f ("tools/record: print the vid/pid
with proper 4 hex digits").

Print the bus name in addition to the bus ID. Only the busses available
in quirks are printed.

Example:

    $ sudo libinput record
    [...]
    # ID: bus 0x0003 (usb) vendor 0x046d product 0x406d version 0x0111
    [...]

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2023-09-01 16:21:15 +02:00
Peter Hutterer
17e556503d tools: rename an enum value to fix a FreeBSD 14 name clash
Fixes #931
2023-08-31 12:21:00 +10:00
Peter Hutterer
4effe6b1b9 evdev: add a helper macro for the absinfo range
The range is (max - min + 1) because the kernel range is inclusive min
and max. Let's fix that once and for all with a helper function.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-08-29 17:07:38 +00:00
Peter Hutterer
65eaabf91f tools/record: print the vid/pid with proper 4 hex digits
The field with includes the 0x if printing with "0x04d". And because
that format prints zero as just 0000, let's move the 0x prefix out and
let printf only handle the actual number.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-08-29 05:35:15 +10:00
Peter Hutterer
83144a0edc man: hide debug-gui from the libinput.man page if disabled
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-06-09 13:00:08 +10:00
Peter Hutterer
bee70901ec tools: add rotation support to debug-events and debug-gui
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-04-27 13:15:14 +10:00
Peter Hutterer
a328ada6ef test: carry the step as argument for arg testing
Simplifies things a bit since it makes it all more explicit

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-04-27 13:15:14 +10:00
Peter Hutterer
861f01928a tools/debug-gui: fix a deprecated warning
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-04-20 09:51:49 +10: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
2432b6eeff tools: add a tool to update our Razer quirks for internal keyboards
openrazer keeps a convenient list of keyboard devices that belong to the
RazerBlade line and thus should be marked as internal by us. Let's
use that one.

This script git clones the current openrazer repo, imports the file we
need and then overwrites our current quirks file with the sorted list of
devices.

For the second part of this to work reliable we need a marker in the
quirks file that marks the start of autogenerated entries.

Heavily influenced by @danryu in !887.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-04-11 14:48:41 +10:00
Peter Hutterer
6bfd658173 tools: honor FDO_CI_CONCURRENT in the tools option parser
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-03-20 22:13:19 +00:00
Yinon Burgansky
93135c2012 filter: add scroll movement type to the custom acceleration profile
Adds a dedicated scroll movement type to the custom acceleration profile.
Supported by physical mouse and touchpad.
Other profiles remain the same by using the same unaccelerated filter for the scroll filter.

Signed-off-by: Yinon Burgansky <51504-Yinon@users.noreply.gitlab.freedesktop.org>
2023-02-24 13:01:34 +02:00
Peter Hutterer
41e7caac48 tools: add --replay-after and --once to libinput replay
For the cases where it's not possible to hit enter to start the replay
because e.g. we cannot change focus, etc.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-02-06 18:02:58 +00:00
Yinon Burgansky
5324f425a1 Introduce custom acceleration profile
The custom acceleration profile allow the user to define custom
acceleration functions for each movement type per device, giving
full control over accelerations behavior at different speeds.

This commit introduces 2 movement types which corresponds to the
2 profiles currently in use by libinput.

regular filter is Motion type.
constant filter is Fallback type.

This allows possible expansion of new movement types for the
different devices.

The custom pointer acceleration profile gives the user full control over the
acceleration behavior at different speeds.
The user needs to provide a custom acceleration function f(x) where
the x-axis is the device speed and the y-axis is the pointer speed.

The user should take into account the native device dpi and screen dpi in
order to achieve the desired behavior/feel of the acceleration.

The custom acceleration function is defined using n points which are spaced
uniformly along the x-axis, starting from 0 and continuing in constant steps.
There by the points defining the custom function are:
(0 * step, f[0]), (1 * step, f[1]), ..., ((n-1) * step, f[n-1])
where f is a list of n unitless values defining the acceleration
factor for each velocity.
When a velocity value does not lie exactly on those points, a linear
interpolation of the two closest points will be calculated.
When a velocity value is greater than the max point defined, a linear
extrapolation of the two biggest points will be calculated.

Signed-off-by: Yinon Burgansky <51504-Yinon@users.noreply.gitlab.freedesktop.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-01-17 01:46:17 +00: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
José Expósito
7bfdf52db2 tools/record: fix quirk error message
When libinput-record fails to parse the quirks, it suggest to use the
--verbose flag to get more details. However, libinput-record does not
support the --verbose flag.

Replace the error message and add a link to the documentation instead.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2022-12-12 19:17:01 +01:00
Peter Hutterer
e6a5c4e175 tools: add a --hid toggle to libinput-list-kernel-devices
Lists all SUBSYSTEM=hid devices, including the respective hidraw and
evdev nodes.

Note that this takes a shortcut in the udev handling: in theory we
*should* compare the hidraw/evdev parent device with our hid device. In
practice, checking if the devpath starts with the same substring is good
enough.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-12-08 10:08:44 +10:00
Peter Hutterer
1250407c7c tools: add a libinput list-kernel-devices tool
Same as libinput list-devices, but lists the available event nodes. This
effectively does the same as libinput record without arguments but it's
more obvious in what it is supposed to do and thus easier to point to.

Also, it uses pyudev instead of libevdev so it does not need to run as
root to discover devices.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-12-08 10:08:44 +10:00
Peter Hutterer
a7e4cbc212 quirks: allow overriding of AttrEventCode and AttrInputProp
This switches the quirk from AttrEventCodeEnable/Disable to just
AttrEventCode with a +/- prefix for each entry.
This switches the quirk from AttrInputPropEnable/Disable to just
AttrInputProp with a +/- prefix for each entry.

Previously, both event codes and input props would only apply the
last-matching section entry for a device. Furthermore, an earlier Disable entry
would take precedence over a later Enable entry. For example, a set of
sections with these lines *should* enable left, right and middle:

  [first]
  AttrEventCodeEnable=BTN_LEFT;BTN_RIGHT;BTN_MIDDLE

  [second]
  AttrEventCodeDisable=BTN_RIGHT

  [third]
  AttrEventCodeEnable=BTN_LEFT;BTN_RIGHT;

Alas: the first line was effectively ignored (quirks only returned the
last-matching one, i.e. the one from "third"). And due to implementation
details in evdev.c, the Disable attribute was processed after Enable,
i.e. the device was enabled for left + right and then disabled for
right. As a result, the device only had BTN_LEFT enabled.

Fix this by changing the attribute to carry both enable/disable
information and merging the commands together.

Internally, all quirks matching a device are simply ref'd into an array
in the struct quirks. The applied value is simply the last entry in the
array corresponding to our quirk.

For AttrEventCode and AttrInputProp instead do this:
- switch them to a tuple with the code as first entry and a boolean
  enable/disable as second entry
- if the struct quirk already has an entry for either, append the more
  recent one to the existing entry (instead of creating a new entry in
  the array). This way we have all entries that match and in-order of
  precedence - i.e. we can process them left-to-right to end up
  with the right state.

Fixes: https://gitlab.freedesktop.org/libinput/libinput/-/issues/821

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-11-28 08:25:41 +10:00
Peter Hutterer
6ae0d1bac4 tools: fix a tab after space whitespace issue
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-11-25 10:08:20 +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
Peter Hutterer
d2f6773831 Remove a few empty lines with nothing but a lonely tab
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-11-25 10:08:20 +10:00
Peter Hutterer
703ecb200c Remove trailing whitespaces in the tree
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-11-25 10:08:20 +10:00
José Expósito
8a6ca3c1c5 sparse: make some variables static
When compiling with Sparse enabled:

	$ CC=cgcc meson builddir

Fix warnings about variables that should be made static.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2022-11-23 21:57:28 +00:00
José Expósito
e8732802b7 debug-gui: avoid locking pointer twice
On Sway, and probably other Wayland compositors based on wlroots, the
window_lock_pointer() was called twice.

Avoid errors when window_lock_pointer() is invoked multiple times.

Fix https://gitlab.freedesktop.org/libinput/libinput/-/issues/808
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2022-10-10 08:46:30 +00:00
José Expósito
9c789cc254 tools: hide debug-gui help when building with -Ddebug-gui=false
Some distributions, like Fedora, compile libinput with the debug-gui
option set to false.

Running "libinput debug-gui" indicates that the program is not
installed; however, the help message suggests that  the command is
available.

Hide debug-gui from the help message when it is not included.

Fix https://gitlab.freedesktop.org/libinput/libinput/-/issues/480
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2022-10-10 08:27:05 +02:00
Peter Hutterer
507b0a38b3 tools: add missing dwtp option setting
Fixes 1f1ddbc6df

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-08-08 13:57:13 +10:00
Peter Hutterer
6a1bd5b0c9 meson.build: check gtk targets before building
We have two different dependencies on Wayland: GTK support and the
wayland-protocols we use directly. If we have GTK support but
wayland-protocols is not installed at meson configure time, our build
fails.

To avoid having multiple ifdefs in the code, let's define two new ones:
HAVE_GTK_WAYLAND and HAVE_GTK_X11, both set if GTK supports that
particular target (from pkgconfig) and we have the other support
libraries we need.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-06-11 10:54:15 +00:00
Peter Hutterer
5dd751a3d0 test: install libinput-test-utils as part of install-tests
This tests a bunch of internal utility functions that may work
differently depending on compiler flags, etc. Let's make that test
available so it can be verified on an installed system.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-05-09 05:03:00 +00:00
Peter Hutterer
43a8d769ac tools: add a libinput test tool as entry point for our test suites
We already install libinput-test-suite if the meson option install-tests
is set, see
  commit be7045cdc7
  test: make the test suite runner available as installed binary

To make other tests easily available and more discoverable, add a new
tool "libinput test" with the matching man page. This will also help us
to enforce some of the namespacing a bit better.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-05-09 05:03:00 +00:00
Peter Hutterer
d48c7e72f7 tools/analyze-recording: improve the repeated-events line printing
When redirecting to a file, we don't want lines like this:
   .. +2 ... +5 ... +9

Let's not print anything until we have collected all those lines and
then print the final result, we don't need a live update here.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-05-06 14:25:50 +10:00
Peter Hutterer
4ac5fd9e24 tools/analyze-recording: add --print-state to always print values
Helpful in comparing values that update frequently - without this the
last printed value may be way off the page when some other value comes
in that it needs to be compared to.

Values not seen yet default to zero - we can't query those from a
recording but it'll be good enough this way.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-05-06 14:05:13 +10:00