34 #define __INCLUDE_FROM_USB_DRIVER
35 #define __INCLUDE_FROM_HID_DRIVER
43 HID_StateTable_t* CurrStateTable = &StateTable[0];
47 uint8_t UsageListSize = 0;
51 memset(CurrStateTable, 0x00,
sizeof(HID_StateTable_t));
58 uint8_t HIDReportItem = *ReportData;
64 switch (HIDReportItem & HID_RI_DATA_SIZE_MASK)
66 case HID_RI_DATA_BITS_32:
71 case HID_RI_DATA_BITS_16:
72 ReportItemData =
le16_to_cpu(*((uint16_t*)ReportData));
76 case HID_RI_DATA_BITS_8:
77 ReportItemData = *((uint8_t*)ReportData);
83 switch (HIDReportItem & (HID_RI_TYPE_MASK | HID_RI_TAG_MASK))
89 memcpy((CurrStateTable + 1),
96 if (CurrStateTable == &StateTable[0])
102 if ((HIDReportItem & HID_RI_DATA_SIZE_MASK) == HID_RI_DATA_BITS_32)
103 CurrStateTable->Attributes.Usage.Page = (ReportItemData >> 16);
105 CurrStateTable->Attributes.Usage.Page = ReportItemData;
108 CurrStateTable->Attributes.Logical.Minimum = ReportItemData;
111 CurrStateTable->Attributes.Logical.Maximum = ReportItemData;
114 CurrStateTable->Attributes.Physical.Minimum = ReportItemData;
117 CurrStateTable->Attributes.Physical.Maximum = ReportItemData;
120 CurrStateTable->Attributes.Unit.Exponent = ReportItemData;
123 CurrStateTable->Attributes.Unit.Type = ReportItemData;
126 CurrStateTable->Attributes.BitSize = ReportItemData;
129 CurrStateTable->ReportCount = ReportItemData;
132 CurrStateTable->ReportID = ReportItemData;
136 CurrReportIDInfo =
NULL;
147 if (CurrReportIDInfo ==
NULL)
159 CurrReportIDInfo->
ReportID = CurrStateTable->ReportID;
165 UsageList[UsageListSize++] = ReportItemData;
168 UsageMinMax.
Minimum = ReportItemData;
171 UsageMinMax.
Maximum = ReportItemData;
174 if (CurrCollectionPath ==
NULL)
189 CurrCollectionPath++;
192 CurrCollectionPath->
Parent = ParentCollectionPath;
195 CurrCollectionPath->
Type = ReportItemData;
196 CurrCollectionPath->
Usage.
Page = CurrStateTable->Attributes.Usage.Page;
200 CurrCollectionPath->
Usage.
Usage = UsageList[0];
202 for (uint8_t i = 0; i < UsageListSize; i++)
203 UsageList[i] = UsageList[i + 1];
214 if (CurrCollectionPath ==
NULL)
217 CurrCollectionPath = CurrCollectionPath->
Parent;
222 for (uint8_t ReportItemNum = 0; ReportItemNum < CurrStateTable->ReportCount; ReportItemNum++)
227 &CurrStateTable->Attributes,
230 NewReportItem.
ItemFlags = ReportItemData;
232 NewReportItem.
ReportID = CurrStateTable->ReportID;
238 for (uint8_t i = 0; i < UsageListSize; i++)
239 UsageList[i] = UsageList[i + 1];
248 uint8_t ItemTypeTag = (HIDReportItem & (HID_RI_TYPE_MASK | HID_RI_TAG_MASK));
277 if ((HIDReportItem & HID_RI_TYPE_MASK) == HID_RI_TYPE_MAIN)
294 if (ReportItem ==
NULL)
298 uint16_t CurrentBit = ReportItem->
BitOffset;
303 if (ReportItem->
ReportID != ReportData[0])
310 ReportItem->
Value = 0;
312 while (DataBitsRem--)
314 if (ReportData[CurrentBit / 8] & (1 << (CurrentBit % 8)))
315 ReportItem->
Value |= BitMask;
327 if (ReportItem ==
NULL)
331 uint16_t CurrentBit = ReportItem->
BitOffset;
336 ReportData[0] = ReportItem->
ReportID;
342 while (DataBitsRem--)
344 if (ReportItem->
Value & (1 << (CurrentBit % 8)))
345 ReportData[CurrentBit / 8] |= BitMask;
353 const uint8_t ReportID,
354 const uint8_t ReportType)
361 return (ReportSizeBits / 8) + ((ReportSizeBits % 8) ? 1 : 0);