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