Clean up excessive whitespace at the end of each line using the wspurify tool made...
[pub/USBasp.git] / Demos / Host / LowLevel / JoystickHostWithParser / JoystickHostWithParser.c
index c7739e9..3bd27da 100644 (file)
@@ -1,7 +1,7 @@
 /*
              LUFA Library
      Copyright (C) Dean Camera, 2010.
 /*
              LUFA Library
      Copyright (C) Dean Camera, 2010.
-              
+
   dean [at] fourwalledcubicle [dot] com
       www.fourwalledcubicle.com
 */
   dean [at] fourwalledcubicle [dot] com
       www.fourwalledcubicle.com
 */
@@ -9,13 +9,13 @@
 /*
   Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com)
 
 /*
   Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com)
 
-  Permission to use, copy, modify, distribute, and sell this 
+  Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
   software and its documentation for any purpose is hereby granted
-  without fee, provided that the above copyright notice appear in 
+  without fee, provided that the above copyright notice appear in
   all copies and that both that the copyright notice and this
   all copies and that both that the copyright notice and this
-  permission notice and warranty disclaimer appear in supporting 
-  documentation, and that the name of the author not be used in 
-  advertising or publicity pertaining to distribution of the 
+  permission notice and warranty disclaimer appear in supporting
+  documentation, and that the name of the author not be used in
+  advertising or publicity pertaining to distribution of the
   software without specific, written prior permission.
 
   The author disclaim all warranties with regard to this
   software without specific, written prior permission.
 
   The author disclaim all warranties with regard to this
@@ -33,7 +33,7 @@
  *  Main source file for the JoystickHostWithParser demo. This file contains the main tasks of
  *  the demo and is responsible for the initial application hardware configuration.
  */
  *  Main source file for the JoystickHostWithParser demo. This file contains the main tasks of
  *  the demo and is responsible for the initial application hardware configuration.
  */
+
 #include "JoystickHostWithParser.h"
 
 /** Main program entry point. This routine configures the hardware required by the application, then
 #include "JoystickHostWithParser.h"
 
 /** Main program entry point. This routine configures the hardware required by the application, then
@@ -64,7 +64,7 @@ void SetupHardware(void)
 
        /* Disable clock division */
        clock_prescale_set(clock_div_1);
 
        /* Disable clock division */
        clock_prescale_set(clock_div_1);
-       
+
        /* Hardware Initialization */
        SerialStream_Init(9600, false);
        LEDs_Init();
        /* Hardware Initialization */
        SerialStream_Init(9600, false);
        LEDs_Init();
@@ -118,7 +118,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8
                                 " -- Error Code %d\r\n"
                                 " -- Sub Error Code %d\r\n"
                                 " -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState);
                                 " -- Error Code %d\r\n"
                                 " -- Sub Error Code %d\r\n"
                                 " -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState);
-       
+
        LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
 }
 
        LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
 }
 
@@ -134,7 +134,7 @@ void Joystick_HID_Task(void)
        {
                case HOST_STATE_Addressed:
                        puts_P(PSTR("Getting Config Data.\r\n"));
        {
                case HOST_STATE_Addressed:
                        puts_P(PSTR("Getting Config Data.\r\n"));
-               
+
                        /* Get and process the configuration descriptor data */
                        if ((ErrorCode = ProcessConfigurationDescriptor()) != SuccessfulConfigRead)
                        {
                        /* Get and process the configuration descriptor data */
                        if ((ErrorCode = ProcessConfigurationDescriptor()) != SuccessfulConfigRead)
                        {
@@ -144,7 +144,7 @@ void Joystick_HID_Task(void)
                                  puts_P(PSTR(ESC_FG_RED "Invalid Device.\r\n"));
 
                                printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode);
                                  puts_P(PSTR(ESC_FG_RED "Invalid Device.\r\n"));
 
                                printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode);
-                               
+
                                /* Indicate error via status LEDs */
                                LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
 
                                /* Indicate error via status LEDs */
                                LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
 
@@ -152,7 +152,7 @@ void Joystick_HID_Task(void)
                                USB_HostState = HOST_STATE_WaitForDeviceRemoval;
                                break;
                        }
                                USB_HostState = HOST_STATE_WaitForDeviceRemoval;
                                break;
                        }
