From ad37555d422d0e4b4662a53f1df5fe77c6a7a841 Mon Sep 17 00:00:00 2001 From: mav Date: Sat, 30 Jul 2011 13:22:44 +0000 Subject: 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 --- lib/libusbhid/parse.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'lib') 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 -- cgit v1.1