SDL 3.0
SDL_gamepad.h
Go to the documentation of this file.
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2024 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 * \file SDL_gamepad.h
24 *
25 * Include file for SDL gamepad event handling
26 */
27
28#ifndef SDL_gamepad_h_
29#define SDL_gamepad_h_
30
31#include <SDL3/SDL_stdinc.h>
32#include <SDL3/SDL_error.h>
33#include <SDL3/SDL_joystick.h>
34#include <SDL3/SDL_properties.h>
35#include <SDL3/SDL_rwops.h>
36#include <SDL3/SDL_sensor.h>
37
38#include <SDL3/SDL_begin_code.h>
39/* Set up for C function definitions, even when using C++ */
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44/**
45 * \file SDL_gamepad.h
46 *
47 * In order to use these functions, SDL_Init() must have been called
48 * with the ::SDL_INIT_GAMEPAD flag. This causes SDL to scan the system
49 * for gamepads, and load appropriate drivers.
50 *
51 * If you would like to receive gamepad updates while the application
52 * is in the background, you should set the following hint before calling
53 * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS
54 */
55
56/**
57 * The structure used to identify an SDL gamepad
58 */
59struct SDL_Gamepad;
60typedef struct SDL_Gamepad SDL_Gamepad;
61
77
78/**
79 * The list of buttons available on a gamepad
80 *
81 * For controllers that use a diamond pattern for the face buttons,
82 * the south/east/west/north buttons below correspond to the locations
83 * in the diamond pattern. For Xbox controllers, this would be A/B/X/Y,
84 * for Nintendo Switch controllers, this would be B/A/Y/X, for
85 * PlayStation controllers this would be Cross/Circle/Square/Triangle.
86 *
87 * For controllers that don't use a diamond pattern for the face buttons,
88 * the south/east/west/north buttons indicate the buttons labeled A, B,
89 * C, D, or 1, 2, 3, 4, or for controllers that aren't labeled, they are
90 * the primary, secondary, etc. buttons.
91 *
92 * The activate action is often the south button and the cancel action
93 * is often the east button, but in some regions this is reversed, so
94 * your game should allow remapping actions based on user preferences.
95 *
96 * You can query the labels for the face buttons using SDL_GetGamepadButtonLabel()
97 */
98typedef enum
99{
101 SDL_GAMEPAD_BUTTON_SOUTH, /* Bottom face button (e.g. Xbox A button) */
102 SDL_GAMEPAD_BUTTON_EAST, /* Right face button (e.g. Xbox B button) */
103 SDL_GAMEPAD_BUTTON_WEST, /* Left face button (e.g. Xbox X button) */
104 SDL_GAMEPAD_BUTTON_NORTH, /* Top face button (e.g. Xbox Y button) */
116 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) */
117 SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1, /* Upper or primary paddle, under your right hand (e.g. Xbox Elite paddle P1) */
118 SDL_GAMEPAD_BUTTON_LEFT_PADDLE1, /* Upper or primary paddle, under your left hand (e.g. Xbox Elite paddle P3) */
119 SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2, /* Lower or secondary paddle, under your right hand (e.g. Xbox Elite paddle P2) */
120 SDL_GAMEPAD_BUTTON_LEFT_PADDLE2, /* Lower or secondary paddle, under your left hand (e.g. Xbox Elite paddle P4) */
121 SDL_GAMEPAD_BUTTON_TOUCHPAD, /* PS4/PS5 touchpad button */
124
125/**
126 * The set of gamepad button labels
127 *
128 * This isn't a complete set, just the face buttons to make it easy to show button prompts.
129 *
130 * For a complete set, you should look at the button and gamepad type and have a set of symbols that work well with your art style.
131 */
144
145/**
146 * The list of axes available on a gamepad
147 *
148 * Thumbstick axis values range from SDL_JOYSTICK_AXIS_MIN to SDL_JOYSTICK_AXIS_MAX,
149 * and are centered within ~8000 of zero, though advanced UI will allow users to set
150 * or autodetect the dead zone, which varies between gamepads.
151 *
152 * Trigger axis values range from 0 (released) to SDL_JOYSTICK_AXIS_MAX
153 * (fully pressed) when reported by SDL_GetGamepadAxis(). Note that this is not the
154 * same range that will be reported by the lower-level SDL_GetJoystickAxis().
155 */
167
175
176typedef struct
177{
179 union
180 {
182
183 struct
184 {
185 int axis;
188 } axis;
189
190 struct
191 {
192 int hat;
194 } hat;
195
196 } input;
197
199 union
200 {
202
203 struct
204 {
206 int axis_min;
207 int axis_max;
208 } axis;
209
210 } output;
211
213
214
215/**
216 * Add support for gamepads that SDL is unaware of or change the binding of an
217 * existing gamepad.
218 *
219 * The mapping string has the format "GUID,name,mapping", where GUID is the
220 * string value from SDL_GetJoystickGUIDString(), name is the human readable
221 * string for the device and mappings are gamepad mappings to joystick ones.
222 * Under Windows there is a reserved GUID of "xinput" that covers all XInput
223 * devices. The mapping format for joystick is:
224 *
225 * - `bX`: a joystick button, index X
226 * - `hX.Y`: hat X with value Y
227 * - `aX`: axis X of the joystick
228 *
229 * Buttons can be used as a gamepad axes and vice versa.
230 *
231 * This string shows an example of a valid mapping for a gamepad:
232 *
233 * ```c
234 * "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"
235 * ```
236 *
237 * \param mapping the mapping string
238 * \returns 1 if a new mapping is added, 0 if an existing mapping is updated,
239 * -1 on error; call SDL_GetError() for more information.
240 *
241 * \since This function is available since SDL 3.0.0.
242 *
243 * \sa SDL_GetGamepadMapping
244 * \sa SDL_GetGamepadMappingForGUID
245 */
246extern DECLSPEC int SDLCALL SDL_AddGamepadMapping(const char *mapping);
247
248/**
249 * Load a set of gamepad mappings from a seekable SDL data stream.
250 *
251 * You can call this function several times, if needed, to load different
252 * database files.
253 *
254 * If a new mapping is loaded for an already known gamepad GUID, the later
255 * version will overwrite the one currently loaded.
256 *
257 * Mappings not belonging to the current platform or with no platform field
258 * specified will be ignored (i.e. mappings for Linux will be ignored in
259 * Windows, etc).
260 *
261 * This function will load the text database entirely in memory before
262 * processing it, so take this into consideration if you are in a memory
263 * constrained environment.
264 *
265 * \param src the data stream for the mappings to be added
266 * \param freesrc if SDL_TRUE, calls SDL_RWclose() on `src` before returning,
267 * even in the case of an error
268 * \returns the number of mappings added or -1 on error; call SDL_GetError()
269 * for more information.
270 *
271 * \since This function is available since SDL 3.0.0.
272 *
273 * \sa SDL_AddGamepadMapping
274 * \sa SDL_AddGamepadMappingsFromFile
275 * \sa SDL_GetGamepadMappingForGUID
276 */
277extern DECLSPEC int SDLCALL SDL_AddGamepadMappingsFromRW(SDL_RWops *src, SDL_bool freesrc);
278
279/**
280 * Load a set of gamepad mappings from a file.
281 *
282 * You can call this function several times, if needed, to load different
283 * database files.
284 *
285 * If a new mapping is loaded for an already known gamepad GUID, the later
286 * version will overwrite the one currently loaded.
287 *
288 * Mappings not belonging to the current platform or with no platform field
289 * specified will be ignored (i.e. mappings for Linux will be ignored in
290 * Windows, etc).
291 *
292 * \param file the mappings file to load
293 * \returns the number of mappings added or -1 on error; call SDL_GetError()
294 * for more information.
295 *
296 * \since This function is available since SDL 3.0.0.
297 *
298 * \sa SDL_AddGamepadMapping
299 * \sa SDL_AddGamepadMappingsFromRW
300 * \sa SDL_GetGamepadMappingForGUID
301 */
302extern DECLSPEC int SDLCALL SDL_AddGamepadMappingsFromFile(const char *file);
303
304/**
305 * Reinitialize the SDL mapping database to its initial state.
306 *
307 * This will generate gamepad events as needed if device mappings change.
308 *
309 * \returns 0 on success or a negative error code on failure; call
310 * SDL_GetError() for more information.
311 *
312 * \since This function is available since SDL 3.0.0.
313 */
314extern DECLSPEC int SDLCALL SDL_ReloadGamepadMappings(void);
315
316/**
317 * Get the mapping at a particular index.
318 *
319 * You must free the returned pointer with SDL_free() when you are done with
320 * it, but you do _not_ free each string in the array.
321 *
322 * \param count a pointer filled in with the number of mappings returned, can
323 * be NULL.
324 * \returns an array of the mapping strings, NULL-terminated. Must be freed
325 * with SDL_free(). Returns NULL on error.
326 *
327 * \since This function is available since SDL 3.0.0.
328 */
329extern DECLSPEC char ** SDLCALL SDL_GetGamepadMappings(int *count);
330
331/**
332 * Get the gamepad mapping string for a given GUID.
333 *
334 * The returned string must be freed with SDL_free().
335 *
336 * \param guid a structure containing the GUID for which a mapping is desired
337 * \returns a mapping string or NULL on error; call SDL_GetError() for more
338 * information.
339 *
340 * \since This function is available since SDL 3.0.0.
341 *
342 * \sa SDL_GetJoystickInstanceGUID
343 * \sa SDL_GetJoystickGUID
344 */
345extern DECLSPEC char * SDLCALL SDL_GetGamepadMappingForGUID(SDL_JoystickGUID guid);
346
347/**
348 * Get the current mapping of a gamepad.
349 *
350 * The returned string must be freed with SDL_free().
351 *
352 * Details about mappings are discussed with SDL_AddGamepadMapping().
353 *
354 * \param gamepad the gamepad you want to get the current mapping for
355 * \returns a string that has the gamepad's mapping or NULL if no mapping is
356 * available; call SDL_GetError() for more information.
357 *
358 * \since This function is available since SDL 3.0.0.
359 *
360 * \sa SDL_AddGamepadMapping
361 * \sa SDL_GetGamepadMappingForGUID
362 * \sa SDL_SetGamepadMapping
363 */
364extern DECLSPEC char * SDLCALL SDL_GetGamepadMapping(SDL_Gamepad *gamepad);
365
366/**
367 * Set the current mapping of a joystick or gamepad.
368 *
369 * Details about mappings are discussed with SDL_AddGamepadMapping().
370 *
371 * \param instance_id the joystick instance ID
372 * \param mapping the mapping to use for this device, or NULL to clear the
373 * mapping
374 * \returns 0 on success or a negative error code on failure; call
375 * SDL_GetError() for more information.
376 *
377 * \since This function is available since SDL 3.0.0.
378 *
379 * \sa SDL_AddGamepadMapping
380 * \sa SDL_GetGamepadMapping
381 */
382extern DECLSPEC int SDLCALL SDL_SetGamepadMapping(SDL_JoystickID instance_id, const char *mapping);
383
384/**
385 * Get a list of currently connected gamepads.
386 *
387 * \param count a pointer filled in with the number of gamepads returned
388 * \returns a 0 terminated array of joystick instance IDs which should be
389 * freed with SDL_free(), or NULL on error; call SDL_GetError() for
390 * more details.
391 *
392 * \since This function is available since SDL 3.0.0.
393 *
394 * \sa SDL_OpenGamepad
395 */
396extern DECLSPEC SDL_JoystickID *SDLCALL SDL_GetGamepads(int *count);
397
398/**
399 * Check if the given joystick is supported by the gamepad interface.
400 *
401 * \param instance_id the joystick instance ID
402 * \returns SDL_TRUE if the given joystick is supported by the gamepad
403 * interface, SDL_FALSE if it isn't or it's an invalid index.
404 *
405 * \since This function is available since SDL 3.0.0.
406 *
407 * \sa SDL_OpenGamepad
408 */
409extern DECLSPEC SDL_bool SDLCALL SDL_IsGamepad(SDL_JoystickID instance_id);
410
411/**
412 * Get the implementation dependent name of a gamepad.
413 *
414 * This can be called before any gamepads are opened.
415 *
416 * \param instance_id the joystick instance ID
417 * \returns the name of the selected gamepad. If no name can be found, this
418 * function returns NULL; call SDL_GetError() for more information.
419 *
420 * \since This function is available since SDL 3.0.0.
421 *
422 * \sa SDL_GetGamepadName
423 * \sa SDL_OpenGamepad
424 */
425extern DECLSPEC const char *SDLCALL SDL_GetGamepadInstanceName(SDL_JoystickID instance_id);
426
427/**
428 * Get the implementation dependent path of a gamepad.
429 *
430 * This can be called before any gamepads are opened.
431 *
432 * \param instance_id the joystick instance ID
433 * \returns the path of the selected gamepad. If no path can be found, this
434 * function returns NULL; call SDL_GetError() for more information.
435 *
436 * \since This function is available since SDL 3.0.0.
437 *
438 * \sa SDL_GetGamepadPath
439 * \sa SDL_OpenGamepad
440 */
441extern DECLSPEC const char *SDLCALL SDL_GetGamepadInstancePath(SDL_JoystickID instance_id);
442
443/**
444 * Get the player index of a gamepad.
445 *
446 * This can be called before any gamepads are opened.
447 *
448 * \param instance_id the joystick instance ID
449 * \returns the player index of a gamepad, or -1 if it's not available
450 *
451 * \since This function is available since SDL 3.0.0.
452 *
453 * \sa SDL_GetGamepadPlayerIndex
454 * \sa SDL_OpenGamepad
455 */
456extern DECLSPEC int SDLCALL SDL_GetGamepadInstancePlayerIndex(SDL_JoystickID instance_id);
457
458/**
459 * Get the implementation-dependent GUID of a gamepad.
460 *
461 * This can be called before any gamepads are opened.
462 *
463 * \param instance_id the joystick instance ID
464 * \returns the GUID of the selected gamepad. If called on an invalid index,
465 * this function returns a zero GUID
466 *
467 * \since This function is available since SDL 3.0.0.
468 *
469 * \sa SDL_GetGamepadGUID
470 * \sa SDL_GetGamepadGUIDString
471 */
472extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_GetGamepadInstanceGUID(SDL_JoystickID instance_id);
473
474/**
475 * Get the USB vendor ID of a gamepad, if available.
476 *
477 * This can be called before any gamepads are opened. If the vendor ID isn't
478 * available this function returns 0.
479 *
480 * \param instance_id the joystick instance ID
481 * \returns the USB vendor ID of the selected gamepad. If called on an invalid
482 * index, this function returns zero
483 *
484 * \since This function is available since SDL 3.0.0.
485 */
486extern DECLSPEC Uint16 SDLCALL SDL_GetGamepadInstanceVendor(SDL_JoystickID instance_id);
487
488/**
489 * Get the USB product ID of a gamepad, if available.
490 *
491 * This can be called before any gamepads are opened. If the product ID isn't
492 * available this function returns 0.
493 *
494 * \param instance_id the joystick instance ID
495 * \returns the USB product ID of the selected gamepad. If called on an
496 * invalid index, this function returns zero
497 *
498 * \since This function is available since SDL 3.0.0.
499 */
500extern DECLSPEC Uint16 SDLCALL SDL_GetGamepadInstanceProduct(SDL_JoystickID instance_id);
501
502/**
503 * Get the product version of a gamepad, if available.
504 *
505 * This can be called before any gamepads are opened. If the product version
506 * isn't available this function returns 0.
507 *
508 * \param instance_id the joystick instance ID
509 * \returns the product version of the selected gamepad. If called on an
510 * invalid index, this function returns zero
511 *
512 * \since This function is available since SDL 3.0.0.
513 */
514extern DECLSPEC Uint16 SDLCALL SDL_GetGamepadInstanceProductVersion(SDL_JoystickID instance_id);
515
516/**
517 * Get the type of a gamepad.
518 *
519 * This can be called before any gamepads are opened.
520 *
521 * \param instance_id the joystick instance ID
522 * \returns the gamepad type.
523 *
524 * \since This function is available since SDL 3.0.0.
525 */
526extern DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadInstanceType(SDL_JoystickID instance_id);
527
528/**
529 * Get the type of a gamepad, ignoring any mapping override.
530 *
531 * This can be called before any gamepads are opened.
532 *
533 * \param instance_id the joystick instance ID
534 * \returns the gamepad type.
535 *
536 * \since This function is available since SDL 3.0.0.
537 */
539
540/**
541 * Get the mapping of a gamepad.
542 *
543 * This can be called before any gamepads are opened.
544 *
545 * \param instance_id the joystick instance ID
546 * \returns the mapping string. Must be freed with SDL_free(). Returns NULL if
547 * no mapping is available.
548 *
549 * \since This function is available since SDL 3.0.0.
550 */
551extern DECLSPEC char *SDLCALL SDL_GetGamepadInstanceMapping(SDL_JoystickID instance_id);
552
553/**
554 * Open a gamepad for use.
555 *
556 * \param instance_id the joystick instance ID
557 * \returns a gamepad identifier or NULL if an error occurred; call
558 * SDL_GetError() for more information.
559 *
560 * \since This function is available since SDL 3.0.0.
561 *
562 * \sa SDL_CloseGamepad
563 * \sa SDL_IsGamepad
564 */
565extern DECLSPEC SDL_Gamepad *SDLCALL SDL_OpenGamepad(SDL_JoystickID instance_id);
566
567/**
568 * Get the SDL_Gamepad associated with a joystick instance ID, if it has been
569 * opened.
570 *
571 * \param instance_id the joystick instance ID of the gamepad
572 * \returns an SDL_Gamepad on success or NULL on failure or if it hasn't been
573 * opened yet; call SDL_GetError() for more information.
574 *
575 * \since This function is available since SDL 3.0.0.
576 */
577extern DECLSPEC SDL_Gamepad *SDLCALL SDL_GetGamepadFromInstanceID(SDL_JoystickID instance_id);
578
579/**
580 * Get the SDL_Gamepad associated with a player index.
581 *
582 * \param player_index the player index, which different from the instance ID
583 * \returns the SDL_Gamepad associated with a player index.
584 *
585 * \since This function is available since SDL 3.0.0.
586 *
587 * \sa SDL_GetGamepadPlayerIndex
588 * \sa SDL_SetGamepadPlayerIndex
589 */
590extern DECLSPEC SDL_Gamepad *SDLCALL SDL_GetGamepadFromPlayerIndex(int player_index);
591
592/**
593 * Get the properties associated with an opened gamepad.
594 *
595 * These properties are shared with the underlying joystick object.
596 *
597 * The following read-only properties are provided by SDL:
598 *
599 * - `SDL_PROP_GAMEPAD_CAP_MONO_LED_BOOLEAN`: true if this gamepad has an LED
600 * that has adjustable brightness
601 * - `SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN`: true if this gamepad has an LED
602 * that has adjustable color
603 * - `SDL_PROP_GAMEPAD_CAP_PLAYER_LED_BOOLEAN`: true if this gamepad has a
604 * player LED
605 * - `SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN`: true if this gamepad has
606 * left/right rumble
607 * - `SDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN`: true if this gamepad has
608 * simple trigger rumble
609 *
610 * \param gamepad a gamepad identifier previously returned by
611 * SDL_OpenGamepad()
612 * \returns a valid property ID on success or 0 on failure; call
613 * SDL_GetError() for more information.
614 *
615 * \since This function is available since SDL 3.0.0.
616 *
617 * \sa SDL_GetProperty
618 * \sa SDL_SetProperty
619 */
620extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetGamepadProperties(SDL_Gamepad *gamepad);
621
622#define SDL_PROP_GAMEPAD_CAP_MONO_LED_BOOLEAN SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN
623#define SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN
624#define SDL_PROP_GAMEPAD_CAP_PLAYER_LED_BOOLEAN SDL_PROP_JOYSTICK_CAP_PLAYER_LED_BOOLEAN
625#define SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN
626#define SDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN
627
628/**
629 * Get the instance ID of an opened gamepad.
630 *
631 * \param gamepad a gamepad identifier previously returned by
632 * SDL_OpenGamepad()
633 * \returns the instance ID of the specified gamepad on success or 0 on
634 * failure; call SDL_GetError() for more information.
635 *
636 * \since This function is available since SDL 3.0.0.
637 *
638 * \sa SDL_OpenGamepad
639 */
640extern DECLSPEC SDL_JoystickID SDLCALL SDL_GetGamepadInstanceID(SDL_Gamepad *gamepad);
641
642/**
643 * Get the implementation-dependent name for an opened gamepad.
644 *
645 * \param gamepad a gamepad identifier previously returned by
646 * SDL_OpenGamepad()
647 * \returns the implementation dependent name for the gamepad, or NULL if
648 * there is no name or the identifier passed is invalid.
649 *
650 * \since This function is available since SDL 3.0.0.
651 *
652 * \sa SDL_GetGamepadInstanceName
653 * \sa SDL_OpenGamepad
654 */
655extern DECLSPEC const char *SDLCALL SDL_GetGamepadName(SDL_Gamepad *gamepad);
656
657/**
658 * Get the implementation-dependent path for an opened gamepad.
659 *
660 * \param gamepad a gamepad identifier previously returned by
661 * SDL_OpenGamepad()
662 * \returns the implementation dependent path for the gamepad, or NULL if
663 * there is no path or the identifier passed is invalid.
664 *
665 * \since This function is available since SDL 3.0.0.
666 *
667 * \sa SDL_GetGamepadInstancePath
668 */
669extern DECLSPEC const char *SDLCALL SDL_GetGamepadPath(SDL_Gamepad *gamepad);
670
671/**
672 * Get the type of an opened gamepad.
673 *
674 * \param gamepad the gamepad object to query.
675 * \returns the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not
676 * available.
677 *
678 * \since This function is available since SDL 3.0.0.
679 *
680 * \sa SDL_GetGamepadInstanceType
681 */
682extern DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadType(SDL_Gamepad *gamepad);
683
684/**
685 * Get the type of an opened gamepad, ignoring any mapping override.
686 *
687 * \param gamepad the gamepad object to query.
688 * \returns the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not
689 * available.
690 *
691 * \since This function is available since SDL 3.0.0.
692 *
693 * \sa SDL_GetRealGamepadInstanceType
694 */
695extern DECLSPEC SDL_GamepadType SDLCALL SDL_GetRealGamepadType(SDL_Gamepad *gamepad);
696
697/**
698 * Get the player index of an opened gamepad.
699 *
700 * For XInput gamepads this returns the XInput user index.
701 *
702 * \param gamepad the gamepad object to query.
703 * \returns the player index for gamepad, or -1 if it's not available.
704 *
705 * \since This function is available since SDL 3.0.0.
706 */
707extern DECLSPEC int SDLCALL SDL_GetGamepadPlayerIndex(SDL_Gamepad *gamepad);
708
709/**
710 * Set the player index of an opened gamepad.
711 *
712 * \param gamepad the gamepad object to adjust.
713 * \param player_index Player index to assign to this gamepad, or -1 to clear
714 * the player index and turn off player LEDs.
715 * \returns 0 on success or a negative error code on failure; call
716 * SDL_GetError() for more information.
717 *
718 * \since This function is available since SDL 3.0.0.
719 */
720extern DECLSPEC int SDLCALL SDL_SetGamepadPlayerIndex(SDL_Gamepad *gamepad, int player_index);
721
722/**
723 * Get the USB vendor ID of an opened gamepad, if available.
724 *
725 * If the vendor ID isn't available this function returns 0.
726 *
727 * \param gamepad the gamepad object to query.
728 * \returns the USB vendor ID, or zero if unavailable.
729 *
730 * \since This function is available since SDL 3.0.0.
731 */
732extern DECLSPEC Uint16 SDLCALL SDL_GetGamepadVendor(SDL_Gamepad *gamepad);
733
734/**
735 * Get the USB product ID of an opened gamepad, if available.
736 *
737 * If the product ID isn't available this function returns 0.
738 *
739 * \param gamepad the gamepad object to query.
740 * \returns the USB product ID, or zero if unavailable.
741 *
742 * \since This function is available since SDL 3.0.0.
743 */
744extern DECLSPEC Uint16 SDLCALL SDL_GetGamepadProduct(SDL_Gamepad *gamepad);
745
746/**
747 * Get the product version of an opened gamepad, if available.
748 *
749 * If the product version isn't available this function returns 0.
750 *
751 * \param gamepad the gamepad object to query.
752 * \returns the USB product version, or zero if unavailable.
753 *
754 * \since This function is available since SDL 3.0.0.
755 */
756extern DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductVersion(SDL_Gamepad *gamepad);
757
758/**
759 * Get the firmware version of an opened gamepad, if available.
760 *
761 * If the firmware version isn't available this function returns 0.
762 *
763 * \param gamepad the gamepad object to query.
764 * \returns the gamepad firmware version, or zero if unavailable.
765 *
766 * \since This function is available since SDL 3.0.0.
767 */
768extern DECLSPEC Uint16 SDLCALL SDL_GetGamepadFirmwareVersion(SDL_Gamepad *gamepad);
769
770/**
771 * Get the serial number of an opened gamepad, if available.
772 *
773 * Returns the serial number of the gamepad, or NULL if it is not available.
774 *
775 * \param gamepad the gamepad object to query.
776 * \returns the serial number, or NULL if unavailable.
777 *
778 * \since This function is available since SDL 3.0.0.
779 */
780extern DECLSPEC const char * SDLCALL SDL_GetGamepadSerial(SDL_Gamepad *gamepad);
781
782/**
783 * Get the Steam Input handle of an opened gamepad, if available.
784 *
785 * Returns an InputHandle_t for the gamepad that can be used with Steam Input
786 * API: https://partner.steamgames.com/doc/api/ISteamInput
787 *
788 * \param gamepad the gamepad object to query.
789 * \returns the gamepad handle, or 0 if unavailable.
790 *
791 * \since This function is available since SDL 3.0.0.
792 */
793extern DECLSPEC Uint64 SDLCALL SDL_GetGamepadSteamHandle(SDL_Gamepad *gamepad);
794
795/**
796 * Get the battery level of a gamepad, if available.
797 *
798 * \param gamepad a gamepad identifier previously returned by
799 * SDL_OpenGamepad()
800 * \returns the current battery level as SDL_JoystickPowerLevel on success or
801 * `SDL_JOYSTICK_POWER_UNKNOWN` if it is unknown
802 *
803 * \since This function is available since SDL 3.0.0.
804 */
806
807/**
808 * Check if a gamepad has been opened and is currently connected.
809 *
810 * \param gamepad a gamepad identifier previously returned by
811 * SDL_OpenGamepad()
812 * \returns SDL_TRUE if the gamepad has been opened and is currently
813 * connected, or SDL_FALSE if not.
814 *
815 * \since This function is available since SDL 3.0.0.
816 *
817 * \sa SDL_CloseGamepad
818 * \sa SDL_OpenGamepad
819 */
820extern DECLSPEC SDL_bool SDLCALL SDL_GamepadConnected(SDL_Gamepad *gamepad);
821
822/**
823 * Get the underlying joystick from a gamepad
824 *
825 * This function will give you a SDL_Joystick object, which allows you to use
826 * the SDL_Joystick functions with a SDL_Gamepad object. This would be useful
827 * for getting a joystick's position at any given time, even if it hasn't
828 * moved (moving it would produce an event, which would have the axis' value).
829 *
830 * The pointer returned is owned by the SDL_Gamepad. You should not call
831 * SDL_CloseJoystick() on it, for example, since doing so will likely cause
832 * SDL to crash.
833 *
834 * \param gamepad the gamepad object that you want to get a joystick from
835 * \returns an SDL_Joystick object; call SDL_GetError() for more information.
836 *
837 * \since This function is available since SDL 3.0.0.
838 */
839extern DECLSPEC SDL_Joystick *SDLCALL SDL_GetGamepadJoystick(SDL_Gamepad *gamepad);
840
841/**
842 * Set the state of gamepad event processing.
843 *
844 * If gamepad events are disabled, you must call SDL_UpdateGamepads() yourself
845 * and check the state of the gamepad when you want gamepad information.
846 *
847 * \param enabled whether to process gamepad events or not
848 *
849 * \since This function is available since SDL 3.0.0.
850 *
851 * \sa SDL_GamepadEventsEnabled
852 */
853extern DECLSPEC void SDLCALL SDL_SetGamepadEventsEnabled(SDL_bool enabled);
854
855/**
856 * Query the state of gamepad event processing.
857 *
858 * If gamepad events are disabled, you must call SDL_UpdateGamepads() yourself
859 * and check the state of the gamepad when you want gamepad information.
860 *
861 * \returns SDL_TRUE if gamepad events are being processed, SDL_FALSE
862 * otherwise.
863 *
864 * \since This function is available since SDL 3.0.0.
865 *
866 * \sa SDL_SetGamepadEventsEnabled
867 */
868extern DECLSPEC SDL_bool SDLCALL SDL_GamepadEventsEnabled(void);
869
870/**
871 * Get the SDL joystick layer bindings for a gamepad
872 *
873 * \param gamepad a gamepad
874 * \param count a pointer filled in with the number of bindings returned
875 * \returns a NULL terminated array of pointers to bindings which should be
876 * freed with SDL_free(), or NULL on error; call SDL_GetError() for
877 * more details.
878 *
879 * \since This function is available since SDL 3.0.0.
880 */
881extern DECLSPEC SDL_GamepadBinding **SDLCALL SDL_GetGamepadBindings(SDL_Gamepad *gamepad, int *count);
882
883/**
884 * Manually pump gamepad updates if not using the loop.
885 *
886 * This function is called automatically by the event loop if events are
887 * enabled. Under such circumstances, it will not be necessary to call this
888 * function.
889 *
890 * \since This function is available since SDL 3.0.0.
891 */
892extern DECLSPEC void SDLCALL SDL_UpdateGamepads(void);
893
894/**
895 * Convert a string into SDL_GamepadType enum.
896 *
897 * This function is called internally to translate SDL_Gamepad mapping strings
898 * for the underlying joystick device into the consistent SDL_Gamepad mapping.
899 * You do not normally need to call this function unless you are parsing
900 * SDL_Gamepad mappings in your own code.
901 *
902 * \param str string representing a SDL_GamepadType type
903 * \returns the SDL_GamepadType enum corresponding to the input string, or
904 * `SDL_GAMEPAD_TYPE_UNKNOWN` if no match was found.
905 *
906 * \since This function is available since SDL 3.0.0.
907 *
908 * \sa SDL_GetGamepadStringForType
909 */
910extern DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadTypeFromString(const char *str);
911
912/**
913 * Convert from an SDL_GamepadType enum to a string.
914 *
915 * The caller should not SDL_free() the returned string.
916 *
917 * \param type an enum value for a given SDL_GamepadType
918 * \returns a string for the given type, or NULL if an invalid type is
919 * specified. The string returned is of the format used by
920 * SDL_Gamepad mapping strings.
921 *
922 * \since This function is available since SDL 3.0.0.
923 *
924 * \sa SDL_GetGamepadTypeFromString
925 */
926extern DECLSPEC const char *SDLCALL SDL_GetGamepadStringForType(SDL_GamepadType type);
927
928/**
929 * Convert a string into SDL_GamepadAxis enum.
930 *
931 * This function is called internally to translate SDL_Gamepad mapping strings
932 * for the underlying joystick device into the consistent SDL_Gamepad mapping.
933 * You do not normally need to call this function unless you are parsing
934 * SDL_Gamepad mappings in your own code.
935 *
936 * Note specially that "righttrigger" and "lefttrigger" map to
937 * `SDL_GAMEPAD_AXIS_RIGHT_TRIGGER` and `SDL_GAMEPAD_AXIS_LEFT_TRIGGER`,
938 * respectively.
939 *
940 * \param str string representing a SDL_Gamepad axis
941 * \returns the SDL_GamepadAxis enum corresponding to the input string, or
942 * `SDL_GAMEPAD_AXIS_INVALID` if no match was found.
943 *
944 * \since This function is available since SDL 3.0.0.
945 *
946 * \sa SDL_GetGamepadStringForAxis
947 */
948extern DECLSPEC SDL_GamepadAxis SDLCALL SDL_GetGamepadAxisFromString(const char *str);
949
950/**
951 * Convert from an SDL_GamepadAxis enum to a string.
952 *
953 * The caller should not SDL_free() the returned string.
954 *
955 * \param axis an enum value for a given SDL_GamepadAxis
956 * \returns a string for the given axis, or NULL if an invalid axis is
957 * specified. The string returned is of the format used by
958 * SDL_Gamepad mapping strings.
959 *
960 * \since This function is available since SDL 3.0.0.
961 *
962 * \sa SDL_GetGamepadAxisFromString
963 */
964extern DECLSPEC const char* SDLCALL SDL_GetGamepadStringForAxis(SDL_GamepadAxis axis);
965
966/**
967 * Query whether a gamepad has a given axis.
968 *
969 * This merely reports whether the gamepad's mapping defined this axis, as
970 * that is all the information SDL has about the physical device.
971 *
972 * \param gamepad a gamepad
973 * \param axis an axis enum value (an SDL_GamepadAxis value)
974 * \returns SDL_TRUE if the gamepad has this axis, SDL_FALSE otherwise.
975 *
976 * \since This function is available since SDL 3.0.0.
977 */
978extern DECLSPEC SDL_bool SDLCALL SDL_GamepadHasAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis);
979
980/**
981 * Get the current state of an axis control on a gamepad.
982 *
983 * The axis indices start at index 0.
984 *
985 * For thumbsticks, the state is a value ranging from -32768 (up/left) to
986 * 32767 (down/right).
987 *
988 * Triggers range from 0 when released to 32767 when fully pressed, and never
989 * return a negative value. Note that this differs from the value reported by
990 * the lower-level SDL_GetJoystickAxis(), which normally uses the full range.
991 *
992 * \param gamepad a gamepad
993 * \param axis an axis index (one of the SDL_GamepadAxis values)
994 * \returns axis state (including 0) on success or 0 (also) on failure; call
995 * SDL_GetError() for more information.
996 *
997 * \since This function is available since SDL 3.0.0.
998 *
999 * \sa SDL_GetGamepadButton
1000 */
1001extern DECLSPEC Sint16 SDLCALL SDL_GetGamepadAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis);
1002
1003/**
1004 * Convert a string into an SDL_GamepadButton enum.
1005 *
1006 * This function is called internally to translate SDL_Gamepad mapping strings
1007 * for the underlying joystick device into the consistent SDL_Gamepad mapping.
1008 * You do not normally need to call this function unless you are parsing
1009 * SDL_Gamepad mappings in your own code.
1010 *
1011 * \param str string representing a SDL_Gamepad axis
1012 * \returns the SDL_GamepadButton enum corresponding to the input string, or
1013 * `SDL_GAMEPAD_BUTTON_INVALID` if no match was found.
1014 *
1015 * \since This function is available since SDL 3.0.0.
1016 */
1017extern DECLSPEC SDL_GamepadButton SDLCALL SDL_GetGamepadButtonFromString(const char *str);
1018
1019/**
1020 * Convert from an SDL_GamepadButton enum to a string.
1021 *
1022 * The caller should not SDL_free() the returned string.
1023 *
1024 * \param button an enum value for a given SDL_GamepadButton
1025 * \returns a string for the given button, or NULL if an invalid button is
1026 * specified. The string returned is of the format used by
1027 * SDL_Gamepad mapping strings.
1028 *
1029 * \since This function is available since SDL 3.0.0.
1030 *
1031 * \sa SDL_GetGamepadButtonFromString
1032 */
1033extern DECLSPEC const char* SDLCALL SDL_GetGamepadStringForButton(SDL_GamepadButton button);
1034
1035/**
1036 * Query whether a gamepad has a given button.
1037 *
1038 * This merely reports whether the gamepad's mapping defined this button, as
1039 * that is all the information SDL has about the physical device.
1040 *
1041 * \param gamepad a gamepad
1042 * \param button a button enum value (an SDL_GamepadButton value)
1043 * \returns SDL_TRUE if the gamepad has this button, SDL_FALSE otherwise.
1044 *
1045 * \since This function is available since SDL 3.0.0.
1046 */
1047extern DECLSPEC SDL_bool SDLCALL SDL_GamepadHasButton(SDL_Gamepad *gamepad, SDL_GamepadButton button);
1048
1049/**
1050 * Get the current state of a button on a gamepad.
1051 *
1052 * \param gamepad a gamepad
1053 * \param button a button index (one of the SDL_GamepadButton values)
1054 * \returns 1 for pressed state or 0 for not pressed state or error; call
1055 * SDL_GetError() for more information.
1056 *
1057 * \since This function is available since SDL 3.0.0.
1058 *
1059 * \sa SDL_GetGamepadAxis
1060 */
1061extern DECLSPEC Uint8 SDLCALL SDL_GetGamepadButton(SDL_Gamepad *gamepad, SDL_GamepadButton button);
1062
1063/**
1064 * Get the label of a button on a gamepad.
1065 *
1066 * \param type the type of gamepad to check
1067 * \param button a button index (one of the SDL_GamepadButton values)
1068 * \returns the SDL_GamepadButtonLabel enum corresponding to the button label
1069 *
1070 * \since This function is available since SDL 3.0.0.
1071 *
1072 * \sa SDL_GetGamepadButtonLabel
1073 */
1075
1076/**
1077 * Get the label of a button on a gamepad.
1078 *
1079 * \param gamepad a gamepad
1080 * \param button a button index (one of the SDL_GamepadButton values)
1081 * \returns the SDL_GamepadButtonLabel enum corresponding to the button label
1082 *
1083 * \since This function is available since SDL 3.0.0.
1084 *
1085 * \sa SDL_GetGamepadButtonLabelForType
1086 */
1088
1089/**
1090 * Get the number of touchpads on a gamepad.
1091 *
1092 * \param gamepad a gamepad
1093 * \returns number of touchpads
1094 *
1095 * \since This function is available since SDL 3.0.0.
1096 */
1097extern DECLSPEC int SDLCALL SDL_GetNumGamepadTouchpads(SDL_Gamepad *gamepad);
1098
1099/**
1100 * Get the number of supported simultaneous fingers on a touchpad on a game
1101 * gamepad.
1102 *
1103 * \param gamepad a gamepad
1104 * \param touchpad a touchpad
1105 * \returns number of supported simultaneous fingers
1106 *
1107 * \since This function is available since SDL 3.0.0.
1108 */
1109extern DECLSPEC int SDLCALL SDL_GetNumGamepadTouchpadFingers(SDL_Gamepad *gamepad, int touchpad);
1110
1111/**
1112 * Get the current state of a finger on a touchpad on a gamepad.
1113 *
1114 * \param gamepad a gamepad
1115 * \param touchpad a touchpad
1116 * \param finger a finger
1117 * \param state filled with state
1118 * \param x filled with x position
1119 * \param y filled with y position
1120 * \param pressure filled with pressure value
1121 * \returns 0 on success or a negative error code on failure; call
1122 * SDL_GetError() for more information.
1123 *
1124 * \since This function is available since SDL 3.0.0.
1125 */
1126extern DECLSPEC int SDLCALL SDL_GetGamepadTouchpadFinger(SDL_Gamepad *gamepad, int touchpad, int finger, Uint8 *state, float *x, float *y, float *pressure);
1127
1128/**
1129 * Return whether a gamepad has a particular sensor.
1130 *
1131 * \param gamepad The gamepad to query
1132 * \param type The type of sensor to query
1133 * \returns SDL_TRUE if the sensor exists, SDL_FALSE otherwise.
1134 *
1135 * \since This function is available since SDL 3.0.0.
1136 */
1137extern DECLSPEC SDL_bool SDLCALL SDL_GamepadHasSensor(SDL_Gamepad *gamepad, SDL_SensorType type);
1138
1139/**
1140 * Set whether data reporting for a gamepad sensor is enabled.
1141 *
1142 * \param gamepad The gamepad to update
1143 * \param type The type of sensor to enable/disable
1144 * \param enabled Whether data reporting should be enabled
1145 * \returns 0 on success or a negative error code on failure; call
1146 * SDL_GetError() for more information.
1147 *
1148 * \since This function is available since SDL 3.0.0.
1149 */
1150extern DECLSPEC int SDLCALL SDL_SetGamepadSensorEnabled(SDL_Gamepad *gamepad, SDL_SensorType type, SDL_bool enabled);
1151
1152/**
1153 * Query whether sensor data reporting is enabled for a gamepad.
1154 *
1155 * \param gamepad The gamepad to query
1156 * \param type The type of sensor to query
1157 * \returns SDL_TRUE if the sensor is enabled, SDL_FALSE otherwise.
1158 *
1159 * \since This function is available since SDL 3.0.0.
1160 */
1161extern DECLSPEC SDL_bool SDLCALL SDL_GamepadSensorEnabled(SDL_Gamepad *gamepad, SDL_SensorType type);
1162
1163/**
1164 * Get the data rate (number of events per second) of a gamepad sensor.
1165 *
1166 * \param gamepad The gamepad to query
1167 * \param type The type of sensor to query
1168 * \returns the data rate, or 0.0f if the data rate is not available.
1169 *
1170 * \since This function is available since SDL 3.0.0.
1171 */
1172extern DECLSPEC float SDLCALL SDL_GetGamepadSensorDataRate(SDL_Gamepad *gamepad, SDL_SensorType type);
1173
1174/**
1175 * Get the current state of a gamepad sensor.
1176 *
1177 * The number of values and interpretation of the data is sensor dependent.
1178 * See SDL_sensor.h for the details for each type of sensor.
1179 *
1180 * \param gamepad The gamepad to query
1181 * \param type The type of sensor to query
1182 * \param data A pointer filled with the current sensor state
1183 * \param num_values The number of values to write to data
1184 * \returns 0 on success or a negative error code on failure; call
1185 * SDL_GetError() for more information.
1186 *
1187 * \since This function is available since SDL 3.0.0.
1188 */
1189extern DECLSPEC int SDLCALL SDL_GetGamepadSensorData(SDL_Gamepad *gamepad, SDL_SensorType type, float *data, int num_values);
1190
1191/**
1192 * Start a rumble effect on a gamepad.
1193 *
1194 * Each call to this function cancels any previous rumble effect, and calling
1195 * it with 0 intensity stops any rumbling.
1196 *
1197 * \param gamepad The gamepad to vibrate
1198 * \param low_frequency_rumble The intensity of the low frequency (left)
1199 * rumble motor, from 0 to 0xFFFF
1200 * \param high_frequency_rumble The intensity of the high frequency (right)
1201 * rumble motor, from 0 to 0xFFFF
1202 * \param duration_ms The duration of the rumble effect, in milliseconds
1203 * \returns 0, or -1 if rumble isn't supported on this gamepad
1204 *
1205 * \since This function is available since SDL 3.0.0.
1206 */
1207extern DECLSPEC int SDLCALL SDL_RumbleGamepad(SDL_Gamepad *gamepad, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
1208
1209/**
1210 * Start a rumble effect in the gamepad's triggers.
1211 *
1212 * Each call to this function cancels any previous trigger rumble effect, and
1213 * calling it with 0 intensity stops any rumbling.
1214 *
1215 * Note that this is rumbling of the _triggers_ and not the gamepad as a
1216 * whole. This is currently only supported on Xbox One gamepads. If you want
1217 * the (more common) whole-gamepad rumble, use SDL_RumbleGamepad() instead.
1218 *
1219 * \param gamepad The gamepad to vibrate
1220 * \param left_rumble The intensity of the left trigger rumble motor, from 0
1221 * to 0xFFFF
1222 * \param right_rumble The intensity of the right trigger rumble motor, from 0
1223 * to 0xFFFF
1224 * \param duration_ms The duration of the rumble effect, in milliseconds
1225 * \returns 0 on success or a negative error code on failure; call
1226 * SDL_GetError() for more information.
1227 *
1228 * \since This function is available since SDL 3.0.0.
1229 */
1230extern DECLSPEC int SDLCALL SDL_RumbleGamepadTriggers(SDL_Gamepad *gamepad, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
1231
1232/**
1233 * Update a gamepad's LED color.
1234 *
1235 * An example of a joystick LED is the light on the back of a PlayStation 4's
1236 * DualShock 4 controller.
1237 *
1238 * For gamepads with a single color LED, the maximum of the RGB values will be
1239 * used as the LED brightness.
1240 *
1241 * \param gamepad The gamepad to update
1242 * \param red The intensity of the red LED
1243 * \param green The intensity of the green LED
1244 * \param blue The intensity of the blue LED
1245 * \returns 0 on success or a negative error code on failure; call
1246 * SDL_GetError() for more information.
1247 *
1248 * \since This function is available since SDL 3.0.0.
1249 */
1250extern DECLSPEC int SDLCALL SDL_SetGamepadLED(SDL_Gamepad *gamepad, Uint8 red, Uint8 green, Uint8 blue);
1251
1252/**
1253 * Send a gamepad specific effect packet
1254 *
1255 * \param gamepad The gamepad to affect
1256 * \param data The data to send to the gamepad
1257 * \param size The size of the data to send to the gamepad
1258 * \returns 0 on success or a negative error code on failure; call
1259 * SDL_GetError() for more information.
1260 *
1261 * \since This function is available since SDL 3.0.0.
1262 */
1263extern DECLSPEC int SDLCALL SDL_SendGamepadEffect(SDL_Gamepad *gamepad, const void *data, int size);
1264
1265/**
1266 * Close a gamepad previously opened with SDL_OpenGamepad().
1267 *
1268 * \param gamepad a gamepad identifier previously returned by
1269 * SDL_OpenGamepad()
1270 *
1271 * \since This function is available since SDL 3.0.0.
1272 *
1273 * \sa SDL_OpenGamepad
1274 */
1275extern DECLSPEC void SDLCALL SDL_CloseGamepad(SDL_Gamepad *gamepad);
1276
1277/**
1278 * Return the sfSymbolsName for a given button on a gamepad on Apple
1279 * platforms.
1280 *
1281 * \param gamepad the gamepad to query
1282 * \param button a button on the gamepad
1283 * \returns the sfSymbolsName or NULL if the name can't be found
1284 *
1285 * \since This function is available since SDL 3.0.0.
1286 *
1287 * \sa SDL_GetGamepadAppleSFSymbolsNameForAxis
1288 */
1289extern DECLSPEC const char* SDLCALL SDL_GetGamepadAppleSFSymbolsNameForButton(SDL_Gamepad *gamepad, SDL_GamepadButton button);
1290
1291/**
1292 * Return the sfSymbolsName for a given axis on a gamepad on Apple platforms.
1293 *
1294 * \param gamepad the gamepad to query
1295 * \param axis an axis on the gamepad
1296 * \returns the sfSymbolsName or NULL if the name can't be found
1297 *
1298 * \since This function is available since SDL 3.0.0.
1299 *
1300 * \sa SDL_GetGamepadAppleSFSymbolsNameForButton
1301 */
1302extern DECLSPEC const char* SDLCALL SDL_GetGamepadAppleSFSymbolsNameForAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis);
1303
1304
1305/* Ends C function definitions when using C++ */
1306#ifdef __cplusplus
1307}
1308#endif
1309#include <SDL3/SDL_close_code.h>
1310
1311#endif /* SDL_gamepad_h_ */
SDL_Gamepad * SDL_OpenGamepad(SDL_JoystickID instance_id)
SDL_bool SDL_GamepadHasAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis)
const char * SDL_GetGamepadInstancePath(SDL_JoystickID instance_id)
int SDL_GetNumGamepadTouchpads(SDL_Gamepad *gamepad)
SDL_GamepadAxis
@ SDL_GAMEPAD_AXIS_RIGHTX
@ SDL_GAMEPAD_AXIS_MAX
@ SDL_GAMEPAD_AXIS_RIGHT_TRIGGER
@ SDL_GAMEPAD_AXIS_LEFTX
@ SDL_GAMEPAD_AXIS_INVALID
@ SDL_GAMEPAD_AXIS_LEFTY
@ SDL_GAMEPAD_AXIS_LEFT_TRIGGER
@ SDL_GAMEPAD_AXIS_RIGHTY
int SDL_GetGamepadTouchpadFinger(SDL_Gamepad *gamepad, int touchpad, int finger, Uint8 *state, float *x, float *y, float *pressure)
Uint8 SDL_GetGamepadButton(SDL_Gamepad *gamepad, SDL_GamepadButton button)
SDL_GamepadType SDL_GetGamepadType(SDL_Gamepad *gamepad)
int SDL_GetGamepadSensorData(SDL_Gamepad *gamepad, SDL_SensorType type, float *data, int num_values)
SDL_GamepadAxis SDL_GetGamepadAxisFromString(const char *str)
SDL_JoystickID SDL_GetGamepadInstanceID(SDL_Gamepad *gamepad)
SDL_GamepadButton SDL_GetGamepadButtonFromString(const char *str)
struct SDL_Gamepad SDL_Gamepad
Definition SDL_gamepad.h:60
SDL_JoystickPowerLevel SDL_GetGamepadPowerLevel(SDL_Gamepad *gamepad)
SDL_bool SDL_GamepadHasButton(SDL_Gamepad *gamepad, SDL_GamepadButton button)
SDL_GamepadBindingType
@ SDL_GAMEPAD_BINDTYPE_HAT
@ SDL_GAMEPAD_BINDTYPE_BUTTON
@ SDL_GAMEPAD_BINDTYPE_NONE
@ SDL_GAMEPAD_BINDTYPE_AXIS
char ** SDL_GetGamepadMappings(int *count)
Uint16 SDL_GetGamepadFirmwareVersion(SDL_Gamepad *gamepad)
int SDL_AddGamepadMappingsFromRW(SDL_RWops *src, SDL_bool freesrc)
SDL_GamepadButton
Definition SDL_gamepad.h:99
@ SDL_GAMEPAD_BUTTON_LEFT_PADDLE2
@ SDL_GAMEPAD_BUTTON_WEST
@ SDL_GAMEPAD_BUTTON_EAST
@ SDL_GAMEPAD_BUTTON_GUIDE
@ SDL_GAMEPAD_BUTTON_LEFT_STICK
@ SDL_GAMEPAD_BUTTON_TOUCHPAD
@ SDL_GAMEPAD_BUTTON_LEFT_SHOULDER
@ SDL_GAMEPAD_BUTTON_DPAD_DOWN
@ SDL_GAMEPAD_BUTTON_MAX
@ SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1
@ SDL_GAMEPAD_BUTTON_INVALID
@ SDL_GAMEPAD_BUTTON_MISC1
@ SDL_GAMEPAD_BUTTON_BACK
@ SDL_GAMEPAD_BUTTON_DPAD_UP
@ SDL_GAMEPAD_BUTTON_LEFT_PADDLE1
@ SDL_GAMEPAD_BUTTON_RIGHT_STICK
@ SDL_GAMEPAD_BUTTON_START
@ SDL_GAMEPAD_BUTTON_DPAD_RIGHT
@ SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER
@ SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2
@ SDL_GAMEPAD_BUTTON_SOUTH
@ SDL_GAMEPAD_BUTTON_DPAD_LEFT
@ SDL_GAMEPAD_BUTTON_NORTH
int SDL_SetGamepadMapping(SDL_JoystickID instance_id, const char *mapping)
SDL_Gamepad * SDL_GetGamepadFromInstanceID(SDL_JoystickID instance_id)
char * SDL_GetGamepadMapping(SDL_Gamepad *gamepad)
Uint16 SDL_GetGamepadProductVersion(SDL_Gamepad *gamepad)
SDL_GamepadType SDL_GetGamepadTypeFromString(const char *str)
char * SDL_GetGamepadInstanceMapping(SDL_JoystickID instance_id)
Uint16 SDL_GetGamepadProduct(SDL_Gamepad *gamepad)
int SDL_SendGamepadEffect(SDL_Gamepad *gamepad, const void *data, int size)
char * SDL_GetGamepadMappingForGUID(SDL_JoystickGUID guid)
int SDL_SetGamepadSensorEnabled(SDL_Gamepad *gamepad, SDL_SensorType type, SDL_bool enabled)
int SDL_GetGamepadPlayerIndex(SDL_Gamepad *gamepad)
const char * SDL_GetGamepadName(SDL_Gamepad *gamepad)
const char * SDL_GetGamepadAppleSFSymbolsNameForAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis)
int SDL_AddGamepadMapping(const char *mapping)
int SDL_RumbleGamepadTriggers(SDL_Gamepad *gamepad, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms)
SDL_bool SDL_GamepadConnected(SDL_Gamepad *gamepad)
int SDL_RumbleGamepad(SDL_Gamepad *gamepad, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
const char * SDL_GetGamepadSerial(SDL_Gamepad *gamepad)
const char * SDL_GetGamepadStringForAxis(SDL_GamepadAxis axis)
int SDL_SetGamepadLED(SDL_Gamepad *gamepad, Uint8 red, Uint8 green, Uint8 blue)
SDL_GamepadButtonLabel SDL_GetGamepadButtonLabelForType(SDL_GamepadType type, SDL_GamepadButton button)
SDL_PropertiesID SDL_GetGamepadProperties(SDL_Gamepad *gamepad)
const char * SDL_GetGamepadAppleSFSymbolsNameForButton(SDL_Gamepad *gamepad, SDL_GamepadButton button)
const char * SDL_GetGamepadStringForType(SDL_GamepadType type)
const char * SDL_GetGamepadStringForButton(SDL_GamepadButton button)
Uint16 SDL_GetGamepadInstanceProduct(SDL_JoystickID instance_id)
void SDL_SetGamepadEventsEnabled(SDL_bool enabled)
SDL_GamepadButtonLabel SDL_GetGamepadButtonLabel(SDL_Gamepad *gamepad, SDL_GamepadButton button)
SDL_Joystick * SDL_GetGamepadJoystick(SDL_Gamepad *gamepad)
Uint16 SDL_GetGamepadInstanceProductVersion(SDL_JoystickID instance_id)
SDL_bool SDL_IsGamepad(SDL_JoystickID instance_id)
int SDL_SetGamepadPlayerIndex(SDL_Gamepad *gamepad, int player_index)
int SDL_AddGamepadMappingsFromFile(const char *file)
SDL_Gamepad * SDL_GetGamepadFromPlayerIndex(int player_index)
SDL_GamepadType SDL_GetRealGamepadInstanceType(SDL_JoystickID instance_id)
SDL_bool SDL_GamepadSensorEnabled(SDL_Gamepad *gamepad, SDL_SensorType type)
const char * SDL_GetGamepadInstanceName(SDL_JoystickID instance_id)
Uint64 SDL_GetGamepadSteamHandle(SDL_Gamepad *gamepad)
Sint16 SDL_GetGamepadAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis)
void SDL_UpdateGamepads(void)
void SDL_CloseGamepad(SDL_Gamepad *gamepad)
SDL_GamepadType
Definition SDL_gamepad.h:63
@ SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT
Definition SDL_gamepad.h:72
@ SDL_GAMEPAD_TYPE_PS5
Definition SDL_gamepad.h:70
@ SDL_GAMEPAD_TYPE_UNKNOWN
Definition SDL_gamepad.h:64
@ SDL_GAMEPAD_TYPE_MAX
Definition SDL_gamepad.h:75
@ SDL_GAMEPAD_TYPE_XBOX360
Definition SDL_gamepad.h:66
@ SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT
Definition SDL_gamepad.h:73
@ SDL_GAMEPAD_TYPE_XBOXONE
Definition SDL_gamepad.h:67
@ SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO
Definition SDL_gamepad.h:71
@ SDL_GAMEPAD_TYPE_PS4
Definition SDL_gamepad.h:69
@ SDL_GAMEPAD_TYPE_PS3
Definition SDL_gamepad.h:68
@ SDL_GAMEPAD_TYPE_STANDARD
Definition SDL_gamepad.h:65
@ SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR
Definition SDL_gamepad.h:74
SDL_JoystickGUID SDL_GetGamepadInstanceGUID(SDL_JoystickID instance_id)
Uint16 SDL_GetGamepadInstanceVendor(SDL_JoystickID instance_id)
SDL_bool SDL_GamepadHasSensor(SDL_Gamepad *gamepad, SDL_SensorType type)
int SDL_GetGamepadInstancePlayerIndex(SDL_JoystickID instance_id)
SDL_GamepadType SDL_GetGamepadInstanceType(SDL_JoystickID instance_id)
SDL_GamepadButtonLabel
@ SDL_GAMEPAD_BUTTON_LABEL_CIRCLE
@ SDL_GAMEPAD_BUTTON_LABEL_X
@ SDL_GAMEPAD_BUTTON_LABEL_TRIANGLE
@ SDL_GAMEPAD_BUTTON_LABEL_B
@ SDL_GAMEPAD_BUTTON_LABEL_SQUARE
@ SDL_GAMEPAD_BUTTON_LABEL_CROSS
@ SDL_GAMEPAD_BUTTON_LABEL_UNKNOWN
@ SDL_GAMEPAD_BUTTON_LABEL_Y
@ SDL_GAMEPAD_BUTTON_LABEL_A
SDL_bool SDL_GamepadEventsEnabled(void)
SDL_GamepadBinding ** SDL_GetGamepadBindings(SDL_Gamepad *gamepad, int *count)
Uint16 SDL_GetGamepadVendor(SDL_Gamepad *gamepad)
int SDL_GetNumGamepadTouchpadFingers(SDL_Gamepad *gamepad, int touchpad)
const char * SDL_GetGamepadPath(SDL_Gamepad *gamepad)
float SDL_GetGamepadSensorDataRate(SDL_Gamepad *gamepad, SDL_SensorType type)
SDL_GamepadType SDL_GetRealGamepadType(SDL_Gamepad *gamepad)
int SDL_ReloadGamepadMappings(void)
SDL_JoystickID * SDL_GetGamepads(int *count)
Uint32 SDL_JoystickID
SDL_JoystickPowerLevel
struct SDL_Joystick SDL_Joystick
Uint32 SDL_PropertiesID
SDL_SensorType
Definition SDL_sensor.h:70
uint8_t Uint8
Definition SDL_stdinc.h:150
uint16_t Uint16
Definition SDL_stdinc.h:162
SDL_MALLOC size_t size
Definition SDL_stdinc.h:400
int SDL_bool
Definition SDL_stdinc.h:137
int16_t Sint16
Definition SDL_stdinc.h:156
uint64_t Uint64
Definition SDL_stdinc.h:187
uint32_t Uint32
Definition SDL_stdinc.h:174
SDL_GamepadButton button
SDL_GamepadBindingType outputType
SDL_GamepadBindingType inputType
SDL_GamepadAxis axis