aboutsummaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/usb_hid.c
diff options
context:
space:
mode:
authorAndrew Thompson <thompsa@FreeBSD.org>2009-05-13 18:06:52 +0000
committerAndrew Thompson <thompsa@FreeBSD.org>2009-05-13 18:06:52 +0000
commitecf65ed434edcf8a40e904b5cc6713b64596fcb5 (patch)
tree450d3769b6a23b5f6417bd772c9c47cffe7ea732 /sys/dev/usb/usb_hid.c
parent07532e4997866496e5466f4e9414dcac2fc03c25 (diff)
downloadsrc-ecf65ed434edcf8a40e904b5cc6713b64596fcb5.tar.gz
src-ecf65ed434edcf8a40e904b5cc6713b64596fcb5.zip
Make sure collections have the usage field set.
Submitted by: Hans Petter Selasky
Notes
Notes: svn path=/head/; revision=192055
Diffstat (limited to 'sys/dev/usb/usb_hid.c')
-rw-r--r--sys/dev/usb/usb_hid.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/sys/dev/usb/usb_hid.c b/sys/dev/usb/usb_hid.c
index 555d324ded43..cfec2096c669 100644
--- a/sys/dev/usb/usb_hid.c
+++ b/sys/dev/usb/usb_hid.c
@@ -309,6 +309,7 @@ hid_get_item(struct hid_data *s, struct hid_item *h)
c->kind = hid_collection;
c->collection = dval;
c->collevel++;
+ c->usage = s->usage_last;
*h = *c;
return (1);
case 11: /* Feature */
@@ -408,6 +409,9 @@ hid_get_item(struct hid_data *s, struct hid_item *h)
if (bSize != 4)
dval = (dval & mask) | c->_usage_page;
+ /* set last usage, in case of a collection */
+ s->usage_last = dval;
+
if (s->nusage < MAXUSAGE) {
s->usages_min[s->nusage] = dval;
s->usages_max[s->nusage] = dval;
@@ -630,9 +634,11 @@ hid_is_collection(const void *desc, usb2_size_t size, uint32_t usage)
if (hd == NULL)
return (0);
- err = hid_get_item(hd, &hi) &&
- hi.kind == hid_collection &&
- hi.usage == usage;
+ while ((err = hid_get_item(hd, &hi))) {
+ if (hi.kind == hid_collection &&
+ hi.usage == usage)
+ break;
+ }
hid_end_parse(hd);
return (err);
}