Fixed MIDI_Host_Flush() not aborting early when the specified MIDI host interface...
[pub/USBasp.git] / Demos / Host / ClassDriver / MouseHostWithParser / MouseHostWithParser.c
index ef7835e..d02424c 100644 (file)
@@ -53,7 +53,7 @@ USB_ClassInfo_HID_Host_t Mouse_HID_Interface =
                                .DataOUTPipeNumber      = 2,
                                .DataOUTPipeDoubleBank  = false,
                                
                                .DataOUTPipeNumber      = 2,
                                .DataOUTPipeDoubleBank  = false,
                                
-                               .HIDInterfaceProtocol   = HID_NON_BOOT_PROTOCOL,
+                               .HIDInterfaceProtocol   = HID_BOOTP_NonBootProtocol,
                                
                                .HIDParserData          = &HIDReportInfo
                        },
                                
                                .HIDParserData          = &HIDReportInfo
                        },
@@ -138,14 +138,14 @@ int main(void)
                                                
                                                /* Determine what report item is being tested, process updated value as needed */
                                                if ((ReportItem->Attributes.Usage.Page        == USAGE_PAGE_BUTTON) &&
                                                
                                                /* Determine what report item is being tested, process updated value as needed */
                                                if ((ReportItem->Attributes.Usage.Page        == USAGE_PAGE_BUTTON) &&
-                                                       (ReportItem->ItemType                     == REPORT_ITEM_TYPE_In))
+                                                       (ReportItem->ItemType                     == HID_REPORT_ITEM_In))
                                                {
                                                        if (ReportItem->Value)
                                                          LEDMask = LEDS_ALL_LEDS;
                                                }
                                                else if ((ReportItem->Attributes.Usage.Page   == USAGE_PAGE_GENERIC_DCTRL) &&
                                                                 (ReportItem->Attributes.Usage.Usage  == USAGE_SCROLL_WHEEL)       &&
                                                {
                                                        if (ReportItem->Value)
                                                          LEDMask = LEDS_ALL_LEDS;
                                                }
                                                else if ((ReportItem->Attributes.Usage.Page   == USAGE_PAGE_GENERIC_DCTRL) &&
                                                                 (ReportItem->Attributes.Usage.Usage  == USAGE_SCROLL_WHEEL)       &&
-                                                                (ReportItem->ItemType                == REPORT_ITEM_TYPE_In))
+                                                                (ReportItem->ItemType                == HID_REPORT_ITEM_In))
                                                {
                                                        int16_t WheelDelta = HID_ALIGN_DATA(ReportItem, int16_t);
                                                        
                                                {
                                                        int16_t WheelDelta = HID_ALIGN_DATA(ReportItem, int16_t);
                                                        
@@ -155,18 +155,15 @@ int main(void)
                                                else if ((ReportItem->Attributes.Usage.Page   == USAGE_PAGE_GENERIC_DCTRL) &&
                                                                 ((ReportItem->Attributes.Usage.Usage == USAGE_X)                  ||
                                                                  (ReportItem->Attributes.Usage.Usage == USAGE_Y))                 &&
                                                else if ((ReportItem->Attributes.Usage.Page   == USAGE_PAGE_GENERIC_DCTRL) &&
                                                                 ((ReportItem->Attributes.Usage.Usage == USAGE_X)                  ||
                                                                  (ReportItem->Attributes.Usage.Usage == USAGE_Y))                 &&
-                                                                (ReportItem->ItemType                == REPORT_ITEM_TYPE_In))
+                                                                (ReportItem->ItemType                == HID_REPORT_ITEM_In))
                                                {
                                                        int16_t DeltaMovement = HID_ALIGN_DATA(ReportItem, int16_t);
                                                        
                                                {
                                                        int16_t DeltaMovement = HID_ALIGN_DATA(ReportItem, int16_t);
                                                        
-                                                       if (ReportItem->Attributes.Usage.Usage == USAGE_X)
+                                                       if (DeltaMovement)
                                                        {
                                                        {
-                                                               if (DeltaMovement)
+                                                               if (ReportItem->Attributes.Usage.Usage == USAGE_X)
                                                                  LEDMask |= ((DeltaMovement > 0) ? LEDS_LED1 : LEDS_LED2);
                                                                  LEDMask |= ((DeltaMovement > 0) ? LEDS_LED1 : LEDS_LED2);
-                                                       }
-                                                       else
-                                                       {
-                                                               if (DeltaMovement)
+                                                               else
                                                                  LEDMask |= ((DeltaMovement > 0) ? LEDS_LED3 : LEDS_LED4);
                                                        }
                                                }
                                                                  LEDMask |= ((DeltaMovement > 0) ? LEDS_LED3 : LEDS_LED4);
                                                        }
                                                }
@@ -240,7 +237,8 @@ void EVENT_USB_Host_HostError(const uint8_t ErrorCode)
 /** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while
  *  enumerating an attached USB device.
  */
 /** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while
  *  enumerating an attached USB device.
  */
-void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode)
+void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
+                                            const uint8_t SubErrorCode)
 {
        printf_P(PSTR(ESC_FG_RED "Dev Enum Error\r\n"
                                 " -- Error Code %d\r\n"
 {
        printf_P(PSTR(ESC_FG_RED "Dev Enum Error\r\n"
                                 " -- Error Code %d\r\n"
@@ -259,7 +257,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8
  *
  *  \return Boolean true if the item should be stored into the HID report structure, false if it should be discarded
  */
  *
  *  \return Boolean true if the item should be stored into the HID report structure, false if it should be discarded
  */
-bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* CurrentItem)
+bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem)
 {
        bool IsMouse = false;
 
 {
        bool IsMouse = false;