| 1 | /* |
| 2 | Simple DirectMedia Layer |
| 3 | Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org> |
| 4 | |
| 5 | This software is provided 'as-is', without any express or implied |
| 6 | warranty. In no event will the authors be held liable for any damages |
| 7 | arising from the use of this software. |
| 8 | |
| 9 | Permission is granted to anyone to use this software for any purpose, |
| 10 | including commercial applications, and to alter it and redistribute it |
| 11 | freely, subject to the following restrictions: |
| 12 | |
| 13 | 1. The origin of this software must not be misrepresented; you must not |
| 14 | claim that you wrote the original software. If you use this software |
| 15 | in a product, an acknowledgment in the product documentation would be |
| 16 | appreciated but is not required. |
| 17 | 2. Altered source versions must be plainly marked as such, and must not be |
| 18 | misrepresented as being the original software. |
| 19 | 3. This notice may not be removed or altered from any source distribution. |
| 20 | */ |
| 21 | |
| 22 | /** |
| 23 | * # CategoryGamepad |
| 24 | * |
| 25 | * SDL provides a low-level joystick API, which just treats joysticks as an |
| 26 | * arbitrary pile of buttons, axes, and hat switches. If you're planning to |
| 27 | * write your own control configuration screen, this can give you a lot of |
| 28 | * flexibility, but that's a lot of work, and most things that we consider |
| 29 | * "joysticks" now are actually console-style gamepads. So SDL provides the |
| 30 | * gamepad API on top of the lower-level joystick functionality. |
| 31 | * |
| 32 | * The difference between a joystick and a gamepad is that a gamepad tells you |
| 33 | * _where_ a button or axis is on the device. You don't speak to gamepads in |
| 34 | * terms of arbitrary numbers like "button 3" or "axis 2" but in standard |
| 35 | * locations: the d-pad, the shoulder buttons, triggers, A/B/X/Y (or |
| 36 | * X/O/Square/Triangle, if you will). |
| 37 | * |
| 38 | * One turns a joystick into a gamepad by providing a magic configuration |
| 39 | * string, which tells SDL the details of a specific device: when you see this |
| 40 | * specific hardware, if button 2 gets pressed, this is actually D-Pad Up, |
| 41 | * etc. |
| 42 | * |
| 43 | * SDL has many popular controllers configured out of the box, and users can |
| 44 | * add their own controller details through an environment variable if it's |
| 45 | * otherwise unknown to SDL. |
| 46 | * |
| 47 | * In order to use these functions, SDL_Init() must have been called with the |
| 48 | * SDL_INIT_GAMEPAD flag. This causes SDL to scan the system for gamepads, and |
| 49 | * load appropriate drivers. |
| 50 | * |
| 51 | * If you would like to receive gamepad updates while the application is in |
| 52 | * the background, you should set the following hint before calling |
| 53 | * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS |
| 54 | * |
| 55 | * Gamepads support various optional features such as rumble, color LEDs, |
| 56 | * touchpad, gyro, etc. The support for these features varies depending on the |
| 57 | * controller and OS support available. You can check for LED and rumble |
| 58 | * capabilities at runtime by calling SDL_GetGamepadProperties() and checking |
| 59 | * the various capability properties. You can check for touchpad by calling |
| 60 | * SDL_GetNumGamepadTouchpads() and check for gyro and accelerometer by |
| 61 | * calling SDL_GamepadHasSensor(). |
| 62 | * |
| 63 | * By default SDL will try to use the most capable driver available, but you |
| 64 | * can tune which OS drivers to use with the various joystick hints in |
| 65 | * SDL_hints.h. |
| 66 | * |
| 67 | * Your application should always support gamepad hotplugging. On some |
| 68 | * platforms like Xbox, Steam Deck, etc., this is a requirement for |
| 69 | * certification. On other platforms, like macOS and Windows when using |
| 70 | * Windows.Gaming.Input, controllers may not be available at startup and will |
| 71 | * come in at some point after you've started processing events. |
| 72 | */ |
| 73 | |
| 74 | #ifndef SDL_gamepad_h_ |
| 75 | #define SDL_gamepad_h_ |
| 76 | |
| 77 | #include <SDL3/SDL_stdinc.h> |
| 78 | #include <SDL3/SDL_error.h> |
| 79 | #include <SDL3/SDL_guid.h> |
| 80 | #include <SDL3/SDL_iostream.h> |
| 81 | #include <SDL3/SDL_joystick.h> |
| 82 | #include <SDL3/SDL_power.h> |
| 83 | #include <SDL3/SDL_properties.h> |
| 84 | #include <SDL3/SDL_sensor.h> |
| 85 | |
| 86 | #include <SDL3/SDL_begin_code.h> |
| 87 | /* Set up for C function definitions, even when using C++ */ |
| 88 | #ifdef __cplusplus |
| 89 | extern "C" { |
| 90 | #endif |
| 91 | |
| 92 | /** |
| 93 | * The structure used to identify an SDL gamepad |
| 94 | * |
| 95 | * \since This struct is available since SDL 3.2.0. |
| 96 | */ |
| 97 | typedef struct SDL_Gamepad SDL_Gamepad; |
| 98 | |
| 99 | /** |
| 100 | * Standard gamepad types. |
| 101 | * |
| 102 | * This type does not necessarily map to first-party controllers from |
| 103 | * Microsoft/Sony/Nintendo; in many cases, third-party controllers can report |
| 104 | * as these, either because they were designed for a specific console, or they |
| 105 | * simply most closely match that console's controllers (does it have A/B/X/Y |
| 106 | * buttons or X/O/Square/Triangle? Does it have a touchpad? etc). |
| 107 | */ |
| 108 | typedef enum SDL_GamepadType |
| 109 | { |
| 110 | SDL_GAMEPAD_TYPE_UNKNOWN = 0, |
| 111 | SDL_GAMEPAD_TYPE_STANDARD, |
| 112 | SDL_GAMEPAD_TYPE_XBOX360, |
| 113 | SDL_GAMEPAD_TYPE_XBOXONE, |
| 114 | SDL_GAMEPAD_TYPE_PS3, |
| 115 | SDL_GAMEPAD_TYPE_PS4, |
| 116 | SDL_GAMEPAD_TYPE_PS5, |
| 117 | SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO, |
| 118 | SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT, |
| 119 | SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT, |
| 120 | SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR, |
| 121 | SDL_GAMEPAD_TYPE_COUNT |
| 122 | } SDL_GamepadType; |
| 123 | |
| 124 | /** |
| 125 | * The list of buttons available on a gamepad |
| 126 | * |
| 127 | * For controllers that use a diamond pattern for the face buttons, the |
| 128 | * south/east/west/north buttons below correspond to the locations in the |
| 129 | * diamond pattern. For Xbox controllers, this would be A/B/X/Y, for Nintendo |
| 130 | * Switch controllers, this would be B/A/Y/X, for PlayStation controllers this |
| 131 | * would be Cross/Circle/Square/Triangle. |
| 132 | * |
| 133 | * For controllers that don't use a diamond pattern for the face buttons, the |
| 134 | * south/east/west/north buttons indicate the buttons labeled A, B, C, D, or |
| 135 | * 1, 2, 3, 4, or for controllers that aren't labeled, they are the primary, |
| 136 | * secondary, etc. buttons. |
| 137 | * |
| 138 | * The activate action is often the south button and the cancel action is |
| 139 | * often the east button, but in some regions this is reversed, so your game |
| 140 | * should allow remapping actions based on user preferences. |
| 141 | * |
| 142 | * You can query the labels for the face buttons using |
| 143 | * SDL_GetGamepadButtonLabel() |
| 144 | * |
| 145 | * \since This enum is available since SDL 3.2.0. |
| 146 | */ |
| 147 | typedef enum SDL_GamepadButton |
| 148 | { |
| 149 | SDL_GAMEPAD_BUTTON_INVALID = -1, |
| 150 | SDL_GAMEPAD_BUTTON_SOUTH, /**< Bottom face button (e.g. Xbox A button) */ |
| 151 | SDL_GAMEPAD_BUTTON_EAST, /**< Right face button (e.g. Xbox B button) */ |
| 152 | SDL_GAMEPAD_BUTTON_WEST, /**< Left face button (e.g. Xbox X button) */ |
| 153 | SDL_GAMEPAD_BUTTON_NORTH, /**< Top face button (e.g. Xbox Y button) */ |
| 154 | SDL_GAMEPAD_BUTTON_BACK, |
| 155 | SDL_GAMEPAD_BUTTON_GUIDE, |
| 156 | SDL_GAMEPAD_BUTTON_START, |
| 157 | SDL_GAMEPAD_BUTTON_LEFT_STICK, |
| 158 | SDL_GAMEPAD_BUTTON_RIGHT_STICK, |
| 159 | SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, |
| 160 | SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, |
| 161 | SDL_GAMEPAD_BUTTON_DPAD_UP, |
| 162 | SDL_GAMEPAD_BUTTON_DPAD_DOWN, |
| 163 | SDL_GAMEPAD_BUTTON_DPAD_LEFT, |
| 164 | SDL_GAMEPAD_BUTTON_DPAD_RIGHT, |
| 165 | SDL_GAMEPAD_BUTTON_MISC1, /**< Additional button (e.g. Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button, Google Stadia capture button) */ |
| 166 | SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1, /**< Upper or primary paddle, under your right hand (e.g. Xbox Elite paddle P1) */ |
| 167 | SDL_GAMEPAD_BUTTON_LEFT_PADDLE1, /**< Upper or primary paddle, under your left hand (e.g. Xbox Elite paddle P3) */ |
| 168 | SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2, /**< Lower or secondary paddle, under your right hand (e.g. Xbox Elite paddle P2) */ |
| 169 | SDL_GAMEPAD_BUTTON_LEFT_PADDLE2, /**< Lower or secondary paddle, under your left hand (e.g. Xbox Elite paddle P4) */ |
| 170 | SDL_GAMEPAD_BUTTON_TOUCHPAD, /**< PS4/PS5 touchpad button */ |
| 171 | SDL_GAMEPAD_BUTTON_MISC2, /**< Additional button */ |
| 172 | SDL_GAMEPAD_BUTTON_MISC3, /**< Additional button */ |
| 173 | SDL_GAMEPAD_BUTTON_MISC4, /**< Additional button */ |
| 174 | SDL_GAMEPAD_BUTTON_MISC5, /**< Additional button */ |
| 175 | SDL_GAMEPAD_BUTTON_MISC6, /**< Additional button */ |
| 176 | SDL_GAMEPAD_BUTTON_COUNT |
| 177 | } SDL_GamepadButton; |
| 178 | |
| 179 | /** |
| 180 | * The set of gamepad button labels |
| 181 | * |
| 182 | * This isn't a complete set, just the face buttons to make it easy to show |
| 183 | * button prompts. |
| 184 | * |
| 185 | * For a complete set, you should look at the button and gamepad type and have |
| 186 | * a set of symbols that work well with your art style. |
| 187 | * |
| 188 | * \since This enum is available since SDL 3.2.0. |
| 189 | */ |
| 190 | typedef enum SDL_GamepadButtonLabel |
| 191 | { |
| 192 | SDL_GAMEPAD_BUTTON_LABEL_UNKNOWN, |
| 193 | SDL_GAMEPAD_BUTTON_LABEL_A, |
| 194 | SDL_GAMEPAD_BUTTON_LABEL_B, |
| 195 | SDL_GAMEPAD_BUTTON_LABEL_X, |
| 196 | SDL_GAMEPAD_BUTTON_LABEL_Y, |
| 197 | SDL_GAMEPAD_BUTTON_LABEL_CROSS, |
| 198 | SDL_GAMEPAD_BUTTON_LABEL_CIRCLE, |
| 199 | SDL_GAMEPAD_BUTTON_LABEL_SQUARE, |
| 200 | SDL_GAMEPAD_BUTTON_LABEL_TRIANGLE |
| 201 | } SDL_GamepadButtonLabel; |
| 202 | |
| 203 | /** |
| 204 | * The list of axes available on a gamepad |
| 205 | * |
| 206 | * Thumbstick axis values range from SDL_JOYSTICK_AXIS_MIN to |
| 207 | * SDL_JOYSTICK_AXIS_MAX, and are centered within ~8000 of zero, though |
| 208 | * advanced UI will allow users to set or autodetect the dead zone, which |
| 209 | * varies between gamepads. |
| 210 | * |
| 211 | * Trigger axis values range from 0 (released) to SDL_JOYSTICK_AXIS_MAX (fully |
| 212 | * pressed) when reported by SDL_GetGamepadAxis(). Note that this is not the |
| 213 | * same range that will be reported by the lower-level SDL_GetJoystickAxis(). |
| 214 | * |
| 215 | * \since This enum is available since SDL 3.2.0. |
| 216 | */ |
| 217 | typedef enum SDL_GamepadAxis |
| 218 | { |
| 219 | SDL_GAMEPAD_AXIS_INVALID = -1, |
| 220 | SDL_GAMEPAD_AXIS_LEFTX, |
| 221 | SDL_GAMEPAD_AXIS_LEFTY, |
| 222 | SDL_GAMEPAD_AXIS_RIGHTX, |
| 223 | SDL_GAMEPAD_AXIS_RIGHTY, |
| 224 | SDL_GAMEPAD_AXIS_LEFT_TRIGGER, |
| 225 | SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, |
| 226 | SDL_GAMEPAD_AXIS_COUNT |
| 227 | } SDL_GamepadAxis; |
| 228 | |
| 229 | /** |
| 230 | * Types of gamepad control bindings. |
| 231 | * |
| 232 | * A gamepad is a collection of bindings that map arbitrary joystick buttons, |
| 233 | * axes and hat switches to specific positions on a generic console-style |
| 234 | * gamepad. This enum is used as part of SDL_GamepadBinding to specify those |
| 235 | * mappings. |
| 236 | * |
| 237 | * \since This enum is available since SDL 3.2.0. |
| 238 | */ |
| 239 | typedef enum SDL_GamepadBindingType |
| 240 | { |
| 241 | SDL_GAMEPAD_BINDTYPE_NONE = 0, |
| 242 | SDL_GAMEPAD_BINDTYPE_BUTTON, |
| 243 | SDL_GAMEPAD_BINDTYPE_AXIS, |
| 244 | SDL_GAMEPAD_BINDTYPE_HAT |
| 245 | } SDL_GamepadBindingType; |
| 246 | |
| 247 | /** |
| 248 | * A mapping between one joystick input to a gamepad control. |
| 249 | * |
| 250 | * A gamepad has a collection of several bindings, to say, for example, when |
| 251 | * joystick button number 5 is pressed, that should be treated like the |
| 252 | * gamepad's "start" button. |
| 253 | * |
| 254 | * SDL has these bindings built-in for many popular controllers, and can add |
| 255 | * more with a simple text string. Those strings are parsed into a collection |
| 256 | * of these structs to make it easier to operate on the data. |
| 257 | * |
| 258 | * \since This struct is available since SDL 3.2.0. |
| 259 | * |
| 260 | * \sa SDL_GetGamepadBindings |
| 261 | */ |
| 262 | typedef struct SDL_GamepadBinding |
| 263 | { |
| 264 | SDL_GamepadBindingType input_type; |
| 265 | union |
| 266 | { |
| 267 | int button; |
| 268 | |
| 269 | struct |
| 270 | { |
| 271 | int axis; |
| 272 | int axis_min; |
| 273 | int axis_max; |
| 274 | } axis; |
| 275 | |
| 276 | struct |
| 277 | { |
| 278 | int hat; |
| 279 | int hat_mask; |
| 280 | } hat; |
| 281 | |
| 282 | } input; |
| 283 | |
| 284 | SDL_GamepadBindingType output_type; |
| 285 | union |
| 286 | { |
| 287 | SDL_GamepadButton button; |
| 288 | |
| 289 | struct |
| 290 | { |
| 291 | SDL_GamepadAxis axis; |
| 292 | int axis_min; |
| 293 | int axis_max; |
| 294 | } axis; |
| 295 | |
| 296 | } output; |
| 297 | } SDL_GamepadBinding; |
| 298 | |
| 299 | |
| 300 | /** |
| 301 | * Add support for gamepads that SDL is unaware of or change the binding of an |
| 302 | * existing gamepad. |
| 303 | * |
| 304 | * The mapping string has the format "GUID,name,mapping", where GUID is the |
| 305 | * string value from SDL_GUIDToString(), name is the human readable string for |
| 306 | * the device and mappings are gamepad mappings to joystick ones. Under |
| 307 | * Windows there is a reserved GUID of "xinput" that covers all XInput |
| 308 | * devices. The mapping format for joystick is: |
| 309 | * |
| 310 | * - `bX`: a joystick button, index X |
| 311 | * - `hX.Y`: hat X with value Y |
| 312 | * - `aX`: axis X of the joystick |
| 313 | * |
| 314 | * Buttons can be used as a gamepad axes and vice versa. |
| 315 | * |
| 316 | * If a device with this GUID is already plugged in, SDL will generate an |
| 317 | * SDL_EVENT_GAMEPAD_ADDED event. |
| 318 | * |
| 319 | * This string shows an example of a valid mapping for a gamepad: |
| 320 | * |
| 321 | * ```c |
| 322 | * "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" |
| 323 | * ``` |
| 324 | * |
| 325 | * \param mapping the mapping string. |
| 326 | * \returns 1 if a new mapping is added, 0 if an existing mapping is updated, |
| 327 | * -1 on failure; call SDL_GetError() for more information. |
| 328 | * |
| 329 | * \threadsafety It is safe to call this function from any thread. |
| 330 | * |
| 331 | * \since This function is available since SDL 3.2.0. |
| 332 | * |
| 333 | * \sa SDL_AddGamepadMappingsFromFile |
| 334 | * \sa SDL_AddGamepadMappingsFromIO |
| 335 | * \sa SDL_GetGamepadMapping |
| 336 | * \sa SDL_GetGamepadMappingForGUID |
| 337 | * \sa SDL_HINT_GAMECONTROLLERCONFIG |
| 338 | * \sa SDL_HINT_GAMECONTROLLERCONFIG_FILE |
| 339 | * \sa SDL_EVENT_GAMEPAD_ADDED |
| 340 | */ |
| 341 | extern SDL_DECLSPEC int SDLCALL SDL_AddGamepadMapping(const char *mapping); |
| 342 | |
| 343 | /** |
| 344 | * Load a set of gamepad mappings from an SDL_IOStream. |
| 345 | * |
| 346 | * You can call this function several times, if needed, to load different |
| 347 | * database files. |
| 348 | * |
| 349 | * If a new mapping is loaded for an already known gamepad GUID, the later |
| 350 | * version will overwrite the one currently loaded. |
| 351 | * |
| 352 | * Any new mappings for already plugged in controllers will generate |
| 353 | * SDL_EVENT_GAMEPAD_ADDED events. |
| 354 | * |
| 355 | * Mappings not belonging to the current platform or with no platform field |
| 356 | * specified will be ignored (i.e. mappings for Linux will be ignored in |
| 357 | * Windows, etc). |
| 358 | * |
| 359 | * This function will load the text database entirely in memory before |
| 360 | * processing it, so take this into consideration if you are in a memory |
| 361 | * constrained environment. |
| 362 | * |
| 363 | * \param src the data stream for the mappings to be added. |
| 364 | * \param closeio if true, calls SDL_CloseIO() on `src` before returning, even |
| 365 | * in the case of an error. |
| 366 | * \returns the number of mappings added or -1 on failure; call SDL_GetError() |
| 367 | * for more information. |
| 368 | * |
| 369 | * \threadsafety It is safe to call this function from any thread. |
| 370 | * |
| 371 | * \since This function is available since SDL 3.2.0. |
| 372 | * |
| 373 | * \sa SDL_AddGamepadMapping |
| 374 | * \sa SDL_AddGamepadMappingsFromFile |
| 375 | * \sa SDL_GetGamepadMapping |
| 376 | * \sa SDL_GetGamepadMappingForGUID |
| 377 | * \sa SDL_HINT_GAMECONTROLLERCONFIG |
| 378 | * \sa SDL_HINT_GAMECONTROLLERCONFIG_FILE |
| 379 | * \sa SDL_EVENT_GAMEPAD_ADDED |
| 380 | */ |
| 381 | extern SDL_DECLSPEC int SDLCALL SDL_AddGamepadMappingsFromIO(SDL_IOStream *src, bool closeio); |
| 382 | |
| 383 | /** |
| 384 | * Load a set of gamepad mappings from a file. |
| 385 | * |
| 386 | * You can call this function several times, if needed, to load different |
| 387 | * database files. |
| 388 | * |
| 389 | * If a new mapping is loaded for an already known gamepad GUID, the later |
| 390 | * version will overwrite the one currently loaded. |
| 391 | * |
| 392 | * Any new mappings for already plugged in controllers will generate |
| 393 | * SDL_EVENT_GAMEPAD_ADDED events. |
| 394 | * |
| 395 | * Mappings not belonging to the current platform or with no platform field |
| 396 | * specified will be ignored (i.e. mappings for Linux will be ignored in |
| 397 | * Windows, etc). |
| 398 | * |
| 399 | * \param file the mappings file to load. |
| 400 | * \returns the number of mappings added or -1 on failure; call SDL_GetError() |
| 401 | * for more information. |
| 402 | * |
| 403 | * \threadsafety It is safe to call this function from any thread. |
| 404 | * |
| 405 | * \since This function is available since SDL 3.2.0. |
| 406 | * |
| 407 | * \sa SDL_AddGamepadMapping |
| 408 | * \sa SDL_AddGamepadMappingsFromIO |
| 409 | * \sa SDL_GetGamepadMapping |
| 410 | * \sa SDL_GetGamepadMappingForGUID |
| 411 | * \sa SDL_HINT_GAMECONTROLLERCONFIG |
| 412 | * \sa SDL_HINT_GAMECONTROLLERCONFIG_FILE |
| 413 | * \sa SDL_EVENT_GAMEPAD_ADDED |
| 414 | */ |
| 415 | extern SDL_DECLSPEC int SDLCALL SDL_AddGamepadMappingsFromFile(const char *file); |
| 416 | |
| 417 | /** |
| 418 | * Reinitialize the SDL mapping database to its initial state. |
| 419 | * |
| 420 | * This will generate gamepad events as needed if device mappings change. |
| 421 | * |
| 422 | * \returns true on success or false on failure; call SDL_GetError() for more |
| 423 | * information. |
| 424 | * |
| 425 | * \since This function is available since SDL 3.2.0. |
| 426 | */ |
| 427 | extern SDL_DECLSPEC bool SDLCALL SDL_ReloadGamepadMappings(void); |
| 428 | |
| 429 | /** |
| 430 | * Get the current gamepad mappings. |
| 431 | * |
| 432 | * \param count a pointer filled in with the number of mappings returned, can |
| 433 | * be NULL. |
| 434 | * \returns an array of the mapping strings, NULL-terminated, or NULL on |
| 435 | * failure; call SDL_GetError() for more information. This is a |
| 436 | * single allocation that should be freed with SDL_free() when it is |
| 437 | * no longer needed. |
| 438 | * |
| 439 | * \since This function is available since SDL 3.2.0. |
| 440 | */ |
| 441 | extern SDL_DECLSPEC char ** SDLCALL SDL_GetGamepadMappings(int *count); |
| 442 | |
| 443 | /** |
| 444 | * Get the gamepad mapping string for a given GUID. |
| 445 | * |
| 446 | * \param guid a structure containing the GUID for which a mapping is desired. |
| 447 | * \returns a mapping string or NULL on failure; call SDL_GetError() for more |
| 448 | * information. This should be freed with SDL_free() when it is no |
| 449 | * longer needed. |
| 450 | * |
| 451 | * \since This function is available since SDL 3.2.0. |
| 452 | * |
| 453 | * \sa SDL_GetJoystickGUIDForID |
| 454 | * \sa SDL_GetJoystickGUID |
| 455 | */ |
| 456 | extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMappingForGUID(SDL_GUID guid); |
| 457 | |
| 458 | /** |
| 459 | * Get the current mapping of a gamepad. |
| 460 | * |
| 461 | * Details about mappings are discussed with SDL_AddGamepadMapping(). |
| 462 | * |
| 463 | * \param gamepad the gamepad you want to get the current mapping for. |
| 464 | * \returns a string that has the gamepad's mapping or NULL if no mapping is |
| 465 | * available; call SDL_GetError() for more information. This should |
| 466 | * be freed with SDL_free() when it is no longer needed. |
| 467 | * |
| 468 | * \since This function is available since SDL 3.2.0. |
| 469 | * |
| 470 | * \sa SDL_AddGamepadMapping |
| 471 | * \sa SDL_GetGamepadMappingForID |
| 472 | * \sa SDL_GetGamepadMappingForGUID |
| 473 | * \sa SDL_SetGamepadMapping |
| 474 | */ |
| 475 | extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMapping(SDL_Gamepad *gamepad); |
| 476 | |
| 477 | /** |
| 478 | * Set the current mapping of a joystick or gamepad. |
| 479 | * |
| 480 | * Details about mappings are discussed with SDL_AddGamepadMapping(). |
| 481 | * |
| 482 | * \param instance_id the joystick instance ID. |
| 483 | * \param mapping the mapping to use for this device, or NULL to clear the |
| 484 | * mapping. |
| 485 | * \returns true on success or false on failure; call SDL_GetError() for more |
| 486 | * information. |
| 487 | * |
| 488 | * \since This function is available since SDL 3.2.0. |
| 489 | * |
| 490 | * \sa SDL_AddGamepadMapping |
| 491 | * \sa SDL_GetGamepadMapping |
| 492 | */ |
| 493 | extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadMapping(SDL_JoystickID instance_id, const char *mapping); |
| 494 | |
| 495 | /** |
| 496 | * Return whether a gamepad is currently connected. |
| 497 | * |
| 498 | * \returns true if a gamepad is connected, false otherwise. |
| 499 | * |
| 500 | * \since This function is available since SDL 3.2.0. |
| 501 | * |
| 502 | * \sa SDL_GetGamepads |
| 503 | */ |
| 504 | extern SDL_DECLSPEC bool SDLCALL SDL_HasGamepad(void); |
| 505 | |
| 506 | /** |
| 507 | * Get a list of currently connected gamepads. |
| 508 | * |
| 509 | * \param count a pointer filled in with the number of gamepads returned, may |
| 510 | * be NULL. |
| 511 | * \returns a 0 terminated array of joystick instance IDs or NULL on failure; |
| 512 | * call SDL_GetError() for more information. This should be freed |
| 513 | * with SDL_free() when it is no longer needed. |
| 514 | * |
| 515 | * \since This function is available since SDL 3.2.0. |
| 516 | * |
| 517 | * \sa SDL_HasGamepad |
| 518 | * \sa SDL_OpenGamepad |
| 519 | */ |
| 520 | extern SDL_DECLSPEC SDL_JoystickID * SDLCALL SDL_GetGamepads(int *count); |
| 521 | |
| 522 | /** |
| 523 | * Check if the given joystick is supported by the gamepad interface. |
| 524 | * |
| 525 | * \param instance_id the joystick instance ID. |
| 526 | * \returns true if the given joystick is supported by the gamepad interface, |
| 527 | * false if it isn't or it's an invalid index. |
| 528 | * |
| 529 | * \since This function is available since SDL 3.2.0. |
| 530 | * |
| 531 | * \sa SDL_GetJoysticks |
| 532 | * \sa SDL_OpenGamepad |
| 533 | */ |
| 534 | extern SDL_DECLSPEC bool SDLCALL SDL_IsGamepad(SDL_JoystickID instance_id); |
| 535 | |
| 536 | /** |
| 537 | * Get the implementation dependent name of a gamepad. |
| 538 | * |
| 539 | * This can be called before any gamepads are opened. |
| 540 | * |
| 541 | * \param instance_id the joystick instance ID. |
| 542 | * \returns the name of the selected gamepad. If no name can be found, this |
| 543 | * function returns NULL; call SDL_GetError() for more information. |
| 544 | * |
| 545 | * \since This function is available since SDL 3.2.0. |
| 546 | * |
| 547 | * \sa SDL_GetGamepadName |
| 548 | * \sa SDL_GetGamepads |
| 549 | */ |
| 550 | extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadNameForID(SDL_JoystickID instance_id); |
| 551 | |
| 552 | /** |
| 553 | * Get the implementation dependent path of a gamepad. |
| 554 | * |
| 555 | * This can be called before any gamepads are opened. |
| 556 | * |
| 557 | * \param instance_id the joystick instance ID. |
| 558 | * \returns the path of the selected gamepad. If no path can be found, this |
| 559 | * function returns NULL; call SDL_GetError() for more information. |
| 560 | * |
| 561 | * \since This function is available since SDL 3.2.0. |
| 562 | * |
| 563 | * \sa SDL_GetGamepadPath |
| 564 | * \sa SDL_GetGamepads |
| 565 | */ |
| 566 | extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadPathForID(SDL_JoystickID instance_id); |
| 567 | |
| 568 | /** |
| 569 | * Get the player index of a gamepad. |
| 570 | * |
| 571 | * This can be called before any gamepads are opened. |
| 572 | * |
| 573 | * \param instance_id the joystick instance ID. |
| 574 | * \returns the player index of a gamepad, or -1 if it's not available. |
| 575 | * |
| 576 | * \since This function is available since SDL 3.2.0. |
| 577 | * |
| 578 | * \sa SDL_GetGamepadPlayerIndex |
| 579 | * \sa SDL_GetGamepads |
| 580 | */ |
| 581 | extern SDL_DECLSPEC int SDLCALL SDL_GetGamepadPlayerIndexForID(SDL_JoystickID instance_id); |
| 582 | |
| 583 | /** |
| 584 | * Get the implementation-dependent GUID of a gamepad. |
| 585 | * |
| 586 | * This can be called before any gamepads are opened. |
| 587 | * |
| 588 | * \param instance_id the joystick instance ID. |
| 589 | * \returns the GUID of the selected gamepad. If called on an invalid index, |
| 590 | * this function returns a zero GUID. |
| 591 | * |
| 592 | * \since This function is available since SDL 3.2.0. |
| 593 | * |
| 594 | * \sa SDL_GUIDToString |
| 595 | * \sa SDL_GetGamepads |
| 596 | */ |
| 597 | extern SDL_DECLSPEC SDL_GUID SDLCALL SDL_GetGamepadGUIDForID(SDL_JoystickID instance_id); |
| 598 | |
| 599 | /** |
| 600 | * Get the USB vendor ID of a gamepad, if available. |
| 601 | * |
| 602 | * This can be called before any gamepads are opened. If the vendor ID isn't |
| 603 | * available this function returns 0. |
| 604 | * |
| 605 | * \param instance_id the joystick instance ID. |
| 606 | * \returns the USB vendor ID of the selected gamepad. If called on an invalid |
| 607 | * index, this function returns zero. |
| 608 | * |
| 609 | * \since This function is available since SDL 3.2.0. |
| 610 | * |
| 611 | * \sa SDL_GetGamepadVendor |
| 612 | * \sa SDL_GetGamepads |
| 613 | */ |
| 614 | extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadVendorForID(SDL_JoystickID instance_id); |
| 615 | |
| 616 | /** |
| 617 | * Get the USB product ID of a gamepad, if available. |
| 618 | * |
| 619 | * This can be called before any gamepads are opened. If the product ID isn't |
| 620 | * available this function returns 0. |
| 621 | * |
| 622 | * \param instance_id the joystick instance ID. |
| 623 | * \returns the USB product ID of the selected gamepad. If called on an |
| 624 | * invalid index, this function returns zero. |
| 625 | * |
| 626 | * \since This function is available since SDL 3.2.0. |
| 627 | * |
| 628 | * \sa SDL_GetGamepadProduct |
| 629 | * \sa SDL_GetGamepads |
| 630 | */ |
| 631 | extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductForID(SDL_JoystickID instance_id); |
| 632 | |
| 633 | /** |
| 634 | * Get the product version of a gamepad, if available. |
| 635 | * |
| 636 | * This can be called before any gamepads are opened. If the product version |
| 637 | * isn't available this function returns 0. |
| 638 | * |
| 639 | * \param instance_id the joystick instance ID. |
| 640 | * \returns the product version of the selected gamepad. If called on an |
| 641 | * invalid index, this function returns zero. |
| 642 | * |
| 643 | * \since This function is available since SDL 3.2.0. |
| 644 | * |
| 645 | * \sa SDL_GetGamepadProductVersion |
| 646 | * \sa SDL_GetGamepads |
| 647 | */ |
| 648 | extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductVersionForID(SDL_JoystickID instance_id); |
| 649 | |
| 650 | /** |
| 651 | * Get the type of a gamepad. |
| 652 | * |
| 653 | * This can be called before any gamepads are opened. |
| 654 | * |
| 655 | * \param instance_id the joystick instance ID. |
| 656 | * \returns the gamepad type. |
| 657 | * |
| 658 | * \since This function is available since SDL 3.2.0. |
| 659 | * |
| 660 | * \sa SDL_GetGamepadType |
| 661 | * \sa SDL_GetGamepads |
| 662 | * \sa SDL_GetRealGamepadTypeForID |
| 663 | */ |
| 664 | extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadTypeForID(SDL_JoystickID instance_id); |
| 665 | |
| 666 | /** |
| 667 | * Get the type of a gamepad, ignoring any mapping override. |
| 668 | * |
| 669 | * This can be called before any gamepads are opened. |
| 670 | * |
| 671 | * \param instance_id the joystick instance ID. |
| 672 | * \returns the gamepad type. |
| 673 | * |
| 674 | * \since This function is available since SDL 3.2.0. |
| 675 | * |
| 676 | * \sa SDL_GetGamepadTypeForID |
| 677 | * \sa SDL_GetGamepads |
| 678 | * \sa SDL_GetRealGamepadType |
| 679 | */ |
| 680 | extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetRealGamepadTypeForID(SDL_JoystickID instance_id); |
| 681 | |
| 682 | /** |
| 683 | * Get the mapping of a gamepad. |
| 684 | * |
| 685 | * This can be called before any gamepads are opened. |
| 686 | * |
| 687 | * \param instance_id the joystick instance ID. |
| 688 | * \returns the mapping string. Returns NULL if no mapping is available. This |
| 689 | * should be freed with SDL_free() when it is no longer needed. |
| 690 | * |
| 691 | * \since This function is available since SDL 3.2.0. |
| 692 | * |
| 693 | * \sa SDL_GetGamepads |
| 694 | * \sa SDL_GetGamepadMapping |
| 695 | */ |
| 696 | extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMappingForID(SDL_JoystickID instance_id); |
| 697 | |
| 698 | /** |
| 699 | * Open a gamepad for use. |
| 700 | * |
| 701 | * \param instance_id the joystick instance ID. |
| 702 | * \returns a gamepad identifier or NULL if an error occurred; call |
| 703 | * SDL_GetError() for more information. |
| 704 | * |
| 705 | * \since This function is available since SDL 3.2.0. |
| 706 | * |
| 707 | * \sa SDL_CloseGamepad |
| 708 | * \sa SDL_IsGamepad |
| 709 | */ |
| 710 | extern SDL_DECLSPEC SDL_Gamepad * SDLCALL SDL_OpenGamepad(SDL_JoystickID instance_id); |
| 711 | |
| 712 | /** |
| 713 | * Get the SDL_Gamepad associated with a joystick instance ID, if it has been |
| 714 | * opened. |
| 715 | * |
| 716 | * \param instance_id the joystick instance ID of the gamepad. |
| 717 | * \returns an SDL_Gamepad on success or NULL on failure or if it hasn't been |
| 718 | * opened yet; call SDL_GetError() for more information. |
| 719 | * |
| 720 | * \since This function is available since SDL 3.2.0. |
| 721 | */ |
| 722 | extern SDL_DECLSPEC SDL_Gamepad * SDLCALL SDL_GetGamepadFromID(SDL_JoystickID instance_id); |
| 723 | |
| 724 | /** |
| 725 | * Get the SDL_Gamepad associated with a player index. |
| 726 | * |
| 727 | * \param player_index the player index, which different from the instance ID. |
| 728 | * \returns the SDL_Gamepad associated with a player index. |
| 729 | * |
| 730 | * \since This function is available since SDL 3.2.0. |
| 731 | * |
| 732 | * \sa SDL_GetGamepadPlayerIndex |
| 733 | * \sa SDL_SetGamepadPlayerIndex |
| 734 | */ |
| 735 | extern SDL_DECLSPEC SDL_Gamepad * SDLCALL SDL_GetGamepadFromPlayerIndex(int player_index); |
| 736 | |
| 737 | /** |
| 738 | * Get the properties associated with an opened gamepad. |
| 739 | * |
| 740 | * These properties are shared with the underlying joystick object. |
| 741 | * |
| 742 | * The following read-only properties are provided by SDL: |
| 743 | * |
| 744 | * - `SDL_PROP_GAMEPAD_CAP_MONO_LED_BOOLEAN`: true if this gamepad has an LED |
| 745 | * that has adjustable brightness |
| 746 | * - `SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN`: true if this gamepad has an LED |
| 747 | * that has adjustable color |
| 748 | * - `SDL_PROP_GAMEPAD_CAP_PLAYER_LED_BOOLEAN`: true if this gamepad has a |
| 749 | * player LED |
| 750 | * - `SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN`: true if this gamepad has |
| 751 | * left/right rumble |
| 752 | * - `SDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN`: true if this gamepad has |
| 753 | * simple trigger rumble |
| 754 | * |
| 755 | * \param gamepad a gamepad identifier previously returned by |
| 756 | * SDL_OpenGamepad(). |
| 757 | * \returns a valid property ID on success or 0 on failure; call |
| 758 | * SDL_GetError() for more information. |
| 759 | * |
| 760 | * \since This function is available since SDL 3.2.0. |
| 761 | */ |
| 762 | extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetGamepadProperties(SDL_Gamepad *gamepad); |
| 763 | |
| 764 | #define SDL_PROP_GAMEPAD_CAP_MONO_LED_BOOLEAN SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN |
| 765 | #define SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN |
| 766 | #define SDL_PROP_GAMEPAD_CAP_PLAYER_LED_BOOLEAN SDL_PROP_JOYSTICK_CAP_PLAYER_LED_BOOLEAN |
| 767 | #define SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN |
| 768 | #define SDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN |
| 769 | |
| 770 | /** |
| 771 | * Get the instance ID of an opened gamepad. |
| 772 | * |
| 773 | * \param gamepad a gamepad identifier previously returned by |
| 774 | * SDL_OpenGamepad(). |
| 775 | * \returns the instance ID of the specified gamepad on success or 0 on |
| 776 | * failure; call SDL_GetError() for more information. |
| 777 | * |
| 778 | * \since This function is available since SDL 3.2.0. |
| 779 | */ |
| 780 | extern SDL_DECLSPEC SDL_JoystickID SDLCALL SDL_GetGamepadID(SDL_Gamepad *gamepad); |
| 781 | |
| 782 | /** |
| 783 | * Get the implementation-dependent name for an opened gamepad. |
| 784 | * |
| 785 | * \param gamepad a gamepad identifier previously returned by |
| 786 | * SDL_OpenGamepad(). |
| 787 | * \returns the implementation dependent name for the gamepad, or NULL if |
| 788 | * there is no name or the identifier passed is invalid. |
| 789 | * |
| 790 | * \since This function is available since SDL 3.2.0. |
| 791 | * |
| 792 | * \sa SDL_GetGamepadNameForID |
| 793 | */ |
| 794 | extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadName(SDL_Gamepad *gamepad); |
| 795 | |
| 796 | /** |
| 797 | * Get the implementation-dependent path for an opened gamepad. |
| 798 | * |
| 799 | * \param gamepad a gamepad identifier previously returned by |
| 800 | * SDL_OpenGamepad(). |
| 801 | * \returns the implementation dependent path for the gamepad, or NULL if |
| 802 | * there is no path or the identifier passed is invalid. |
| 803 | * |
| 804 | * \since This function is available since SDL 3.2.0. |
| 805 | * |
| 806 | * \sa SDL_GetGamepadPathForID |
| 807 | */ |
| 808 | extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadPath(SDL_Gamepad *gamepad); |
| 809 | |
| 810 | /** |
| 811 | * Get the type of an opened gamepad. |
| 812 | * |
| 813 | * \param gamepad the gamepad object to query. |
| 814 | * \returns the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not |
| 815 | * available. |
| 816 | * |
| 817 | * \since This function is available since SDL 3.2.0. |
| 818 | * |
| 819 | * \sa SDL_GetGamepadTypeForID |
| 820 | */ |
| 821 | extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadType(SDL_Gamepad *gamepad); |
| 822 | |
| 823 | /** |
| 824 | * Get the type of an opened gamepad, ignoring any mapping override. |
| 825 | * |
| 826 | * \param gamepad the gamepad object to query. |
| 827 | * \returns the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not |
| 828 | * available. |
| 829 | * |
| 830 | * \since This function is available since SDL 3.2.0. |
| 831 | * |
| 832 | * \sa SDL_GetRealGamepadTypeForID |
| 833 | */ |
| 834 | extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetRealGamepadType(SDL_Gamepad *gamepad); |
| 835 | |
| 836 | /** |
| 837 | * Get the player index of an opened gamepad. |
| 838 | * |
| 839 | * For XInput gamepads this returns the XInput user index. |
| 840 | * |
| 841 | * \param gamepad the gamepad object to query. |
| 842 | * \returns the player index for gamepad, or -1 if it's not available. |
| 843 | * |
| 844 | * \since This function is available since SDL 3.2.0. |
| 845 | * |
| 846 | * \sa SDL_SetGamepadPlayerIndex |
| 847 | */ |
| 848 | extern SDL_DECLSPEC int SDLCALL SDL_GetGamepadPlayerIndex(SDL_Gamepad *gamepad); |
| 849 | |
| 850 | /** |
| 851 | * Set the player index of an opened gamepad. |
| 852 | * |
| 853 | * \param gamepad the gamepad object to adjust. |
| 854 | * \param player_index player index to assign to this gamepad, or -1 to clear |
| 855 | * the player index and turn off player LEDs. |
| 856 | * \returns true on success or false on failure; call SDL_GetError() for more |
| 857 | * information. |
| 858 | * |
| 859 | * \since This function is available since SDL 3.2.0. |
| 860 | * |
| 861 | * \sa SDL_GetGamepadPlayerIndex |
| 862 | */ |
| 863 | extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadPlayerIndex(SDL_Gamepad *gamepad, int player_index); |
| 864 | |
| 865 | /** |
| 866 | * Get the USB vendor ID of an opened gamepad, if available. |
| 867 | * |
| 868 | * If the vendor ID isn't available this function returns 0. |
| 869 | * |
| 870 | * \param gamepad the gamepad object to query. |
| 871 | * \returns the USB vendor ID, or zero if unavailable. |
| 872 | * |
| 873 | * \since This function is available since SDL 3.2.0. |
| 874 | * |
| 875 | * \sa SDL_GetGamepadVendorForID |
| 876 | */ |
| 877 | extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadVendor(SDL_Gamepad *gamepad); |
| 878 | |
| 879 | /** |
| 880 | * Get the USB product ID of an opened gamepad, if available. |
| 881 | * |
| 882 | * If the product ID isn't available this function returns 0. |
| 883 | * |
| 884 | * \param gamepad the gamepad object to query. |
| 885 | * \returns the USB product ID, or zero if unavailable. |
| 886 | * |
| 887 | * \since This function is available since SDL 3.2.0. |
| 888 | * |
| 889 | * \sa SDL_GetGamepadProductForID |
| 890 | */ |
| 891 | extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProduct(SDL_Gamepad *gamepad); |
| 892 | |
| 893 | /** |
| 894 | * Get the product version of an opened gamepad, if available. |
| 895 | * |
| 896 | * If the product version isn't available this function returns 0. |
| 897 | * |
| 898 | * \param gamepad the gamepad object to query. |
| 899 | * \returns the USB product version, or zero if unavailable. |
| 900 | * |
| 901 | * \since This function is available since SDL 3.2.0. |
| 902 | * |
| 903 | * \sa SDL_GetGamepadProductVersionForID |
| 904 | */ |
| 905 | extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductVersion(SDL_Gamepad *gamepad); |
| 906 | |
| 907 | /** |
| 908 | * Get the firmware version of an opened gamepad, if available. |
| 909 | * |
| 910 | * If the firmware version isn't available this function returns 0. |
| 911 | * |
| 912 | * \param gamepad the gamepad object to query. |
| 913 | * \returns the gamepad firmware version, or zero if unavailable. |
| 914 | * |
| 915 | * \since This function is available since SDL 3.2.0. |
| 916 | */ |
| 917 | extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadFirmwareVersion(SDL_Gamepad *gamepad); |
| 918 | |
| 919 | /** |
| 920 | * Get the serial number of an opened gamepad, if available. |
| 921 | * |
| 922 | * Returns the serial number of the gamepad, or NULL if it is not available. |
| 923 | * |
| 924 | * \param gamepad the gamepad object to query. |
| 925 | * \returns the serial number, or NULL if unavailable. |
| 926 | * |
| 927 | * \since This function is available since SDL 3.2.0. |
| 928 | */ |
| 929 | extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadSerial(SDL_Gamepad *gamepad); |
| 930 | |
| 931 | /** |
| 932 | * Get the Steam Input handle of an opened gamepad, if available. |
| 933 | * |
| 934 | * Returns an InputHandle_t for the gamepad that can be used with Steam Input |
| 935 | * API: https://partner.steamgames.com/doc/api/ISteamInput |
| 936 | * |
| 937 | * \param gamepad the gamepad object to query. |
| 938 | * \returns the gamepad handle, or 0 if unavailable. |
| 939 | * |
| 940 | * \since This function is available since SDL 3.2.0. |
| 941 | */ |
| 942 | extern SDL_DECLSPEC Uint64 SDLCALL SDL_GetGamepadSteamHandle(SDL_Gamepad *gamepad); |
| 943 | |
| 944 | /** |
| 945 | * Get the connection state of a gamepad. |
| 946 | * |
| 947 | * \param gamepad the gamepad object to query. |
| 948 | * \returns the connection state on success or |
| 949 | * `SDL_JOYSTICK_CONNECTION_INVALID` on failure; call SDL_GetError() |
| 950 | * for more information. |
| 951 | * |
| 952 | * \since This function is available since SDL 3.2.0. |
| 953 | */ |
| 954 | extern SDL_DECLSPEC SDL_JoystickConnectionState SDLCALL SDL_GetGamepadConnectionState(SDL_Gamepad *gamepad); |
| 955 | |
| 956 | /** |
| 957 | * Get the battery state of a gamepad. |
| 958 | * |
| 959 | * You should never take a battery status as absolute truth. Batteries |
| 960 | * (especially failing batteries) are delicate hardware, and the values |
| 961 | * reported here are best estimates based on what that hardware reports. It's |
| 962 | * not uncommon for older batteries to lose stored power much faster than it |
| 963 | * reports, or completely drain when reporting it has 20 percent left, etc. |
| 964 | * |
| 965 | * \param gamepad the gamepad object to query. |
| 966 | * \param percent a pointer filled in with the percentage of battery life |
| 967 | * left, between 0 and 100, or NULL to ignore. This will be |
| 968 | * filled in with -1 we can't determine a value or there is no |
| 969 | * battery. |
| 970 | * \returns the current battery state. |
| 971 | * |
| 972 | * \since This function is available since SDL 3.2.0. |
| 973 | */ |
| 974 | extern SDL_DECLSPEC SDL_PowerState SDLCALL SDL_GetGamepadPowerInfo(SDL_Gamepad *gamepad, int *percent); |
| 975 | |
| 976 | /** |
| 977 | * Check if a gamepad has been opened and is currently connected. |
| 978 | * |
| 979 | * \param gamepad a gamepad identifier previously returned by |
| 980 | * SDL_OpenGamepad(). |
| 981 | * \returns true if the gamepad has been opened and is currently connected, or |
| 982 | * false if not. |
| 983 | * |
| 984 | * \since This function is available since SDL 3.2.0. |
| 985 | */ |
| 986 | extern SDL_DECLSPEC bool SDLCALL SDL_GamepadConnected(SDL_Gamepad *gamepad); |
| 987 | |
| 988 | /** |
| 989 | * Get the underlying joystick from a gamepad. |
| 990 | * |
| 991 | * This function will give you a SDL_Joystick object, which allows you to use |
| 992 | * the SDL_Joystick functions with a SDL_Gamepad object. This would be useful |
| 993 | * for getting a joystick's position at any given time, even if it hasn't |
| 994 | * moved (moving it would produce an event, which would have the axis' value). |
| 995 | * |
| 996 | * The pointer returned is owned by the SDL_Gamepad. You should not call |
| 997 | * SDL_CloseJoystick() on it, for example, since doing so will likely cause |
| 998 | * SDL to crash. |
| 999 | * |
| 1000 | * \param gamepad the gamepad object that you want to get a joystick from. |
| 1001 | * \returns an SDL_Joystick object, or NULL on failure; call SDL_GetError() |
| 1002 | * for more information. |
| 1003 | * |
| 1004 | * \since This function is available since SDL 3.2.0. |
| 1005 | */ |
| 1006 | extern SDL_DECLSPEC SDL_Joystick * SDLCALL SDL_GetGamepadJoystick(SDL_Gamepad *gamepad); |
| 1007 | |
| 1008 | /** |
| 1009 | * Set the state of gamepad event processing. |
| 1010 | * |
| 1011 | * If gamepad events are disabled, you must call SDL_UpdateGamepads() yourself |
| 1012 | * and check the state of the gamepad when you want gamepad information. |
| 1013 | * |
| 1014 | * \param enabled whether to process gamepad events or not. |
| 1015 | * |
| 1016 | * \since This function is available since SDL 3.2.0. |
| 1017 | * |
| 1018 | * \sa SDL_GamepadEventsEnabled |
| 1019 | * \sa SDL_UpdateGamepads |
| 1020 | */ |
| 1021 | extern SDL_DECLSPEC void SDLCALL SDL_SetGamepadEventsEnabled(bool enabled); |
| 1022 | |
| 1023 | /** |
| 1024 | * Query the state of gamepad event processing. |
| 1025 | * |
| 1026 | * If gamepad events are disabled, you must call SDL_UpdateGamepads() yourself |
| 1027 | * and check the state of the gamepad when you want gamepad information. |
| 1028 | * |
| 1029 | * \returns true if gamepad events are being processed, false otherwise. |
| 1030 | * |
| 1031 | * \since This function is available since SDL 3.2.0. |
| 1032 | * |
| 1033 | * \sa SDL_SetGamepadEventsEnabled |
| 1034 | */ |
| 1035 | extern SDL_DECLSPEC bool SDLCALL SDL_GamepadEventsEnabled(void); |
| 1036 | |
| 1037 | /** |
| 1038 | * Get the SDL joystick layer bindings for a gamepad. |
| 1039 | * |
| 1040 | * \param gamepad a gamepad. |
| 1041 | * \param count a pointer filled in with the number of bindings returned. |
| 1042 | * \returns a NULL terminated array of pointers to bindings or NULL on |
| 1043 | * failure; call SDL_GetError() for more information. This is a |
| 1044 | * single allocation that should be freed with SDL_free() when it is |
| 1045 | * no longer needed. |
| 1046 | * |
| 1047 | * \since This function is available since SDL 3.2.0. |
| 1048 | */ |
| 1049 | extern SDL_DECLSPEC SDL_GamepadBinding ** SDLCALL SDL_GetGamepadBindings(SDL_Gamepad *gamepad, int *count); |
| 1050 | |
| 1051 | /** |
| 1052 | * Manually pump gamepad updates if not using the loop. |
| 1053 | * |
| 1054 | * This function is called automatically by the event loop if events are |
| 1055 | * enabled. Under such circumstances, it will not be necessary to call this |
| 1056 | * function. |
| 1057 | * |
| 1058 | * \since This function is available since SDL 3.2.0. |
| 1059 | */ |
| 1060 | extern SDL_DECLSPEC void SDLCALL SDL_UpdateGamepads(void); |
| 1061 | |
| 1062 | /** |
| 1063 | * Convert a string into SDL_GamepadType enum. |
| 1064 | * |
| 1065 | * This function is called internally to translate SDL_Gamepad mapping strings |
| 1066 | * for the underlying joystick device into the consistent SDL_Gamepad mapping. |
| 1067 | * You do not normally need to call this function unless you are parsing |
| 1068 | * SDL_Gamepad mappings in your own code. |
| 1069 | * |
| 1070 | * \param str string representing a SDL_GamepadType type. |
| 1071 | * \returns the SDL_GamepadType enum corresponding to the input string, or |
| 1072 | * `SDL_GAMEPAD_TYPE_UNKNOWN` if no match was found. |
| 1073 | * |
| 1074 | * \since This function is available since SDL 3.2.0. |
| 1075 | * |
| 1076 | * \sa SDL_GetGamepadStringForType |
| 1077 | */ |
| 1078 | extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadTypeFromString(const char *str); |
| 1079 | |
| 1080 | /** |
| 1081 | * Convert from an SDL_GamepadType enum to a string. |
| 1082 | * |
| 1083 | * \param type an enum value for a given SDL_GamepadType. |
| 1084 | * \returns a string for the given type, or NULL if an invalid type is |
| 1085 | * specified. The string returned is of the format used by |
| 1086 | * SDL_Gamepad mapping strings. |
| 1087 | * |
| 1088 | * \since This function is available since SDL 3.2.0. |
| 1089 | * |
| 1090 | * \sa SDL_GetGamepadTypeFromString |
| 1091 | */ |
| 1092 | extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForType(SDL_GamepadType type); |
| 1093 | |
| 1094 | /** |
| 1095 | * Convert a string into SDL_GamepadAxis enum. |
| 1096 | * |
| 1097 | * This function is called internally to translate SDL_Gamepad mapping strings |
| 1098 | * for the underlying joystick device into the consistent SDL_Gamepad mapping. |
| 1099 | * You do not normally need to call this function unless you are parsing |
| 1100 | * SDL_Gamepad mappings in your own code. |
| 1101 | * |
| 1102 | * Note specially that "righttrigger" and "lefttrigger" map to |
| 1103 | * `SDL_GAMEPAD_AXIS_RIGHT_TRIGGER` and `SDL_GAMEPAD_AXIS_LEFT_TRIGGER`, |
| 1104 | * respectively. |
| 1105 | * |
| 1106 | * \param str string representing a SDL_Gamepad axis. |
| 1107 | * \returns the SDL_GamepadAxis enum corresponding to the input string, or |
| 1108 | * `SDL_GAMEPAD_AXIS_INVALID` if no match was found. |
| 1109 | * |
| 1110 | * \since This function is available since SDL 3.2.0. |
| 1111 | * |
| 1112 | * \sa SDL_GetGamepadStringForAxis |
| 1113 | */ |
| 1114 | extern SDL_DECLSPEC SDL_GamepadAxis SDLCALL SDL_GetGamepadAxisFromString(const char *str); |
| 1115 | |
| 1116 | /** |
| 1117 | * Convert from an SDL_GamepadAxis enum to a string. |
| 1118 | * |
| 1119 | * \param axis an enum value for a given SDL_GamepadAxis. |
| 1120 | * \returns a string for the given axis, or NULL if an invalid axis is |
| 1121 | * specified. The string returned is of the format used by |
| 1122 | * SDL_Gamepad mapping strings. |
| 1123 | * |
| 1124 | * \since This function is available since SDL 3.2.0. |
| 1125 | * |
| 1126 | * \sa SDL_GetGamepadAxisFromString |
| 1127 | */ |
| 1128 | extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForAxis(SDL_GamepadAxis axis); |
| 1129 | |
| 1130 | /** |
| 1131 | * Query whether a gamepad has a given axis. |
| 1132 | * |
| 1133 | * This merely reports whether the gamepad's mapping defined this axis, as |
| 1134 | * that is all the information SDL has about the physical device. |
| 1135 | * |
| 1136 | * \param gamepad a gamepad. |
| 1137 | * \param axis an axis enum value (an SDL_GamepadAxis value). |
| 1138 | * \returns true if the gamepad has this axis, false otherwise. |
| 1139 | * |
| 1140 | * \since This function is available since SDL 3.2.0. |
| 1141 | * |
| 1142 | * \sa SDL_GamepadHasButton |
| 1143 | * \sa SDL_GetGamepadAxis |
| 1144 | */ |
| 1145 | extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis); |
| 1146 | |
| 1147 | /** |
| 1148 | * Get the current state of an axis control on a gamepad. |
| 1149 | * |
| 1150 | * The axis indices start at index 0. |
| 1151 | * |
| 1152 | * For thumbsticks, the state is a value ranging from -32768 (up/left) to |
| 1153 | * 32767 (down/right). |
| 1154 | * |
| 1155 | * Triggers range from 0 when released to 32767 when fully pressed, and never |
| 1156 | * return a negative value. Note that this differs from the value reported by |
| 1157 | * the lower-level SDL_GetJoystickAxis(), which normally uses the full range. |
| 1158 | * |
| 1159 | * Note that for invalid gamepads or axes, this will return 0. Zero is also a |
| 1160 | * valid value in normal operation; usually it means a centered axis. |
| 1161 | * |
| 1162 | * \param gamepad a gamepad. |
| 1163 | * \param axis an axis index (one of the SDL_GamepadAxis values). |
| 1164 | * \returns axis state. |
| 1165 | * |
| 1166 | * \since This function is available since SDL 3.2.0. |
| 1167 | * |
| 1168 | * \sa SDL_GamepadHasAxis |
| 1169 | * \sa SDL_GetGamepadButton |
| 1170 | */ |
| 1171 | extern SDL_DECLSPEC Sint16 SDLCALL SDL_GetGamepadAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis); |
| 1172 | |
| 1173 | /** |
| 1174 | * Convert a string into an SDL_GamepadButton enum. |
| 1175 | * |
| 1176 | * This function is called internally to translate SDL_Gamepad mapping strings |
| 1177 | * for the underlying joystick device into the consistent SDL_Gamepad mapping. |
| 1178 | * You do not normally need to call this function unless you are parsing |
| 1179 | * SDL_Gamepad mappings in your own code. |
| 1180 | * |
| 1181 | * \param str string representing a SDL_Gamepad axis. |
| 1182 | * \returns the SDL_GamepadButton enum corresponding to the input string, or |
| 1183 | * `SDL_GAMEPAD_BUTTON_INVALID` if no match was found. |
| 1184 | * |
| 1185 | * \since This function is available since SDL 3.2.0. |
| 1186 | * |
| 1187 | * \sa SDL_GetGamepadStringForButton |
| 1188 | */ |
| 1189 | extern SDL_DECLSPEC SDL_GamepadButton SDLCALL SDL_GetGamepadButtonFromString(const char *str); |
| 1190 | |
| 1191 | /** |
| 1192 | * Convert from an SDL_GamepadButton enum to a string. |
| 1193 | * |
| 1194 | * \param button an enum value for a given SDL_GamepadButton. |
| 1195 | * \returns a string for the given button, or NULL if an invalid button is |
| 1196 | * specified. The string returned is of the format used by |
| 1197 | * SDL_Gamepad mapping strings. |
| 1198 | * |
| 1199 | * \since This function is available since SDL 3.2.0. |
| 1200 | * |
| 1201 | * \sa SDL_GetGamepadButtonFromString |
| 1202 | */ |
| 1203 | extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForButton(SDL_GamepadButton button); |
| 1204 | |
| 1205 | /** |
| 1206 | * Query whether a gamepad has a given button. |
| 1207 | * |
| 1208 | * This merely reports whether the gamepad's mapping defined this button, as |
| 1209 | * that is all the information SDL has about the physical device. |
| 1210 | * |
| 1211 | * \param gamepad a gamepad. |
| 1212 | * \param button a button enum value (an SDL_GamepadButton value). |
| 1213 | * \returns true if the gamepad has this button, false otherwise. |
| 1214 | * |
| 1215 | * \since This function is available since SDL 3.2.0. |
| 1216 | * |
| 1217 | * \sa SDL_GamepadHasAxis |
| 1218 | */ |
| 1219 | extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasButton(SDL_Gamepad *gamepad, SDL_GamepadButton button); |
| 1220 | |
| 1221 | /** |
| 1222 | * Get the current state of a button on a gamepad. |
| 1223 | * |
| 1224 | * \param gamepad a gamepad. |
| 1225 | * \param button a button index (one of the SDL_GamepadButton values). |
| 1226 | * \returns true if the button is pressed, false otherwise. |
| 1227 | * |
| 1228 | * \since This function is available since SDL 3.2.0. |
| 1229 | * |
| 1230 | * \sa SDL_GamepadHasButton |
| 1231 | * \sa SDL_GetGamepadAxis |
| 1232 | */ |
| 1233 | extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadButton(SDL_Gamepad *gamepad, SDL_GamepadButton button); |
| 1234 | |
| 1235 | /** |
| 1236 | * Get the label of a button on a gamepad. |
| 1237 | * |
| 1238 | * \param type the type of gamepad to check. |
| 1239 | * \param button a button index (one of the SDL_GamepadButton values). |
| 1240 | * \returns the SDL_GamepadButtonLabel enum corresponding to the button label. |
| 1241 | * |
| 1242 | * \since This function is available since SDL 3.2.0. |
| 1243 | * |
| 1244 | * \sa SDL_GetGamepadButtonLabel |
| 1245 | */ |
| 1246 | extern SDL_DECLSPEC SDL_GamepadButtonLabel SDLCALL SDL_GetGamepadButtonLabelForType(SDL_GamepadType type, SDL_GamepadButton button); |
| 1247 | |
| 1248 | /** |
| 1249 | * Get the label of a button on a gamepad. |
| 1250 | * |
| 1251 | * \param gamepad a gamepad. |
| 1252 | * \param button a button index (one of the SDL_GamepadButton values). |
| 1253 | * \returns the SDL_GamepadButtonLabel enum corresponding to the button label. |
| 1254 | * |
| 1255 | * \since This function is available since SDL 3.2.0. |
| 1256 | * |
| 1257 | * \sa SDL_GetGamepadButtonLabelForType |
| 1258 | */ |
| 1259 | extern SDL_DECLSPEC SDL_GamepadButtonLabel SDLCALL SDL_GetGamepadButtonLabel(SDL_Gamepad *gamepad, SDL_GamepadButton button); |
| 1260 | |
| 1261 | /** |
| 1262 | * Get the number of touchpads on a gamepad. |
| 1263 | * |
| 1264 | * \param gamepad a gamepad. |
| 1265 | * \returns number of touchpads. |
| 1266 | * |
| 1267 | * \since This function is available since SDL 3.2.0. |
| 1268 | * |
| 1269 | * \sa SDL_GetNumGamepadTouchpadFingers |
| 1270 | */ |
| 1271 | extern SDL_DECLSPEC int SDLCALL SDL_GetNumGamepadTouchpads(SDL_Gamepad *gamepad); |
| 1272 | |
| 1273 | /** |
| 1274 | * Get the number of supported simultaneous fingers on a touchpad on a game |
| 1275 | * gamepad. |
| 1276 | * |
| 1277 | * \param gamepad a gamepad. |
| 1278 | * \param touchpad a touchpad. |
| 1279 | * \returns number of supported simultaneous fingers. |
| 1280 | * |
| 1281 | * \since This function is available since SDL 3.2.0. |
| 1282 | * |
| 1283 | * \sa SDL_GetGamepadTouchpadFinger |
| 1284 | * \sa SDL_GetNumGamepadTouchpads |
| 1285 | */ |
| 1286 | extern SDL_DECLSPEC int SDLCALL SDL_GetNumGamepadTouchpadFingers(SDL_Gamepad *gamepad, int touchpad); |
| 1287 | |
| 1288 | /** |
| 1289 | * Get the current state of a finger on a touchpad on a gamepad. |
| 1290 | * |
| 1291 | * \param gamepad a gamepad. |
| 1292 | * \param touchpad a touchpad. |
| 1293 | * \param finger a finger. |
| 1294 | * \param down a pointer filled with true if the finger is down, false |
| 1295 | * otherwise, may be NULL. |
| 1296 | * \param x a pointer filled with the x position, normalized 0 to 1, with the |
| 1297 | * origin in the upper left, may be NULL. |
| 1298 | * \param y a pointer filled with the y position, normalized 0 to 1, with the |
| 1299 | * origin in the upper left, may be NULL. |
| 1300 | * \param pressure a pointer filled with pressure value, may be NULL. |
| 1301 | * \returns true on success or false on failure; call SDL_GetError() for more |
| 1302 | * information. |
| 1303 | * |
| 1304 | * \since This function is available since SDL 3.2.0. |
| 1305 | * |
| 1306 | * \sa SDL_GetNumGamepadTouchpadFingers |
| 1307 | */ |
| 1308 | extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadTouchpadFinger(SDL_Gamepad *gamepad, int touchpad, int finger, bool *down, float *x, float *y, float *pressure); |
| 1309 | |
| 1310 | /** |
| 1311 | * Return whether a gamepad has a particular sensor. |
| 1312 | * |
| 1313 | * \param gamepad the gamepad to query. |
| 1314 | * \param type the type of sensor to query. |
| 1315 | * \returns true if the sensor exists, false otherwise. |
| 1316 | * |
| 1317 | * \since This function is available since SDL 3.2.0. |
| 1318 | * |
| 1319 | * \sa SDL_GetGamepadSensorData |
| 1320 | * \sa SDL_GetGamepadSensorDataRate |
| 1321 | * \sa SDL_SetGamepadSensorEnabled |
| 1322 | */ |
| 1323 | extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasSensor(SDL_Gamepad *gamepad, SDL_SensorType type); |
| 1324 | |
| 1325 | /** |
| 1326 | * Set whether data reporting for a gamepad sensor is enabled. |
| 1327 | * |
| 1328 | * \param gamepad the gamepad to update. |
| 1329 | * \param type the type of sensor to enable/disable. |
| 1330 | * \param enabled whether data reporting should be enabled. |
| 1331 | * \returns true on success or false on failure; call SDL_GetError() for more |
| 1332 | * information. |
| 1333 | * |
| 1334 | * \since This function is available since SDL 3.2.0. |
| 1335 | * |
| 1336 | * \sa SDL_GamepadHasSensor |
| 1337 | * \sa SDL_GamepadSensorEnabled |
| 1338 | */ |
| 1339 | extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadSensorEnabled(SDL_Gamepad *gamepad, SDL_SensorType type, bool enabled); |
| 1340 | |
| 1341 | /** |
| 1342 | * Query whether sensor data reporting is enabled for a gamepad. |
| 1343 | * |
| 1344 | * \param gamepad the gamepad to query. |
| 1345 | * \param type the type of sensor to query. |
| 1346 | * \returns true if the sensor is enabled, false otherwise. |
| 1347 | * |
| 1348 | * \since This function is available since SDL 3.2.0. |
| 1349 | * |
| 1350 | * \sa SDL_SetGamepadSensorEnabled |
| 1351 | */ |
| 1352 | extern SDL_DECLSPEC bool SDLCALL SDL_GamepadSensorEnabled(SDL_Gamepad *gamepad, SDL_SensorType type); |
| 1353 | |
| 1354 | /** |
| 1355 | * Get the data rate (number of events per second) of a gamepad sensor. |
| 1356 | * |
| 1357 | * \param gamepad the gamepad to query. |
| 1358 | * \param type the type of sensor to query. |
| 1359 | * \returns the data rate, or 0.0f if the data rate is not available. |
| 1360 | * |
| 1361 | * \since This function is available since SDL 3.2.0. |
| 1362 | */ |
| 1363 | extern SDL_DECLSPEC float SDLCALL SDL_GetGamepadSensorDataRate(SDL_Gamepad *gamepad, SDL_SensorType type); |
| 1364 | |
| 1365 | /** |
| 1366 | * Get the current state of a gamepad sensor. |
| 1367 | * |
| 1368 | * The number of values and interpretation of the data is sensor dependent. |
| 1369 | * See SDL_sensor.h for the details for each type of sensor. |
| 1370 | * |
| 1371 | * \param gamepad the gamepad to query. |
| 1372 | * \param type the type of sensor to query. |
| 1373 | * \param data a pointer filled with the current sensor state. |
| 1374 | * \param num_values the number of values to write to data. |
| 1375 | * \returns true on success or false on failure; call SDL_GetError() for more |
| 1376 | * information. |
| 1377 | * |
| 1378 | * \since This function is available since SDL 3.2.0. |
| 1379 | */ |
| 1380 | extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadSensorData(SDL_Gamepad *gamepad, SDL_SensorType type, float *data, int num_values); |
| 1381 | |
| 1382 | /** |
| 1383 | * Start a rumble effect on a gamepad. |
| 1384 | * |
| 1385 | * Each call to this function cancels any previous rumble effect, and calling |
| 1386 | * it with 0 intensity stops any rumbling. |
| 1387 | * |
| 1388 | * This function requires you to process SDL events or call |
| 1389 | * SDL_UpdateJoysticks() to update rumble state. |
| 1390 | * |
| 1391 | * \param gamepad the gamepad to vibrate. |
| 1392 | * \param low_frequency_rumble the intensity of the low frequency (left) |
| 1393 | * rumble motor, from 0 to 0xFFFF. |
| 1394 | * \param high_frequency_rumble the intensity of the high frequency (right) |
| 1395 | * rumble motor, from 0 to 0xFFFF. |
| 1396 | * \param duration_ms the duration of the rumble effect, in milliseconds. |
| 1397 | * \returns true on success or false on failure; call SDL_GetError() for more |
| 1398 | * information. |
| 1399 | * |
| 1400 | * \since This function is available since SDL 3.2.0. |
| 1401 | */ |
| 1402 | extern SDL_DECLSPEC bool SDLCALL SDL_RumbleGamepad(SDL_Gamepad *gamepad, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms); |
| 1403 | |
| 1404 | /** |
| 1405 | * Start a rumble effect in the gamepad's triggers. |
| 1406 | * |
| 1407 | * Each call to this function cancels any previous trigger rumble effect, and |
| 1408 | * calling it with 0 intensity stops any rumbling. |
| 1409 | * |
| 1410 | * Note that this is rumbling of the _triggers_ and not the gamepad as a |
| 1411 | * whole. This is currently only supported on Xbox One gamepads. If you want |
| 1412 | * the (more common) whole-gamepad rumble, use SDL_RumbleGamepad() instead. |
| 1413 | * |
| 1414 | * This function requires you to process SDL events or call |
| 1415 | * SDL_UpdateJoysticks() to update rumble state. |
| 1416 | * |
| 1417 | * \param gamepad the gamepad to vibrate. |
| 1418 | * \param left_rumble the intensity of the left trigger rumble motor, from 0 |
| 1419 | * to 0xFFFF. |
| 1420 | * \param right_rumble the intensity of the right trigger rumble motor, from 0 |
| 1421 | * to 0xFFFF. |
| 1422 | * \param duration_ms the duration of the rumble effect, in milliseconds. |
| 1423 | * \returns true on success or false on failure; call SDL_GetError() for more |
| 1424 | * information. |
| 1425 | * |
| 1426 | * \since This function is available since SDL 3.2.0. |
| 1427 | * |
| 1428 | * \sa SDL_RumbleGamepad |
| 1429 | */ |
| 1430 | extern SDL_DECLSPEC bool SDLCALL SDL_RumbleGamepadTriggers(SDL_Gamepad *gamepad, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms); |
| 1431 | |
| 1432 | /** |
| 1433 | * Update a gamepad's LED color. |
| 1434 | * |
| 1435 | * An example of a joystick LED is the light on the back of a PlayStation 4's |
| 1436 | * DualShock 4 controller. |
| 1437 | * |
| 1438 | * For gamepads with a single color LED, the maximum of the RGB values will be |
| 1439 | * used as the LED brightness. |
| 1440 | * |
| 1441 | * \param gamepad the gamepad to update. |
| 1442 | * \param red the intensity of the red LED. |
| 1443 | * \param green the intensity of the green LED. |
| 1444 | * \param blue the intensity of the blue LED. |
| 1445 | * \returns true on success or false on failure; call SDL_GetError() for more |
| 1446 | * information. |
| 1447 | * |
| 1448 | * \since This function is available since SDL 3.2.0. |
| 1449 | */ |
| 1450 | extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadLED(SDL_Gamepad *gamepad, Uint8 red, Uint8 green, Uint8 blue); |
| 1451 | |
| 1452 | /** |
| 1453 | * Send a gamepad specific effect packet. |
| 1454 | * |
| 1455 | * \param gamepad the gamepad to affect. |
| 1456 | * \param data the data to send to the gamepad. |
| 1457 | * \param size the size of the data to send to the gamepad. |
| 1458 | * \returns true on success or false on failure; call SDL_GetError() for more |
| 1459 | * information. |
| 1460 | * |
| 1461 | * \since This function is available since SDL 3.2.0. |
| 1462 | */ |
| 1463 | extern SDL_DECLSPEC bool SDLCALL SDL_SendGamepadEffect(SDL_Gamepad *gamepad, const void *data, int size); |
| 1464 | |
| 1465 | /** |
| 1466 | * Close a gamepad previously opened with SDL_OpenGamepad(). |
| 1467 | * |
| 1468 | * \param gamepad a gamepad identifier previously returned by |
| 1469 | * SDL_OpenGamepad(). |
| 1470 | * |
| 1471 | * \since This function is available since SDL 3.2.0. |
| 1472 | * |
| 1473 | * \sa SDL_OpenGamepad |
| 1474 | */ |
| 1475 | extern SDL_DECLSPEC void SDLCALL SDL_CloseGamepad(SDL_Gamepad *gamepad); |
| 1476 | |
| 1477 | /** |
| 1478 | * Return the sfSymbolsName for a given button on a gamepad on Apple |
| 1479 | * platforms. |
| 1480 | * |
| 1481 | * \param gamepad the gamepad to query. |
| 1482 | * \param button a button on the gamepad. |
| 1483 | * \returns the sfSymbolsName or NULL if the name can't be found. |
| 1484 | * |
| 1485 | * \since This function is available since SDL 3.2.0. |
| 1486 | * |
| 1487 | * \sa SDL_GetGamepadAppleSFSymbolsNameForAxis |
| 1488 | */ |
| 1489 | extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadAppleSFSymbolsNameForButton(SDL_Gamepad *gamepad, SDL_GamepadButton button); |
| 1490 | |
| 1491 | /** |
| 1492 | * Return the sfSymbolsName for a given axis on a gamepad on Apple platforms. |
| 1493 | * |
| 1494 | * \param gamepad the gamepad to query. |
| 1495 | * \param axis an axis on the gamepad. |
| 1496 | * \returns the sfSymbolsName or NULL if the name can't be found. |
| 1497 | * |
| 1498 | * \since This function is available since SDL 3.2.0. |
| 1499 | * |
| 1500 | * \sa SDL_GetGamepadAppleSFSymbolsNameForButton |
| 1501 | */ |
| 1502 | extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadAppleSFSymbolsNameForAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis); |
| 1503 | |
| 1504 | |
| 1505 | /* Ends C function definitions when using C++ */ |
| 1506 | #ifdef __cplusplus |
| 1507 | } |
| 1508 | #endif |
| 1509 | #include <SDL3/SDL_close_code.h> |
| 1510 | |
| 1511 | #endif /* SDL_gamepad_h_ */ |
| 1512 | |