Add support for the Micropendous (Arduino-like) series of boards (revisions 1 and 2).
[pub/USBasp.git] / LUFA / Drivers / USB / Class / Common / HIDParser.c
index eb2f14c..d3e7d02 100644 (file)
@@ -1,13 +1,13 @@
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2011.
+     Copyright (C) Dean Camera, 2012.
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
-  Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+  Copyright 2012  Dean Camera (dean [at] fourwalledcubicle [dot] com)
 
   Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
@@ -98,7 +98,7 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,
                        case HID_RI_USAGE_PAGE(0):
                                if ((HIDReportItem & HID_RI_DATA_SIZE_MASK) == HID_RI_DATA_BITS_32)
                                  CurrStateTable->Attributes.Usage.Page = (ReportItemData >> 16);
-                               
+
                                CurrStateTable->Attributes.Usage.Page       = ReportItemData;
                                break;
                        case HID_RI_LOGICAL_MINIMUM(0):
@@ -189,7 +189,7 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,
                                        CurrCollectionPath->Parent = ParentCollectionPath;
                                }
 
-                               CurrCollectionPath->Type = ReportItemData;
+                               CurrCollectionPath->Type       = ReportItemData;
                                CurrCollectionPath->Usage.Page = CurrStateTable->Attributes.Usage.Page;
 
                                if (UsageListSize)
@@ -255,19 +255,16 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,
 
                                        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;
@@ -291,7 +288,7 @@ bool USB_GetHIDReportItemInfo(const uint8_t* ReportData,
                               HID_ReportItem_t* const ReportItem)
 {
        if (ReportItem == NULL)
-               return false;
+         return false;
 
        uint16_t DataBitsRem  = ReportItem->Attributes.BitSize;
        uint16_t CurrentBit   = ReportItem->BitOffset;
@@ -324,7 +321,7 @@ void USB_SetHIDReportItemInfo(uint8_t* ReportData,
                               HID_ReportItem_t* const ReportItem)
 {
        if (ReportItem == NULL)
-               return;
+         return;
 
        uint16_t DataBitsRem  = ReportItem->Attributes.BitSize;
        uint16_t CurrentBit   = ReportItem->BitOffset;
@@ -362,3 +359,4 @@ uint16_t USB_GetHIDReportSize(HID_ReportInfo_t* const ParserData,
 
        return 0;
 }
+