Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/usbhidctl Handle devices with a report id correctly.
details: https://anonhg.NetBSD.org/src/rev/c1aa55446bf7
branches: trunk
changeset: 472110:c1aa55446bf7
user: augustss <augustss%NetBSD.org@localhost>
date: Wed Apr 21 16:23:14 1999 +0000
description:
Handle devices with a report id correctly.
diffstat:
usr.bin/usbhidctl/hidsubr.c | 14 ++++++++++----
usr.bin/usbhidctl/hidsubr.h | 4 ++--
usr.bin/usbhidctl/usbhid.c | 15 ++++++++-------
3 files changed, 20 insertions(+), 13 deletions(-)
diffs (113 lines):
diff -r a996a6d2d9a1 -r c1aa55446bf7 usr.bin/usbhidctl/hidsubr.c
--- a/usr.bin/usbhidctl/hidsubr.c Wed Apr 21 15:38:09 1999 +0000
+++ b/usr.bin/usbhidctl/hidsubr.c Wed Apr 21 16:23:14 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hidsubr.c,v 1.4 1998/12/02 16:37:48 augustss Exp $ */
+/* $NetBSD: hidsubr.c,v 1.5 1999/04/21 16:23:14 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -350,17 +350,23 @@
}
int
-hid_report_size(u_char *buf, int len, enum hid_kind k)
+hid_report_size(u_char *buf, int len, enum hid_kind k, int *idp)
{
struct hid_data *d;
struct hid_item h;
int size, id;
id = 0;
+ if (idp)
+ *idp = 0;
memset(&h, 0, sizeof h);
- for (d = hid_start_parse(buf, len, 1<<k); hid_get_item(d, &h); )
- if (h.report_ID != 0)
+ for (d = hid_start_parse(buf, len, 1<<k); hid_get_item(d, &h); ) {
+ if (h.report_ID != 0) {
+ if (idp)
+ *idp = h.report_ID;
id = 8;
+ }
+ }
hid_end_parse(d);
size = h.pos + id;
return ((size + 7) / 8);
diff -r a996a6d2d9a1 -r c1aa55446bf7 usr.bin/usbhidctl/hidsubr.h
--- a/usr.bin/usbhidctl/hidsubr.h Wed Apr 21 15:38:09 1999 +0000
+++ b/usr.bin/usbhidctl/hidsubr.h Wed Apr 21 16:23:14 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hidsubr.h,v 1.2 1998/11/25 22:17:08 augustss Exp $ */
+/* $NetBSD: hidsubr.h,v 1.3 1999/04/21 16:23:14 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -80,7 +80,7 @@
struct hid_data *hid_start_parse(u_char *d, int len, int kindset);
void hid_end_parse(struct hid_data *s);
int hid_get_item(struct hid_data *s, struct hid_item *h);
-int hid_report_size(u_char *buf, int len, enum hid_kind k);
+int hid_report_size(u_char *buf, int len, enum hid_kind k, int *idp);
char *usage_page(int i);
char *usage_in_page(unsigned int u);
void init_hid(char *file);
diff -r a996a6d2d9a1 -r c1aa55446bf7 usr.bin/usbhidctl/usbhid.c
--- a/usr.bin/usbhidctl/usbhid.c Wed Apr 21 15:38:09 1999 +0000
+++ b/usr.bin/usbhidctl/usbhid.c Wed Apr 21 16:23:14 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: usbhid.c,v 1.6 1998/12/03 20:46:10 augustss Exp $ */
+/* $NetBSD: usbhid.c,v 1.7 1999/04/21 16:23:14 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -141,11 +141,11 @@
}
hid_end_parse(d);
printf("Total input size %d bytes\n",
- hid_report_size(buf, len, hid_input));
+ hid_report_size(buf, len, hid_input, 0));
printf("Total output size %d bytes\n",
- hid_report_size(buf, len, hid_output));
+ hid_report_size(buf, len, hid_output, 0));
printf("Total feature size %d bytes\n",
- hid_report_size(buf, len, hid_feature));
+ hid_report_size(buf, len, hid_feature, 0));
}
void
@@ -196,7 +196,7 @@
if (h->logical_minimum < 0)
printf("%ld", (long)data);
else
- printf("%lu", data);
+ printf("%04lx", data);
pos += h->report_size;
}
}
@@ -211,6 +211,7 @@
static int one = 1;
u_int32_t colls[100];
int sp = 0;
+ int report_id;
char namebuf[10000], *namep;
hids = 0;
@@ -229,7 +230,7 @@
}
hid_end_parse(d);
rev(&hids);
- dlen = hid_report_size(buf, len, hid_input);
+ dlen = hid_report_size(buf, len, hid_input, &report_id);
dbuf = malloc(dlen);
if (!loop)
if (ioctl(f, USB_SET_IMMED, &one) < 0) {
@@ -254,7 +255,7 @@
if (all || gotname(namebuf)) {
if (!noname)
printf("%s=", namebuf);
- prdata(dbuf, n);
+ prdata(dbuf + (report_id != 0), n);
if (verbose)
printf(" [%d - %d]",
n->logical_minimum,
Home |
Main Index |
Thread Index |
Old Index