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