Fixed HID report parser collection paths invalid due to misplaced semicolon in the free path item search loop. Increased the default number of collection paths allowable by the parser.
This commit is contained in:
parent
ba8ffa4cb7
commit
4670b39070
4 changed files with 11 additions and 35 deletions
|
@ -42,16 +42,12 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID
|
|||
uint16_t UsageStack[HID_USAGE_STACK_DEPTH];
|
||||
uint8_t UsageStackSize = 0;
|
||||
|
||||
ParserData->TotalReportItems = 0;
|
||||
ParserData->TotalDeviceReports = 1;
|
||||
ParserData->UsingReportIDs = false;
|
||||
|
||||
for (uint8_t CurrCollection = 0; CurrCollection < HID_MAX_COLLECTIONS; CurrCollection++)
|
||||
ParserData->CollectionPaths[CurrCollection].Parent = NULL;
|
||||
|
||||
memset(ParserData, 0x00, sizeof(HID_ReportInfo_t));
|
||||
memset(CurrStateTable, 0x00, sizeof(HID_StateTable_t));
|
||||
memset(CurrReportIDInfo, 0x00, sizeof(HID_ReportSizeInfo_t));
|
||||
|
||||
ParserData->TotalDeviceReports = 1;
|
||||
|
||||
while (ReportSize)
|
||||
{
|
||||
uint8_t HIDReportItem = *ReportData;
|
||||
|
@ -177,7 +173,7 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID
|
|||
|
||||
CurrCollectionPath = &ParserData->CollectionPaths[1];
|
||||
|
||||
while (CurrCollectionPath->Parent != NULL);
|
||||
while (CurrCollectionPath->Parent != NULL)
|
||||
{
|
||||
if (CurrCollectionPath == &ParserData->CollectionPaths[HID_MAX_COLLECTIONS - 1])
|
||||
return HID_PARSE_InsufficientCollectionPaths;
|
||||
|
@ -200,10 +196,6 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID
|
|||
|
||||
UsageStackSize--;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrCollectionPath->Usage.Usage = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
case (TYPE_MAIN | TAG_MAIN_ENDCOLLECTION):
|
||||
|
@ -211,7 +203,6 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID
|
|||
return HID_PARSE_UnexpectedEndCollection;
|
||||
|
||||
CurrCollectionPath = CurrCollectionPath->Parent;
|
||||
|
||||
break;
|
||||
case (TYPE_MAIN | TAG_MAIN_INPUT):
|
||||
case (TYPE_MAIN | TAG_MAIN_OUTPUT):
|
||||
|
@ -237,39 +228,26 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID
|
|||
|
||||
UsageStackSize--;
|
||||
}
|
||||
else
|
||||
{
|
||||
NewReportItem.Attributes.Usage.Usage = 0;
|
||||
}
|
||||
|
||||
uint8_t ReportSizeIndex = 0;
|
||||
|
||||
switch (HIDReportItem & TAG_MASK)
|
||||
{
|
||||
case TAG_MAIN_INPUT:
|
||||
NewReportItem.ItemType = REPORT_ITEM_TYPE_In;
|
||||
NewReportItem.BitOffset = CurrReportIDInfo->ReportSizeBits[REPORT_ITEM_TYPE_In];
|
||||
|
||||
ReportSizeIndex = REPORT_ITEM_TYPE_In;
|
||||
break;
|
||||
case TAG_MAIN_OUTPUT:
|
||||
NewReportItem.ItemType = REPORT_ITEM_TYPE_Out;
|
||||
NewReportItem.BitOffset = CurrReportIDInfo->ReportSizeBits[REPORT_ITEM_TYPE_Out];
|
||||
|
||||
ReportSizeIndex = REPORT_ITEM_TYPE_Out;
|
||||
break;
|
||||
case TAG_MAIN_FEATURE:
|
||||
NewReportItem.ItemType = REPORT_ITEM_TYPE_Feature;
|
||||
NewReportItem.BitOffset = CurrReportIDInfo->ReportSizeBits[REPORT_ITEM_TYPE_Feature];
|
||||
|
||||
ReportSizeIndex = REPORT_ITEM_TYPE_Feature;
|
||||
break;
|
||||
}
|
||||
|
||||
CurrReportIDInfo->ReportSizeBits[ReportSizeIndex] += CurrStateTable->Attributes.BitSize;
|
||||
NewReportItem.BitOffset = CurrReportIDInfo->ReportSizeBits[NewReportItem.ItemType];
|
||||
|
||||
if (ParserData->LargestReportSizeBits < CurrReportIDInfo->ReportSizeBits[ReportSizeIndex])
|
||||
ParserData->LargestReportSizeBits = CurrReportIDInfo->ReportSizeBits[ReportSizeIndex];
|
||||
CurrReportIDInfo->ReportSizeBits[NewReportItem.ItemType] += CurrStateTable->Attributes.BitSize;
|
||||
|
||||
if (ParserData->LargestReportSizeBits < NewReportItem.BitOffset)
|
||||
ParserData->LargestReportSizeBits = NewReportItem.BitOffset;
|
||||
|
||||
if (!(ReportItemData & IOF_CONSTANT) && CALLBACK_HIDParser_FilterHIDReportItem(&NewReportItem))
|
||||
{
|
||||
|
@ -283,8 +261,6 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID
|
|||
}
|
||||
}
|
||||
|
||||
UsageStackSize = 0;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue