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.

pull/1469/head
Dean Camera 15 years ago
parent ba8ffa4cb7
commit 4670b39070

@ -42,16 +42,12 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID
uint16_t UsageStack[HID_USAGE_STACK_DEPTH]; uint16_t UsageStack[HID_USAGE_STACK_DEPTH];
uint8_t UsageStackSize = 0; uint8_t UsageStackSize = 0;
ParserData->TotalReportItems = 0; memset(ParserData, 0x00, sizeof(HID_ReportInfo_t));
ParserData->TotalDeviceReports = 1;
ParserData->UsingReportIDs = false;
for (uint8_t CurrCollection = 0; CurrCollection < HID_MAX_COLLECTIONS; CurrCollection++)
ParserData->CollectionPaths[CurrCollection].Parent = NULL;
memset(CurrStateTable, 0x00, sizeof(HID_StateTable_t)); memset(CurrStateTable, 0x00, sizeof(HID_StateTable_t));
memset(CurrReportIDInfo, 0x00, sizeof(HID_ReportSizeInfo_t)); memset(CurrReportIDInfo, 0x00, sizeof(HID_ReportSizeInfo_t));
ParserData->TotalDeviceReports = 1;
while (ReportSize) while (ReportSize)
{ {
uint8_t HIDReportItem = *ReportData; uint8_t HIDReportItem = *ReportData;
@ -177,7 +173,7 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID
CurrCollectionPath = &ParserData->CollectionPaths[1]; CurrCollectionPath = &ParserData->CollectionPaths[1];
while (CurrCollectionPath->Parent != NULL); while (CurrCollectionPath->Parent != NULL)
{ {
if (CurrCollectionPath == &ParserData->CollectionPaths[HID_MAX_COLLECTIONS - 1]) if (CurrCollectionPath == &ParserData->CollectionPaths[HID_MAX_COLLECTIONS - 1])
return HID_PARSE_InsufficientCollectionPaths; return HID_PARSE_InsufficientCollectionPaths;
@ -200,10 +196,6 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID
UsageStackSize--; UsageStackSize--;
} }
else
{
CurrCollectionPath->Usage.Usage = 0;
}
break; break;
case (TYPE_MAIN | TAG_MAIN_ENDCOLLECTION): 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; return HID_PARSE_UnexpectedEndCollection;
CurrCollectionPath = CurrCollectionPath->Parent; CurrCollectionPath = CurrCollectionPath->Parent;
break; break;
case (TYPE_MAIN | TAG_MAIN_INPUT): case (TYPE_MAIN | TAG_MAIN_INPUT):
case (TYPE_MAIN | TAG_MAIN_OUTPUT): case (TYPE_MAIN | TAG_MAIN_OUTPUT):
@ -237,39 +228,26 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID
UsageStackSize--; UsageStackSize--;
} }
else
{
NewReportItem.Attributes.Usage.Usage = 0;
}
uint8_t ReportSizeIndex = 0;
switch (HIDReportItem & TAG_MASK) switch (HIDReportItem & TAG_MASK)
{ {
case TAG_MAIN_INPUT: case TAG_MAIN_INPUT:
NewReportItem.ItemType = REPORT_ITEM_TYPE_In; NewReportItem.ItemType = REPORT_ITEM_TYPE_In;
NewReportItem.BitOffset = CurrReportIDInfo->ReportSizeBits[REPORT_ITEM_TYPE_In];
ReportSizeIndex = REPORT_ITEM_TYPE_In;
break; break;
case TAG_MAIN_OUTPUT: case TAG_MAIN_OUTPUT:
NewReportItem.ItemType = REPORT_ITEM_TYPE_Out; NewReportItem.ItemType = REPORT_ITEM_TYPE_Out;
NewReportItem.BitOffset = CurrReportIDInfo->ReportSizeBits[REPORT_ITEM_TYPE_Out];
ReportSizeIndex = REPORT_ITEM_TYPE_Out;
break; break;
case TAG_MAIN_FEATURE: case TAG_MAIN_FEATURE:
NewReportItem.ItemType = REPORT_ITEM_TYPE_Feature; NewReportItem.ItemType = REPORT_ITEM_TYPE_Feature;
NewReportItem.BitOffset = CurrReportIDInfo->ReportSizeBits[REPORT_ITEM_TYPE_Feature];
ReportSizeIndex = REPORT_ITEM_TYPE_Feature;
break; break;
} }
CurrReportIDInfo->ReportSizeBits[ReportSizeIndex] += CurrStateTable->Attributes.BitSize; NewReportItem.BitOffset = CurrReportIDInfo->ReportSizeBits[NewReportItem.ItemType];
if (ParserData->LargestReportSizeBits < CurrReportIDInfo->ReportSizeBits[ReportSizeIndex]) CurrReportIDInfo->ReportSizeBits[NewReportItem.ItemType] += CurrStateTable->Attributes.BitSize;
ParserData->LargestReportSizeBits = CurrReportIDInfo->ReportSizeBits[ReportSizeIndex];
if (ParserData->LargestReportSizeBits < NewReportItem.BitOffset)
ParserData->LargestReportSizeBits = NewReportItem.BitOffset;
if (!(ReportItemData & IOF_CONSTANT) && CALLBACK_HIDParser_FilterHIDReportItem(&NewReportItem)) 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; break;
} }

@ -99,7 +99,7 @@
* overridden by defining HID_MAX_COLLECTIONS to another value in the user project makefile, passing * overridden by defining HID_MAX_COLLECTIONS to another value in the user project makefile, passing
* the define to the compiler using the -D compiler switch. * the define to the compiler using the -D compiler switch.
*/ */
#define HID_MAX_COLLECTIONS 5 #define HID_MAX_COLLECTIONS 10
#endif #endif
#if !defined(HID_MAX_REPORTITEMS) || defined(__DOXYGEN__) #if !defined(HID_MAX_REPORTITEMS) || defined(__DOXYGEN__)

@ -42,6 +42,7 @@
* - Fixed incorrect event name rule in demo/project/bootloader makefiles * - Fixed incorrect event name rule in demo/project/bootloader makefiles
* - Fixed HID device class driver not reselecting the correct endpoint once the user callback routines have been called * - Fixed HID device class driver not reselecting the correct endpoint once the user callback routines have been called
* - Corrected HID descriptor in the Joystick Device demos - buttons should be placed outside the pointer collection * - Corrected HID descriptor in the Joystick Device demos - buttons should be placed outside the pointer collection
* - Fixed HID report parser collection paths invalid due to misplaced semicolon in the free path item search loop
* *
* \section Sec_ChangeLog090924 Version 090924 * \section Sec_ChangeLog090924 Version 090924
* *

@ -27,7 +27,6 @@
* - Make new demos * - Make new demos
* -# Keyboard/Mouse Dual Class Host * -# Keyboard/Mouse Dual Class Host
* -# Multiple-Report HID device * -# Multiple-Report HID device
* -# Joystick Host
* - Port LUFA to other architectures * - Port LUFA to other architectures
* -# AVR32 UC3B series microcontrollers * -# AVR32 UC3B series microcontrollers
* -# Atmel ARM7 series microcontrollers * -# Atmel ARM7 series microcontrollers

Loading…
Cancel
Save