Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: UsbHostMAX3421E_Hello
controllerEnums.h
00001 /* Copyright (C) 2013 Kristian Lauszus, TKJ Electronics. All rights reserved. 00002 00003 This software may be distributed and modified under the terms of the GNU 00004 General Public License version 2 (GPL2) as published by the Free Software 00005 Foundation and appearing in the file GPL2.TXT included in the packaging of 00006 this file. Please note that GPL2 Section 2[b] requires that all works based 00007 on this software must also be made publicly available under the terms of 00008 the GPL2 ("Copyleft"). 00009 00010 Contact information 00011 ------------------- 00012 00013 Kristian Lauszus, TKJ Electronics 00014 Web : http://www.tkjelectronics.com 00015 e-mail : kristianl@tkjelectronics.com 00016 */ 00017 00018 #ifndef _controllerenums_h 00019 #define _controllerenums_h 00020 00021 #ifdef TOOLCHAIN_GCC 00022 #include "math.h" 00023 #else 00024 #define M_PI 3.14159265358979323846 00025 #endif 00026 00027 #define RAD_TO_DEG 180/M_PI 00028 #define micros millis 00029 00030 #if defined(ESP32) 00031 #undef PS 00032 #endif 00033 00034 /** 00035 * This header file is used to store different enums for the controllers, 00036 * This is necessary so all the different libraries can be used at once. 00037 */ 00038 00039 /** Enum used to turn on the LEDs on the different controllers. */ 00040 enum LEDEnum { 00041 OFF = 0, 00042 #ifndef RBL_NRF51822 00043 LED_1 = 1, 00044 LED_2 = 2, 00045 LED_3 = 3, 00046 LED_4 = 4, 00047 #endif 00048 LED_5 = 5, 00049 LED_6 = 6, 00050 LED_7 = 7, 00051 LED_8 = 8, 00052 LED_9 = 9, 00053 LED_10 = 10, 00054 /** Used to blink all LEDs on the Xbox controller */ 00055 ALL = 5, 00056 }; 00057 00058 /** Used to set the colors of the Move and PS4 controller. */ 00059 enum ColorsEnum { 00060 /** r = 255, g = 0, b = 0 */ 00061 Red = 0xFF0000, 00062 /** r = 0, g = 255, b = 0 */ 00063 Green = 0xFF00, 00064 /** r = 0, g = 0, b = 255 */ 00065 Blue = 0xFF, 00066 00067 /** r = 255, g = 235, b = 4 */ 00068 Yellow = 0xFFEB04, 00069 /** r = 0, g = 255, b = 255 */ 00070 Lightblue = 0xFFFF, 00071 /** r = 255, g = 0, b = 255 */ 00072 Purple = 0xFF00FF, 00073 Purble = 0xFF00FF, 00074 00075 /** r = 255, g = 255, b = 255 */ 00076 White = 0xFFFFFF, 00077 /** r = 0, g = 0, b = 0 */ 00078 Off = 0x00, 00079 }; 00080 00081 enum RumbleEnum { 00082 RumbleHigh = 0x10, 00083 RumbleLow = 0x20, 00084 }; 00085 00086 /** This enum is used to read all the different buttons on the different controllers */ 00087 enum ButtonEnum { 00088 /**@{*/ 00089 /** These buttons are available on all the the controllers */ 00090 UP = 0, 00091 RIGHT = 1, 00092 DOWN = 2, 00093 LEFT = 3, 00094 /**@}*/ 00095 00096 /**@{*/ 00097 /** Wii buttons */ 00098 PLUS = 5, 00099 TWO = 6, 00100 ONE = 7, 00101 MINUS = 8, 00102 HOME = 9, 00103 Z = 10, 00104 C = 11, 00105 B = 12, 00106 A = 13, 00107 /**@}*/ 00108 00109 /**@{*/ 00110 /** These are only available on the Wii U Pro Controller */ 00111 L = 16, 00112 R = 17, 00113 ZL = 18, 00114 ZR = 19, 00115 /**@}*/ 00116 00117 /**@{*/ 00118 /** PS3 controllers buttons */ 00119 SELECT = 4, 00120 START = 5, 00121 L3 = 6, 00122 R3 = 7, 00123 00124 L2 = 8, 00125 R2 = 9, 00126 L1 = 10, 00127 R1 = 11, 00128 TRIANGLE = 12, 00129 CIRCLE = 13, 00130 CROSS = 14, 00131 SQUARE = 15, 00132 00133 PS = 16, 00134 00135 MOVE = 17, // Covers 12 bits - we only need to read the top 8 00136 T = 18, // Covers 12 bits - we only need to read the top 8 00137 /**@}*/ 00138 00139 /** PS4 controllers buttons - SHARE and OPTIONS are present instead of SELECT and START */ 00140 SHARE = 4, 00141 OPTIONS = 5, 00142 TOUCHPAD = 17, 00143 /**@}*/ 00144 00145 /**@{*/ 00146 /** Xbox buttons */ 00147 BACK = 4, 00148 X = 14, 00149 Y = 15, 00150 XBOX = 16, 00151 SYNC = 17, 00152 BLACK = 8, // Available on the original Xbox controller 00153 WHITE = 9, // Available on the original Xbox controller 00154 /**@}*/ 00155 00156 /** PS Buzz controllers */ 00157 RED = 0, 00158 YELLOW = 1, 00159 GREEN = 2, 00160 ORANGE = 3, 00161 BLUE = 4, 00162 /**@}*/ 00163 }; 00164 00165 /** Joysticks on the PS3 and Xbox controllers. */ 00166 enum AnalogHatEnum { 00167 /** Left joystick x-axis */ 00168 LeftHatX = 0, 00169 /** Left joystick y-axis */ 00170 LeftHatY = 1, 00171 /** Right joystick x-axis */ 00172 RightHatX = 2, 00173 /** Right joystick y-axis */ 00174 RightHatY = 3, 00175 }; 00176 00177 /** 00178 * Sensors inside the Sixaxis Dualshock 3, Move controller and PS4 controller. 00179 * <B>Note:</B> that the location is shifted 9 when it's connected via USB on the PS3 controller. 00180 */ 00181 enum SensorEnum { 00182 /** Accelerometer values */ 00183 aX = 50, aY = 52, aZ = 54, 00184 /** Gyro z-axis */ 00185 gZ = 56, 00186 gX, gY, // These are not available on the PS3 controller 00187 00188 /** Accelerometer x-axis */ 00189 aXmove = 28, 00190 /** Accelerometer z-axis */ 00191 aZmove = 30, 00192 /** Accelerometer y-axis */ 00193 aYmove = 32, 00194 00195 /** Gyro x-axis */ 00196 gXmove = 40, 00197 /** Gyro z-axis */ 00198 gZmove = 42, 00199 /** Gyro y-axis */ 00200 gYmove = 44, 00201 00202 /** Temperature sensor */ 00203 tempMove = 46, 00204 00205 /** Magnetometer x-axis */ 00206 mXmove = 47, 00207 /** Magnetometer z-axis */ 00208 mZmove = 49, 00209 /** Magnetometer y-axis */ 00210 mYmove = 50, 00211 }; 00212 00213 /** Used to get the angle calculated using the PS3 controller and PS4 controller. */ 00214 enum AngleEnum { 00215 Pitch = 0x01, 00216 Roll = 0x02, 00217 }; 00218 00219 #endif
Generated on Tue Jul 12 2022 18:12:04 by
1.7.2