Page MenuHomeFreeBSD

D27748.1775341535.diff
No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None

D27748.1775341535.diff

diff --git a/sys/dev/usb/usb_hid.c b/sys/dev/usb/usb_hid.c
--- a/sys/dev/usb/usb_hid.c
+++ b/sys/dev/usb/usb_hid.c
@@ -111,7 +111,8 @@
c->loc.count = 0;
c->loc.size = 0;
- c->usage = 0;
+ c->nusages = 0;
+ memset(c->usages, 0, sizeof(c->usages));
c->usage_minimum = 0;
c->usage_maximum = 0;
c->designator_index = 0;
@@ -273,6 +274,16 @@
DPRINTFN(1, "Using last usage\n");
dval = s->usage_last;
}
+ c->nusages = 1;
+ /* array type HID item may have multiple usages */
+ while ((c->flags & HIO_VARIABLE) == 0 && s->ousage == 0 &&
+ s->iusage < s->nusage && c->nusages < HID_ITEM_MAXUSAGE)
+ c->usages[c->nusages++] = s->usages_min[s->iusage++];
+ if ((c->flags & HIO_VARIABLE) == 0 && s->ousage == 0 &&
+ s->iusage < s->nusage)
+ DPRINTFN(0, "HID_ITEM_MAXUSAGE should be increased "
+ "up to %hhu to parse the HID report descriptor\n",
+ s->nusage);
s->icount ++;
/*
* Only copy HID item, increment position and return
@@ -381,6 +392,7 @@
c->collection = dval;
c->collevel++;
c->usage = s->usage_last;
+ c->nusages = 1;
*h = *c;
return (1);
case 11: /* Feature */
@@ -620,19 +632,22 @@
{
struct hid_data *d;
struct hid_item h;
+ int i;
for (d = hid_start_parse(desc, size, 1 << k); hid_get_item(d, &h);) {
- if (h.kind == k && h.usage == u) {
- if (index--)
- continue;
- if (loc != NULL)
- *loc = h.loc;
- if (flags != NULL)
- *flags = h.flags;
- if (id != NULL)
- *id = h.report_ID;
- hid_end_parse(d);
- return (1);
+ for (i = 0; i < h.nusages; i++) {
+ if (h.kind == k && h.usages[i] == u) {
+ if (index--)
+ break;
+ if (loc != NULL)
+ *loc = h.loc;
+ if (flags != NULL)
+ *flags = h.flags;
+ if (id != NULL)
+ *id = h.report_ID;
+ hid_end_parse(d);
+ return (1);
+ }
}
}
if (loc != NULL)
diff --git a/sys/dev/usb/usbhid.h b/sys/dev/usb/usbhid.h
--- a/sys/dev/usb/usbhid.h
+++ b/sys/dev/usb/usbhid.h
@@ -208,6 +208,8 @@
#if defined(_KERNEL) || defined(_STANDALONE)
struct usb_config_descriptor;
+#define HID_ITEM_MAXUSAGE 4
+
enum hid_kind {
hid_input, hid_output, hid_feature, hid_collection, hid_endcollection
};
@@ -229,7 +231,11 @@
int32_t unit;
int32_t report_ID;
/* Local */
- int32_t usage;
+ int nusages;
+ union {
+ int32_t usage;
+ int32_t usages[HID_ITEM_MAXUSAGE];
+ };
int32_t usage_minimum;
int32_t usage_maximum;
int32_t designator_index;

File Metadata

Mime Type
text/plain
Expires
Sat, Apr 4, 10:25 PM (12 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28261689
Default Alt Text
D27748.1775341535.diff (2 KB)

Event Timeline