Fixed HID report parser corruption when parsing PUSH and POP report item elements.
[pub/lufa.git] / LUFA / Drivers / USB / Class / Common / HIDParser.c
index c01ceaf..87eaf7c 100644 (file)
@@ -1,13 +1,13 @@
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2016.
+     Copyright (C) Dean Camera, 2018.
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
-  Copyright 2016  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+  Copyright 2018  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
@@ -92,7 +92,7 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,
 
                                memcpy((CurrStateTable + 1),
                                       CurrStateTable,
-                                      sizeof(HID_ReportItem_t));
+                                      sizeof(HID_StateTable_t));
 
                                CurrStateTable++;
                                break;
@@ -364,8 +364,8 @@ void USB_SetHIDReportItemInfo(uint8_t* ReportData,
 
        while (DataBitsRem--)
        {
-               if (ReportItem->Value & (1 << (CurrentBit % 8)))
-                 ReportData[CurrentBit / 8] |= BitMask;
+               if (ReportItem->Value & BitMask)
+                 ReportData[CurrentBit / 8] |= (1 << (CurrentBit % 8));
 
                CurrentBit++;
                BitMask <<= 1;