Remove remaining void* descriptor casts in the projects and demos that were not remov...
[pub/USBasp.git] / Demos / Host / LowLevel / MouseHostWithParser / MouseHostWithParser.c
index efe1421..38e4b25 100644 (file)
@@ -112,7 +112,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.
  */
-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"
@@ -298,19 +299,15 @@ void ProcessMouseReport(uint8_t* MouseReport)
                        if (!(FoundData))
                          continue;
                          
-                       int16_t DeltaMovement = (int16_t)(ReportItem->Value << (16 - ReportItem->Attributes.BitSize));
+                       int16_t DeltaMovement = HID_ALIGN_DATA(ReportItem, int16_t);
                        
-                       /* Determine if the report is for the X or Y delta movement */
-                       if (ReportItem->Attributes.Usage.Usage == USAGE_X)
+                       /* Check to see if a (non-zero) delta movement has been indicated */
+                       if (DeltaMovement)
                        {
-                               /* Turn on the appropriate LED according to direction if the delta is non-zero */
-                               if (DeltaMovement)
+                               /* Determine if the report is for the X or Y delta movement, light LEDs as appropriate */
+                               if (ReportItem->Attributes.Usage.Usage == USAGE_X)
                                  LEDMask |= ((DeltaMovement > 0) ? LEDS_LED1 : LEDS_LED2);
-                       }
-                       else
-                       {
-                               /* Turn on the appropriate LED according to direction if the delta is non-zero */
-                               if (DeltaMovement)
+                               else
                                  LEDMask |= ((DeltaMovement > 0) ? LEDS_LED3 : LEDS_LED4);
                        }
                }