summaryrefslogtreecommitdiffstats
path: root/lib/libusbhid/parse.c
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2011-07-30 13:22:44 +0000
committermav <mav@FreeBSD.org>2011-07-30 13:22:44 +0000
commitad37555d422d0e4b4662a53f1df5fe77c6a7a841 (patch)
tree71e3c3510b7c799897cb17384eecaf618c0fe4f7 /lib/libusbhid/parse.c
parent443209104b215fe51c5924578a81a05e0ecd3309 (diff)
downloadFreeBSD-src-ad37555d422d0e4b4662a53f1df5fe77c6a7a841.zip
FreeBSD-src-ad37555d422d0e4b4662a53f1df5fe77c6a7a841.tar.gz
MFprojects/hid:
- Fix usbhidctl and usbhidaction to handle HID devices with multiple report ids, such as multimedia keyboards. - Add collection type and report id to the `usbhidctl -r` output. They are important for proper device understanding and debugging. - Fix usbhidaction tool to properly handle items having report_count more then 1. Approved by: re (kib) MFC after: 2 weeks
Diffstat (limited to 'lib/libusbhid/parse.c')
-rw-r--r--lib/libusbhid/parse.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/libusbhid/parse.c b/lib/libusbhid/parse.c
index ce034b1..d2b49d4 100644
--- a/lib/libusbhid/parse.c
+++ b/lib/libusbhid/parse.c
@@ -322,6 +322,8 @@ hid_get_item(hid_data_t s, hid_item_t *h)
* one and one item:
*/
c->report_count = 1;
+ c->usage_minimum = 0;
+ c->usage_maximum = 0;
} else {
s->ncount = 1;
}
@@ -512,13 +514,14 @@ hid_report_size(report_desc_t r, enum hid_kind k, int id)
uint32_t temp;
uint32_t hpos;
uint32_t lpos;
+ int report_id = 0;
hpos = 0;
lpos = 0xFFFFFFFF;
memset(&h, 0, sizeof h);
for (d = hid_start_parse(r, 1 << k, id); hid_get_item(d, &h); ) {
- if (h.report_ID == id && h.kind == k) {
+ if ((h.report_ID == id || id < 0) && h.kind == k) {
/* compute minimum */
if (lpos > h.pos)
lpos = h.pos;
@@ -527,6 +530,8 @@ hid_report_size(report_desc_t r, enum hid_kind k, int id)
/* compute maximum */
if (hpos < temp)
hpos = temp;
+ if (h.report_ID != 0)
+ report_id = 1;
}
}
hid_end_parse(d);
@@ -537,11 +542,8 @@ hid_report_size(report_desc_t r, enum hid_kind k, int id)
else
temp = hpos - lpos;
- if (id)
- temp += 8;
-
/* return length in bytes rounded up */
- return ((temp + 7) / 8);
+ return ((temp + 7) / 8 + report_id);
}
int
OpenPOWER on IntegriCloud