USB Host Shield 2.0
Loading...
Searching...
No Matches
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
31enum 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
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
73 RumbleHigh = 0x10,
74 RumbleLow = 0x20,
75};
76
81 UP = 0,
82 RIGHT = 1,
83 DOWN = 2,
84 LEFT = 3,
93
96
99
104
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
142
144 // START, // listed under Playstation buttons
145
150
153
154 BLACK, // Available on the original Xbox controller
155 WHITE, // Available on the original Xbox controller
173 // B, // listed under Xbox buttons
174 // A, // listed under Xbox buttons
189};
190
191inline 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
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
256
258 mXmove = 47,
260 mZmove = 49,
262 mYmove = 50,
263};
264
267 Pitch = 0x01,
268 Roll = 0x02,
269};
270
271#endif
SensorEnum
@ aZmove
@ gXmove
@ mZmove
@ tempMove
@ aYmove
@ aXmove
@ gYmove
@ mXmove
@ gZmove
@ 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
@ TWO
@ START
@ SELECT
@ OPTIONS
@ WHITE
@ CAPTURE
@ TRIANGLE
@ BLUE
@ SHARE
@ SQUARE
@ SYNC
@ CREATE
@ MENU
@ VIEW
@ TOUCHPAD
@ L3
@ ONE
@ PLUS
@ HOME
@ DOWN
@ GREEN
@ CIRCLE
@ R3
@ UP
@ BACK
@ ORANGE
@ XBOX
@ CROSS
@ LEFT
@ MICROPHONE
@ YELLOW
@ RIGHT
@ MOVE
@ MINUS
@ BLACK
@ RED
ColorsEnum
@ Purple
@ Purble
@ Lightblue
@ White
@ Yellow
@ Green
@ Red
@ Off
@ Blue
RumbleEnum
@ RumbleLow
@ RumbleHigh