SDL standard library
SDL_gamecontroller.h@0:dda4f4550403, 2016-09-07 (annotated)
- Committer:
- miruga27
- Date:
- Wed Sep 07 18:46:53 2016 +0000
- Revision:
- 0:dda4f4550403
7/09/2016;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
miruga27 | 0:dda4f4550403 | 1 | /* |
miruga27 | 0:dda4f4550403 | 2 | Simple DirectMedia Layer |
miruga27 | 0:dda4f4550403 | 3 | Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org> |
miruga27 | 0:dda4f4550403 | 4 | |
miruga27 | 0:dda4f4550403 | 5 | This software is provided 'as-is', without any express or implied |
miruga27 | 0:dda4f4550403 | 6 | warranty. In no event will the authors be held liable for any damages |
miruga27 | 0:dda4f4550403 | 7 | arising from the use of this software. |
miruga27 | 0:dda4f4550403 | 8 | |
miruga27 | 0:dda4f4550403 | 9 | Permission is granted to anyone to use this software for any purpose, |
miruga27 | 0:dda4f4550403 | 10 | including commercial applications, and to alter it and redistribute it |
miruga27 | 0:dda4f4550403 | 11 | freely, subject to the following restrictions: |
miruga27 | 0:dda4f4550403 | 12 | |
miruga27 | 0:dda4f4550403 | 13 | 1. The origin of this software must not be misrepresented; you must not |
miruga27 | 0:dda4f4550403 | 14 | claim that you wrote the original software. If you use this software |
miruga27 | 0:dda4f4550403 | 15 | in a product, an acknowledgment in the product documentation would be |
miruga27 | 0:dda4f4550403 | 16 | appreciated but is not required. |
miruga27 | 0:dda4f4550403 | 17 | 2. Altered source versions must be plainly marked as such, and must not be |
miruga27 | 0:dda4f4550403 | 18 | misrepresented as being the original software. |
miruga27 | 0:dda4f4550403 | 19 | 3. This notice may not be removed or altered from any source distribution. |
miruga27 | 0:dda4f4550403 | 20 | */ |
miruga27 | 0:dda4f4550403 | 21 | |
miruga27 | 0:dda4f4550403 | 22 | /** |
miruga27 | 0:dda4f4550403 | 23 | * \file SDL_gamecontroller.h |
miruga27 | 0:dda4f4550403 | 24 | * |
miruga27 | 0:dda4f4550403 | 25 | * Include file for SDL game controller event handling |
miruga27 | 0:dda4f4550403 | 26 | */ |
miruga27 | 0:dda4f4550403 | 27 | |
miruga27 | 0:dda4f4550403 | 28 | #ifndef _SDL_gamecontroller_h |
miruga27 | 0:dda4f4550403 | 29 | #define _SDL_gamecontroller_h |
miruga27 | 0:dda4f4550403 | 30 | |
miruga27 | 0:dda4f4550403 | 31 | #include "SDL_stdinc.h" |
miruga27 | 0:dda4f4550403 | 32 | #include "SDL_error.h" |
miruga27 | 0:dda4f4550403 | 33 | #include "SDL_rwops.h" |
miruga27 | 0:dda4f4550403 | 34 | #include "SDL_joystick.h" |
miruga27 | 0:dda4f4550403 | 35 | |
miruga27 | 0:dda4f4550403 | 36 | #include "begin_code.h" |
miruga27 | 0:dda4f4550403 | 37 | /* Set up for C function definitions, even when using C++ */ |
miruga27 | 0:dda4f4550403 | 38 | #ifdef __cplusplus |
miruga27 | 0:dda4f4550403 | 39 | extern "C" { |
miruga27 | 0:dda4f4550403 | 40 | #endif |
miruga27 | 0:dda4f4550403 | 41 | |
miruga27 | 0:dda4f4550403 | 42 | /** |
miruga27 | 0:dda4f4550403 | 43 | * \file SDL_gamecontroller.h |
miruga27 | 0:dda4f4550403 | 44 | * |
miruga27 | 0:dda4f4550403 | 45 | * In order to use these functions, SDL_Init() must have been called |
miruga27 | 0:dda4f4550403 | 46 | * with the ::SDL_INIT_JOYSTICK flag. This causes SDL to scan the system |
miruga27 | 0:dda4f4550403 | 47 | * for game controllers, and load appropriate drivers. |
miruga27 | 0:dda4f4550403 | 48 | * |
miruga27 | 0:dda4f4550403 | 49 | * If you would like to receive controller updates while the application |
miruga27 | 0:dda4f4550403 | 50 | * is in the background, you should set the following hint before calling |
miruga27 | 0:dda4f4550403 | 51 | * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS |
miruga27 | 0:dda4f4550403 | 52 | */ |
miruga27 | 0:dda4f4550403 | 53 | |
miruga27 | 0:dda4f4550403 | 54 | /* The gamecontroller structure used to identify an SDL game controller */ |
miruga27 | 0:dda4f4550403 | 55 | struct _SDL_GameController; |
miruga27 | 0:dda4f4550403 | 56 | typedef struct _SDL_GameController SDL_GameController; |
miruga27 | 0:dda4f4550403 | 57 | |
miruga27 | 0:dda4f4550403 | 58 | |
miruga27 | 0:dda4f4550403 | 59 | typedef enum |
miruga27 | 0:dda4f4550403 | 60 | { |
miruga27 | 0:dda4f4550403 | 61 | SDL_CONTROLLER_BINDTYPE_NONE = 0, |
miruga27 | 0:dda4f4550403 | 62 | SDL_CONTROLLER_BINDTYPE_BUTTON, |
miruga27 | 0:dda4f4550403 | 63 | SDL_CONTROLLER_BINDTYPE_AXIS, |
miruga27 | 0:dda4f4550403 | 64 | SDL_CONTROLLER_BINDTYPE_HAT |
miruga27 | 0:dda4f4550403 | 65 | } SDL_GameControllerBindType; |
miruga27 | 0:dda4f4550403 | 66 | |
miruga27 | 0:dda4f4550403 | 67 | /** |
miruga27 | 0:dda4f4550403 | 68 | * Get the SDL joystick layer binding for this controller button/axis mapping |
miruga27 | 0:dda4f4550403 | 69 | */ |
miruga27 | 0:dda4f4550403 | 70 | typedef struct SDL_GameControllerButtonBind |
miruga27 | 0:dda4f4550403 | 71 | { |
miruga27 | 0:dda4f4550403 | 72 | SDL_GameControllerBindType bindType; |
miruga27 | 0:dda4f4550403 | 73 | union |
miruga27 | 0:dda4f4550403 | 74 | { |
miruga27 | 0:dda4f4550403 | 75 | int button; |
miruga27 | 0:dda4f4550403 | 76 | int axis; |
miruga27 | 0:dda4f4550403 | 77 | struct { |
miruga27 | 0:dda4f4550403 | 78 | int hat; |
miruga27 | 0:dda4f4550403 | 79 | int hat_mask; |
miruga27 | 0:dda4f4550403 | 80 | } hat; |
miruga27 | 0:dda4f4550403 | 81 | } value; |
miruga27 | 0:dda4f4550403 | 82 | |
miruga27 | 0:dda4f4550403 | 83 | } SDL_GameControllerButtonBind; |
miruga27 | 0:dda4f4550403 | 84 | |
miruga27 | 0:dda4f4550403 | 85 | |
miruga27 | 0:dda4f4550403 | 86 | /** |
miruga27 | 0:dda4f4550403 | 87 | * To count the number of game controllers in the system for the following: |
miruga27 | 0:dda4f4550403 | 88 | * int nJoysticks = SDL_NumJoysticks(); |
miruga27 | 0:dda4f4550403 | 89 | * int nGameControllers = 0; |
miruga27 | 0:dda4f4550403 | 90 | * for ( int i = 0; i < nJoysticks; i++ ) { |
miruga27 | 0:dda4f4550403 | 91 | * if ( SDL_IsGameController(i) ) { |
miruga27 | 0:dda4f4550403 | 92 | * nGameControllers++; |
miruga27 | 0:dda4f4550403 | 93 | * } |
miruga27 | 0:dda4f4550403 | 94 | * } |
miruga27 | 0:dda4f4550403 | 95 | * |
miruga27 | 0:dda4f4550403 | 96 | * Using the SDL_HINT_GAMECONTROLLERCONFIG hint or the SDL_GameControllerAddMapping you can add support for controllers SDL is unaware of or cause an existing controller to have a different binding. The format is: |
miruga27 | 0:dda4f4550403 | 97 | * guid,name,mappings |
miruga27 | 0:dda4f4550403 | 98 | * |
miruga27 | 0:dda4f4550403 | 99 | * Where GUID is the string value from SDL_JoystickGetGUIDString(), name is the human readable string for the device and mappings are controller mappings to joystick ones. |
miruga27 | 0:dda4f4550403 | 100 | * Under Windows there is a reserved GUID of "xinput" that covers any XInput devices. |
miruga27 | 0:dda4f4550403 | 101 | * The mapping format for joystick is: |
miruga27 | 0:dda4f4550403 | 102 | * bX - a joystick button, index X |
miruga27 | 0:dda4f4550403 | 103 | * hX.Y - hat X with value Y |
miruga27 | 0:dda4f4550403 | 104 | * aX - axis X of the joystick |
miruga27 | 0:dda4f4550403 | 105 | * Buttons can be used as a controller axis and vice versa. |
miruga27 | 0:dda4f4550403 | 106 | * |
miruga27 | 0:dda4f4550403 | 107 | * This string shows an example of a valid mapping for a controller |
miruga27 | 0:dda4f4550403 | 108 | * "341a3608000000000000504944564944,Afterglow PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7", |
miruga27 | 0:dda4f4550403 | 109 | * |
miruga27 | 0:dda4f4550403 | 110 | */ |
miruga27 | 0:dda4f4550403 | 111 | |
miruga27 | 0:dda4f4550403 | 112 | /** |
miruga27 | 0:dda4f4550403 | 113 | * Load a set of mappings from a seekable SDL data stream (memory or file), filtered by the current SDL_GetPlatform() |
miruga27 | 0:dda4f4550403 | 114 | * A community sourced database of controllers is available at https://raw.github.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt |
miruga27 | 0:dda4f4550403 | 115 | * |
miruga27 | 0:dda4f4550403 | 116 | * If \c freerw is non-zero, the stream will be closed after being read. |
miruga27 | 0:dda4f4550403 | 117 | * |
miruga27 | 0:dda4f4550403 | 118 | * \return number of mappings added, -1 on error |
miruga27 | 0:dda4f4550403 | 119 | */ |
miruga27 | 0:dda4f4550403 | 120 | extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW( SDL_RWops * rw, int freerw ); |
miruga27 | 0:dda4f4550403 | 121 | |
miruga27 | 0:dda4f4550403 | 122 | /** |
miruga27 | 0:dda4f4550403 | 123 | * Load a set of mappings from a file, filtered by the current SDL_GetPlatform() |
miruga27 | 0:dda4f4550403 | 124 | * |
miruga27 | 0:dda4f4550403 | 125 | * Convenience macro. |
miruga27 | 0:dda4f4550403 | 126 | */ |
miruga27 | 0:dda4f4550403 | 127 | #define SDL_GameControllerAddMappingsFromFile(file) SDL_GameControllerAddMappingsFromRW(SDL_RWFromFile(file, "rb"), 1) |
miruga27 | 0:dda4f4550403 | 128 | |
miruga27 | 0:dda4f4550403 | 129 | /** |
miruga27 | 0:dda4f4550403 | 130 | * Add or update an existing mapping configuration |
miruga27 | 0:dda4f4550403 | 131 | * |
miruga27 | 0:dda4f4550403 | 132 | * \return 1 if mapping is added, 0 if updated, -1 on error |
miruga27 | 0:dda4f4550403 | 133 | */ |
miruga27 | 0:dda4f4550403 | 134 | extern DECLSPEC int SDLCALL SDL_GameControllerAddMapping( const char* mappingString ); |
miruga27 | 0:dda4f4550403 | 135 | |
miruga27 | 0:dda4f4550403 | 136 | /** |
miruga27 | 0:dda4f4550403 | 137 | * Get a mapping string for a GUID |
miruga27 | 0:dda4f4550403 | 138 | * |
miruga27 | 0:dda4f4550403 | 139 | * \return the mapping string. Must be freed with SDL_free. Returns NULL if no mapping is available |
miruga27 | 0:dda4f4550403 | 140 | */ |
miruga27 | 0:dda4f4550403 | 141 | extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForGUID( SDL_JoystickGUID guid ); |
miruga27 | 0:dda4f4550403 | 142 | |
miruga27 | 0:dda4f4550403 | 143 | /** |
miruga27 | 0:dda4f4550403 | 144 | * Get a mapping string for an open GameController |
miruga27 | 0:dda4f4550403 | 145 | * |
miruga27 | 0:dda4f4550403 | 146 | * \return the mapping string. Must be freed with SDL_free. Returns NULL if no mapping is available |
miruga27 | 0:dda4f4550403 | 147 | */ |
miruga27 | 0:dda4f4550403 | 148 | extern DECLSPEC char * SDLCALL SDL_GameControllerMapping( SDL_GameController * gamecontroller ); |
miruga27 | 0:dda4f4550403 | 149 | |
miruga27 | 0:dda4f4550403 | 150 | /** |
miruga27 | 0:dda4f4550403 | 151 | * Is the joystick on this index supported by the game controller interface? |
miruga27 | 0:dda4f4550403 | 152 | */ |
miruga27 | 0:dda4f4550403 | 153 | extern DECLSPEC SDL_bool SDLCALL SDL_IsGameController(int joystick_index); |
miruga27 | 0:dda4f4550403 | 154 | |
miruga27 | 0:dda4f4550403 | 155 | |
miruga27 | 0:dda4f4550403 | 156 | /** |
miruga27 | 0:dda4f4550403 | 157 | * Get the implementation dependent name of a game controller. |
miruga27 | 0:dda4f4550403 | 158 | * This can be called before any controllers are opened. |
miruga27 | 0:dda4f4550403 | 159 | * If no name can be found, this function returns NULL. |
miruga27 | 0:dda4f4550403 | 160 | */ |
miruga27 | 0:dda4f4550403 | 161 | extern DECLSPEC const char *SDLCALL SDL_GameControllerNameForIndex(int joystick_index); |
miruga27 | 0:dda4f4550403 | 162 | |
miruga27 | 0:dda4f4550403 | 163 | /** |
miruga27 | 0:dda4f4550403 | 164 | * Open a game controller for use. |
miruga27 | 0:dda4f4550403 | 165 | * The index passed as an argument refers to the N'th game controller on the system. |
miruga27 | 0:dda4f4550403 | 166 | * This index is the value which will identify this controller in future controller |
miruga27 | 0:dda4f4550403 | 167 | * events. |
miruga27 | 0:dda4f4550403 | 168 | * |
miruga27 | 0:dda4f4550403 | 169 | * \return A controller identifier, or NULL if an error occurred. |
miruga27 | 0:dda4f4550403 | 170 | */ |
miruga27 | 0:dda4f4550403 | 171 | extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerOpen(int joystick_index); |
miruga27 | 0:dda4f4550403 | 172 | |
miruga27 | 0:dda4f4550403 | 173 | /** |
miruga27 | 0:dda4f4550403 | 174 | * Return the name for this currently opened controller |
miruga27 | 0:dda4f4550403 | 175 | */ |
miruga27 | 0:dda4f4550403 | 176 | extern DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController *gamecontroller); |
miruga27 | 0:dda4f4550403 | 177 | |
miruga27 | 0:dda4f4550403 | 178 | /** |
miruga27 | 0:dda4f4550403 | 179 | * Returns SDL_TRUE if the controller has been opened and currently connected, |
miruga27 | 0:dda4f4550403 | 180 | * or SDL_FALSE if it has not. |
miruga27 | 0:dda4f4550403 | 181 | */ |
miruga27 | 0:dda4f4550403 | 182 | extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerGetAttached(SDL_GameController *gamecontroller); |
miruga27 | 0:dda4f4550403 | 183 | |
miruga27 | 0:dda4f4550403 | 184 | /** |
miruga27 | 0:dda4f4550403 | 185 | * Get the underlying joystick object used by a controller |
miruga27 | 0:dda4f4550403 | 186 | */ |
miruga27 | 0:dda4f4550403 | 187 | extern DECLSPEC SDL_Joystick *SDLCALL SDL_GameControllerGetJoystick(SDL_GameController *gamecontroller); |
miruga27 | 0:dda4f4550403 | 188 | |
miruga27 | 0:dda4f4550403 | 189 | /** |
miruga27 | 0:dda4f4550403 | 190 | * Enable/disable controller event polling. |
miruga27 | 0:dda4f4550403 | 191 | * |
miruga27 | 0:dda4f4550403 | 192 | * If controller events are disabled, you must call SDL_GameControllerUpdate() |
miruga27 | 0:dda4f4550403 | 193 | * yourself and check the state of the controller when you want controller |
miruga27 | 0:dda4f4550403 | 194 | * information. |
miruga27 | 0:dda4f4550403 | 195 | * |
miruga27 | 0:dda4f4550403 | 196 | * The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE. |
miruga27 | 0:dda4f4550403 | 197 | */ |
miruga27 | 0:dda4f4550403 | 198 | extern DECLSPEC int SDLCALL SDL_GameControllerEventState(int state); |
miruga27 | 0:dda4f4550403 | 199 | |
miruga27 | 0:dda4f4550403 | 200 | /** |
miruga27 | 0:dda4f4550403 | 201 | * Update the current state of the open game controllers. |
miruga27 | 0:dda4f4550403 | 202 | * |
miruga27 | 0:dda4f4550403 | 203 | * This is called automatically by the event loop if any game controller |
miruga27 | 0:dda4f4550403 | 204 | * events are enabled. |
miruga27 | 0:dda4f4550403 | 205 | */ |
miruga27 | 0:dda4f4550403 | 206 | extern DECLSPEC void SDLCALL SDL_GameControllerUpdate(void); |
miruga27 | 0:dda4f4550403 | 207 | |
miruga27 | 0:dda4f4550403 | 208 | |
miruga27 | 0:dda4f4550403 | 209 | /** |
miruga27 | 0:dda4f4550403 | 210 | * The list of axes available from a controller |
miruga27 | 0:dda4f4550403 | 211 | */ |
miruga27 | 0:dda4f4550403 | 212 | typedef enum |
miruga27 | 0:dda4f4550403 | 213 | { |
miruga27 | 0:dda4f4550403 | 214 | SDL_CONTROLLER_AXIS_INVALID = -1, |
miruga27 | 0:dda4f4550403 | 215 | SDL_CONTROLLER_AXIS_LEFTX, |
miruga27 | 0:dda4f4550403 | 216 | SDL_CONTROLLER_AXIS_LEFTY, |
miruga27 | 0:dda4f4550403 | 217 | SDL_CONTROLLER_AXIS_RIGHTX, |
miruga27 | 0:dda4f4550403 | 218 | SDL_CONTROLLER_AXIS_RIGHTY, |
miruga27 | 0:dda4f4550403 | 219 | SDL_CONTROLLER_AXIS_TRIGGERLEFT, |
miruga27 | 0:dda4f4550403 | 220 | SDL_CONTROLLER_AXIS_TRIGGERRIGHT, |
miruga27 | 0:dda4f4550403 | 221 | SDL_CONTROLLER_AXIS_MAX |
miruga27 | 0:dda4f4550403 | 222 | } SDL_GameControllerAxis; |
miruga27 | 0:dda4f4550403 | 223 | |
miruga27 | 0:dda4f4550403 | 224 | /** |
miruga27 | 0:dda4f4550403 | 225 | * turn this string into a axis mapping |
miruga27 | 0:dda4f4550403 | 226 | */ |
miruga27 | 0:dda4f4550403 | 227 | extern DECLSPEC SDL_GameControllerAxis SDLCALL SDL_GameControllerGetAxisFromString(const char *pchString); |
miruga27 | 0:dda4f4550403 | 228 | |
miruga27 | 0:dda4f4550403 | 229 | /** |
miruga27 | 0:dda4f4550403 | 230 | * turn this axis enum into a string mapping |
miruga27 | 0:dda4f4550403 | 231 | */ |
miruga27 | 0:dda4f4550403 | 232 | extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForAxis(SDL_GameControllerAxis axis); |
miruga27 | 0:dda4f4550403 | 233 | |
miruga27 | 0:dda4f4550403 | 234 | /** |
miruga27 | 0:dda4f4550403 | 235 | * Get the SDL joystick layer binding for this controller button mapping |
miruga27 | 0:dda4f4550403 | 236 | */ |
miruga27 | 0:dda4f4550403 | 237 | extern DECLSPEC SDL_GameControllerButtonBind SDLCALL |
miruga27 | 0:dda4f4550403 | 238 | SDL_GameControllerGetBindForAxis(SDL_GameController *gamecontroller, |
miruga27 | 0:dda4f4550403 | 239 | SDL_GameControllerAxis axis); |
miruga27 | 0:dda4f4550403 | 240 | |
miruga27 | 0:dda4f4550403 | 241 | /** |
miruga27 | 0:dda4f4550403 | 242 | * Get the current state of an axis control on a game controller. |
miruga27 | 0:dda4f4550403 | 243 | * |
miruga27 | 0:dda4f4550403 | 244 | * The state is a value ranging from -32768 to 32767. |
miruga27 | 0:dda4f4550403 | 245 | * |
miruga27 | 0:dda4f4550403 | 246 | * The axis indices start at index 0. |
miruga27 | 0:dda4f4550403 | 247 | */ |
miruga27 | 0:dda4f4550403 | 248 | extern DECLSPEC Sint16 SDLCALL |
miruga27 | 0:dda4f4550403 | 249 | SDL_GameControllerGetAxis(SDL_GameController *gamecontroller, |
miruga27 | 0:dda4f4550403 | 250 | SDL_GameControllerAxis axis); |
miruga27 | 0:dda4f4550403 | 251 | |
miruga27 | 0:dda4f4550403 | 252 | /** |
miruga27 | 0:dda4f4550403 | 253 | * The list of buttons available from a controller |
miruga27 | 0:dda4f4550403 | 254 | */ |
miruga27 | 0:dda4f4550403 | 255 | typedef enum |
miruga27 | 0:dda4f4550403 | 256 | { |
miruga27 | 0:dda4f4550403 | 257 | SDL_CONTROLLER_BUTTON_INVALID = -1, |
miruga27 | 0:dda4f4550403 | 258 | SDL_CONTROLLER_BUTTON_A, |
miruga27 | 0:dda4f4550403 | 259 | SDL_CONTROLLER_BUTTON_B, |
miruga27 | 0:dda4f4550403 | 260 | SDL_CONTROLLER_BUTTON_X, |
miruga27 | 0:dda4f4550403 | 261 | SDL_CONTROLLER_BUTTON_Y, |
miruga27 | 0:dda4f4550403 | 262 | SDL_CONTROLLER_BUTTON_BACK, |
miruga27 | 0:dda4f4550403 | 263 | SDL_CONTROLLER_BUTTON_GUIDE, |
miruga27 | 0:dda4f4550403 | 264 | SDL_CONTROLLER_BUTTON_START, |
miruga27 | 0:dda4f4550403 | 265 | SDL_CONTROLLER_BUTTON_LEFTSTICK, |
miruga27 | 0:dda4f4550403 | 266 | SDL_CONTROLLER_BUTTON_RIGHTSTICK, |
miruga27 | 0:dda4f4550403 | 267 | SDL_CONTROLLER_BUTTON_LEFTSHOULDER, |
miruga27 | 0:dda4f4550403 | 268 | SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, |
miruga27 | 0:dda4f4550403 | 269 | SDL_CONTROLLER_BUTTON_DPAD_UP, |
miruga27 | 0:dda4f4550403 | 270 | SDL_CONTROLLER_BUTTON_DPAD_DOWN, |
miruga27 | 0:dda4f4550403 | 271 | SDL_CONTROLLER_BUTTON_DPAD_LEFT, |
miruga27 | 0:dda4f4550403 | 272 | SDL_CONTROLLER_BUTTON_DPAD_RIGHT, |
miruga27 | 0:dda4f4550403 | 273 | SDL_CONTROLLER_BUTTON_MAX |
miruga27 | 0:dda4f4550403 | 274 | } SDL_GameControllerButton; |
miruga27 | 0:dda4f4550403 | 275 | |
miruga27 | 0:dda4f4550403 | 276 | /** |
miruga27 | 0:dda4f4550403 | 277 | * turn this string into a button mapping |
miruga27 | 0:dda4f4550403 | 278 | */ |
miruga27 | 0:dda4f4550403 | 279 | extern DECLSPEC SDL_GameControllerButton SDLCALL SDL_GameControllerGetButtonFromString(const char *pchString); |
miruga27 | 0:dda4f4550403 | 280 | |
miruga27 | 0:dda4f4550403 | 281 | /** |
miruga27 | 0:dda4f4550403 | 282 | * turn this button enum into a string mapping |
miruga27 | 0:dda4f4550403 | 283 | */ |
miruga27 | 0:dda4f4550403 | 284 | extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForButton(SDL_GameControllerButton button); |
miruga27 | 0:dda4f4550403 | 285 | |
miruga27 | 0:dda4f4550403 | 286 | /** |
miruga27 | 0:dda4f4550403 | 287 | * Get the SDL joystick layer binding for this controller button mapping |
miruga27 | 0:dda4f4550403 | 288 | */ |
miruga27 | 0:dda4f4550403 | 289 | extern DECLSPEC SDL_GameControllerButtonBind SDLCALL |
miruga27 | 0:dda4f4550403 | 290 | SDL_GameControllerGetBindForButton(SDL_GameController *gamecontroller, |
miruga27 | 0:dda4f4550403 | 291 | SDL_GameControllerButton button); |
miruga27 | 0:dda4f4550403 | 292 | |
miruga27 | 0:dda4f4550403 | 293 | |
miruga27 | 0:dda4f4550403 | 294 | /** |
miruga27 | 0:dda4f4550403 | 295 | * Get the current state of a button on a game controller. |
miruga27 | 0:dda4f4550403 | 296 | * |
miruga27 | 0:dda4f4550403 | 297 | * The button indices start at index 0. |
miruga27 | 0:dda4f4550403 | 298 | */ |
miruga27 | 0:dda4f4550403 | 299 | extern DECLSPEC Uint8 SDLCALL SDL_GameControllerGetButton(SDL_GameController *gamecontroller, |
miruga27 | 0:dda4f4550403 | 300 | SDL_GameControllerButton button); |
miruga27 | 0:dda4f4550403 | 301 | |
miruga27 | 0:dda4f4550403 | 302 | /** |
miruga27 | 0:dda4f4550403 | 303 | * Close a controller previously opened with SDL_GameControllerOpen(). |
miruga27 | 0:dda4f4550403 | 304 | */ |
miruga27 | 0:dda4f4550403 | 305 | extern DECLSPEC void SDLCALL SDL_GameControllerClose(SDL_GameController *gamecontroller); |
miruga27 | 0:dda4f4550403 | 306 | |
miruga27 | 0:dda4f4550403 | 307 | |
miruga27 | 0:dda4f4550403 | 308 | /* Ends C function definitions when using C++ */ |
miruga27 | 0:dda4f4550403 | 309 | #ifdef __cplusplus |
miruga27 | 0:dda4f4550403 | 310 | } |
miruga27 | 0:dda4f4550403 | 311 | #endif |
miruga27 | 0:dda4f4550403 | 312 | #include "close_code.h" |
miruga27 | 0:dda4f4550403 | 313 | |
miruga27 | 0:dda4f4550403 | 314 | #endif /* _SDL_gamecontroller_h */ |
miruga27 | 0:dda4f4550403 | 315 | |
miruga27 | 0:dda4f4550403 | 316 | /* vi: set ts=4 sw=4 expandtab: */ |