diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2021-04-29 10:12:46 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2021-04-30 14:54:35 +1000 |
commit | b38c6ca69fd43dba374283f0c9ace8e911e28aad (patch) | |
tree | 4bb50c30208884e41fac6fbbca62aa1047dda943 | |
parent | 7da7cd216f42a223d38b587556e33e74a08e225e (diff) | |
download | libinput-b38c6ca69fd43dba374283f0c9ace8e911e28aad.tar.gz |
tools/record: linebreak the hid report descriptor every 16 bytes
New output:
hid: [
0x05, 0x0d, 0x09, 0x04, 0xa1, 0x01, 0x85, 0x01, 0x09, 0x22, 0xa1, 0x02, 0x09, 0x42, 0x15, 0x00,
0x25, 0x01, 0x75, 0x01, 0x95, 0x01, 0x81, 0x02, 0x75, 0x01, 0x81, 0x03, 0x75, 0x06, 0x09, 0x51,
0x25, 0x3f, 0x81, 0x02, 0x26, 0xff, 0x00, 0x75, 0x08, 0x09, 0x48, 0x81, 0x02, 0x09, 0x49, 0x81,
...
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | tools/libinput-record.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/tools/libinput-record.c b/tools/libinput-record.c index a4d055a4..1e763f36 100644 --- a/tools/libinput-record.c +++ b/tools/libinput-record.c @@ -1597,11 +1597,25 @@ print_hid_report_descriptor(struct record_device *dev) while ((len = read(fd, buf, sizeof(buf))) > 0) { for (int i = 0; i < len; i++) { - iprintf(dev->fp, I_NONE, "%s0x%02x", sep, buf[i]); + /* We can't have a trailing comma, so our line-break + * handling is awkward. + * For a linebreak: print the comma, break, indent, + * then just the hex code. + * For the other values: print the comma plus the + * hex code, unindented. + */ + if (i % 16 == 0) { + iprintf(dev->fp, I_NONE, "%s\n", sep); + iprintf(dev->fp, I_DEVICE, " "); + iprintf(dev->fp, I_NONE, "0x%02x", buf[i]); + } else { + iprintf(dev->fp, I_NONE, "%s0x%02x", sep, buf[i]); + } sep = ", "; } } - iprintf(dev->fp, I_NONE, "]\n"); + iprintf(dev->fp, I_NONE, "\n"); + iprintf(dev->fp, I_DEVICE, "]\n"); close(fd); } |