USB Host Shield 2.0
controllerEnums.h
Go to the documentation of this file.
1 /* Copyright (C) 2013 Kristian Lauszus, TKJ Electronics. All rights reserved.
2 
3  This software may be distributed and modified under the terms of the GNU
4  General Public License version 2 (GPL2) as published by the Free Software
5  Foundation and appearing in the file GPL2.TXT included in the packaging of
6  this file. Please note that GPL2 Section 2[b] requires that all works based
7  on this software must also be made publicly available under the terms of
8  the GPL2 ("Copyleft").
9 
10  Contact information
11  -------------------
12 
13  Kristian Lauszus, TKJ Electronics
14  Web : http://www.tkjelectronics.com
15  e-mail : kristianl@tkjelectronics.com
16  */
17 
18 #ifndef _controllerenums_h
19 #define _controllerenums_h
20 
21 #if defined(ESP32)
22 #undef PS
23 #endif
24 
31 enum LEDEnum {
32  OFF = 0,
33 #ifndef RBL_NRF51822
34  LED1 = 1,
35  LED2 = 2,
36  LED3 = 3,
37  LED4 = 4,
38 #endif
39  LED5 = 5,
40  LED6 = 6,
41  LED7 = 7,
42  LED8 = 8,
43  LED9 = 9,
44  LED10 = 10,
46  ALL = 5,
47 };
48 
50 enum ColorsEnum {
52  Red = 0xFF0000,
54  Green = 0xFF00,
56  Blue = 0xFF,
57 
59  Yellow = 0xFFEB04,
61  Lightblue = 0xFFFF,
63  Purple = 0xFF00FF,
64  Purble = 0xFF00FF,
65 
67  White = 0xFFFFFF,
69  Off = 0x00,
70 };
71 
72 enum RumbleEnum {
73  RumbleHigh = 0x10,
74  RumbleLow = 0x20,
75 };
76 
78 enum ButtonEnum {
81  UP = 0,
82  RIGHT = 1,
83  DOWN = 2,
84  LEFT = 3,
93 
96 
97  L3,
98  R3,
99 
100  L1,
101  R1,
102  L2,
103  R2,
104 
105  PS,
110  MOVE, // Covers 12 bits - we only need to read the top 8
111  T, // Covers 12 bits - we only need to read the top 8
138  A,
139  B,
140  X,
141  Y,
142 
144  // START, // listed under Playstation buttons
145 
146  LB,
147  RB,
148  LT,
149  RT,
150 
153 
154  BLACK, // Available on the original Xbox controller
155  WHITE, // Available on the original Xbox controller
171  Z,
172  C,
173  // B, // listed under Xbox buttons
174  // A, // listed under Xbox buttons
179  L,
180  R,
181  ZL,
182  ZR,
189 };
190 
191 inline constexpr int8_t ButtonIndex(ButtonEnum key) {
192  // using a chained ternary in place of a switch for constexpr on older compilers
193  return
194  (key == UP || key == RED) ? 0 :
195  (key == RIGHT || key == YELLOW) ? 1 :
196  (key == DOWN || key == GREEN) ? 2 :
197  (key == LEFT || key == ORANGE) ? 3 :
198  (key == SELECT || key == SHARE || key == BACK || key == VIEW || key == BLUE || key == CREATE || key == CAPTURE) ? 4 :
199  (key == START || key == OPTIONS || key == MENU || key == PLUS) ? 5 :
200  (key == L3 || key == TWO) ? 6 :
201  (key == R3 || key == ONE) ? 7 :
202  (key == L2 || key == LT || key == MINUS || key == BLACK) ? 8 :
203  (key == R2 || key == RT || key == HOME || key == WHITE) ? 9 :
204  (key == L1 || key == LB || key == Z) ? 10 :
205  (key == R1 || key == RB || key == C) ? 11 :
206  (key == TRIANGLE || key == B) ? 12 :
207  (key == CIRCLE || key == A) ? 13 :
208  (key == CROSS || key == X) ? 14 :
209  (key == SQUARE || key == Y) ? 15 :
210  (key == L || key == PS || key == XBOX) ? 16 :
211  (key == R || key == MOVE || key == TOUCHPAD || key == SYNC) ? 17 :
212  (key == ZL || key == T || key == MICROPHONE) ? 18 :
213  (key == ZR) ? 19 :
214  -1; // not a match
215 }
216 
220  LeftHatX = 0,
222  LeftHatY = 1,
227 };
228 
235  aX = 50, aY = 52, aZ = 54,
237  gZ = 56,
238  gX, gY, // These are not available on the PS3 controller
239 
241  aXmove = 28,
243  aZmove = 30,
245  aYmove = 32,
246 
248  gXmove = 40,
250  gZmove = 42,
252  gYmove = 44,
253 
255  tempMove = 46,
256 
258  mXmove = 47,
260  mZmove = 49,
262  mYmove = 50,
263 };
264 
266 enum AngleEnum {
267  Pitch = 0x01,
268  Roll = 0x02,
269 };
270 
271 #endif
SensorEnum
@ gY
@ aZmove
@ gX
@ gXmove
@ mZmove
@ aX
@ tempMove
@ aZ
@ aYmove
@ gZ
@ aXmove
@ gYmove
@ mXmove
@ gZmove
@ aY
@ mYmove
constexpr int8_t ButtonIndex(ButtonEnum key)
AnalogHatEnum
@ LeftHatX
@ RightHatY
@ RightHatX
@ LeftHatY
LEDEnum
@ LED9
@ LED6
@ LED7
@ LED10
@ LED8
@ LED3
@ LED2
@ OFF
@ ALL
@ LED4
@ LED1
@ LED5
AngleEnum
@ Roll
@ Pitch
ButtonEnum
@ L2
@ TWO
@ START
@ SELECT
@ R
@ PS
@ OPTIONS
@ ZR
@ T
@ WHITE
@ CAPTURE
@ TRIANGLE
@ BLUE
@ SHARE
@ B
@ SQUARE
@ A
@ SYNC
@ CREATE
@ LT
@ MENU
@ ZL
@ Y
@ VIEW
@ X
@ RB
@ TOUCHPAD
@ R2
@ C
@ L3
@ ONE
@ PLUS
@ HOME
@ DOWN
@ GREEN
@ Z
@ CIRCLE
@ R3
@ UP
@ BACK
@ ORANGE
@ XBOX
@ CROSS
@ LEFT
@ MICROPHONE
@ L1
@ YELLOW
@ LB
@ RIGHT
@ MOVE
@ L
@ RT
@ MINUS
@ BLACK
@ RED
@ R1
ColorsEnum
@ Purple
@ Purble
@ Lightblue
@ White
@ Yellow
@ Green
@ Red
@ Off
@ Blue
RumbleEnum
@ RumbleLow
@ RumbleHigh