summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Batard <pbatard@gmail.com>2010-04-08 11:48:58 +0100
committerPete Batard <pbatard@gmail.com>2010-04-08 11:48:58 +0100
commit2ec0c2b1ffb1acf16a64177da78fca2949e18285 (patch)
tree573f906d87fac2fb0323148f0198f560464dd952
parentbb3280741d3675dee6274be60ce352e3a2f5370a (diff)
downloadlibusb-2ec0c2b1ffb1acf16a64177da78fca2949e18285.tar.gz
fixed HID record size computation in xusb
-rw-r--r--examples/xusb.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/examples/xusb.c b/examples/xusb.c
index 85351c8..4ee0348 100644
--- a/examples/xusb.c
+++ b/examples/xusb.c
@@ -435,24 +435,27 @@ int get_hid_record_size(uint8_t *hid_report_descriptor, int size, int type)
offset = (hid_report_descriptor[i]&0x03) + 1;
if (offset == 4)
offset = 5;
- switch (hid_report_descriptor[i]) {
- case 0x75: // bitsize
+ switch (hid_report_descriptor[i] & 0xFC) {
+ case 0x74: // bitsize
nb_bits = hid_report_descriptor[i+1];
found_bits = true;
break;
- case 0x95: // count
- nb_items = hid_report_descriptor[i+1];
+ case 0x94: // count
+ nb_items = 0;
+ for (j=1; j<offset; j++) {
+ nb_items = ((uint32_t)hid_report_descriptor[i+j]) << (8*(j-1));
+ }
found_items = true;
break;
- case 0x81: // input
+ case 0x80: // input
found_record_marker = true;
j = 0;
break;
- case 0x91: // output
+ case 0x90: // output
found_record_marker = true;
j = 1;
break;
- case 0xb2: // feature
+ case 0xb0: // feature
found_record_marker = true;
j = 2;
break;