]> git.donarmstrong.com Git - qmk_firmware.git/blob - protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BUMBLEB/Joystick.h
92c7a2e72f36145fb9346e90145d3aef3a55c1c6
[qmk_firmware.git] / protocol / lufa / LUFA-120730 / LUFA / Drivers / Board / AVR8 / BUMBLEB / Joystick.h
1 /*\r
2              LUFA Library\r
3      Copyright (C) Dean Camera, 2012.\r
4 \r
5   dean [at] fourwalledcubicle [dot] com\r
6            www.lufa-lib.org\r
7 */\r
8 \r
9 /*\r
10   Copyright 2012  Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
11 \r
12   Permission to use, copy, modify, distribute, and sell this\r
13   software and its documentation for any purpose is hereby granted\r
14   without fee, provided that the above copyright notice appear in\r
15   all copies and that both that the copyright notice and this\r
16   permission notice and warranty disclaimer appear in supporting\r
17   documentation, and that the name of the author not be used in\r
18   advertising or publicity pertaining to distribution of the\r
19   software without specific, written prior permission.\r
20 \r
21   The author disclaim all warranties with regard to this\r
22   software, including all implied warranties of merchantability\r
23   and fitness.  In no event shall the author be liable for any\r
24   special, indirect or consequential damages or any damages\r
25   whatsoever resulting from loss of use, data or profits, whether\r
26   in an action of contract, negligence or other tortious action,\r
27   arising out of or in connection with the use or performance of\r
28   this software.\r
29 */\r
30 \r
31 /** \file\r
32  *  \brief Board specific joystick driver header for the Fletchtronics BUMBLEB.\r
33  *  \copydetails Group_Joystick_BUMBLEB\r
34  *\r
35  *  \note This file should not be included directly. It is automatically included as needed by the joystick driver\r
36  *        dispatch header located in LUFA/Drivers/Board/Joystick.h.\r
37  */\r
38 \r
39 /** \ingroup Group_Joystick\r
40  *  \defgroup Group_Joystick_BUMBLEB BUMBLEB\r
41  *  \brief Board specific joystick driver header for the Fletchtronics BUMBLEB.\r
42  *\r
43  *  Board specific joystick driver header for the Fletchtronics BUMBLEB (http://fletchtronics.net/bumble-b). The BUMBLEB\r
44  *  third-party board does not include any on-board peripherals, but does have an officially recommended external peripheral\r
45  *  layout for buttons, LEDs and a Joystick.\r
46  *\r
47  *  <table>\r
48  *    <tr><th>Left Port Pin</th><th>Up Port Pin</th><th>Right Port Pin</th><th>Down Port Pin</th><th>Press Port Pin</th></tr>\r
49  *    <tr><td>PORTD.2</td><td>PORTD.3</td><td>PORTD.0</td><td>PORTD.1</td><td>PORTD.4</td></tr>\r
50  *  </table>\r
51  *\r
52  *  @{\r
53  */\r
54 \r
55 #ifndef __JOYSTICK_BUMBLEB_H__\r
56 #define __JOYSTICK_BUMBLEB_H__\r
57 \r
58         /* Includes: */\r
59                 #include "../../../../Common/Common.h"\r
60 \r
61         /* Enable C linkage for C++ Compilers: */\r
62                 #if defined(__cplusplus)\r
63                         extern "C" {\r
64                 #endif\r
65 \r
66         /* Preprocessor Checks: */\r
67                 #if !defined(__INCLUDE_FROM_JOYSTICK_H)\r
68                         #error Do not include this file directly. Include LUFA/Drivers/Board/Joystick.h instead.\r
69                 #endif\r
70 \r
71         /* Private Interface - For use in library only: */\r
72         #if !defined(__DOXYGEN__)\r
73                 /* Macros: */\r
74                         #define JOY_MASK                 ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4))\r
75         #endif\r
76 \r
77         /* Public Interface - May be used in end-application: */\r
78                 /* Macros: */\r
79                         /** Mask for the joystick being pushed in the left direction. */\r
80                         #define JOY_LEFT                  (1 << 2)\r
81 \r
82                         /** Mask for the joystick being pushed in the upward direction. */\r
83                         #define JOY_UP                    (1 << 3)\r
84 \r
85                         /** Mask for the joystick being pushed in the right direction. */\r
86                         #define JOY_RIGHT                 (1 << 0)\r
87 \r
88                         /** Mask for the joystick being pushed in the downward direction. */\r
89                         #define JOY_DOWN                  (1 << 1)\r
90 \r
91                         /** Mask for the joystick being pushed inward. */\r
92                         #define JOY_PRESS                 (1 << 4)\r
93 \r
94                 /* Inline Functions: */\r
95                 #if !defined(__DOXYGEN__)\r
96                         static inline void Joystick_Init(void)\r
97                         {\r
98                                 DDRD  &= ~JOY_MASK;\r
99                                 PORTD |=  JOY_MASK;\r
100                         }\r
101 \r
102                         static inline void Joystick_Disable(void)\r
103                         {\r
104                                 DDRD  &= ~JOY_MASK;\r
105                                 PORTD &= ~JOY_MASK;\r
106                         }\r
107 \r
108                         static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
109                         static inline uint8_t Joystick_GetStatus(void)\r
110                         {\r
111                                 return (uint8_t)(~PIND & JOY_MASK);\r
112                         }\r
113                 #endif\r
114 \r
115         /* Disable C linkage for C++ Compilers: */\r
116                 #if defined(__cplusplus)\r
117                         }\r
118                 #endif\r
119 \r
120 #endif\r
121 \r
122 /** @} */\r
123 \r