MCPcopy Create free account
hub / github.com/Santroller/Santroller / USB_ProcessHIDReport

Function USB_ProcessHIDReport

lib/hidparser/hidparser.c:205–550  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203}
204
205uint8_t USB_ProcessHIDReport(const uint8_t *ReportData,
206 uint16_t ReportSize,
207 HID_ReportInfo_t **ParserDataOut)
208{
209 HID_ReportSizeInfo_t *FirstReportIDSize = acquire_HID_ReportSizeInfo();
210 HID_CollectionPath_t *FirstCollectionPath = acquire_HID_CollectionPath();
211 memset(FirstCollectionPath, 0, sizeof(HID_CollectionPath_t));
212 HID_ReportInfo_t *ParserData = acquire_HID_ReportInfo();
213 HID_StateTable_t StateTable[HID_STATETABLE_STACK_DEPTH];
214 HID_StateTable_t *CurrStateTable = &StateTable[0];
215 HID_CollectionPath_t *CurrCollectionPath = NULL;
216 HID_ReportSizeInfo_t *CurrReportIDInfo = FirstReportIDSize;
217 uint16_t UsageList[HID_USAGE_STACK_DEPTH];
218 uint8_t UsageListSize = 0;
219 HID_MinMax_t UsageMinMax = {0, 0};
220
221 memset(ParserData, 0x00, sizeof(HID_ReportInfo_t));
222 memset(CurrStateTable, 0x00, sizeof(HID_StateTable_t));
223 memset(CurrReportIDInfo, 0x00, sizeof(HID_ReportSizeInfo_t));
224
225 ParserData->TotalDeviceReports = 1;
226 uint8_t Result = HID_PARSE_Successful;
227
228 while (ReportSize)
229 {
230 uint8_t HIDReportItem = *ReportData;
231 uint32_t ReportItemData;
232
233 ReportData++;
234 ReportSize--;
235
236 switch (HIDReportItem & HID_RI_DATA_SIZE_MASK)
237 {
238 case HID_RI_DATA_BITS_32:
239 ReportItemData = (((uint32_t)ReportData[3] << 24) | ((uint32_t)ReportData[2] << 16) |
240 ((uint16_t)ReportData[1] << 8) | ReportData[0]);
241 ReportSize -= 4;
242 ReportData += 4;
243 break;
244
245 case HID_RI_DATA_BITS_16:
246 ReportItemData = (((uint16_t)ReportData[1] << 8) | (ReportData[0]));
247 ReportSize -= 2;
248 ReportData += 2;
249 break;
250
251 case HID_RI_DATA_BITS_8:
252 ReportItemData = ReportData[0];
253 ReportSize -= 1;
254 ReportData += 1;
255 break;
256
257 default:
258 ReportItemData = 0;
259 break;
260 }
261
262 switch (HIDReportItem & (HID_RI_TYPE_MASK | HID_RI_TAG_MASK))

Callers 2

xinputh_openFunction · 0.85
openMethod · 0.85

Calls 4

memsetFunction · 0.85
memcpyFunction · 0.85
USB_FreeReportInfoFunction · 0.85

Tested by

no test coverage detected