2013-01-28 13:00:37 +01:00
|
|
|
/* Copyright (C) 2013 Kristian Lauszus, TKJ Electronics. All rights reserved.
|
2013-03-28 09:46:43 +01:00
|
|
|
|
2013-01-27 21:25:50 +01:00
|
|
|
This software may be distributed and modified under the terms of the GNU
|
|
|
|
General Public License version 2 (GPL2) as published by the Free Software
|
|
|
|
Foundation and appearing in the file GPL2.TXT included in the packaging of
|
|
|
|
this file. Please note that GPL2 Section 2[b] requires that all works based
|
|
|
|
on this software must also be made publicly available under the terms of
|
|
|
|
the GPL2 ("Copyleft").
|
2013-03-28 09:46:43 +01:00
|
|
|
|
2013-01-27 21:25:50 +01:00
|
|
|
Contact information
|
|
|
|
-------------------
|
2013-03-28 09:46:43 +01:00
|
|
|
|
2013-01-27 21:25:50 +01:00
|
|
|
Kristian Lauszus, TKJ Electronics
|
|
|
|
Web : http://www.tkjelectronics.com
|
|
|
|
e-mail : kristianl@tkjelectronics.com
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _controllerenums_h
|
|
|
|
#define _controllerenums_h
|
|
|
|
|
2017-10-29 13:08:39 +01:00
|
|
|
#if defined(ESP32)
|
|
|
|
#undef PS
|
|
|
|
#endif
|
|
|
|
|
2014-01-18 22:50:05 +01:00
|
|
|
/**
|
|
|
|
* This header file is used to store different enums for the controllers,
|
|
|
|
* This is necessary so all the different libraries can be used at once.
|
2013-03-28 09:46:43 +01:00
|
|
|
*/
|
2013-01-27 21:25:50 +01:00
|
|
|
|
2013-02-05 19:51:45 +01:00
|
|
|
/** Enum used to turn on the LEDs on the different controllers. */
|
2014-01-04 13:43:49 +01:00
|
|
|
enum LEDEnum {
|
|
|
|
OFF = 0,
|
2016-03-18 22:40:10 +01:00
|
|
|
#ifndef RBL_NRF51822
|
2014-01-04 13:43:49 +01:00
|
|
|
LED1 = 1,
|
|
|
|
LED2 = 2,
|
|
|
|
LED3 = 3,
|
|
|
|
LED4 = 4,
|
2016-03-18 22:40:10 +01:00
|
|
|
#endif
|
2014-01-04 13:43:49 +01:00
|
|
|
LED5 = 5,
|
|
|
|
LED6 = 6,
|
|
|
|
LED7 = 7,
|
|
|
|
LED8 = 8,
|
|
|
|
LED9 = 9,
|
|
|
|
LED10 = 10,
|
2013-03-28 09:46:43 +01:00
|
|
|
/** Used to blink all LEDs on the Xbox controller */
|
2014-01-04 13:43:49 +01:00
|
|
|
ALL = 5,
|
2013-01-27 21:25:50 +01:00
|
|
|
};
|
2013-03-28 09:46:43 +01:00
|
|
|
|
2014-02-17 00:21:21 +01:00
|
|
|
/** Used to set the colors of the Move and PS4 controller. */
|
|
|
|
enum ColorsEnum {
|
|
|
|
/** r = 255, g = 0, b = 0 */
|
|
|
|
Red = 0xFF0000,
|
|
|
|
/** r = 0, g = 255, b = 0 */
|
|
|
|
Green = 0xFF00,
|
|
|
|
/** r = 0, g = 0, b = 255 */
|
|
|
|
Blue = 0xFF,
|
|
|
|
|
|
|
|
/** r = 255, g = 235, b = 4 */
|
|
|
|
Yellow = 0xFFEB04,
|
|
|
|
/** r = 0, g = 255, b = 255 */
|
|
|
|
Lightblue = 0xFFFF,
|
|
|
|
/** r = 255, g = 0, b = 255 */
|
2015-05-17 18:52:25 +02:00
|
|
|
Purple = 0xFF00FF,
|
2014-02-17 00:21:21 +01:00
|
|
|
Purble = 0xFF00FF,
|
|
|
|
|
|
|
|
/** r = 255, g = 255, b = 255 */
|
|
|
|
White = 0xFFFFFF,
|
|
|
|
/** r = 0, g = 0, b = 0 */
|
|
|
|
Off = 0x00,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum RumbleEnum {
|
|
|
|
RumbleHigh = 0x10,
|
|
|
|
RumbleLow = 0x20,
|
|
|
|
};
|
|
|
|
|
2013-02-05 19:51:45 +01:00
|
|
|
/** This enum is used to read all the different buttons on the different controllers */
|
2014-01-04 13:43:49 +01:00
|
|
|
enum ButtonEnum {
|
2013-03-28 09:46:43 +01:00
|
|
|
/**@{*/
|
2021-03-26 00:20:05 +01:00
|
|
|
/** Directional Pad Buttons - available on most controllers */
|
2013-03-28 09:46:43 +01:00
|
|
|
UP = 0,
|
|
|
|
RIGHT = 1,
|
|
|
|
DOWN = 2,
|
|
|
|
LEFT = 3,
|
|
|
|
/**@}*/
|
|
|
|
|
|
|
|
/**@{*/
|
2021-03-26 00:20:05 +01:00
|
|
|
/** Playstation buttons */
|
|
|
|
TRIANGLE,
|
|
|
|
CIRCLE,
|
|
|
|
CROSS,
|
|
|
|
SQUARE,
|
2013-03-28 09:46:43 +01:00
|
|
|
|
2021-03-25 21:18:36 +01:00
|
|
|
SELECT,
|
|
|
|
START,
|
2021-03-26 00:20:05 +01:00
|
|
|
|
2021-03-25 21:18:36 +01:00
|
|
|
L3,
|
|
|
|
R3,
|
|
|
|
|
|
|
|
L1,
|
|
|
|
R1,
|
2021-03-26 00:20:05 +01:00
|
|
|
L2,
|
|
|
|
R2,
|
2021-03-25 21:18:36 +01:00
|
|
|
|
|
|
|
PS,
|
2021-03-26 00:20:05 +01:00
|
|
|
/**@}*/
|
2021-03-25 21:18:36 +01:00
|
|
|
|
2021-03-26 00:20:05 +01:00
|
|
|
/**@{*/
|
|
|
|
/** PS3 Move Controller */
|
2021-03-25 21:18:36 +01:00
|
|
|
MOVE, // Covers 12 bits - we only need to read the top 8
|
|
|
|
T, // Covers 12 bits - we only need to read the top 8
|
2013-03-28 09:46:43 +01:00
|
|
|
/**@}*/
|
|
|
|
|
2021-03-26 00:20:05 +01:00
|
|
|
/**@{*/
|
|
|
|
/** PS Buzz controllers */
|
|
|
|
RED,
|
|
|
|
YELLOW,
|
|
|
|
GREEN,
|
|
|
|
ORANGE,
|
|
|
|
BLUE,
|
|
|
|
/**@}*/
|
|
|
|
|
|
|
|
/**@{*/
|
|
|
|
/** PS4 buttons - SHARE and OPTIONS are present instead of SELECT and START */
|
2021-03-25 21:18:36 +01:00
|
|
|
SHARE,
|
|
|
|
OPTIONS,
|
|
|
|
TOUCHPAD,
|
2014-01-10 17:44:51 +01:00
|
|
|
/**@}*/
|
|
|
|
|
2021-03-26 00:20:05 +01:00
|
|
|
/**@{*/
|
|
|
|
/** PS5 buttons */
|
|
|
|
CREATE,
|
|
|
|
MICROPHONE,
|
|
|
|
/**@}*/
|
|
|
|
|
2013-03-28 09:46:43 +01:00
|
|
|
/**@{*/
|
|
|
|
/** Xbox buttons */
|
2021-03-26 00:20:05 +01:00
|
|
|
A,
|
|
|
|
B,
|
2021-03-25 21:18:36 +01:00
|
|
|
X,
|
|
|
|
Y,
|
2021-03-26 00:20:05 +01:00
|
|
|
|
|
|
|
BACK,
|
|
|
|
// START, // listed under Playstation buttons
|
|
|
|
|
|
|
|
// L1, // listed under Playstation buttons
|
|
|
|
// R1, // listed under Playstation buttons
|
|
|
|
// L2, // listed under Playstation buttons
|
|
|
|
// R2, // listed under Playstation buttons
|
|
|
|
|
2021-03-25 21:18:36 +01:00
|
|
|
XBOX,
|
|
|
|
SYNC,
|
2021-03-26 00:20:05 +01:00
|
|
|
|
2021-03-25 21:18:36 +01:00
|
|
|
BLACK, // Available on the original Xbox controller
|
|
|
|
WHITE, // Available on the original Xbox controller
|
2013-03-28 09:46:43 +01:00
|
|
|
/**@}*/
|
2014-06-29 18:05:50 +02:00
|
|
|
|
2020-11-15 17:29:54 +01:00
|
|
|
/**@{*/
|
|
|
|
/** Xbox One S buttons */
|
2021-03-25 21:18:36 +01:00
|
|
|
VIEW,
|
|
|
|
MENU,
|
2020-11-15 17:29:54 +01:00
|
|
|
/**@}*/
|
|
|
|
|
2021-01-17 20:17:32 +01:00
|
|
|
/**@{*/
|
2021-03-26 00:20:05 +01:00
|
|
|
/** Wii buttons */
|
|
|
|
PLUS,
|
|
|
|
TWO,
|
|
|
|
ONE,
|
|
|
|
MINUS,
|
|
|
|
HOME,
|
|
|
|
Z,
|
|
|
|
C,
|
|
|
|
// B, // listed under Xbox buttons
|
|
|
|
// A, // listed under Xbox buttons
|
2014-06-29 18:05:50 +02:00
|
|
|
/**@}*/
|
2021-01-17 20:17:32 +01:00
|
|
|
|
|
|
|
/**@{*/
|
2021-03-26 00:20:05 +01:00
|
|
|
/** Wii U Pro Controller */
|
|
|
|
L,
|
|
|
|
R,
|
|
|
|
ZL,
|
|
|
|
ZR,
|
2021-01-17 20:17:32 +01:00
|
|
|
/**@}*/
|
2013-01-28 00:55:01 +01:00
|
|
|
};
|
2013-03-28 09:46:43 +01:00
|
|
|
|
2021-03-27 13:35:55 +01:00
|
|
|
inline constexpr int8_t ButtonIndex(ButtonEnum key) {
|
2021-03-27 12:20:55 +01:00
|
|
|
// using a chained ternary in place of a switch for constexpr on older compilers
|
|
|
|
return
|
|
|
|
(key == UP || key == RED) ? 0 :
|
|
|
|
(key == RIGHT || key == YELLOW) ? 1 :
|
|
|
|
(key == DOWN || key == GREEN) ? 2 :
|
|
|
|
(key == LEFT || key == ORANGE) ? 3 :
|
|
|
|
(key == SELECT || key == SHARE || key == BACK || key == VIEW || key == BLUE || key == CREATE) ? 4 :
|
2021-03-27 20:05:16 +01:00
|
|
|
(key == START || key == OPTIONS || key == MENU || key == PLUS) ? 5 :
|
|
|
|
(key == L3 || key == TWO) ? 6 :
|
|
|
|
(key == R3 || key == ONE) ? 7 :
|
|
|
|
(key == L2 || key == MINUS || key == BLACK) ? 8 :
|
|
|
|
(key == R2 || key == HOME || key == WHITE) ? 9 :
|
|
|
|
(key == L1 || key == Z) ? 10 :
|
|
|
|
(key == R1 || key == C) ? 11 :
|
|
|
|
(key == TRIANGLE || key == B) ? 12 :
|
|
|
|
(key == CIRCLE || key == A) ? 13 :
|
2021-03-27 12:20:55 +01:00
|
|
|
(key == CROSS || key == X) ? 14 :
|
|
|
|
(key == SQUARE || key == Y) ? 15 :
|
|
|
|
(key == L || key == PS || key == XBOX) ? 16 :
|
|
|
|
(key == R || key == MOVE || key == TOUCHPAD || key == SYNC) ? 17 :
|
|
|
|
(key == ZL || key == T || key == MICROPHONE) ? 18 :
|
|
|
|
(key == ZR) ? 19 :
|
|
|
|
-1; // not a match
|
2021-03-25 21:18:36 +01:00
|
|
|
}
|
|
|
|
|
2013-02-05 19:51:45 +01:00
|
|
|
/** Joysticks on the PS3 and Xbox controllers. */
|
2014-01-04 13:43:49 +01:00
|
|
|
enum AnalogHatEnum {
|
2013-03-28 09:46:43 +01:00
|
|
|
/** Left joystick x-axis */
|
|
|
|
LeftHatX = 0,
|
|
|
|
/** Left joystick y-axis */
|
|
|
|
LeftHatY = 1,
|
|
|
|
/** Right joystick x-axis */
|
|
|
|
RightHatX = 2,
|
|
|
|
/** Right joystick y-axis */
|
|
|
|
RightHatY = 3,
|
2013-01-27 21:25:50 +01:00
|
|
|
};
|
|
|
|
|
2014-01-18 22:50:05 +01:00
|
|
|
/**
|
|
|
|
* Sensors inside the Sixaxis Dualshock 3, Move controller and PS4 controller.
|
|
|
|
* <B>Note:</B> that the location is shifted 9 when it's connected via USB on the PS3 controller.
|
|
|
|
*/
|
|
|
|
enum SensorEnum {
|
|
|
|
/** Accelerometer values */
|
|
|
|
aX = 50, aY = 52, aZ = 54,
|
|
|
|
/** Gyro z-axis */
|
|
|
|
gZ = 56,
|
|
|
|
gX, gY, // These are not available on the PS3 controller
|
|
|
|
|
|
|
|
/** Accelerometer x-axis */
|
|
|
|
aXmove = 28,
|
|
|
|
/** Accelerometer z-axis */
|
|
|
|
aZmove = 30,
|
|
|
|
/** Accelerometer y-axis */
|
|
|
|
aYmove = 32,
|
|
|
|
|
|
|
|
/** Gyro x-axis */
|
|
|
|
gXmove = 40,
|
|
|
|
/** Gyro z-axis */
|
|
|
|
gZmove = 42,
|
|
|
|
/** Gyro y-axis */
|
|
|
|
gYmove = 44,
|
|
|
|
|
|
|
|
/** Temperature sensor */
|
|
|
|
tempMove = 46,
|
|
|
|
|
|
|
|
/** Magnetometer x-axis */
|
|
|
|
mXmove = 47,
|
|
|
|
/** Magnetometer z-axis */
|
|
|
|
mZmove = 49,
|
|
|
|
/** Magnetometer y-axis */
|
|
|
|
mYmove = 50,
|
|
|
|
};
|
|
|
|
|
2014-01-18 22:36:01 +01:00
|
|
|
/** Used to get the angle calculated using the PS3 controller and PS4 controller. */
|
|
|
|
enum AngleEnum {
|
|
|
|
Pitch = 0x01,
|
|
|
|
Roll = 0x02,
|
|
|
|
};
|
|
|
|
|
2013-12-25 11:09:57 +01:00
|
|
|
#endif
|