Commit graph

598 commits

Author SHA1 Message Date
Peter Hutterer
ff598741a9 tools: add a tool to analyze the finger count from a recording
Given a libinput recording, print the timestamps of any finger changes, i.e.
which slots are currently logically down. For example:

Timestamp | Rel time |     Slots     |
--------------------------------------
 0.000000 |  +0.000s | + |   |   |   |
 0.454631 |  +0.454s |   |   |   |   |
 5.065401 |  +4.610s | + |   |   |   |
 6.140281 |  +1.074s | + | + |   |   |
 7.410377 |  +1.270s |   | + |   |   |
 7.420200 |  +0.009s |   |   |   |   |
11.233108 |  +3.812s | + | + |   |   |
11.850206 |  +0.617s |   |   |   |   |
13.827740 |  +1.977s | + |   |   |   |
14.704027 |  +0.876s | + | + |   |   |
16.050577 |  +1.346s | + |   |   |   |
16.905186 |  +0.854s |   |   |   |   |

This data is available with the per-slot-delta tool but the output here is
more compressed, making it easier to detect stuck fingers. Pressure
thresholds are not currently supported.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-01-29 08:06:53 +10:00
Peter Hutterer
9925594257 tools/record: print the wall clock time every few seconds
For long-running recordings it's useful to know what the actual time was when
a particular event occured. A user can simply check the clock or system logs
for the time and thus know which portion of the recording to focus on.

Let's print the time into the recording, every 5 seconds (aligned at the 5,
10, 15s marks) or, if no events occured in the last 5 seconds, before the next
event. This granularity should be enough to identify the interesting parts of
a recording.

Let's print this as a comment until we have a use-case that requires parsing
this data.

The timer is the simplest approach, it just repeats at a fixed 5 seconds
interval from startup. There may be time drift, we can fix that if needed.

Fixes #560

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-01-29 07:31:46 +10:00
Peter Hutterer
0b8ad77624 tools/record: use a pointer to the libinput fd poll entry
No functional changes, this makes the code slightly more readable, especially
once we start adding more "special" fds.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-01-29 07:31:46 +10:00
Peter Hutterer
773287e745 tools/record: use a pointer to the signalfd poll entry
No functional changes, this makes the code slightly more readable, especially
once we start adding more "special" fds.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-01-29 07:31:46 +10:00
Peter Hutterer
b1f8ea0a5e tools/record: narrow the scope of two variables
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-01-29 07:31:46 +10:00
Peter Hutterer
f2133ef0f3 tools/record: initialize all pollfds in the same loop
Minor tidying up the code, set the default values for all fds in the same loop
instead of having it split to wherever the fd is created.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-01-29 07:31:46 +10:00
Peter Hutterer
1dbdef8fdb Use python black for all pyhon file formatting
Let's enforce a consistent (and verifiable) style everywhere.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-01-28 21:02:45 +00:00
Peter Hutterer
ba0aed7b27 gitlab CI: fix flake8 complaints
tools/libinput-measure-fuzz.py:212:15:
 F523 '...'.format(...) has unused arguments at position(s): 1

But the E741 is better turned off in general:
  tools/libinput-measure-fuzz.py:319:29: E741 ambiguous variable name 'l'

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-01-04 12:02:46 +10:00
Torstein Husebø
18c9265224 treewide: fix typos
Signed-off-by: Torstein Husebø <torstein@huseboe.net>
2020-12-16 22:08:23 +01:00
Peter Hutterer
2c50ffab24 tools: print the AttrEventCodeEnable and AttrInputPropEnable/Disable quirks
Introduced in e3c4ff3 and e882bd02

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-11-10 14:27:22 +10: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
82bf473d99 tools: color-group the debugging messages
Alternate between two randomly-chosen colors for each batch of debug messages
to make it easier to visually group the two.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-07 07:22:52 +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
Peter Hutterer
1303adbf1b tools/record: compress a set of printfs into one
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-09-17 12:38:53 +10:00
Peter Hutterer
6e8aba9354 tools/record: prefix the device list with a # character
Too many recordings end up with the device list at the top when users redirect
stderr and stdout to the recordings file. This breaks yaml parsing and
requires manual removal of the first few lines.

