/*
LUFA Library
- Copyright (C) Dean Camera, 2012.
+ Copyright (C) Dean Camera, 2018.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
- Copyright 2012 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
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
- The author disclaim all warranties with regard to this
+ The author disclaims all warranties with regard to this
software, including all implied warranties of merchantability
and fitness. In no event shall the author be liable for any
special, indirect or consequential damages or any damages
HID_ReportInfo_t* const ParserData)
{
HID_StateTable_t StateTable[HID_STATETABLE_STACK_DEPTH];
- HID_StateTable_t* CurrStateTable = &StateTable[0];
- HID_CollectionPath_t* CurrCollectionPath = NULL;
- HID_ReportSizeInfo_t* CurrReportIDInfo = &ParserData->ReportIDSizes[0];
+ HID_StateTable_t* CurrStateTable = &StateTable[0];
+ HID_CollectionPath_t* CurrCollectionPath = NULL;
+ HID_ReportSizeInfo_t* CurrReportIDInfo = &ParserData->ReportIDSizes[0];
uint16_t UsageList[HID_USAGE_STACK_DEPTH];
- uint8_t UsageListSize = 0;
- HID_MinMax_t UsageMinMax = {0, 0};
+ uint8_t UsageListSize = 0;
+ HID_MinMax_t UsageMinMax = {0, 0};
memset(ParserData, 0x00, sizeof(HID_ReportInfo_t));
memset(CurrStateTable, 0x00, sizeof(HID_StateTable_t));
memcpy((CurrStateTable + 1),
CurrStateTable,
- sizeof(HID_ReportItem_t));
+ sizeof(HID_StateTable_t));
CurrStateTable++;
break;
+
case HID_RI_POP(0):
if (CurrStateTable == &StateTable[0])
return HID_PARSE_HIDStackUnderflow;
CurrStateTable--;
break;
+
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):
CurrStateTable->Attributes.Logical.Minimum = ReportItemData;
break;
+
case HID_RI_LOGICAL_MAXIMUM(0):
CurrStateTable->Attributes.Logical.Maximum = ReportItemData;
break;
+
case HID_RI_PHYSICAL_MINIMUM(0):
CurrStateTable->Attributes.Physical.Minimum = ReportItemData;
break;
+
case HID_RI_PHYSICAL_MAXIMUM(0):
CurrStateTable->Attributes.Physical.Maximum = ReportItemData;
break;
+
case HID_RI_UNIT_EXPONENT(0):
CurrStateTable->Attributes.Unit.Exponent = ReportItemData;
break;
+
case HID_RI_UNIT(0):
CurrStateTable->Attributes.Unit.Type = ReportItemData;
break;
+
case HID_RI_REPORT_SIZE(0):
CurrStateTable->Attributes.BitSize = ReportItemData;
break;
+
case HID_RI_REPORT_COUNT(0):
CurrStateTable->ReportCount = ReportItemData;
break;
+
case HID_RI_REPORT_ID(0):
CurrStateTable->ReportID = ReportItemData;
CurrReportIDInfo->ReportID = CurrStateTable->ReportID;
break;
+
case HID_RI_USAGE(0):
if (UsageListSize == HID_USAGE_STACK_DEPTH)
return HID_PARSE_UsageListOverflow;
UsageList[UsageListSize++] = ReportItemData;
break;
+
case HID_RI_USAGE_MINIMUM(0):
UsageMinMax.Minimum = ReportItemData;
break;
+
case HID_RI_USAGE_MAXIMUM(0):
UsageMinMax.Maximum = ReportItemData;
break;
+
case HID_RI_COLLECTION(0):
if (CurrCollectionPath == NULL)
{
{
CurrCollectionPath->Usage.Usage = UsageList[0];
- for (uint8_t i = 0; i < UsageListSize; i++)
- UsageList[i] = UsageList[i + 1];
+ for (uint8_t i = 1; i < UsageListSize; i++)
+ UsageList[i - 1] = UsageList[i];
UsageListSize--;
}
}
break;
+
case HID_RI_END_COLLECTION(0):
if (CurrCollectionPath == NULL)
return HID_PARSE_UnexpectedEndCollection;
CurrCollectionPath = CurrCollectionPath->Parent;
break;
+
case HID_RI_INPUT(0):
case HID_RI_OUTPUT(0):
case HID_RI_FEATURE(0):
{
NewReportItem.Attributes.Usage.Usage = UsageList[0];
- for (uint8_t i = 0; i < UsageListSize; i++)
- UsageList[i] = UsageList[i + 1];
+ for (uint8_t i = 1; i < UsageListSize; i++)
+ UsageList[i - 1] = UsageList[i];
UsageListSize--;
}
}
break;
-
+
default:
break;
}
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;