Commit graph

784 commits

Author SHA1 Message Date
Peter Hutterer
33b30d4631 tools/record: rework the event printing
For historical (but not very good) reasons, libinput record printed events
from the first device to the output file (or stdout) and buffered everything
else. On ctrl+c, the other devices' descriptions and the buffered events were
appended to the output file.

This makes the printing code rather complex. Simplify it by giving each device
a separate FILE* - the first device points to the real output file, the others
to a tempfile. On Ctrl+C we just append those tempfiles to the real output
file one-by-one and done.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-30 09:02:31 +10:00
Peter Hutterer
bacf4e5a62 tools/record: rename the output file handling
Less confusing than having output_file, out_file, and outfile.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-30 09:02:31 +10:00
Peter Hutterer
7957f1980d tools/record: remember the first device in the context
No functional changes since we can get this easily from the list itself, but
in the future the first device will be used more extensively.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-30 09:02:31 +10:00
Peter Hutterer
0b23cb1ba2 tools/record: append the devices in-order
Using list_insert() here means the last device specified on the commandline is
the one that ends up in the file first - not very obvious...

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-30 09:02:31 +10:00
Peter Hutterer
0cdf459643 tools/record: get rid of indent push/pop, replace with fixed indents
Our file format is static enough that we don't need to use push/pop, we know
exactly which line is going where. So let's replace it with a static
indent instead.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-30 09:02:31 +10:00
Peter Hutterer
632eedadf5 tools/record: mark the iprintf function as printf
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-30 08:33:49 +10:00
Peter Hutterer
9011f91868 tools/record: switch the output file from an fd to a FILE*
This is prep work to be more consistent with the use of tempfile later for
individual devices.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-30 08:33:49 +10:00
Peter Hutterer
7f4df04d59 tools/record: deduplicate the device opening logic
With a new helper function strv_from_argv we can re-use the device opening
loop for all the use-cases we have.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-30 08:26:30 +10:00
Peter Hutterer
4da9349a91 tools/record: free the namelist when we're done
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-26 10:12:40 +10:00
Peter Hutterer
e511f96201 tools/record: localize a variable
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-26 10:12:40 +10:00
Peter Hutterer
8b822a84c4 tools/record: de-duplicate an error message
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-26 10:12:40 +10:00
Peter Hutterer
0828fdcea0 tools/record: factor out the output file collection
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-26 10:12:40 +10:00
Peter Hutterer
39b64107e9 tools/debug-gui: draw a sprite for the unaccelerated pointer as well
Add a second grey v-shaped (upside down triangle) pointer that moves around
with the unaccelerated deltas. This makes it easier to visualize how the
unaccelerated pointer moves around, the snake helps for some use-cases but not
all of them.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-11 10:40:00 +10:00
Peter Hutterer
1926a66fab tools/debug-gui: move the abs pointer position into a struct point
No functional changes

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-11 10:40:00 +10:00
Peter Hutterer
e99f59422c tools/debug-gui: move the pointer position into a struct point
No functional change

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-11 10:40:00 +10:00
Peter Hutterer
c71fa06607 tools/debug-gui: start the unaccelerated motion deltas in the screen center
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-11 10:40:00 +10:00
Peter Hutterer
f17ef2d543 tools/per-slot-delta: handle KeyboardInterrupts nicely
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-10 00:24:51 +00:00
Peter Hutterer
fe30bea36e tools/per-slot-delta: print the button state too while analyzing
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-10 00:24:51 +00:00
weizhixiang
c00c5cb691 replace strncmp with strneq for safety-check
Signed-off-by: weizhixiang <weizhixiang@uniontech.com>
2021-03-08 20:59:20 +00:00
Konstantin Kharlamov
3d3d9b7f69 treewide: get rid of tmp argument in list_for_each_safe
Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
2021-03-02 09:10:35 +03:00
Peter Hutterer
1b00eb5e03 tools/record: fix two coverity complaints
In both cases we only read to drain the fd, we don't care about the return
value.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-23 16:55:58 +10:00
Peter Hutterer
6a6435ae4b tools: add a tool to print a libinput recording as a table
This makes it easier to visualize changes in various axes or key states that
should not be there, doubly so for long recordings.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-23 13:46:00 +10:00
Peter Hutterer
9323cdfc11 meson.build: build libinput replay as well
Just like the other python-based tools it's just a basename copy, so let's be
consistent here and have all tools perform that way.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-23 13:30:42 +10:00
Peter Hutterer
627a3dd2b2 tools/record: use a helper function to get the next event for a device
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-23 10:56:53 +10:00
Peter Hutterer
4a7dece88c tools/record: switch record over to using epoll
Using poll means more difficult fd management, epoll (together with am
modified version of the libinput_sources) makes this a lot easier by simply
using dispatch.

This means we are no longer reliant on a specific file descriptor order in the
poll array.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-23 10:56:53 +10:00
Peter Hutterer
d8b64d413d tools/record: reword parts of the man page
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-23 10:56:53 +10:00
Peter Hutterer
ca9067992e tools/record: use safe_basename() to get to the hid report descriptor
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-23 10:56:53 +10:00
Peter Hutterer
fd9d165a77 tools/record: simplify the behavior to emulate Python's join()
Instead of a boolean "is_first", just change the separator.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-23 10:56:53 +10:00
Peter Hutterer
ff87151764 tools/replay: Enter quits if there are no events
If we have no events in any of the recorded devices, state that this is the
case and make Enter simply quit instead of a pointless while loop.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-23 10:53:31 +10:00
Peter Hutterer
f30342644a tools/replay: search for the first event with a timestamp
When running with --with-libinput, the first event is the DEVICE_ADDED event
for our device. Those events do not have a timestamp.

We have to find the first event in the recording with a timestamp instead.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-23 10:43:52 +10:00
Peter Hutterer
59ca971898 tools/record: print a header as first line
To make the file format easier to detect

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-22 14:53:41 +10:00
Peter Hutterer
4b0f200936 tools/record: fix outdated comment
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-19 09:09:53 +10:00
Peter Hutterer
a8597e3ab3 tools/record: de-inline our functions
Let's leave this up to the compiler, the usual side-effect of inline (compiler
doesn't complain about an unused static function) doesn't apply here.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-19 09:09:53 +10:00
Peter Hutterer
ea4f89bd1d tools/record: correct the evdev data format in the man page
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-19 09:09:53 +10:00
Peter Hutterer
f6c05ae4cc tools/record: remove a useless assignment
It's overwritten a few lines south of here.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-12 07:35:58 +10:00
Peter Hutterer
6c32f78020 tools/record: add some curly braces
list_for_each is just a fancy for loop but it looks weird without braces.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-12 07:35:58 +10:00
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