/* According to USB HID Specification, report descriptors are composed of pieces of information. Each piece of information is called an Item. This function retrieves each item from the report descriptor and updates USB_MOUSE_DEV. */
EFI_STATUS ParseMouseReportDescriptor(OUT USB_MOUSE_DEV *UsbMouse, IN UINT8 *ReportDescriptor, IN UINTN ReportSize)
/* According to USB HID Specification, report descriptors are composed of pieces of information. Each piece of information is called an Item. This function retrieves each item from the report descriptor and updates USB_MOUSE_DEV. */
EFI_STATUS ParseMouseReportDescriptor(OUT USB_MOUSE_DEV *UsbMouse, IN UINT8 *ReportDescriptor, IN UINTN ReportSize)
{
  UINT8     *DescriptorEnd;
  UINT8     *Ptr;
  HID_ITEM  HidItem;
  DescriptorEnd = ReportDescriptor + ReportSize;
  Ptr = GetNextHidItem (ReportDescriptor, DescriptorEnd, &HidItem);
  while (Ptr != NULL) {
    if (HidItem.Format != HID_ITEM_FORMAT_SHORT) {
      return EFI_UNSUPPORTED;
    }
    ParseHidItem (UsbMouse, &HidItem);
    Ptr = GetNextHidItem (Ptr, DescriptorEnd, &HidItem);
  }
  UsbMouse->NumberOfButtons = (UINT8)(UsbMouse->PrivateData.ButtonMaxIndex - UsbMouse->PrivateData.ButtonMinIndex + 1);
  UsbMouse->XLogicMax       = 127;
  UsbMouse->YLogicMax       = 127;
  UsbMouse->XLogicMin       = -127;
  UsbMouse->YLogicMin       = -127;
  return EFI_SUCCESS;
}