Add tag for the 120219 release.
[pub/USBasp.git] / Demos / Device / LowLevel / Mouse / Mouse.c
index 40ec25a..98da9be 100644 (file)
@@ -1,13 +1,13 @@
 /*
              LUFA Library
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2011.
+     Copyright (C) Dean Camera, 2012.
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
-  Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+  Copyright 2012  Dean Camera (dean [at] fourwalledcubicle [dot] com)
 
   Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
 
   Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
 /** Indicates what report mode the host has requested, true for normal HID reporting mode, false for special boot
  *  protocol reporting mode.
  */
 /** Indicates what report mode the host has requested, true for normal HID reporting mode, false for special boot
  *  protocol reporting mode.
  */
-bool UsingReportProtocol = true;
+static bool UsingReportProtocol = true;
 
 /** Current Idle period. This is set by the host via a Set Idle HID class request to silence the device's reports
  *  for either the entire idle duration, or until the report status changes (e.g. the user moves the mouse).
  */
 
 /** Current Idle period. This is set by the host via a Set Idle HID class request to silence the device's reports
  *  for either the entire idle duration, or until the report status changes (e.g. the user moves the mouse).
  */
-uint16_t IdleCount = 0;
+static uint16_t IdleCount = 0;
 
 /** Current Idle period remaining. When the IdleCount value is set, this tracks the remaining number of idle
  *  milliseconds. This is separate to the IdleCount timer and is incremented and compared as the host may request
  *  the current idle period via a Get Idle HID class request, thus its value must be preserved.
  */
 
 /** Current Idle period remaining. When the IdleCount value is set, this tracks the remaining number of idle
  *  milliseconds. This is separate to the IdleCount timer and is incremented and compared as the host may request
  *  the current idle period via a Get Idle HID class request, thus its value must be preserved.
  */
-uint16_t IdleMSRemaining = 0;
+static uint16_t IdleMSRemaining = 0;
 
 
 /** Main program entry point. This routine configures the hardware required by the application, then
 
 
 /** Main program entry point. This routine configures the hardware required by the application, then
@@ -160,7 +160,7 @@ void EVENT_USB_Device_ControlRequest(void)
                                Endpoint_ClearSETUP();
 
                                /* Write the current protocol flag to the host */
                                Endpoint_ClearSETUP();
 
                                /* Write the current protocol flag to the host */
-                               Endpoint_Write_Byte(UsingReportProtocol);
+                               Endpoint_Write_8(UsingReportProtocol);
 
                                Endpoint_ClearIN();
                                Endpoint_ClearStatusStage();
 
                                Endpoint_ClearIN();
                                Endpoint_ClearStatusStage();
@@ -195,7 +195,7 @@ void EVENT_USB_Device_ControlRequest(void)
                                Endpoint_ClearSETUP();
 
                                /* Write the current idle duration to the host, must be divided by 4 before sent to host */
                                Endpoint_ClearSETUP();
 
                                /* Write the current idle duration to the host, must be divided by 4 before sent to host */
-                               Endpoint_Write_Byte(IdleCount >> 2);
+                               Endpoint_Write_8(IdleCount >> 2);
 
                                Endpoint_ClearIN();
                                Endpoint_ClearStatusStage();
 
                                Endpoint_ClearIN();
                                Endpoint_ClearStatusStage();
@@ -233,10 +233,10 @@ void CreateMouseReport(USB_MouseReport_Data_t* const ReportData)
        if (JoyStatus_LCL & JOY_LEFT)
          ReportData->X = -1;
        else if (JoyStatus_LCL & JOY_RIGHT)
        if (JoyStatus_LCL & JOY_LEFT)
          ReportData->X = -1;
        else if (JoyStatus_LCL & JOY_RIGHT)
-         ReportData->X = 1;
+         ReportData->X =  1;
 
        if (JoyStatus_LCL & JOY_PRESS)
 
        if (JoyStatus_LCL & JOY_PRESS)
-         ReportData->Button  = (1 << 0);
+         ReportData->Button |= (1 << 0);
 
        if (ButtonStatus_LCL & BUTTONS_BUTTON1)
          ReportData->Button |= (1 << 1);
 
        if (ButtonStatus_LCL & BUTTONS_BUTTON1)
          ReportData->Button |= (1 << 1);