CI: Build on Arch (bleeding-ege) and Ubuntu (stable) AVR-GCC toolchains.
[pub/USBasp.git] / LUFA / Drivers / Board / Joystick.h
index 7affe2e..b0a31a5 100644 (file)
@@ -1,13 +1,13 @@
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2011.
+     Copyright (C) Dean Camera, 2018.
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
-  Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+  Copyright 2018  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
@@ -18,7 +18,7 @@
   advertising or publicity pertaining to distribution of the
   software without specific, written prior permission.
 
-  The author disclaim all warranties with regard to this
+  The author disclaims all warranties with regard to this
   software, including all implied warranties of merchantability
   and fitness.  In no event shall the author be liable for any
   special, indirect or consequential damages or any damages
  *  \defgroup Group_Joystick Joystick Driver - LUFA/Drivers/Board/Joystick.h
  *  \brief Digital joystick board hardware driver.
  *
- *  \section Sec_Dependencies Module Source Dependencies
+ *  \section Sec_Joystick_Dependencies Module Source Dependencies
  *  The following files must be built with any user project that uses this module:
  *    - None
  *
- *  \section Sec_ModDescription Module Description
+ *  \section Sec_Joystick_ModDescription Module Description
  *  Hardware Joystick driver. This module provides an easy to use interface to control the hardware digital Joystick
  *  located on many boards.
  *
  *  If the \c BOARD value is set to \c BOARD_USER, this will include the \c /Board/Joystick.h file in the user project
- *  directory. Otherwise, it will include the appropriate built in board driver header file.
+ *  directory. Otherwise, it will include the appropriate built-in board driver header file.
  *
  *  For possible \c BOARD makefile values, see \ref Group_BoardTypes.
  *
- *  \section Sec_ExampleUsage Example Usage
+ *  \section Sec_Joystick_ExampleUsage Example Usage
  *  The following snippet is an example of how this module may be used within a typical
  *  application.
  *
  *
  *      // Display which direction the joystick was moved in
  *      printf("Joystick moved:\r\n");
- *      
+ *
  *      if (JoystickMovement & (JOY_UP | JOY_DOWN))
  *        printf("%s ", (JoystickMovement & JOY_UP) ? "Up" : "Down");
  *
  *      if (JoystickMovement & (JOY_LEFT | JOY_RIGHT))
  *        printf("%s ", (JoystickMovement & JOY_LEFT) ? "Left" : "Right");
  *
- *      if (JoystickMovement & JOY_PRESSED)
+ *      if (JoystickMovement & JOY_PRESS)
  *        printf("Pressed");
  *  \endcode
  *
                #include "../../Common/Common.h"
 
                #if (BOARD == BOARD_NONE)
-                       #error The Board Joystick driver cannot be used if the makefile BOARD option is not set.
+                       #define JOY_UP           0
+                       #define JOY_DOWN         0
+                       #define JOY_LEFT         0
+                       #define JOY_RIGHT        0
+                       #define JOY_PRESS        0
+                       static inline void       Joystick_Init(void) {}
+                       static inline void       Joystick_Disable(void) {}
+                       static inline uint_reg_t Joystick_GetStatus(void) { return 0; }
                #elif (BOARD == BOARD_USBKEY)
                        #include "AVR8/USBKEY/Joystick.h"
                #elif (BOARD == BOARD_STK525)
                        #include "Board/Joystick.h"
                #endif
 
-               /* Pseudo-Functions for Doxygen: */
-               #if defined(__DOXYGEN__)
-                       /** Initializes the joystick driver so that the joystick position can be read. This sets the appropriate
-                        *  I/O pins to inputs with their pull-ups enabled.
-                        */
-                       static inline void Joystick_Init(void);
-
-                       /** Returns the current status of the joystick, as a mask indicating the direction the joystick is
-                        *  currently facing in (multiple bits can be set).
-                        *
-                        *  \return Mask indicating the joystick direction - see corresponding board specific Joystick.h file
-                        *          for direction masks.
-                        */
-                       static inline uint_reg_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
-               #endif
+       /* Pseudo-Functions for Doxygen: */
+       #if defined(__DOXYGEN__)
+               /** Initializes the joystick driver so that the joystick position can be read. This sets the appropriate
+                *  I/O pins to inputs with their pull-ups enabled.
+                *
+                *  This must be called before any Joystick driver functions are used.
+                */
+               static inline void Joystick_Init(void);
+
+               /** Disables the joystick driver, releasing the I/O pins back to their default high-impedance input mode. */
+               static inline void Joystick_Disable(void);
+
+               /** Returns the current status of the joystick, as a mask indicating the direction the joystick is
+                *  currently facing in (multiple bits can be set).
+                *
+                *  \return Mask of \c JOYSTICK_* constants indicating the current joystick direction(s).
+                */
+               static inline uint_reg_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
+       #endif
 
 #endif