Commit graph

110 commits

Author SHA1 Message Date
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
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
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
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
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
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
2b3fd5aa30 tools: record: use the right exit code when the output file is missing
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-03-16 16:21:04 +10:00
Peter Hutterer
6ed3a0b079 tools: record: allow for an output file without --o
libinput record touchpad.yml /dev/input/eventX
or just
  libinput record touchpad.yml
are simpler invocations and since we're quite limited in what we can record
(i.e. only device files) we can just check the argument list to figure out
whether there is something to record to.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-03-16 13:04:50 +10:00
Peter Hutterer
850925910f tools: record: fix dmi recording
Processing os-release in the same buffer that the dmi modalias used caused the
dmi to be recorded as 'dmi: "VERSION_ID=31"'. The cause for that was simply
that the dmi modalias was read but not printed until after the os-release
information was processed.

Fix this two-fold: rearrange that each part now reads and prints in
one go, and rename the buffers so we don't re-use them.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-03-09 10:20:49 +10:00
Peter Hutterer
294298880d tools: record: fix fallback os-release file handling
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-02-21 11:42:01 +10:00
Peter Hutterer
428acee867 tools: record: record basic os-release information as well
Because sometimes it's useful to know what distro a recording was made on, and
the kernel version doesn't always reveal that.

Fixes #428

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-02-19 08:31:18 +00:00
Peter Hutterer
7198e33ecf tools: record: rename a variable to just buf
Better name for re-use

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-02-19 08:31:17 +00:00
Peter Hutterer
ed1d181cf6 tools: record: record the EVDEV_ABS properties correctly
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-02-07 16:18:27 +10:00
Peter Hutterer
0a2bbdf6e7 tools: record: record the EV_ABS deltas along with the absolute value
It's useful to have this in the immediate recording. Example output now:

 - evdev:
    - [  2, 300309,   3,  47,       0] # EV_ABS / ABS_MT_SLOT               0
    - [  2, 300309,   3,  54,    3547] # EV_ABS / ABS_MT_POSITION_Y      3547 (+8)
    - [  2, 300309,   3,  58,      70] # EV_ABS / ABS_MT_PRESSURE          70 (-14)
    - [  2, 300309,   3,  47,       1] # EV_ABS / ABS_MT_SLOT               1
    - [  2, 300309,   3,  54,    3112] # EV_ABS / ABS_MT_POSITION_Y      3112 (+4)
    - [  2, 300309,   3,  58,      68] # EV_ABS / ABS_MT_PRESSURE          68 (-4)
    - [  2, 300309,   3,   1,    3547] # EV_ABS / ABS_Y                  3547 (+8)
    - [  2, 300309,   3,  24,      70] # EV_ABS / ABS_PRESSURE             70 (-14)
    - [  2, 300309,   0,   0,       0] # ------------ SYN_REPORT (0) ---------- +49ms

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-01-31 10:40:49 +00:00
Peter Hutterer
da9eace8db tools: record: fix broken event time stamp recording
event->time ended up being an uninitialized field. Introduced in 5dc1a7e, the
event here isn't a struct input event but rather our internal event struct.
Fix this and reshuffle the time handling a bit so it's a bit more obvious
here.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-01-30 02:10:33 +00:00
Peter Hutterer
fb1f0a6886 tools: record: wrap the time offset handling into a helper function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-01-30 02:10:33 +00:00
Peter Hutterer
eb16ce2520 tools: libinput-record: drop the explicit --multiple argument
If we want to record multiple events, let's just specify multiple event nodes.
No need for a specific extra argument here.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-11-27 10:34:18 +10:00
Peter Hutterer
5a275ef171 tools: libinput-record: return the correct exit value on invalid usage
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-11-27 10:34:18 +10:00
Peter Hutterer
1457ac8446 tools: libinput-record: bail out on invalid commandline arguments
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-11-27 10:34:18 +10:00
Peter Hutterer
5dc1a7ebd3 Adjust for 64bit time_t for 32bit architectures
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-11-26 15:11:44 +10:00
Peter Hutterer
eef00ff3c6 tools: libinput-record: expand the evdev event value to 7 digits
MSC_TIMESTAMPS need 7 digits so let's make sure everything is nicely aligned

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-11-18 05:34:56 +00:00
Peter Hutterer
1e6802b91b Remove some usage of libinput-util.h
Positive side-effect - this exposed a bunch of missing #includes that got
pulled in by other headers before.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-09-11 12:23:06 +10:00
Peter Hutterer
4ab8a51b68 tools: record: fix two memory leaks
Found by coverity.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-01 08:41:01 +10:00
Peter Hutterer
803519ae59 tools: record: fix segfault on exit
If we don't supply --with-libinput, the device is NULL so we can't unref it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-01 08:40:58 +10:00
Peter Hutterer
9c2ac8f9ee tools: record: when running from the builddir, load the quirks correctly
Fixes #324

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-07-24 14:57:56 +10:00
Peter Hutterer
247b2344a5 tools: record: increase value size to 6 digits
Tablets commonly have higher axis ranges, might as well make sure they line
up.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-04-01 09:45:29 +10:00
Peter Hutterer
26702e4d73 Fix three coverity complaints
Two resource leaks, one uninitialized variable.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-03-25 15:15:13 +10:00
Peter Hutterer
1272db297a tools: record: print a helpful error message when we don't have devices
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-03-04 04:54:27 +00:00
Peter Hutterer
b8a04553de tools: libinput-record: record the hid report descriptor where available
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-01-02 15:24:04 +00:00
Peter Hutterer
d616218c9a tools: fix a bunch of format conversion complaints
Fixes #137

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-09-12 13:28:16 +10:00
Peter Hutterer
e33fd7157f tools: record: don't bother setting last_ms to 0 on the first event
The first event we receive is set to a 0ms offset anyway. Setting last_ms to 0
on the first event means the first two events have +0ms offset printed to the
log. Skip it, so the second event has the right offset.