-               
+
                        /* Set the device configuration to the first configuration (rarely do devices use multiple configurations) */
                        if ((ErrorCode = USB_Host_SetDeviceConfiguration(1)) != HOST_SENDCONTROL_Successful)
                        {
                        /* Set the device configuration to the first configuration (rarely do devices use multiple configurations) */
                        if ((ErrorCode = USB_Host_SetDeviceConfiguration(1)) != HOST_SENDCONTROL_Successful)
                        {
@@ -161,12 +161,12 @@ void Joystick_HID_Task(void)
 
                                /* Indicate error via status LEDs */
                                LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
 
                                /* Indicate error via status LEDs */
                                LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
-                               
+
                                /* Wait until USB device disconnected */
                                USB_HostState = HOST_STATE_WaitForDeviceRemoval;
                                break;
                        }
                                /* Wait until USB device disconnected */
                                USB_HostState = HOST_STATE_WaitForDeviceRemoval;
                                break;
                        }
-                       
+
                        printf_P(PSTR("Processing HID Report (Size %d Bytes).\r\n"), HIDReportSize);
 
                        /* Get and process the device's first HID report descriptor */
                        printf_P(PSTR("Processing HID Report (Size %d Bytes).\r\n"), HIDReportSize);
 
                        /* Get and process the device's first HID report descriptor */
@@ -178,21 +178,21 @@ void Joystick_HID_Task(void)
                                        puts_P(PSTR("Not a valid Joystick." ESC_FG_WHITE));
                                else
                                        printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode);
                                        puts_P(PSTR("Not a valid Joystick." ESC_FG_WHITE));
                                else
                                        printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode);
-                       
+
                                /* Indicate error via status LEDs */
                                LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
                                /* Indicate error via status LEDs */
                                LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
-                               
+
                                /* Wait until USB device disconnected */
                                USB_HostState = HOST_STATE_WaitForDeviceRemoval;
                                break;
                        }
                                /* Wait until USB device disconnected */
                                USB_HostState = HOST_STATE_WaitForDeviceRemoval;
                                break;
                        }
-                       
+
                        printf("Total Reports: %d\r\n", HIDReportInfo.TotalDeviceReports);
 
                        for (uint8_t i = 0; i < HIDReportInfo.TotalDeviceReports; i++)
                        {
                                HID_ReportSizeInfo_t* CurrReportIDInfo = &HIDReportInfo.ReportIDSizes[i];
                        printf("Total Reports: %d\r\n", HIDReportInfo.TotalDeviceReports);
 
                        for (uint8_t i = 0; i < HIDReportInfo.TotalDeviceReports; i++)
                        {
                                HID_ReportSizeInfo_t* CurrReportIDInfo = &HIDReportInfo.ReportIDSizes[i];
-                               
+
                                uint8_t ReportSizeInBits      = CurrReportIDInfo->ReportSizeBits[HID_REPORT_ITEM_In];
                                uint8_t ReportSizeOutBits     = CurrReportIDInfo->ReportSizeBits[HID_REPORT_ITEM_Out];
                                uint8_t ReportSizeFeatureBits = CurrReportIDInfo->ReportSizeBits[HID_REPORT_ITEM_Feature];
                                uint8_t ReportSizeInBits      = CurrReportIDInfo->ReportSizeBits[HID_REPORT_ITEM_In];
                                uint8_t ReportSizeOutBits     = CurrReportIDInfo->ReportSizeBits[HID_REPORT_ITEM_Out];
                                uint8_t ReportSizeFeatureBits = CurrReportIDInfo->ReportSizeBits[HID_REPORT_ITEM_Feature];
@@ -211,9 +211,9 @@ void Joystick_HID_Task(void)
                        break;
                case HOST_STATE_Configured:
                        /* Select and unfreeze joystick data pipe */
                        break;
                case HOST_STATE_Configured:
                        /* Select and unfreeze joystick data pipe */
-                       Pipe_SelectPipe(JOYSTICK_DATA_IN_PIPE); 
+                       Pipe_SelectPipe(JOYSTICK_DATA_IN_PIPE);
                        Pipe_Unfreeze();
                        Pipe_Unfreeze();
-                       
+
                        /* Check to see if a packet has been received */
                        if (Pipe_IsINReceived())
                        {
                        /* Check to see if a packet has been received */
                        if (Pipe_IsINReceived())
                        {
@@ -225,11 +225,11 @@ void Joystick_HID_Task(void)
 
                                        /* Load in the joystick report */
                                        Pipe_Read_Stream_LE(JoystickReport, Pipe_BytesInPipe());
 
                                        /* Load in the joystick report */
                                        Pipe_Read_Stream_LE(JoystickReport, Pipe_BytesInPipe());
-                               
+
                                        /* Process the read in joystick report from the device */
                                        ProcessJoystickReport(JoystickReport);
                                }
                                        /* Process the read in joystick report from the device */
                                        ProcessJoystickReport(JoystickReport);
                                }
-                               
+
                                /* Clear the IN endpoint, ready for next data packet */
                                Pipe_ClearIN();
                        }
                                /* Clear the IN endpoint, ready for next data packet */
                                Pipe_ClearIN();
                        }
