Add new attributes to the HID Report Parser and HID Host Mode Class driver to keep track of the largest report the device can send for buffer allocation purposes. Change MouseHostWithParser and KeyboardHostWithParser demos to only allocate the needed number of bytes.
This commit is contained in:
parent
3ffa7543a0
commit
242303c160
9 changed files with 41 additions and 25 deletions
|
@ -241,29 +241,36 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID
|
|||
{
|
||||
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];
|
||||
|
||||
CurrReportIDInfo->ReportSizeBits[REPORT_ITEM_TYPE_In] += CurrStateTable->Attributes.BitSize;
|
||||
ReportSizeIndex = REPORT_ITEM_TYPE_In;
|
||||
break;
|
||||
case TAG_MAIN_OUTPUT:
|
||||
NewReportItem.ItemType = REPORT_ITEM_TYPE_Out;
|
||||
NewReportItem.BitOffset = CurrReportIDInfo->ReportSizeBits[REPORT_ITEM_TYPE_Out];
|
||||
|
||||
CurrReportIDInfo->ReportSizeBits[REPORT_ITEM_TYPE_Out] += CurrStateTable->Attributes.BitSize;
|
||||
ReportSizeIndex = REPORT_ITEM_TYPE_Out;
|
||||
break;
|
||||
case TAG_MAIN_FEATURE:
|
||||
NewReportItem.ItemType = REPORT_ITEM_TYPE_Feature;
|
||||
NewReportItem.BitOffset = CurrReportIDInfo->ReportSizeBits[REPORT_ITEM_TYPE_Feature];
|
||||
|
||||
CurrReportIDInfo->ReportSizeBits[REPORT_ITEM_TYPE_Feature] += CurrStateTable->Attributes.BitSize;
|
||||
ReportSizeIndex = REPORT_ITEM_TYPE_Feature;
|
||||
break;
|
||||
}
|
||||
|
||||
CurrReportIDInfo->ReportSizeBits[ReportSizeIndex] += CurrStateTable->Attributes.BitSize;
|
||||
|
||||
if (ParserData->LargestReportSizeBits < CurrReportIDInfo->ReportSizeBits[ReportSizeIndex])
|
||||
ParserData->LargestReportSizeBits = CurrReportIDInfo->ReportSizeBits[ReportSizeIndex];
|
||||
|
||||
if (!(ReportItemData & IOF_CONSTANT) && CALLBACK_HIDParser_FilterHIDReportItem(&CurrStateTable->Attributes))
|
||||
{
|
||||
if (ParserData->TotalReportItems == HID_MAX_REPORTITEMS)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue