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