aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/USB/Class/Host/HIDParser.c
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-09-21 12:23:09 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-09-21 12:23:09 +0000
commit242303c1607fca405d9407b9fab6fb78cae676e2 (patch)
tree1163c20f5035ee4df711d1c718ef310ba89d2b53 /LUFA/Drivers/USB/Class/Host/HIDParser.c
parent3ffa7543a05761a0c69144c9b66196b08d8f1249 (diff)
downloadlufa-242303c1607fca405d9407b9fab6fb78cae676e2.tar.gz
lufa-242303c1607fca405d9407b9fab6fb78cae676e2.tar.bz2
lufa-242303c1607fca405d9407b9fab6fb78cae676e2.zip
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.
Diffstat (limited to 'LUFA/Drivers/USB/Class/Host/HIDParser.c')
-rw-r--r--LUFA/Drivers/USB/Class/Host/HIDParser.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/LUFA/Drivers/USB/Class/Host/HIDParser.c b/LUFA/Drivers/USB/Class/Host/HIDParser.c
index b302a94b4..450f6afb0 100644
--- a/LUFA/Drivers/USB/Class/Host/HIDParser.c
+++ b/LUFA/Drivers/USB/Class/Host/HIDParser.c
@@ -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)