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