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_CAP_MONO_LED_BOOLEAN`: true if this gamepad has an LED
811 * that has adjustable brightness
812 * - `SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN`: true if this gamepad has an LED
813 * that has adjustable color
814 * - `SDL_PROP_GAMEPAD_CAP_PLAYER_LED_BOOLEAN`: true if this gamepad has a
815 * player LED
816 * - `SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN`: true if this gamepad has
817 * left/right rumble
818 * - `SDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN`: true if this gamepad has
819 * simple trigger rumble
820 *
821 * \param gamepad a gamepad identifier previously returned by
822 * SDL_OpenGamepad().
823 * \returns a valid property ID on success or 0 on failure; call
824 * SDL_GetError() for more information.
825 *
826 * \threadsafety It is safe to call this function from any thread.
827 *
828 * \since This function is available since SDL 3.2.0.
829 */
830extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetGamepadProperties(SDL_Gamepad *gamepad);
831
832#define SDL_PROP_GAMEPAD_CAP_MONO_LED_BOOLEAN SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN
833#define SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN
834#define SDL_PROP_GAMEPAD_CAP_PLAYER_LED_BOOLEAN SDL_PROP_JOYSTICK_CAP_PLAYER_LED_BOOLEAN
835#define SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN
836#define SDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN
837
838/**
839 * Get the instance ID of an opened gamepad.
840 *
841 * \param gamepad a gamepad identifier previously returned by
842 * SDL_OpenGamepad().
843 * \returns the instance ID of the specified gamepad on success or 0 on
844 * failure; call SDL_GetError() for more information.
845 *
846 * \threadsafety It is safe to call this function from any thread.
847 *
848 * \since This function is available since SDL 3.2.0.
849 */
850extern SDL_DECLSPEC SDL_JoystickID SDLCALL SDL_GetGamepadID(SDL_Gamepad *gamepad);
851
852/**
853 * Get the implementation-dependent name for an opened gamepad.
854 *
855 * \param gamepad a gamepad identifier previously returned by
856 * SDL_OpenGamepad().
857 * \returns the implementation dependent name for the gamepad, or NULL if
858 * there is no name or the identifier passed is invalid.
859 *
860 * \threadsafety It is safe to call this function from any thread.
861 *
862 * \since This function is available since SDL 3.2.0.
863 *
864 * \sa SDL_GetGamepadNameForID
865 */
866extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadName(SDL_Gamepad *gamepad);
867
868/**
869 * Get the implementation-dependent path for an opened gamepad.
870 *
871 * \param gamepad a gamepad identifier previously returned by
872 * SDL_OpenGamepad().
873 * \returns the implementation dependent path for the gamepad, or NULL if
874 * there is no path or the identifier passed is invalid.
875 *
876 * \threadsafety It is safe to call this function from any thread.
877 *
878 * \since This function is available since SDL 3.2.0.
879 *
880 * \sa SDL_GetGamepadPathForID
881 */
882extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadPath(SDL_Gamepad *gamepad);
883
884/**
885 * Get the type of an opened gamepad.
886 *
887 * \param gamepad the gamepad object to query.
888 * \returns the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not
889 * available.
890 *
891 * \threadsafety It is safe to call this function from any thread.
892 *
893 * \since This function is available since SDL 3.2.0.
894 *
895 * \sa SDL_GetGamepadTypeForID
896 */
897extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadType(SDL_Gamepad *gamepad);
898
899/**
900 * Get the type of an opened gamepad, ignoring any mapping override.
901 *
902 * \param gamepad the gamepad object to query.
903 * \returns the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not
904 * available.
905 *
906 * \threadsafety It is safe to call this function from any thread.
907 *
908 * \since This function is available since SDL 3.2.0.
909 *
910 * \sa SDL_GetRealGamepadTypeForID
911 */
912extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetRealGamepadType(SDL_Gamepad *gamepad);
913
914/**
915 * Get the player index of an opened gamepad.
916 *
917 * For XInput gamepads this returns the XInput user index.
918 *
919 * \param gamepad the gamepad object to query.
920 * \returns the player index for gamepad, or -1 if it's not available.
921 *
922 * \threadsafety It is safe to call this function from any thread.
923 *
924 * \since This function is available since SDL 3.2.0.
925 *
926 * \sa SDL_SetGamepadPlayerIndex
927 */
928extern SDL_DECLSPEC int SDLCALL SDL_GetGamepadPlayerIndex(SDL_Gamepad *gamepad);
929
930/**
931 * Set the player index of an opened gamepad.
932 *
933 * \param gamepad the gamepad object to adjust.
934 * \param player_index player index to assign to this gamepad, or -1 to clear
935 * the player index and turn off player LEDs.
936 * \returns true on success or false on failure; call SDL_GetError() for more
937 * information.
938 *
939 * \threadsafety It is safe to call this function from any thread.
940 *
941 * \since This function is available since SDL 3.2.0.
942 *
943 * \sa SDL_GetGamepadPlayerIndex
944 */
945extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadPlayerIndex(SDL_Gamepad *gamepad, int player_index);
946
947/**
948 * Get the USB vendor ID of an opened gamepad, if available.
949 *
950 * If the vendor ID isn't available this function returns 0.
951 *
952 * \param gamepad the gamepad object to query.
953 * \returns the USB vendor ID, or zero if unavailable.
954 *
955 * \threadsafety It is safe to call this function from any thread.
956 *
957 * \since This function is available since SDL 3.2.0.
958 *
959 * \sa SDL_GetGamepadVendorForID
960 */
961extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadVendor(SDL_Gamepad *gamepad);
962
963/**
964 * Get the USB product ID of an opened gamepad, if available.
965 *
966 * If the product ID isn't available this function returns 0.
967 *
968 * \param gamepad the gamepad object to query.
969 * \returns the USB product ID, or zero if unavailable.
970 *
971 * \threadsafety It is safe to call this function from any thread.
972 *
973 * \since This function is available since SDL 3.2.0.
974 *
975 * \sa SDL_GetGamepadProductForID
976 */
977extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProduct(SDL_Gamepad *gamepad);
978
979/**
980 * Get the product version of an opened gamepad, if available.
981 *
982 * If the product version isn't available this function returns 0.
983 *
984 * \param gamepad the gamepad object to query.
985 * \returns the USB product version, or zero if unavailable.
986 *
987 * \threadsafety It is safe to call this function from any thread.
988 *
989 * \since This function is available since SDL 3.2.0.
990 *
991 * \sa SDL_GetGamepadProductVersionForID
992 */
993extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductVersion(SDL_Gamepad *gamepad);
994
995/**
996 * Get the firmware version of an opened gamepad, if available.
997 *
998 * If the firmware version isn't available this function returns 0.
999 *
1000 * \param gamepad the gamepad object to query.
1001 * \returns the gamepad firmware version, or zero if unavailable.
1002 *
1003 * \threadsafety It is safe to call this function from any thread.
1004 *
1005 * \since This function is available since SDL 3.2.0.
1006 */
1007extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadFirmwareVersion(SDL_Gamepad *gamepad);
1008
1009/**
1010 * Get the serial number of an opened gamepad, if available.
1011 *
1012 * Returns the serial number of the gamepad, or NULL if it is not available.
1013 *
1014 * \param gamepad the gamepad object to query.
1015 * \returns the serial number, or NULL if unavailable.
1016 *
1017 * \threadsafety It is safe to call this function from any thread.
1018 *
1019 * \since This function is available since SDL 3.2.0.
1020 */
1021extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadSerial(SDL_Gamepad *gamepad);
1022
1023/**
1024 * Get the Steam Input handle of an opened gamepad, if available.
1025 *
1026 * Returns an InputHandle_t for the gamepad that can be used with Steam Input
1027 * API: https://partner.steamgames.com/doc/api/ISteamInput
1028 *
1029 * \param gamepad the gamepad object to query.
1030 * \returns the gamepad handle, or 0 if unavailable.
1031 *
1032 * \threadsafety It is safe to call this function from any thread.
1033 *
1034 * \since This function is available since SDL 3.2.0.
1035 */
1036extern SDL_DECLSPEC Uint64 SDLCALL SDL_GetGamepadSteamHandle(SDL_Gamepad *gamepad);
1037
1038/**
1039 * Get the connection state of a gamepad.
1040 *
1041 * \param gamepad the gamepad object to query.
1042 * \returns the connection state on success or
1043 * `SDL_JOYSTICK_CONNECTION_INVALID` on failure; call SDL_GetError()
1044 * for more information.
1045 *
1046 * \threadsafety It is safe to call this function from any thread.
1047 *
1048 * \since This function is available since SDL 3.2.0.
1049 */
1051
1052/**
1053 * Get the battery state of a gamepad.
1054 *
1055 * You should never take a battery status as absolute truth. Batteries
1056 * (especially failing batteries) are delicate hardware, and the values
1057 * reported here are best estimates based on what that hardware reports. It's
1058 * not uncommon for older batteries to lose stored power much faster than it
1059 * reports, or completely drain when reporting it has 20 percent left, etc.
1060 *
1061 * \param gamepad the gamepad object to query.
1062 * \param percent a pointer filled in with the percentage of battery life
1063 * left, between 0 and 100, or NULL to ignore. This will be
1064 * filled in with -1 we can't determine a value or there is no
1065 * battery.
1066 * \returns the current battery state.
1067 *
1068 * \threadsafety It is safe to call this function from any thread.
1069 *
1070 * \since This function is available since SDL 3.2.0.
1071 */
1072extern SDL_DECLSPEC SDL_PowerState SDLCALL SDL_GetGamepadPowerInfo(SDL_Gamepad *gamepad, int *percent);
1073
1074/**
1075 * Check if a gamepad has been opened and is currently connected.
1076 *
1077 * \param gamepad a gamepad identifier previously returned by
1078 * SDL_OpenGamepad().
1079 * \returns true if the gamepad has been opened and is currently connected, or
1080 * false if not.
1081 *
1082 * \threadsafety It is safe to call this function from any thread.
1083 *
1084 * \since This function is available since SDL 3.2.0.
1085 */
1086extern SDL_DECLSPEC bool SDLCALL SDL_GamepadConnected(SDL_Gamepad *gamepad);
1087
1088/**
1089 * Get the underlying joystick from a gamepad.
1090 *
1091 * This function will give you a SDL_Joystick object, which allows you to use
1092 * the SDL_Joystick functions with a SDL_Gamepad object. This would be useful
1093 * for getting a joystick's position at any given time, even if it hasn't
1094 * moved (moving it would produce an event, which would have the axis' value).
1095 *
1096 * The pointer returned is owned by the SDL_Gamepad. You should not call
1097 * SDL_CloseJoystick() on it, for example, since doing so will likely cause
1098 * SDL to crash.
1099 *
1100 * \param gamepad the gamepad object that you want to get a joystick from.
1101 * \returns an SDL_Joystick object, or NULL on failure; call SDL_GetError()
1102 * for more information.
1103 *
1104 * \threadsafety It is safe to call this function from any thread.
1105 *
1106 * \since This function is available since SDL 3.2.0.
1107 */
1108extern SDL_DECLSPEC SDL_Joystick * SDLCALL SDL_GetGamepadJoystick(SDL_Gamepad *gamepad);
1109
1110/**
1111 * Set the state of gamepad event processing.
1112 *
1113 * If gamepad events are disabled, you must call SDL_UpdateGamepads() yourself
1114 * and check the state of the gamepad when you want gamepad information.
1115 *
1116 * \param enabled whether to process gamepad events or not.
1117 *
1118 * \threadsafety It is safe to call this function from any thread.
1119 *
1120 * \since This function is available since SDL 3.2.0.
1121 *
1122 * \sa SDL_GamepadEventsEnabled
1123 * \sa SDL_UpdateGamepads
1124 */
1125extern SDL_DECLSPEC void SDLCALL SDL_SetGamepadEventsEnabled(bool enabled);
1126
1127/**
1128 * Query the state of gamepad event processing.
1129 *
1130 * If gamepad events are disabled, you must call SDL_UpdateGamepads() yourself
1131 * and check the state of the gamepad when you want gamepad information.
1132 *
1133 * \returns true if gamepad events are being processed, false otherwise.
1134 *
1135 * \threadsafety It is safe to call this function from any thread.
1136 *
1137 * \since This function is available since SDL 3.2.0.
1138 *
1139 * \sa SDL_SetGamepadEventsEnabled
1140 */
1141extern SDL_DECLSPEC bool SDLCALL SDL_GamepadEventsEnabled(void);
1142
1143/**
1144 * Get the SDL joystick layer bindings for a gamepad.
1145 *
1146 * \param gamepad a gamepad.
1147 * \param count a pointer filled in with the number of bindings returned.
1148 * \returns a NULL terminated array of pointers to bindings or NULL on
1149 * failure; call SDL_GetError() for more information. This is a
1150 * single allocation that should be freed with SDL_free() when it is
1151 * no longer needed.
1152 *
1153 * \threadsafety It is safe to call this function from any thread.
1154 *
1155 * \since This function is available since SDL 3.2.0.
1156 */
1157extern SDL_DECLSPEC SDL_GamepadBinding ** SDLCALL SDL_GetGamepadBindings(SDL_Gamepad *gamepad, int *count);
1158
1159/**
1160 * Manually pump gamepad updates if not using the loop.
1161 *
1162 * This function is called automatically by the event loop if events are
1163 * enabled. Under such circumstances, it will not be necessary to call this
1164 * function.
1165 *
1166 * \threadsafety It is safe to call this function from any thread.
1167 *
1168 * \since This function is available since SDL 3.2.0.
1169 */
1170extern SDL_DECLSPEC void SDLCALL SDL_UpdateGamepads(void);
1171
1172/**
1173 * Convert a string into SDL_GamepadType enum.
1174 *
1175 * This function is called internally to translate SDL_Gamepad mapping strings
1176 * for the underlying joystick device into the consistent SDL_Gamepad mapping.
1177 * You do not normally need to call this function unless you are parsing
1178 * SDL_Gamepad mappings in your own code.
1179 *
1180 * \param str string representing a SDL_GamepadType type.
1181 * \returns the SDL_GamepadType enum corresponding to the input string, or
1182 * `SDL_GAMEPAD_TYPE_UNKNOWN` if no match was found.
1183 *
1184 * \threadsafety It is safe to call this function from any thread.
1185 *
1186 * \since This function is available since SDL 3.2.0.
1187 *
1188 * \sa SDL_GetGamepadStringForType
1189 */
1190extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadTypeFromString(const char *str);
1191
1192/**
1193 * Convert from an SDL_GamepadType enum to a string.
1194 *
1195 * \param type an enum value for a given SDL_GamepadType.
1196 * \returns a string for the given type, or NULL if an invalid type is
1197 * specified. The string returned is of the format used by
1198 * SDL_Gamepad mapping strings.
1199 *
1200 * \threadsafety It is safe to call this function from any thread.
1201 *
1202 * \since This function is available since SDL 3.2.0.
1203 *
1204 * \sa SDL_GetGamepadTypeFromString
1205 */
1206extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForType(SDL_GamepadType type);
1207
1208/**
1209 * Convert a string into SDL_GamepadAxis enum.
1210 *
1211 * This function is called internally to translate SDL_Gamepad mapping strings
1212 * for the underlying joystick device into the consistent SDL_Gamepad mapping.
1213 * You do not normally need to call this function unless you are parsing
1214 * SDL_Gamepad mappings in your own code.
1215 *
1216 * Note specially that "righttrigger" and "lefttrigger" map to
1217 * `SDL_GAMEPAD_AXIS_RIGHT_TRIGGER` and `SDL_GAMEPAD_AXIS_LEFT_TRIGGER`,
1218 * respectively.
1219 *
1220 * \param str string representing a SDL_Gamepad axis.
1221 * \returns the SDL_GamepadAxis enum corresponding to the input string, or
1222 * `SDL_GAMEPAD_AXIS_INVALID` if no match was found.
1223 *
1224 * \threadsafety It is safe to call this function from any thread.
1225 *
1226 * \since This function is available since SDL 3.2.0.
1227 *
1228 * \sa SDL_GetGamepadStringForAxis
1229 */
1230extern SDL_DECLSPEC SDL_GamepadAxis SDLCALL SDL_GetGamepadAxisFromString(const char *str);
1231
1232/**
1233 * Convert from an SDL_GamepadAxis enum to a string.
1234 *
1235 * \param axis an enum value for a given SDL_GamepadAxis.
1236 * \returns a string for the given axis, or NULL if an invalid axis is
1237 * specified. The string returned is of the format used by
1238 * SDL_Gamepad mapping strings.
1239 *
1240 * \threadsafety It is safe to call this function from any thread.
1241 *
1242 * \since This function is available since SDL 3.2.0.
1243 *
1244 * \sa SDL_GetGamepadAxisFromString
1245 */
1246extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForAxis(SDL_GamepadAxis axis);
1247
1248/**
1249 * Query whether a gamepad has a given axis.
1250 *
1251 * This merely reports whether the gamepad's mapping defined this axis, as
1252 * that is all the information SDL has about the physical device.
1253 *
1254 * \param gamepad a gamepad.
1255 * \param axis an axis enum value (an SDL_GamepadAxis value).
1256 * \returns true if the gamepad has this axis, false otherwise.
1257 *
1258 * \threadsafety It is safe to call this function from any thread.
1259 *
1260 * \since This function is available since SDL 3.2.0.
1261 *
1262 * \sa SDL_GamepadHasButton
1263 * \sa SDL_GetGamepadAxis
1264 */
1265extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis);
1266
1267/**
1268 * Get the current state of an axis control on a gamepad.
1269 *
1270 * The axis indices start at index 0.
1271 *
1272 * For thumbsticks, the state is a value ranging from -32768 (up/left) to
1273 * 32767 (down/right).
1274 *
1275 * Triggers range from 0 when released to 32767 when fully pressed, and never
1276 * return a negative value. Note that this differs from the value reported by
1277 * the lower-level SDL_GetJoystickAxis(), which normally uses the full range.
1278 *
1279 * Note that for invalid gamepads or axes, this will return 0. Zero is also a
1280 * valid value in normal operation; usually it means a centered axis.
1281 *
1282 * \param gamepad a gamepad.
1283 * \param axis an axis index (one of the SDL_GamepadAxis values).
1284 * \returns axis state.
1285 *
1286 * \threadsafety It is safe to call this function from any thread.
1287 *
1288 * \since This function is available since SDL 3.2.0.
1289 *
1290 * \sa SDL_GamepadHasAxis
1291 * \sa SDL_GetGamepadButton
1292 */
1293extern SDL_DECLSPEC Sint16 SDLCALL SDL_GetGamepadAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis);
1294
1295/**
1296 * Convert a string into an SDL_GamepadButton enum.
1297 *
1298 * This function is called internally to translate SDL_Gamepad mapping strings
1299 * for the underlying joystick device into the consistent SDL_Gamepad mapping.
1300 * You do not normally need to call this function unless you are parsing
1301 * SDL_Gamepad mappings in your own code.
1302 *
1303 * \param str string representing a SDL_Gamepad button.
1304 * \returns the SDL_GamepadButton enum corresponding to the input string, or
1305 * `SDL_GAMEPAD_BUTTON_INVALID` if no match was found.
1306 *
1307 * \threadsafety It is safe to call this function from any thread.
1308 *
1309 * \since This function is available since SDL 3.2.0.
1310 *
1311 * \sa SDL_GetGamepadStringForButton
1312 */
1313extern SDL_DECLSPEC SDL_GamepadButton SDLCALL SDL_GetGamepadButtonFromString(const char *str);
1314
1315/**
1316 * Convert from an SDL_GamepadButton enum to a string.
1317 *
1318 * \param button an enum value for a given SDL_GamepadButton.
1319 * \returns a string for the given button, or NULL if an invalid button is
1320 * specified. The string returned is of the format used by
1321 * SDL_Gamepad mapping strings.
1322 *
1323 * \threadsafety It is safe to call this function from any thread.
1324 *
1325 * \since This function is available since SDL 3.2.0.
1326 *
1327 * \sa SDL_GetGamepadButtonFromString
1328 */
1329extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForButton(SDL_GamepadButton button);
1330
1331/**
1332 * Query whether a gamepad has a given button.
1333 *
1334 * This merely reports whether the gamepad's mapping defined this button, as
1335 * that is all the information SDL has about the physical device.
1336 *
1337 * \param gamepad a gamepad.
1338 * \param button a button enum value (an SDL_GamepadButton value).
1339 * \returns true if the gamepad has this button, false otherwise.
1340 *
1341 * \threadsafety It is safe to call this function from any thread.
1342 *
1343 * \since This function is available since SDL 3.2.0.
1344 *
1345 * \sa SDL_GamepadHasAxis
1346 */
1347extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasButton(SDL_Gamepad *gamepad, SDL_GamepadButton button);
1348
1349/**
1350 * Get the current state of a button on a gamepad.
1351 *
1352 * \param gamepad a gamepad.
1353 * \param button a button index (one of the SDL_GamepadButton values).
1354 * \returns true if the button is pressed, false otherwise.
1355 *
1356 * \threadsafety It is safe to call this function from any thread.
1357 *
1358 * \since This function is available since SDL 3.2.0.
1359 *
1360 * \sa SDL_GamepadHasButton
1361 * \sa SDL_GetGamepadAxis
1362 */
1363extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadButton(SDL_Gamepad *gamepad, SDL_GamepadButton button);
1364
1365/**
1366 * Get the label of a button on a gamepad.
1367 *
1368 * \param type the type of gamepad to check.
1369 * \param button a button index (one of the SDL_GamepadButton values).
1370 * \returns the SDL_GamepadButtonLabel enum corresponding to the button label.
1371 *
1372 * \threadsafety It is safe to call this function from any thread.
1373 *
1374 * \since This function is available since SDL 3.2.0.
1375 *
1376 * \sa SDL_GetGamepadButtonLabel
1377 */
1379
1380/**
1381 * Get the label of a button on a gamepad.
1382 *
1383 * \param gamepad a gamepad.
1384 * \param button a button index (one of the SDL_GamepadButton values).
1385 * \returns the SDL_GamepadButtonLabel enum corresponding to the button label.
1386 *
1387 * \threadsafety It is safe to call this function from any thread.
1388 *
1389 * \since This function is available since SDL 3.2.0.
1390 *
1391 * \sa SDL_GetGamepadButtonLabelForType
1392 */
1394
1395/**
1396 * Get the number of touchpads on a gamepad.
1397 *
1398 * \param gamepad a gamepad.
1399 * \returns number of touchpads.
1400 *
1401 * \threadsafety It is safe to call this function from any thread.
1402 *
1403 * \since This function is available since SDL 3.2.0.
1404 *
1405 * \sa SDL_GetNumGamepadTouchpadFingers
1406 */
1407extern SDL_DECLSPEC int SDLCALL SDL_GetNumGamepadTouchpads(SDL_Gamepad *gamepad);
1408
1409/**
1410 * Get the number of supported simultaneous fingers on a touchpad on a game
1411 * gamepad.
1412 *
1413 * \param gamepad a gamepad.
1414 * \param touchpad a touchpad.
1415 * \returns number of supported simultaneous fingers.
1416 *
1417 * \threadsafety It is safe to call this function from any thread.
1418 *
1419 * \since This function is available since SDL 3.2.0.
1420 *
1421 * \sa SDL_GetGamepadTouchpadFinger
1422 * \sa SDL_GetNumGamepadTouchpads
1423 */
1424extern SDL_DECLSPEC int SDLCALL SDL_GetNumGamepadTouchpadFingers(SDL_Gamepad *gamepad, int touchpad);
1425
1426/**
1427 * Get the current state of a finger on a touchpad on a gamepad.
1428 *
1429 * \param gamepad a gamepad.
1430 * \param touchpad a touchpad.
1431 * \param finger a finger.
1432 * \param down a pointer filled with true if the finger is down, false
1433 * otherwise, may be NULL.
1434 * \param x a pointer filled with the x position, normalized 0 to 1, with the
1435 * origin in the upper left, may be NULL.
1436 * \param y a pointer filled with the y position, normalized 0 to 1, with the
1437 * origin in the upper left, may be NULL.
1438 * \param pressure a pointer filled with pressure value, may be NULL.
1439 * \returns true on success or false on failure; call SDL_GetError() for more
1440 * information.
1441 *
1442 * \threadsafety It is safe to call this function from any thread.
1443 *
1444 * \since This function is available since SDL 3.2.0.
1445 *
1446 * \sa SDL_GetNumGamepadTouchpadFingers
1447 */
1448extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadTouchpadFinger(SDL_Gamepad *gamepad, int touchpad, int finger, bool *down, float *x, float *y, float *pressure);
1449
1450/**
1451 * Return whether a gamepad has a particular sensor.
1452 *
1453 * \param gamepad the gamepad to query.
1454 * \param type the type of sensor to query.
1455 * \returns true if the sensor exists, false otherwise.
1456 *
1457 * \threadsafety It is safe to call this function from any thread.
1458 *
1459 * \since This function is available since SDL 3.2.0.
1460 *
1461 * \sa SDL_GetGamepadSensorData
1462 * \sa SDL_GetGamepadSensorDataRate
1463 * \sa SDL_SetGamepadSensorEnabled
1464 */
1465extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasSensor(SDL_Gamepad *gamepad, SDL_SensorType type);
1466
1467/**
1468 * Set whether data reporting for a gamepad sensor is enabled.
1469 *
1470 * \param gamepad the gamepad to update.
1471 * \param type the type of sensor to enable/disable.
1472 * \param enabled whether data reporting should be enabled.
1473 * \returns true on success or false on failure; call SDL_GetError() for more
1474 * information.
1475 *
1476 * \threadsafety It is safe to call this function from any thread.
1477 *
1478 * \since This function is available since SDL 3.2.0.
1479 *
1480 * \sa SDL_GamepadHasSensor
1481 * \sa SDL_GamepadSensorEnabled
1482 */
1483extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadSensorEnabled(SDL_Gamepad *gamepad, SDL_SensorType type, bool enabled);
1484
1485/**
1486 * Query whether sensor data reporting is enabled for a gamepad.
1487 *
1488 * \param gamepad the gamepad to query.
1489 * \param type the type of sensor to query.
1490 * \returns true if the sensor is enabled, false otherwise.
1491 *
1492 * \threadsafety It is safe to call this function from any thread.
1493 *
1494 * \since This function is available since SDL 3.2.0.
1495 *
1496 * \sa SDL_SetGamepadSensorEnabled
1497 */
1498extern SDL_DECLSPEC bool SDLCALL SDL_GamepadSensorEnabled(SDL_Gamepad *gamepad, SDL_SensorType type);
1499
1500/**
1501 * Get the data rate (number of events per second) of a gamepad sensor.
1502 *
1503 * \param gamepad the gamepad to query.
1504 * \param type the type of sensor to query.
1505 * \returns the data rate, or 0.0f if the data rate is not available.
1506 *
1507 * \threadsafety It is safe to call this function from any thread.
1508 *
1509 * \since This function is available since SDL 3.2.0.
1510 */
1511extern SDL_DECLSPEC float SDLCALL SDL_GetGamepadSensorDataRate(SDL_Gamepad *gamepad, SDL_SensorType type);
1512
1513/**
1514 * Get the current state of a gamepad sensor.
1515 *
1516 * The number of values and interpretation of the data is sensor dependent.
1517 * See the remarks in SDL_SensorType for details for each type of sensor.
1518 *
1519 * \param gamepad the gamepad to query.
1520 * \param type the type of sensor to query.
1521 * \param data a pointer filled with the current sensor state.
1522 * \param num_values the number of values to write to data.
1523 * \returns true on success or false on failure; call SDL_GetError() for more
1524 * information.
1525 *
1526 * \threadsafety It is safe to call this function from any thread.
1527 *
1528 * \since This function is available since SDL 3.2.0.
1529 */
1530extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadSensorData(SDL_Gamepad *gamepad, SDL_SensorType type, float *data, int num_values);
1531
1532/**
1533 * Return whether a gamepad has a particular capsense.
1534 *
1535 * \param gamepad the gamepad to query.
1536 * \param type the type of capsense to query.
1537 * \returns true if the capsense exists, false otherwise.
1538 *
1539 * \threadsafety It is safe to call this function from any thread.
1540 *
1541 * \since This function is available since SDL 3.6.0.
1542 *
1543 * \sa SDL_GetGamepadCapSense
1544 */
1545extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasCapSense(SDL_Gamepad *gamepad, SDL_GamepadCapSenseType type);
1546
1547/**
1548 * Get the current state of a capsense on a gamepad.
1549 *
1550 * \param gamepad a gamepad.
1551 * \param type the type of capsense to query.
1552 * \returns true if the capsense is touched, false otherwise.
1553 *
1554 * \threadsafety It is safe to call this function from any thread.
1555 *
1556 * \since This function is available since SDL 3.6.0.
1557 *
1558 * \sa SDL_GamepadHasCapSense
1559 */
1560extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadCapSense(SDL_Gamepad *gamepad, SDL_GamepadCapSenseType type);
1561
1562/**
1563 * Start a rumble effect on a gamepad.
1564 *
1565 * Each call to this function cancels any previous rumble effect, and calling
1566 * it with 0 intensity stops any rumbling.
1567 *
1568 * This function requires you to process SDL events or call
1569 * SDL_UpdateJoysticks() to update rumble state.
1570 *
1571 * \param gamepad the gamepad to vibrate.
1572 * \param low_frequency_rumble the intensity of the low frequency (left)
1573 * rumble motor, from 0 to 0xFFFF.
1574 * \param high_frequency_rumble the intensity of the high frequency (right)
1575 * rumble motor, from 0 to 0xFFFF.
1576 * \param duration_ms the duration of the rumble effect, in milliseconds.
1577 * \returns true on success or false on failure; call SDL_GetError() for more
1578 * information.
1579 *
1580 * \threadsafety It is safe to call this function from any thread.
1581 *
1582 * \since This function is available since SDL 3.2.0.
1583 */
1584extern SDL_DECLSPEC bool SDLCALL SDL_RumbleGamepad(SDL_Gamepad *gamepad, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
1585
1586/**
1587 * Start a rumble effect in the gamepad's triggers.
1588 *
1589 * Each call to this function cancels any previous trigger rumble effect, and
1590 * calling it with 0 intensity stops any rumbling.
1591 *
1592 * Note that this is rumbling of the _triggers_ and not the gamepad as a
1593 * whole. This is currently only supported on Xbox One gamepads. If you want
1594 * the (more common) whole-gamepad rumble, use SDL_RumbleGamepad() instead.
1595 *
1596 * This function requires you to process SDL events or call
1597 * SDL_UpdateJoysticks() to update rumble state.
1598 *
1599 * \param gamepad the gamepad to vibrate.
1600 * \param left_rumble the intensity of the left trigger rumble motor, from 0
1601 * to 0xFFFF.
1602 * \param right_rumble the intensity of the right trigger rumble motor, from 0
1603 * to 0xFFFF.
1604 * \param duration_ms the duration of the rumble effect, in milliseconds.
1605 * \returns true on success or false on failure; call SDL_GetError() for more
1606 * information.
1607 *
1608 * \threadsafety It is safe to call this function from any thread.
1609 *
1610 * \since This function is available since SDL 3.2.0.
1611 *
1612 * \sa SDL_RumbleGamepad
1613 */
1614extern SDL_DECLSPEC bool SDLCALL SDL_RumbleGamepadTriggers(SDL_Gamepad *gamepad, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
1615
1616/**
1617 * Update a gamepad's LED color.
1618 *
1619 * An example of a joystick LED is the light on the back of a PlayStation 4's
1620 * DualShock 4 controller.
1621 *
1622 * For gamepads with a single color LED, the maximum of the RGB values will be
1623 * used as the LED brightness.
1624 *
1625 * \param gamepad the gamepad to update.
1626 * \param red the intensity of the red LED.
1627 * \param green the intensity of the green LED.
1628 * \param blue the intensity of the blue LED.
1629 * \returns true on success or false on failure; call SDL_GetError() for more
1630 * information.
1631 *
1632 * \threadsafety It is safe to call this function from any thread.
1633 *
1634 * \since This function is available since SDL 3.2.0.
1635 */
1636extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadLED(SDL_Gamepad *gamepad, Uint8 red, Uint8 green, Uint8 blue);
1637
1638/**
1639 * Send a gamepad specific effect packet.
1640 *
1641 * \param gamepad the gamepad to affect.
1642 * \param data the data to send to the gamepad.
1643 * \param size the size of the data to send to the gamepad.
1644 * \returns true on success or false on failure; call SDL_GetError() for more
1645 * information.
1646 *
1647 * \threadsafety It is safe to call this function from any thread.
1648 *
1649 * \since This function is available since SDL 3.2.0.
1650 */
1651extern SDL_DECLSPEC bool SDLCALL SDL_SendGamepadEffect(SDL_Gamepad *gamepad, const void *data, int size);
1652
1653/**
1654 * Close a gamepad previously opened with SDL_OpenGamepad().
1655 *
1656 * \param gamepad a gamepad identifier previously returned by
1657 * SDL_OpenGamepad().
1658 *
1659 * \threadsafety It is safe to call this function from any thread.
1660 *
1661 * \since This function is available since SDL 3.2.0.
1662 *
1663 * \sa SDL_OpenGamepad
1664 */
1665extern SDL_DECLSPEC void SDLCALL SDL_CloseGamepad(SDL_Gamepad *gamepad);
1666
1667/**
1668 * Return the sfSymbolsName for a given button on a gamepad on Apple
1669 * platforms.
1670 *
1671 * \param gamepad the gamepad to query.
1672 * \param button a button on the gamepad.
1673 * \returns the sfSymbolsName or NULL if the name can't be found.
1674 *
1675 * \threadsafety It is safe to call this function from any thread.
1676 *
1677 * \since This function is available since SDL 3.2.0.
1678 *
1679 * \sa SDL_GetGamepadAppleSFSymbolsNameForAxis
1680 */
1681extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadAppleSFSymbolsNameForButton(SDL_Gamepad *gamepad, SDL_GamepadButton button);
1682
1683/**
1684 * Return the sfSymbolsName for a given axis on a gamepad on Apple platforms.
1685 *
1686 * \param gamepad the gamepad to query.
1687 * \param axis an axis on the gamepad.
1688 * \returns the sfSymbolsName or NULL if the name can't be found.
1689 *
1690 * \threadsafety It is safe to call this function from any thread.
1691 *
1692 * \since This function is available since SDL 3.2.0.
1693 *
1694 * \sa SDL_GetGamepadAppleSFSymbolsNameForButton
1695 */
1696extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadAppleSFSymbolsNameForAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis);
1697
1698
1699/* Ends C function definitions when using C++ */
1700#ifdef __cplusplus
1701}
1702#endif
1703#include <SDL3/SDL_close_code.h>
1704
1705#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::@346220156327041330373375233275367133327117356321 input
SDL_GamepadBindingType output_type
union SDL_GamepadBinding::@023246265104251154152301236323361032100102034315 output