Handle devices with a report id correctly.
This commit is contained in:
parent
bfde703554
commit
f52e3c039b
@ -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 @@ hid_get_item(struct hid_data *s, struct hid_item *h)
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -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_item {
|
||||
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);
|
||||
|
@ -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 @@ dumpitems(u_char *buf, int len)
|
||||
}
|
||||
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 @@ prdata(u_char *buf, struct hid_item *h)
|
||||
if (h->logical_minimum < 0)
|
||||
printf("%ld", (long)data);
|
||||
else
|
||||
printf("%lu", data);
|
||||
printf("%04lx", data);
|
||||
pos += h->report_size;
|
||||
}
|
||||
}
|
||||
@ -211,6 +211,7 @@ dumpdata(int f, u_char *buf, int len, int loop)
|
||||
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 @@ dumpdata(int f, u_char *buf, int len, int loop)
|
||||
}
|
||||
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 @@ dumpdata(int f, u_char *buf, int len, int loop)
|
||||
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,
|
||||
|
Loading…
Reference in New Issue
Block a user