Slightly less efficient but easier to read and it's not possible to
accidentally provide the wrong length. Plus it handles null pointers
correctly so get to skip the checks (which weren't needed for strneq()
either, but still).
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1121>
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>
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>
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>
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>
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>
Commit 0cdf459643
tools/record: get rid of indent push/pop, replace with fixed indents
Introduced some magic to detect if there's a '-' at the start of the
format string to fix the identation. This only works if the format
string is constant though, leading to an indentation error when record
is run with --with-libinput.
Fixes 0cdf459643
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
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>