This is human-readable data only, no effect on the recording file itself.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-06 14:06:48 +10:00
Greg V
f8b412052e Import versionsort implementation from musl for systems without versionsort
versionsort is a GNU extension, not available on *BSD systems.
2018-07-16 13:44:11 +03:00
Peter Hutterer
e6cad92005 Rename data/ to quirks/
A better, less ambiguous name than just "datadir"

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-07-13 13:30:54 +10:00
Peter Hutterer
ea5edf09c4 tools: libinput-record: print the list of quirks
Now that all device quirks are in the quirks subsystem we have to print those
instead of just the udev devices.

Since libinput-record is there to record system devices, the system-installed
quirk list is used (without any commandline overrides right now). This is
useful to capture misconfigurations or missing quirks on the host system.

Fixes https://gitlab.freedesktop.org/libinput/libinput/issues/58

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-06-26 13:59:30 +10:00
Peter Hutterer
b4ff592a5a tools: libinput-record: put extra guard in to protect from OOB access
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-06-11 13:43:40 +10:00
Peter Hutterer
7ad3dcf939 tools: libinput-record: fix leaking memory in the error cases
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-16 14:23:12 +10:00
Peter Hutterer
b476345959 tools: libinput-record: print switch events in --with-libinput
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-03 14:03:30 +10:00
Peter Hutterer
8bf2c5ae16 tools: libinput-record: print tablet events in --with-libinput
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-03 13:39:44 +10:00
Peter Hutterer
d140bb7c2d tools: libinput-record: move the event time offset to the first place we get it
Leftover from a previous version where printing and handling an event was
identical. Now we may handle events but not actually print them until a bit
later, so other events may have a (wrong) zero timestamp.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-03 12:20:03 +10:00
Peter Hutterer
aca0e3729a tools: libinput-record: add gesture support
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-19 16:04:41 +10:00
Peter Hutterer
b2fb2adefa Remove some duplicate empty lines
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-16 15:14:23 +10:00
Peter Hutterer
8b6d799510 tools: libinput-record: print the mouse and pointingstick udev properties
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-20 13:51:31 +10:00
Peter Hutterer
a1ba6186e7 tools: libinput-record: print a progress bar when recording to a file
To let users know something is happening.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-19 14:24:15 +10:00
Peter Hutterer
056a5eb64a tools: libinput-record: print a comment when the device is in a neutral state
Common problem: some touch sequence does something to confuse libinput but it
cannot easily be captureed. The result is a long sequence of touche that need
to be picked apart and isolated.

Print an easy-to-search  for message in the evdev output that signals that the
device touch state is now neutral (i.e. no finger down). Same can be achieved
by searching for BTN_TOOL_FINGER but that provides false positives for
switching between one and two fingers.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-03-19 14:24:15 +10:00