From 9a2a66f1bbee857d732413b674032c4e52579019 Mon Sep 17 00:00:00 2001 From: Greg Lehey Date: Thu, 23 Nov 2006 00:20:54 +0000 Subject: [PATCH] Add option -x to display output values in hex in addition to decimal. --- usr.bin/usbhidctl/usbhid.c | 30 +++++++++++++++++++++--------- usr.bin/usbhidctl/usbhidctl.1 | 3 +++ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/usr.bin/usbhidctl/usbhid.c b/usr.bin/usbhidctl/usbhid.c index a6c3351e5fac..82072f041f6b 100644 --- a/usr.bin/usbhidctl/usbhid.c +++ b/usr.bin/usbhidctl/usbhid.c @@ -54,6 +54,7 @@ int verbose = 0; int all = 0; int noname = 0; +int hexdump = 0; static int reportid; char **names; @@ -94,8 +95,14 @@ usage(void) { extern char *__progname; - fprintf(stderr, "usage: %s -f device [-l] [-n] [-r] [-t tablefile] [-v] name ...\n", __progname); - fprintf(stderr, " %s -f device [-l] [-n] [-r] [-t tablefile] [-v] -a\n", __progname); + fprintf(stderr, + "usage: %s -f device " + "[-l] [-n] [-r] [-t tablefile] [-v] [x] name ...\n", + __progname); + fprintf(stderr, + " %s -f device " + "[-l] [-n] [-r] [-t tablefile] [-v] [x] -a\n", + __progname); exit(1); } @@ -105,8 +112,8 @@ dumpitem(const char *label, struct hid_item *h) if ((h->flags & HIO_CONST) && !verbose) return; printf("%s size=%d count=%d page=%s usage=%s%s", label, - h->report_size, h->report_count, - hid_usage_page(HID_PAGE(h->usage)), + h->report_size, h->report_count, + hid_usage_page(HID_PAGE(h->usage)), hid_usage_in_page(h->usage), h->flags & HIO_CONST ? " Const" : ""); printf(", logical range %d..%d", @@ -130,7 +137,7 @@ dumpitems(report_desc_t r) switch (h.kind) { case hid_collection: printf("Collection page=%s usage=%s\n", - hid_usage_page(HID_PAGE(h.usage)), + hid_usage_page(HID_PAGE(h.usage)), hid_usage_in_page(h.usage)); break; case hid_endcollection: @@ -187,6 +194,8 @@ prdata(u_char *buf, struct hid_item *h) printf("%d", (int)data); else printf("%u", data); + if (hexdump) + printf(" [0x%x]", data); pos += h->report_size; } } @@ -204,7 +213,7 @@ dumpdata(int f, report_desc_t rd, int loop) char namebuf[10000], *namep; hids = 0; - for (d = hid_start_parse(rd, 1<