Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F174392182
D27748.id81113.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D27748.id81113.diff
View Options
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;
+ bzero(c->usages, sizeof(c->usages));
c->usage_minimum = 0;
c->usage_maximum = 0;
c->designator_index = 0;
@@ -273,6 +274,15 @@
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 < HI_MAXUSAGE)
+ c->usages[c->nusages++] = s->usages_min[s->iusage++];
+ if ((c->flags & HIO_VARIABLE) == 0 && s->ousage == 0 &&
+ s->iusage < s->nusage)
+ DPRINTF("HI_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 +391,7 @@
c->collection = dval;
c->collevel++;
c->usage = s->usage_last;
+ c->nusages = 1;
*h = *c;
return (1);
case 11: /* Feature */
@@ -620,19 +631,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
@@ -206,6 +206,9 @@
#define HUM_DEGREE 0x14
#if defined(_KERNEL) || defined(_STANDALONE)
+
+#define HI_MAXUSAGE 4
+
struct usb_config_descriptor;
enum hid_kind {
@@ -229,7 +232,11 @@
int32_t unit;
int32_t report_ID;
/* Local */
- int32_t usage;
+ int nusages;
+ union {
+ int32_t usage;
+ int32_t usages[HI_MAXUSAGE];
+ };
int32_t usage_minimum;
int32_t usage_maximum;
int32_t designator_index;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Oct 3, 9:17 PM (12 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40154165
Default Alt Text
D27748.id81113.diff (2 KB)
Attached To
Mode
D27748: hid: Allow HID report descriptor parser to return more then 1 usage per item.
Attached
Detach File
Event Timeline
Log In to Comment