Avoid this by prefixing the lines with a command character, this way the yaml
stays correct.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-09-17 12:38:53 +10:00
Peter Hutterer
2d641e6b7b tools/record: add --grab option
Useful to record devices like power buttons, lid switches, etc.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-09-16 23:59:57 +00:00
weizhixiang
bb84fcc738 check return value for udev_new()
Signed-off-by: weizhixiang <1138871845@qq.com>
2020-09-15 10:42:47 +08:00
Peter Hutterer
5ebd7bd1f0 tools/replay: check the recorded udev properties against the local properties
Where a device is replayed locally for testing, its udev properties should
match the recorded properties. Otherwise the testing results will not be
reliable.

The exception here is the device group which we currently don't set for
emulated devices and even if we did, it may intentionally differ anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-09-11 04:36:03 +00: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
Rosen Penev
467752047e
[clang-tidy] do not use else after return
Found with readability-else-after-return

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-08-27 01:17:24 -07:00
Peter Hutterer
e926d3d919 tools: fix a replay exception when a recording has an empty quirks list
Fixes https://gitlab.freedesktop.org/libinput/libinput/-/issues/520

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-24 08:35:12 +10:00
Peter Hutterer
912a457f18 tools: add missing linebreak in error message
Missing from a0643a9c98

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-08 13:25:12 +10:00
Peter Hutterer
3403692ff0 tools: when running the test suite, start the debug-gui minimized
This allows us to run the option parsing test without getting interrupted by a
million debug-gui windows popping up for half a second.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-07 18:51:33 +10:00
Peter Hutterer
a0643a9c98 tools: change the error message for missing tools
Given that some people appear to not read until the "is not installed" part of
the error message, let's reduce the error message to just that part. This may
be confusing where a user mistypes the actual command but that happens rarely
compared to those that can't run libinput record because it's in a different
package.

Fixes #500

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-01 01:21:21 +00:00
Peter Hutterer
d724dc060b Replace strneq() with strstartswith() for variable prefixes
Leaving in-place all those where we know the length of the prefix, but
replacing all those where we were calling strlen on the prefix.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-17 07:52:00 +00:00
Peter Hutterer
9b3e0e8043 tools: per-slot-delta: if a NONE touch gets data, assume it's starting
If we have a recording that started after the touch down, let's start that
touch on the first x/y position update.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-04 10:43:33 +10:00
Peter Hutterer
9ecac89bab tools: per-slot-delta: construct the right InputEvent
d107d5 broke this tool because the InputEvent was our local datastructure,
which needed the evbit redirect.

Fixes d107d58cd2

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-04 10:43:33 +10:00
Peter Hutterer
ba68cdf67e tools: replay: allow for missing quirks entry in libinput recordings
Older recordings don't have that field so we should just ignore that
case.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-05-22 03:41:05 +00:00
Peter Hutterer
975d036713 tools: measure-fuzz: sleep for 2 seconds to give the hwdb time
one second isn't always enough here.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-04-19 16:04:58 +10:00
Peter Hutterer
28e7f62302 tools: measure-fuzz: fix the tool to work again
Where libinput is installed, checking whether the fuzz is applied to the
device will always fail with an error - the udev rules will remove the
fuzz and copy its value to the LIBINPUT_FUZZ properties instead.

So let's fix this: where the fuzz shows up on the device print a warning
because libinput's udev rule isn't working. And where it's missing check
the udev properties and compare those to the settings instead.

Fixes #472

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-04-19 16:04:58 +10:00
Peter Hutterer
a22137e7fd tools: measure-fuzz: run systemd-hwdb update, not udevadm hwdb
For backwards compatibility reasons, the hwdb.bin created udevadm hwdb
does not actually apply matches in the way you'd expect. systemd-hwdb
creates the newer format and is preferred.