@@ -254,7 +254,7 @@ void ProcessJoystickReport(uint8_t* JoystickReport)
        {
                /* Create a temporary item pointer to the next report item */
                HID_ReportItem_t* ReportItem = &HIDReportInfo.ReportItems[ReportNumber];
        {
                /* Create a temporary item pointer to the next report item */
                HID_ReportItem_t* ReportItem = &HIDReportInfo.ReportItems[ReportNumber];
-               
+
                bool FoundData;
 
                if ((ReportItem->Attributes.Usage.Page        == USAGE_PAGE_BUTTON) &&
                bool FoundData;
 
                if ((ReportItem->Attributes.Usage.Page        == USAGE_PAGE_BUTTON) &&
@@ -262,7 +262,7 @@ void ProcessJoystickReport(uint8_t* JoystickReport)
                {
                        /* Get the joystick button value */
                        FoundData = USB_GetHIDReportItemInfo(JoystickReport, ReportItem);
                {
                        /* Get the joystick button value */
                        FoundData = USB_GetHIDReportItemInfo(JoystickReport, ReportItem);
-                       
+
                        /* For multi-report devices - if the requested data was not in the issued report, continue */
                        if (!(FoundData))
                          continue;
                        /* For multi-report devices - if the requested data was not in the issued report, continue */
                        if (!(FoundData))
                          continue;
@@ -278,13 +278,13 @@ void ProcessJoystickReport(uint8_t* JoystickReport)
                {
                        /* Get the joystick relative position value */
                        FoundData = USB_GetHIDReportItemInfo(JoystickReport, ReportItem);
                {
                        /* Get the joystick relative position value */
                        FoundData = USB_GetHIDReportItemInfo(JoystickReport, ReportItem);
-                       
+
                        /* For multi-report devices - if the requested data was not in the issued report, continue */
                        if (!(FoundData))
                          continue;
                        /* For multi-report devices - if the requested data was not in the issued report, continue */
                        if (!(FoundData))
                          continue;
-                         
+
                        int16_t DeltaMovement = HID_ALIGN_DATA(ReportItem, int16_t);
                        int16_t DeltaMovement = HID_ALIGN_DATA(ReportItem, int16_t);
-                       
+
                        /* Check to see if a (non-zero) delta movement has been indicated */
                        if (DeltaMovement)
                        {
                        /* Check to see if a (non-zero) delta movement has been indicated */
                        if (DeltaMovement)
                        {
@@ -296,7 +296,7 @@ void ProcessJoystickReport(uint8_t* JoystickReport)
                        }
                }
        }
                        }
                }
        }
-       
+
        /* Display the button information on the board LEDs */
        LEDs_SetAllLEDs(LEDMask);
        /* Display the button information on the board LEDs */
        LEDs_SetAllLEDs(LEDMask);
-}
\ No newline at end of file
+}