+/** Processes a read HID report from an attached mouse, extracting out elements via the HID parser results\r
+ * as required and displays movement and button presses on the board LEDs.\r
+ *\r
+ * \param MouseReport Pointer to a HID report from an attached mouse device\r
+ */\r
+void ProcessMouseReport(uint8_t* MouseReport)\r
+{\r
+ uint8_t LEDMask = LEDS_NO_LEDS;\r
+\r
+ /* Check each HID report item in turn, looking for mouse X/Y/button reports */\r
+ for (uint8_t ReportNumber = 0; ReportNumber < HIDReportInfo.TotalReportItems; ReportNumber++)\r
+ {\r
+ /* Create a temporary item pointer to the next report item */\r
+ HID_ReportItem_t* ReportItem = &HIDReportInfo.ReportItems[ReportNumber];\r
+ \r
+ bool FoundData;\r
+\r
+ if ((ReportItem->Attributes.Usage.Page == USAGE_PAGE_BUTTON) &&\r
+ (ReportItem->ItemType == REPORT_ITEM_TYPE_In))\r
+ {\r
+ /* Get the mouse button value */\r
+ FoundData = GetReportItemInfo(MouseReport, ReportItem);\r
+ \r
+ /* For multi-report devices - if the requested data was not in the issued report, continue */\r
+ if (!(FoundData))\r
+ continue;\r
+\r
+ /* If button is pressed, all LEDs are turned on */\r
+ if (ReportItem->Value)\r
+ LEDMask = LEDS_ALL_LEDS;\r
+ }\r
+ else if ((ReportItem->Attributes.Usage.Page == USAGE_PAGE_GENERIC_DCTRL) &&\r
+ ((ReportItem->Attributes.Usage.Usage == USAGE_X) ||\r
+ (ReportItem->Attributes.Usage.Usage == USAGE_Y)) &&\r
+ (ReportItem->ItemType == REPORT_ITEM_TYPE_In))\r
+ {\r
+ /* Get the mouse relative position value */\r
+ FoundData = GetReportItemInfo(MouseReport, ReportItem);\r
+ \r
+ /* For multi-report devices - if the requested data was not in the issued report, continue */\r
+ if (!(FoundData))\r
+ continue;\r
+ \r
+ int16_t DeltaMovement;\r
+ \r
+ if (ReportItem->Attributes.BitSize > 8)\r
+ DeltaMovement = (int16_t)ReportItem->Value;\r
+ else\r
+ DeltaMovement = (int8_t)ReportItem->Value;\r
+ \r
+ /* Determine if the report is for the X or Y delta movement */\r
+ if (ReportItem->Attributes.Usage.Usage == USAGE_X)\r
+ {\r
+ /* Turn on the appropriate LED according to direction if the delta is non-zero */\r
+ if (DeltaMovement)\r
+ LEDMask |= ((DeltaMovement > 0) ? LEDS_LED1 : LEDS_LED2);\r
+ }\r
+ else\r
+ {\r
+ /* Turn on the appropriate LED according to direction if the delta is non-zero */\r
+ if (DeltaMovement)\r
+ LEDMask |= ((DeltaMovement > 0) ? LEDS_LED3 : LEDS_LED4);\r
+ }\r
+ }\r
+ }\r
+ \r
+ /* Display the button information on the board LEDs */\r
+ LEDs_SetAllLEDs(LEDMask);\r
+}
\ No newline at end of file