From 18e811b4ee1c8d9149631d474b37940c34518703 Mon Sep 17 00:00:00 2001 From: Robert Fisk Date: Thu, 28 Apr 2016 21:37:34 +1200 Subject: [PATCH] HID report parser now handles collections. --- Downstream/Inc/downstream_hid.h | 4 ++++ Downstream/Src/downstream_hid.c | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/Downstream/Inc/downstream_hid.h b/Downstream/Inc/downstream_hid.h index 033392e..a9f2fd2 100644 --- a/Downstream/Inc/downstream_hid.h +++ b/Downstream/Inc/downstream_hid.h @@ -25,6 +25,10 @@ #define HID_ITEM_USAGE_PAGE_BUTTON 0x09 #define HID_ITEM_USAGE_PAGE_DESKTOP 0x01 +#define HID_ITEM_COLLECTION 0xA1 +#define HID_ITEM_COLLECTION_PHYS 0x00 +#define HID_ITEM_END_COLLECTION 0xC0 + #define HID_ITEM_USAGE 0x09 //'local' usage #define HID_ITEM_USAGE_X 0x30 #define HID_ITEM_USAGE_Y 0x31 diff --git a/Downstream/Src/downstream_hid.c b/Downstream/Src/downstream_hid.c index 095ab1c..c383344 100644 --- a/Downstream/Src/downstream_hid.c +++ b/Downstream/Src/downstream_hid.c @@ -106,6 +106,23 @@ HAL_StatusTypeDef Downstream_HID_Mouse_ParseReportDescriptor(void) wheelUsageIndex = 0xFF; break; + case HID_ITEM_COLLECTION: //Physical collections also clear the usage index... + if (ItemData == HID_ITEM_COLLECTION_PHYS) + { + currentUsageIndex = 0; + xUsageIndex = 0xFF; + yUsageIndex = 0xFF; + wheelUsageIndex = 0xFF; + } + break; + + case HID_ITEM_END_COLLECTION: //...and so do collection ends + currentUsageIndex = 0; + xUsageIndex = 0xFF; + yUsageIndex = 0xFF; + wheelUsageIndex = 0xFF; + break; + case HID_ITEM_USAGE: switch (ItemData) {