Related: #472

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-04-19 15:23:23 +10:00
Peter Hutterer
3ec74cfc35 tools: measure-fuzz: handle a None return correctly
Fixes #472

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-04-19 15:18:42 +10:00
Peter Hutterer
d107d58cd2 tools: per-slot-delta: skip the extra evbit indirection
e.code is the evbit anyway, we don't have to convert it

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-04-16 06:10:25 +00:00
Peter Hutterer
78dcbec7a4 tools: per-slot-delta: drop an unused variable
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-04-11 15:32:22 +10:00
Peter Hutterer
f5ab18ab8f tools: per-slot-delta: always mark slot 0 as used
If a device never sends ABS_MT_SLOT, our output was emtpy.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-04-11 15:32:17 +10:00
Peter Hutterer
d88ad293d2 tools: per-slot-delta: add arguments to set a threshold and ignore-below
The threshold colors events above a certain value in red, ignore-below skips
any line below that threshold.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-04-11 14:35:27 +10:00
Peter Hutterer
61296feaee tools: per-slot-delta: init the slots with the right index
The index is unused, but useful during debugging

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-04-11 13:50:53 +10:00
Peter Hutterer
4e03175307 tools: per-slot-delta: move printing the slot data into a helper function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-04-11 13:50:53 +10:00
Peter Hutterer
5a9fb539d9 tools: per-slot-delta: print the BTN_TOUCH etc. bits in-line
New output example:

 9.408899    +5ms DBL: ↑↗    1/  -9 | →→    0/   0 |

where DBL stands for BTN_DOUBLE.

This also widens the relative time by one so we don't lose formatting for >1s
delta time.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-04-11 13:38:48 +10:00
Peter Hutterer
c23484a9ec tools: per-slot-delta: only render the slots that have been seen
Makes the output easier to understand given that most touchpads have 5+ slots
but don't actually use them (or the users don't).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-04-11 13:38:48 +10:00
Loïc Yhuel
dd0370f73c quirks: correctly print boolean values
When a boolean quirk is set to "0", it is correctly disabled, but "libinput quirks list" and
"libinput record" showed it as "1".

This happens for example if ModelXXXX=0 is set in /etc/libinput/local-overrides.quirks, to
override a default quirk.

Signed-off-by: Loïc Yhuel <loic.yhuel@softathome.com>
2020-04-06 23:51:01 +02:00
Peter Hutterer
4a9d3e8796 tools: add a measure touchpad-size tool
Replacement for the touchpad-edge-detector tool with a slightly more
expressive design, hopefully cutting down on some of the bug reports.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-03-30 15:14:45 +10:00
Peter Hutterer
101cbe16c3 tools: make the thumb threshold configurable while measuring pressure
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-03-30 14:45:19 +10:00
Peter Hutterer
ef5204fda7 tools: revamp the touchpad-pressure measuring tool
Let's hope this one is more obvious to use for users.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-03-30 14:44:47 +10:00
Peter Hutterer
1f5a27bf3d tools: add libinput analyze to the libinput tool help output
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-03-29 15:33:24 +10:00
Peter Hutterer
d80bbcb028 tools: record: drop quotes from os-release information
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-03-21 11:02:48 +10:00
Peter Hutterer
4d92ea116c tools: if pytest fails to import, skip the tool option parsing test
It's not the most important test outside of my machine and CI, so let's just
skip over it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Michel Dänzer <mdaenzer@redhat.com>
2020-03-20 20:42:51 +10:00
Peter Hutterer
b35a32dd9d man: install the analyze per-slot-delta man page
And add libinput analyze to the main libinput man page

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-03-20 16:10:11 +10:00
Peter Hutterer
d0eb8d58a3 tools: switch tool option parsing test to use pytest
pytest is more powerful than unittest, so let's switch to that instead. And in
the process fix a few tests that for some reason succeeded even though they
shouldn't have (e.g. the autorestart test).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-03-17 10:08:48 +10:00