Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/usbhidctl Dump more HID info.
details: https://anonhg.NetBSD.org/src/rev/26a1672339ab
branches: trunk
changeset: 472112:26a1672339ab
user: augustss <augustss%NetBSD.org@localhost>
date: Wed Apr 21 17:41:08 1999 +0000
description:
Dump more HID info.
diffstat:
usr.bin/usbhidctl/usbhid.c | 73 +++++++++++++++++++++++++++------------------
1 files changed, 44 insertions(+), 29 deletions(-)
diffs (141 lines):
diff -r 7492dacef8a9 -r 26a1672339ab usr.bin/usbhidctl/usbhid.c
--- a/usr.bin/usbhidctl/usbhid.c Wed Apr 21 17:13:22 1999 +0000
+++ b/usr.bin/usbhidctl/usbhid.c Wed Apr 21 17:41:08 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: usbhid.c,v 1.7 1999/04/21 16:23:14 augustss Exp $ */
+/* $NetBSD: usbhid.c,v 1.8 1999/04/21 17:41:08 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -62,6 +62,7 @@
void prbits(int bits, char **strs, int n);
void usage(void);
+void dumpitem(char *label, struct hid_item *h);
void dumpitems(u_char *buf, int len);
void rev(struct hid_item **p);
u_long getdata(u_char *buf, int hpos, int hsize, int sign);
@@ -101,10 +102,31 @@
}
void
+dumpitem(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,
+ usage_page(HID_PAGE(h->usage)),
+ usage_in_page(h->usage),
+ h->flags & HIO_CONST ? " Const" : "");
+ printf(", logical range %d..%d",
+ h->logical_minimum, h->logical_maximum);
+ if (h->physical_minimum != h->physical_maximum)
+ printf(", physical range %d..%d",
+ h->physical_minimum, h->physical_maximum);
+ if (h->unit)
+ printf(", unit=0x%02x exp=%d", h->unit, h->unit_exponent);
+ printf("\n");
+}
+
+void
dumpitems(u_char *buf, int len)
{
struct hid_data *d;
struct hid_item h;
+ int report_id, size;
for (d = hid_start_parse(buf, len, ~0); hid_get_item(d, &h); ) {
switch (h.kind) {
@@ -117,35 +139,31 @@
printf("End collection\n");
break;
case hid_input:
- printf("Input size=%d count=%d page=%s usage=%s%s\n",
- h.report_size, h.report_count,
- usage_page(HID_PAGE(h.usage)),
- usage_in_page(h.usage),
- h.flags & HIO_CONST ? " Const" : "");
+ dumpitem("Input ", &h);
break;
case hid_output:
- printf("Output size=%d count=%d page=%s usage=%s%s\n",
- h.report_size, h.report_count,
- usage_page(HID_PAGE(h.usage)),
- usage_in_page(h.usage),
- h.flags & HIO_CONST ? " Const" : "");
+ dumpitem("Output ", &h);
break;
case hid_feature:
- printf("Feature size=%d count=%d page=%s usage=%s%s\n",
- h.report_size, h.report_count,
- usage_page(HID_PAGE(h.usage)),
- usage_in_page(h.usage),
- h.flags & HIO_CONST ? " Const" : "");
+ dumpitem("Feature", &h);
break;
}
}
hid_end_parse(d);
- printf("Total input size %d bytes\n",
- hid_report_size(buf, len, hid_input, 0));
- printf("Total output size %d bytes\n",
- hid_report_size(buf, len, hid_output, 0));
- printf("Total feature size %d bytes\n",
- hid_report_size(buf, len, hid_feature, 0));
+ size = hid_report_size(buf, len, hid_input, &report_id);
+ size -= report_id != 0;
+ printf("Total input size %s%d bytes\n",
+ report_id && size ? "1+" : "", size);
+
+ size = hid_report_size(buf, len, hid_output, &report_id);
+ size -= report_id != 0;
+ printf("Total output size %s%d bytes\n",
+ report_id && size ? "1+" : "", size);
+
+ size = hid_report_size(buf, len, hid_feature, &report_id);
+ size -= report_id != 0;
+ printf("Total feature size %s%d bytes\n",
+ report_id && size ? "1+" : "", size);
}
void
@@ -196,7 +214,7 @@
if (h->logical_minimum < 0)
printf("%ld", (long)data);
else
- printf("%04lx", data);
+ printf("%lu", data);
pos += h->report_size;
}
}
@@ -256,10 +274,6 @@
if (!noname)
printf("%s=", namebuf);
prdata(dbuf + (report_id != 0), n);
- if (verbose)
- printf(" [%d - %d]",
- n->logical_minimum,
- n->logical_maximum);
printf("\n");
}
}
@@ -317,7 +331,7 @@
names = argv;
nnames = argc;
- if (nnames == 0 && !all)
+ if (nnames == 0 && !all && !repdump)
usage();
if (dev[0] != '/') {
@@ -343,7 +357,8 @@
printf("Report descriptor\n");
dumpitems(rep.data, rep.size);
}
- dumpdata(f, rep.data, rep.size, loop);
+ if (nnames != 0 || all)
+ dumpdata(f, rep.data, rep.size, loop);
exit(0);
}
Home |
Main Index |
Thread Index |
Old Index