Refactor and improve HID report item parsing

USG_1.0
Robert Fisk 8 years ago
parent 0e42cf71dd
commit 42d6030e7b

@ -32,7 +32,7 @@
//Stuff for parsing HID descriptors: //Stuff for parsing HID descriptors:
#define HID_ITEM_LONG 0xFE #define HID_ITEM_LONG 0xFC
#define HID_ITEM_MASK 0xFC #define HID_ITEM_MASK 0xFC
#define HID_ITEM_LENGTH_MASK 0x03 #define HID_ITEM_LENGTH_MASK 0x03

@ -93,7 +93,7 @@ static HAL_StatusTypeDef Downstream_HID_Mouse_ParseReportDescriptor(void)
(ReportYBitLength == 0) || (ReportYBitLength == 0) ||
(ReportWheelBitLength == 0))) (ReportWheelBitLength == 0)))
{ {
switch (ItemHeader & HID_ITEM_MASK) switch (ItemHeader)
{ {
case HID_ITEM_USAGE_PAGE: case HID_ITEM_USAGE_PAGE:
currentUsagePage = ItemData; currentUsagePage = ItemData;
@ -239,8 +239,14 @@ static HAL_StatusTypeDef Downstream_HID_GetNextReportItem(void)
return HAL_ERROR; return HAL_ERROR;
} }
ItemHeader = *ReportDataPointer++; ItemHeader = *ReportDataPointer & HID_ITEM_MASK;
itemLength = ItemHeader & HID_ITEM_LENGTH_MASK; itemLength = *ReportDataPointer & HID_ITEM_LENGTH_MASK;
ReportDataPointer++;
if (itemLength == 3)
{
itemLength = 4; //Length = 3 actually means 4 bytes
}
if (ItemHeader == HID_ITEM_LONG) if (ItemHeader == HID_ITEM_LONG)
{ {

Loading…
Cancel
Save