CurrCollectionPath->Parent = ParentCollectionPath;
}
- CurrCollectionPath->Type = ReportItemData;
+ CurrCollectionPath->Type = ReportItemData;
CurrCollectionPath->Usage.Page = CurrStateTable->Attributes.Usage.Page;
if (UsageListSize)
CurrReportIDInfo->ReportSizeBits[NewReportItem.ItemType] += CurrStateTable->Attributes.BitSize;
- if (ParserData->LargestReportSizeBits < NewReportItem.BitOffset)
- ParserData->LargestReportSizeBits = NewReportItem.BitOffset;
+ ParserData->LargestReportSizeBits = MAX(ParserData->LargestReportSizeBits, CurrReportIDInfo->ReportSizeBits[NewReportItem.ItemType]);
- if (!(ReportItemData & HID_IOF_CONSTANT) && CALLBACK_HIDParser_FilterHIDReportItem(&NewReportItem))
- {
- if (ParserData->TotalReportItems == HID_MAX_REPORTITEMS)
- return HID_PARSE_InsufficientReportItems;
+ if (ParserData->TotalReportItems == HID_MAX_REPORTITEMS)
+ return HID_PARSE_InsufficientReportItems;
- memcpy(&ParserData->ReportItems[ParserData->TotalReportItems],
- &NewReportItem, sizeof(HID_ReportItem_t));
+ memcpy(&ParserData->ReportItems[ParserData->TotalReportItems],
+ &NewReportItem, sizeof(HID_ReportItem_t));
- ParserData->TotalReportItems++;
- }
+ if (!(ReportItemData & HID_IOF_CONSTANT) && CALLBACK_HIDParser_FilterHIDReportItem(&NewReportItem))
+ ParserData->TotalReportItems++;
}
break;
bool USB_GetHIDReportItemInfo(const uint8_t* ReportData,
HID_ReportItem_t* const ReportItem)
{
+ if (ReportItem == NULL)
+ return false;
+
uint16_t DataBitsRem = ReportItem->Attributes.BitSize;
uint16_t CurrentBit = ReportItem->BitOffset;
uint32_t BitMask = (1 << 0);
void USB_SetHIDReportItemInfo(uint8_t* ReportData,
HID_ReportItem_t* const ReportItem)
{
+ if (ReportItem == NULL)
+ return;
+
uint16_t DataBitsRem = ReportItem->Attributes.BitSize;
uint16_t CurrentBit = ReportItem->BitOffset;
uint32_t BitMask = (1 << 0);
uint16_t ReportSizeBits = ParserData->ReportIDSizes[i].ReportSizeBits[ReportType];
if (ParserData->ReportIDSizes[i].ReportID == ReportID)
- return ((ReportSizeBits >> 3) + ((ReportSizeBits & 0x07) ? 1 : 0));
+ return (ReportSizeBits / 8) + ((ReportSizeBits % 8) ? 1 : 0);
}
return 0;