- if (!(HIDReportInfo.TotalReportItems))
- puts_P(PSTR("Not a valid Joystick." ESC_FG_WHITE));
- else
- printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode);
-
- /* Indicate error via status LEDs */
- LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
-
- /* Wait until USB device disconnected */
- USB_HostState = HOST_STATE_WaitForDeviceRemoval;
- break;
- }
-
- printf("Total Reports: %d\r\n", HIDReportInfo.TotalDeviceReports);
-
- for (uint8_t i = 0; i < HIDReportInfo.TotalDeviceReports; i++)
- {
- HID_ReportSizeInfo_t* CurrReportIDInfo = &HIDReportInfo.ReportIDSizes[i];
-
- uint8_t ReportSizeInBits = CurrReportIDInfo->ReportSizeBits[HID_REPORT_ITEM_In];
- uint8_t ReportSizeOutBits = CurrReportIDInfo->ReportSizeBits[HID_REPORT_ITEM_Out];
- uint8_t ReportSizeFeatureBits = CurrReportIDInfo->ReportSizeBits[HID_REPORT_ITEM_Feature];
-
- /* Print out the byte sizes of each report within the device */
- printf_P(PSTR(" + Report ID %d - In: %d bytes, Out: %d bytes, Feature: %d bytes\r\n"),
- CurrReportIDInfo->ReportID,
- ((ReportSizeInBits >> 3) + ((ReportSizeInBits & 0x07) != 0)),
- ((ReportSizeOutBits >> 3) + ((ReportSizeOutBits & 0x07) != 0)),
- ((ReportSizeFeatureBits >> 3) + ((ReportSizeFeatureBits & 0x07) != 0)));
- }
-
- puts_P(PSTR("Joystick Enumerated.\r\n"));
-
- USB_HostState = HOST_STATE_Configured;
- break;
- case HOST_STATE_Configured:
- /* Select and unfreeze joystick data pipe */
- Pipe_SelectPipe(JOYSTICK_DATAPIPE);
- Pipe_Unfreeze();
-
- /* Check to see if a packet has been received */
- if (Pipe_IsINReceived())
- {
- /* Check if data has been received from the attached joystick */
- if (Pipe_IsReadWriteAllowed())
- {
- /* Create buffer big enough for the report */
- uint8_t JoystickReport[Pipe_BytesInPipe()];
-
- /* Load in the joystick report */
- Pipe_Read_Stream_LE(JoystickReport, Pipe_BytesInPipe());
-
- /* Process the read in joystick report from the device */
- ProcessJoystickReport(JoystickReport);
- }
-
- /* Clear the IN endpoint, ready for next data packet */
- Pipe_ClearIN();
- }