Clean up CORE build system mode makefile.
[pub/USBasp.git] / Demos / Device / LowLevel / Joystick / Joystick.c
index 24f744f..cfdfaae 100644 (file)
@@ -1,13 +1,13 @@
 /*
              LUFA Library
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2010.
+     Copyright (C) Dean Camera, 2012.
 
   dean [at] fourwalledcubicle [dot] com
 
   dean [at] fourwalledcubicle [dot] com
-      www.fourwalledcubicle.com
+           www.lufa-lib.org
 */
 
 /*
 */
 
 /*
-  Copyright 2010  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
@@ -96,23 +96,22 @@ void EVENT_USB_Device_ConfigurationChanged(void)
        bool ConfigSuccess = true;
 
        /* Setup HID Report Endpoint */
        bool ConfigSuccess = true;
 
        /* Setup HID Report Endpoint */
-       ConfigSuccess &= Endpoint_ConfigureEndpoint(JOYSTICK_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN,
-                                                   JOYSTICK_EPSIZE, ENDPOINT_BANK_SINGLE);
+       ConfigSuccess &= Endpoint_ConfigureEndpoint(JOYSTICK_EPADDR, EP_TYPE_INTERRUPT, JOYSTICK_EPSIZE, 1);
 
        /* Indicate endpoint configuration success or failure */
        LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR);
 }
 
 
        /* Indicate endpoint configuration success or failure */
        LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR);
 }
 
-/** Event handler for the USB_UnhandledControlRequest event. This is used to catch standard and class specific
- *  control requests that are not handled internally by the USB library (including the HID commands, which are
- *  all issued via the control endpoint), so that they can be handled appropriately for the application.
+/** Event handler for the USB_ControlRequest event. This is used to catch and process control requests sent to
+ *  the device from the USB host before passing along unhandled control requests to the library for processing
+ *  internally.
  */
  */
-void EVENT_USB_Device_UnhandledControlRequest(void)
+void EVENT_USB_Device_ControlRequest(void)
 {
        /* Handle HID Class specific requests */
        switch (USB_ControlRequest.bRequest)
        {
 {
        /* Handle HID Class specific requests */
        switch (USB_ControlRequest.bRequest)
        {
-               case REQ_GetReport:
+               case HID_REQ_GetReport:
                        if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
                        {
                                USB_JoystickReport_Data_t JoystickReportData;
                        if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
                        {
                                USB_JoystickReport_Data_t JoystickReportData;
@@ -159,7 +158,7 @@ bool GetNextReport(USB_JoystickReport_Data_t* const ReportData)
          ReportData->X =  100;
 
        if (JoyStatus_LCL & JOY_PRESS)
          ReportData->X =  100;
 
        if (JoyStatus_LCL & JOY_PRESS)
-         ReportData->Button  = (1 << 1);
+         ReportData->Button |= (1 << 1);
 
        if (ButtonStatus_LCL & BUTTONS_BUTTON1)
          ReportData->Button |= (1 << 0);
 
        if (ButtonStatus_LCL & BUTTONS_BUTTON1)
          ReportData->Button |= (1 << 0);
@@ -183,7 +182,7 @@ void HID_Task(void)
          return;
 
        /* Select the Joystick Report Endpoint */
          return;
 
        /* Select the Joystick Report Endpoint */
-       Endpoint_SelectEndpoint(JOYSTICK_EPNUM);
+       Endpoint_SelectEndpoint(JOYSTICK_EPADDR);
 
        /* Check to see if the host is ready for another packet */
        if (Endpoint_IsINReady())
 
        /* Check to see if the host is ready for another packet */
        if (Endpoint_IsINReady())
@@ -194,7 +193,7 @@ void HID_Task(void)
                GetNextReport(&JoystickReportData);
 
                /* Write Joystick Report Data */
                GetNextReport(&JoystickReportData);
 
                /* Write Joystick Report Data */
-               Endpoint_Write_Stream_LE(&JoystickReportData, sizeof(JoystickReportData));
+               Endpoint_Write_Stream_LE(&JoystickReportData, sizeof(JoystickReportData), NULL);
 
                /* Finalize the stream transfer to send the last packet */
                Endpoint_ClearIN();
 
                /* Finalize the stream transfer to send the last packet */
                Endpoint_ClearIN();