All cases we have in our code base have an otherwise unused variable to
loop through the array. Let's auto-declare this as part of the loop.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
In the various logging functions where we need to modify the format
argument, disable the compiler warnings. Interestingly, GCC doesn't seem
to mind those but building with clang unleashes pages of warnings.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Let a few obvious modifiers through, including the F-key range. Especially
left control is useful to know if it's down.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
New commandline switch --with-hidraw. This will open all hidraw devices
associated with this device and add any reports to the output in the
form:
events:
- hid:
time: [0, 0]
hidraw1: [0x01, 0x02, 0x03, 0x05, 0x06]
hidraw2: [0x07, 0x08, 0x09, 0x0a, 0x0b]
- evdev:
...
i.e. there's a nesting of `hid` with a list of reports, each with the hidraw
node as dictionary entry.
Because hidraw events do not have timestamps and always occur before the evdev
events, they are in a separate frame (as shown above). We could try to figure
out how to match them with the upcoming evdev frame but it's not worth it for
now.
The timestamp itself is a special key in the hidraw with the timestamp from
clock_gettime.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
YAML does support hex as long as it's 0x-prefixed. The comment here (probably)
dates from an in-development version of libinput-record that used JSON.
Anyway, let's print the HID report descriptor as hex because that's the common
format for it.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>