/* Copyright (C) 2013 Kristian Lauszus, TKJ Electronics. All rights reserved. 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"). Contact information ------------------- Kristian Lauszus, TKJ Electronics Web : http://www.tkjelectronics.com e-mail : kristianl@tkjelectronics.com */ #ifndef _controllerenums_h #define _controllerenums_h #if defined(ESP32) #undef PS #endif /** * 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. */ /** Enum used to turn on the LEDs on the different controllers. */ enum LEDEnum { OFF = 0, #ifndef RBL_NRF51822 LED1 = 1, LED2 = 2, LED3 = 3, LED4 = 4, #endif LED5 = 5, LED6 = 6, LED7 = 7, LED8 = 8, LED9 = 9, LED10 = 10, /** Used to blink all LEDs on the Xbox controller */ ALL = 5, }; /** 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 */ Purple = 0xFF00FF, Purble = 0xFF00FF, /** r = 255, g = 255, b = 255 */ White = 0xFFFFFF, /** r = 0, g = 0, b = 0 */ Off = 0x00, }; enum RumbleEnum { RumbleHigh = 0x10, RumbleLow = 0x20, }; /** This enum is used to read all the different buttons on the different controllers */ enum ButtonEnum { /**@{*/ /** Directional Pad Buttons - available on most controllers */ UP = 0, RIGHT = 1, DOWN = 2, LEFT = 3, /**@}*/ /**@{*/ /** Playstation buttons */ TRIANGLE, CIRCLE, CROSS, SQUARE, SELECT, START, L3, R3, L1, R1, L2, R2, PS, /**@}*/ /**@{*/ /** PS3 Move Controller */ MOVE, // Covers 12 bits - we only need to read the top 8 T, // Covers 12 bits - we only need to read the top 8 /**@}*/ /**@{*/ /** PS Buzz controllers */ RED, YELLOW, GREEN, ORANGE, BLUE, /**@}*/ /**@{*/ /** PS4 buttons - SHARE and OPTIONS are present instead of SELECT and START */ SHARE, OPTIONS, TOUCHPAD, /**@}*/ /**@{*/ /** PS5 buttons */ CREATE, MICROPHONE, /**@}*/ /**@{*/ /** Xbox buttons */ A, B, X, Y, 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 XBOX, SYNC, BLACK, // Available on the original Xbox controller WHITE, // Available on the original Xbox controller /**@}*/ /**@{*/ /** Xbox One S buttons */ VIEW, MENU, /**@}*/ /**@{*/ /** Wii buttons */ PLUS, TWO, ONE, MINUS, HOME, Z, C, // B, // listed under Xbox buttons // A, // listed under Xbox buttons /**@}*/ /**@{*/ /** Wii U Pro Controller */ L, R, ZL, ZR, /**@}*/ }; inline int8_t legacyButtonValues(ButtonEnum key) { switch (key) { case UP: case RED: return 0; case RIGHT: case YELLOW: return 1; case DOWN: case GREEN: return 2; case LEFT: case ORANGE: return 3; case SELECT: case SHARE: case BACK: case VIEW: case BLUE: case CREATE: return 4; case PLUS: case START: case OPTIONS: case MENU: return 5; case TWO: case L3: return 6; case ONE: case R3: return 7; case MINUS: case L2: case BLACK: return 8; case HOME: case R2: case WHITE: return 9; case Z: case L1: return 10; case C: case R1: return 11; case B: case TRIANGLE: return 12; case A: case CIRCLE: return 13; case CROSS: case X: return 14; case SQUARE: case Y: return 15; case L: case PS: case XBOX: return 16; case R: case MOVE: case TOUCHPAD: case SYNC: return 17; case ZL: case T: case MICROPHONE: return 18; case ZR: return 19; default: return -1; } return -1; } /** Joysticks on the PS3 and Xbox controllers. */ enum AnalogHatEnum { /** Left joystick x-axis */ LeftHatX = 0, /** Left joystick y-axis */ LeftHatY = 1, /** Right joystick x-axis */ RightHatX = 2, /** Right joystick y-axis */ RightHatY = 3, }; /** * Sensors inside the Sixaxis Dualshock 3, Move controller and PS4 controller. * Note: 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, }; /** Used to get the angle calculated using the PS3 controller and PS4 controller. */ enum AngleEnum { Pitch = 0x01, Roll = 0x02, }; #endif