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