@ -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 ] ;
CurrReportIDInfo - > ReportSizeBits [ NewReportItem . ItemType ] + = CurrStateTable - > Attributes . BitSize ;
if ( ParserData - > LargestReportSizeBits < CurrReportIDInfo - > ReportSizeBits [ ReportSizeIndex ] )
if ( ParserData - > LargestReportSizeBits < NewReportItem. BitOffset )
ParserData - > LargestReportSizeBits = CurrReportIDInfo- > ReportSizeBits [ ReportSizeIndex ] ;
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 ;
}
}