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 * Types of gamepad control bindings.
237 *
238 * A gamepad is a collection of bindings that map arbitrary joystick buttons,
239 * axes and hat switches to specific positions on a generic console-style
240 * gamepad. This enum is used as part of SDL_GamepadBinding to specify those
241 * mappings.
242 *
243 * \since This enum is available since SDL 3.2.0.
244 */
252
253/**
254 * A mapping between one joystick input to a gamepad control.
255 *
256 * A gamepad has a collection of several bindings, to say, for example, when
257 * joystick button number 5 is pressed, that should be treated like the
258 * gamepad's "start" button.
259 *
260 * SDL has these bindings built-in for many popular controllers, and can add
261 * more with a simple text string. Those strings are parsed into a collection
262 * of these structs to make it easier to operate on the data.
263 *
264 * \since This struct is available since SDL 3.2.0.
265 *
266 * \sa SDL_GetGamepadBindings
267 */
268typedef struct SDL_GamepadBinding
269{
271 union
272 {
274
275 struct
276 {
277 int axis;
281
282 struct
283 {
284 int hat;
287
289
291 union
292 {
294
295 struct
296 {
298 int axis_min;
299 int axis_max;
301
304
305
306/**
307 * Add support for gamepads that SDL is unaware of or change the binding of an
308 * existing gamepad.
309 *
310 * The mapping string has the format "GUID,name,mapping", where GUID is the
311 * string value from SDL_GUIDToString(), name is the human readable string for
312 * the device and mappings are gamepad mappings to joystick ones. Under
313 * Windows there is a reserved GUID of "xinput" that covers all XInput
314 * devices. The mapping format for joystick is:
315 *
316 * - `bX`: a joystick button, index X
317 * - `hX.Y`: hat X with value Y
318 * - `aX`: axis X of the joystick
319 *
320 * Buttons can be used as a gamepad axes and vice versa.
321 *
322 * If a device with this GUID is already plugged in, SDL will generate an
323 * SDL_EVENT_GAMEPAD_ADDED event.
324 *
325 * This string shows an example of a valid mapping for a gamepad:
326 *
327 * ```c
328 * "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"
329 * ```
330 *
331 * \param mapping the mapping string.
332 * \returns 1 if a new mapping is added, 0 if an existing mapping is updated,
333 * -1 on failure; call SDL_GetError() for more information.
334 *
335 * \threadsafety It is safe to call this function from any thread.
336 *
337 * \since This function is available since SDL 3.2.0.
338 *
339 * \sa SDL_AddGamepadMappingsFromFile
340 * \sa SDL_AddGamepadMappingsFromIO
341 * \sa SDL_GetGamepadMapping
342 * \sa SDL_GetGamepadMappingForGUID
343 * \sa SDL_HINT_GAMECONTROLLERCONFIG
344 * \sa SDL_HINT_GAMECONTROLLERCONFIG_FILE
345 * \sa SDL_EVENT_GAMEPAD_ADDED
346 */
347extern SDL_DECLSPEC int SDLCALL SDL_AddGamepadMapping(const char *mapping);
348
349/**
350 * Load a set of gamepad mappings from an SDL_IOStream.
351 *
352 * You can call this function several times, if needed, to load different
353 * database files.
354 *
355 * If a new mapping is loaded for an already known gamepad GUID, the later
356 * version will overwrite the one currently loaded.
357 *
358 * Any new mappings for already plugged in controllers will generate
359 * SDL_EVENT_GAMEPAD_ADDED events.
360 *
361 * Mappings not belonging to the current platform or with no platform field
362 * specified will be ignored (i.e. mappings for Linux will be ignored in
363 * Windows, etc).
364 *
365 * This function will load the text database entirely in memory before
366 * processing it, so take this into consideration if you are in a memory
367 * constrained environment.
368 *
369 * \param src the data stream for the mappings to be added.
370 * \param closeio if true, calls SDL_CloseIO() on `src` before returning, even
371 * in the case of an error.
372 * \returns the number of mappings added or -1 on failure; call SDL_GetError()
373 * for more information.
374 *
375 * \threadsafety It is safe to call this function from any thread.
376 *
377 * \since This function is available since SDL 3.2.0.
378 *
379 * \sa SDL_AddGamepadMapping
380 * \sa SDL_AddGamepadMappingsFromFile
381 * \sa SDL_GetGamepadMapping
382 * \sa SDL_GetGamepadMappingForGUID
383 * \sa SDL_HINT_GAMECONTROLLERCONFIG
384 * \sa SDL_HINT_GAMECONTROLLERCONFIG_FILE
385 * \sa SDL_EVENT_GAMEPAD_ADDED
386 */
387extern SDL_DECLSPEC int SDLCALL SDL_AddGamepadMappingsFromIO(SDL_IOStream *src, bool closeio);
388
389/**
390 * Load a set of gamepad mappings from a file.
391 *
392 * You can call this function several times, if needed, to load different
393 * database files.
394 *
395 * If a new mapping is loaded for an already known gamepad GUID, the later
396 * version will overwrite the one currently loaded.
397 *
398 * Any new mappings for already plugged in controllers will generate
399 * SDL_EVENT_GAMEPAD_ADDED events.
400 *
401 * Mappings not belonging to the current platform or with no platform field
402 * specified will be ignored (i.e. mappings for Linux will be ignored in
403 * Windows, etc).
404 *
405 * \param file the mappings file to load.
406 * \returns the number of mappings added or -1 on failure; call SDL_GetError()
407 * for more information.
408 *
409 * \threadsafety It is safe to call this function from any thread.
410 *
411 * \since This function is available since SDL 3.2.0.
412 *
413 * \sa SDL_AddGamepadMapping
414 * \sa SDL_AddGamepadMappingsFromIO
415 * \sa SDL_GetGamepadMapping
416 * \sa SDL_GetGamepadMappingForGUID
417 * \sa SDL_HINT_GAMECONTROLLERCONFIG
418 * \sa SDL_HINT_GAMECONTROLLERCONFIG_FILE
419 * \sa SDL_EVENT_GAMEPAD_ADDED
420 */
421extern SDL_DECLSPEC int SDLCALL SDL_AddGamepadMappingsFromFile(const char *file);
422
423/**
424 * Reinitialize the SDL mapping database to its initial state.
425 *
426 * This will generate gamepad events as needed if device mappings change.
427 *
428 * \returns true on success or false on failure; call SDL_GetError() for more
429 * information.
430 *
431 * \threadsafety It is safe to call this function from any thread.
432 *
433 * \since This function is available since SDL 3.2.0.
434 */
435extern SDL_DECLSPEC bool SDLCALL SDL_ReloadGamepadMappings(void);
436
437/**
438 * Get the current gamepad mappings.
439 *
440 * \param count a pointer filled in with the number of mappings returned, can
441 * be NULL.
442 * \returns an array of the mapping strings, NULL-terminated, or NULL on
443 * failure; call SDL_GetError() for more information. This is a
444 * single allocation that should be freed with SDL_free() when it is
445 * no longer needed.
446 *
447 * \threadsafety It is safe to call this function from any thread.
448 *
449 * \since This function is available since SDL 3.2.0.
450 */
451extern SDL_DECLSPEC char ** SDLCALL SDL_GetGamepadMappings(int *count);
452
453/**
454 * Get the gamepad mapping string for a given GUID.
455 *
456 * \param guid a structure containing the GUID for which a mapping is desired.
457 * \returns a mapping string or NULL on failure; call SDL_GetError() for more
458 * information. This should be freed with SDL_free() when it is no
459 * longer needed.
460 *
461 * \threadsafety It is safe to call this function from any thread.
462 *
463 * \since This function is available since SDL 3.2.0.
464 *
465 * \sa SDL_GetJoystickGUIDForID
466 * \sa SDL_GetJoystickGUID
467 */
468extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMappingForGUID(SDL_GUID guid);
469
470/**
471 * Get the current mapping of a gamepad.
472 *
473 * Details about mappings are discussed with SDL_AddGamepadMapping().
474 *
475 * \param gamepad the gamepad you want to get the current mapping for.
476 * \returns a string that has the gamepad's mapping or NULL if no mapping is
477 * available; call SDL_GetError() for more information. This should
478 * be freed with SDL_free() when it is no longer needed.
479 *
480 * \threadsafety It is safe to call this function from any thread.
481 *
482 * \since This function is available since SDL 3.2.0.
483 *
484 * \sa SDL_AddGamepadMapping
485 * \sa SDL_GetGamepadMappingForID
486 * \sa SDL_GetGamepadMappingForGUID
487 * \sa SDL_SetGamepadMapping
488 */
489extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMapping(SDL_Gamepad *gamepad);
490
491/**
492 * Set the current mapping of a joystick or gamepad.
493 *
494 * Details about mappings are discussed with SDL_AddGamepadMapping().
495 *
496 * \param instance_id the joystick instance ID.
497 * \param mapping the mapping to use for this device, or NULL to clear the
498 * mapping.
499 * \returns true on success or false on failure; call SDL_GetError() for more
500 * information.
501 *
502 * \threadsafety It is safe to call this function from any thread.
503 *
504 * \since This function is available since SDL 3.2.0.
505 *
506 * \sa SDL_AddGamepadMapping
507 * \sa SDL_GetGamepadMapping
508 */
509extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadMapping(SDL_JoystickID instance_id, const char *mapping);
510
511/**
512 * Return whether a gamepad is currently connected.
513 *
514 * \returns true if a gamepad is connected, false otherwise.
515 *
516 * \threadsafety It is safe to call this function from any thread.
517 *
518 * \since This function is available since SDL 3.2.0.
519 *
520 * \sa SDL_GetGamepads
521 */
522extern SDL_DECLSPEC bool SDLCALL SDL_HasGamepad(void);
523
524/**
525 * Get a list of currently connected gamepads.
526 *
527 * \param count a pointer filled in with the number of gamepads returned, may
528 * be NULL.
529 * \returns a 0 terminated array of joystick instance IDs or NULL on failure;
530 * call SDL_GetError() for more information. This should be freed
531 * with SDL_free() when it is no longer needed.
532 *
533 * \threadsafety It is safe to call this function from any thread.
534 *
535 * \since This function is available since SDL 3.2.0.
536 *
537 * \sa SDL_HasGamepad
538 * \sa SDL_OpenGamepad
539 */
540extern SDL_DECLSPEC SDL_JoystickID * SDLCALL SDL_GetGamepads(int *count);
541
542/**
543 * Check if the given joystick is supported by the gamepad interface.
544 *
545 * \param instance_id the joystick instance ID.
546 * \returns true if the given joystick is supported by the gamepad interface,
547 * false if it isn't or it's an invalid index.
548 *
549 * \threadsafety It is safe to call this function from any thread.
550 *
551 * \since This function is available since SDL 3.2.0.
552 *
553 * \sa SDL_GetJoysticks
554 * \sa SDL_OpenGamepad
555 */
556extern SDL_DECLSPEC bool SDLCALL SDL_IsGamepad(SDL_JoystickID instance_id);
557
558/**
559 * Get the implementation dependent name of a gamepad.
560 *
561 * This can be called before any gamepads are opened.
562 *
563 * \param instance_id the joystick instance ID.
564 * \returns the name of the selected gamepad. If no name can be found, this
565 * function returns NULL; call SDL_GetError() for more information.
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_GetGamepadName
572 * \sa SDL_GetGamepads
573 */
574extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadNameForID(SDL_JoystickID instance_id);
575
576/**
577 * Get the implementation dependent path 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 path of the selected gamepad. If no path 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_GetGamepadPath
590 * \sa SDL_GetGamepads
591 */
592extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadPathForID(SDL_JoystickID instance_id);
593
594/**
595 * Get the player index 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 player index of a gamepad, or -1 if it's not available.
601 *
602 * \threadsafety It is safe to call this function from any thread.
603 *
604 * \since This function is available since SDL 3.2.0.
605 *
606 * \sa SDL_GetGamepadPlayerIndex
607 * \sa SDL_GetGamepads
608 */
609extern SDL_DECLSPEC int SDLCALL SDL_GetGamepadPlayerIndexForID(SDL_JoystickID instance_id);
610
611/**
612 * Get the implementation-dependent GUID of a gamepad.
613 *
614 * This can be called before any gamepads are opened.
615 *
616 * \param instance_id the joystick instance ID.
617 * \returns the GUID of the selected gamepad. If called on an invalid index,
618 * this function returns a zero GUID.
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_GUIDToString
625 * \sa SDL_GetGamepads
626 */
627extern SDL_DECLSPEC SDL_GUID SDLCALL SDL_GetGamepadGUIDForID(SDL_JoystickID instance_id);
628
629/**
630 * Get the USB vendor ID of a gamepad, if available.
631 *
632 * This can be called before any gamepads are opened. If the vendor ID isn't
633 * available this function returns 0.
634 *
635 * \param instance_id the joystick instance ID.
636 * \returns the USB vendor ID of the selected gamepad. If called on an invalid
637 * index, this function returns zero.
638 *
639 * \threadsafety It is safe to call this function from any thread.
640 *
641 * \since This function is available since SDL 3.2.0.
642 *
643 * \sa SDL_GetGamepadVendor
644 * \sa SDL_GetGamepads
645 */
646extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadVendorForID(SDL_JoystickID instance_id);
647
648/**
649 * Get the USB product ID of a gamepad, if available.
650 *
651 * This can be called before any gamepads are opened. If the product ID isn't
652 * available this function returns 0.
653 *
654 * \param instance_id the joystick instance ID.
655 * \returns the USB product ID of the selected gamepad. If called on an
656 * invalid index, this function returns zero.
657 *
658 * \threadsafety It is safe to call this function from any thread.
659 *
660 * \since This function is available since SDL 3.2.0.
661 *
662 * \sa SDL_GetGamepadProduct
663 * \sa SDL_GetGamepads
664 */
665extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductForID(SDL_JoystickID instance_id);
666
667/**
668 * Get the product version of a gamepad, if available.
669 *
670 * This can be called before any gamepads are opened. If the product version
671 * isn't available this function returns 0.
672 *
673 * \param instance_id the joystick instance ID.
674 * \returns the product version of the selected gamepad. If called on an
675 * invalid index, this function returns zero.
676 *
677 * \threadsafety It is safe to call this function from any thread.
678 *
679 * \since This function is available since SDL 3.2.0.
680 *
681 * \sa SDL_GetGamepadProductVersion
682 * \sa SDL_GetGamepads
683 */
684extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductVersionForID(SDL_JoystickID instance_id);
685
686/**
687 * Get the type of a gamepad.
688 *
689 * This can be called before any gamepads are opened.
690 *
691 * \param instance_id the joystick instance ID.
692 * \returns the gamepad type.
693 *
694 * \threadsafety It is safe to call this function from any thread.
695 *
696 * \since This function is available since SDL 3.2.0.
697 *
698 * \sa SDL_GetGamepadType
699 * \sa SDL_GetGamepads
700 * \sa SDL_GetRealGamepadTypeForID
701 */
702extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadTypeForID(SDL_JoystickID instance_id);
703
704/**
705 * Get the type of a gamepad, ignoring any mapping override.
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_GetGamepadTypeForID
717 * \sa SDL_GetGamepads
718 * \sa SDL_GetRealGamepadType
719 */
720extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetRealGamepadTypeForID(SDL_JoystickID instance_id);
721
722/**
723 * Get the mapping of a gamepad.
724 *
725 * This can be called before any gamepads are opened.
726 *
727 * \param instance_id the joystick instance ID.
728 * \returns the mapping string. Returns NULL if no mapping is available. This
729 * should be freed with SDL_free() when it is no longer needed.
730 *
731 * \threadsafety It is safe to call this function from any thread.
732 *
733 * \since This function is available since SDL 3.2.0.
734 *
735 * \sa SDL_GetGamepads
736 * \sa SDL_GetGamepadMapping
737 */
738extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMappingForID(SDL_JoystickID instance_id);
739
740/**
741 * Open a gamepad for use.
742 *
743 * \param instance_id the joystick instance ID.
744 * \returns a gamepad identifier or NULL if an error occurred; call
745 * SDL_GetError() for more information.
746 *
747 * \threadsafety It is safe to call this function from any thread.
748 *
749 * \since This function is available since SDL 3.2.0.
750 *
751 * \sa SDL_CloseGamepad
752 * \sa SDL_IsGamepad
753 */
754extern SDL_DECLSPEC SDL_Gamepad * SDLCALL SDL_OpenGamepad(SDL_JoystickID instance_id);
755
756/**
757 * Get the SDL_Gamepad associated with a joystick instance ID, if it has been
758 * opened.
759 *
760 * \param instance_id the joystick instance ID of the gamepad.
761 * \returns an SDL_Gamepad on success or NULL on failure or if it hasn't been
762 * opened yet; call SDL_GetError() for more information.
763 *
764 * \threadsafety It is safe to call this function from any thread.
765 *
766 * \since This function is available since SDL 3.2.0.
767 */
768extern SDL_DECLSPEC SDL_Gamepad * SDLCALL SDL_GetGamepadFromID(SDL_JoystickID instance_id);
769
770/**
771 * Get the SDL_Gamepad associated with a player index.
772 *
773 * \param player_index the player index, which different from the instance ID.
774 * \returns the SDL_Gamepad associated with a player index.
775 *
776 * \threadsafety It is safe to call this function from any thread.
777 *
778 * \since This function is available since SDL 3.2.0.
779 *
780 * \sa SDL_GetGamepadPlayerIndex
781 * \sa SDL_SetGamepadPlayerIndex
782 */
783extern SDL_DECLSPEC SDL_Gamepad * SDLCALL SDL_GetGamepadFromPlayerIndex(int player_index);
784
785/**
786 * Get the properties associated with an opened gamepad.
787 *
788 * These properties are shared with the underlying joystick object.
789 *
790 * The following read-only properties are provided by SDL:
791 *
792 * - `SDL_PROP_GAMEPAD_CAP_MONO_LED_BOOLEAN`: true if this gamepad has an LED
793 * that has adjustable brightness
794 * - `SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN`: true if this gamepad has an LED
795 * that has adjustable color
796 * - `SDL_PROP_GAMEPAD_CAP_PLAYER_LED_BOOLEAN`: true if this gamepad has a
797 * player LED
798 * - `SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN`: true if this gamepad has
799 * left/right rumble
800 * - `SDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN`: true if this gamepad has
801 * simple trigger rumble
802 *
803 * \param gamepad a gamepad identifier previously returned by
804 * SDL_OpenGamepad().
805 * \returns a valid property ID on success or 0 on failure; call
806 * SDL_GetError() for more information.
807 *
808 * \threadsafety It is safe to call this function from any thread.
809 *
810 * \since This function is available since SDL 3.2.0.
811 */
812extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetGamepadProperties(SDL_Gamepad *gamepad);
813
814#define SDL_PROP_GAMEPAD_CAP_MONO_LED_BOOLEAN SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN
815#define SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN
816#define SDL_PROP_GAMEPAD_CAP_PLAYER_LED_BOOLEAN SDL_PROP_JOYSTICK_CAP_PLAYER_LED_BOOLEAN
817#define SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN
818#define SDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN
819
820/**
821 * Get the instance ID of an opened gamepad.
822 *
823 * \param gamepad a gamepad identifier previously returned by
824 * SDL_OpenGamepad().
825 * \returns the instance ID of the specified gamepad on success or 0 on
826 * failure; call SDL_GetError() for more information.
827 *
828 * \threadsafety It is safe to call this function from any thread.
829 *
830 * \since This function is available since SDL 3.2.0.
831 */
832extern SDL_DECLSPEC SDL_JoystickID SDLCALL SDL_GetGamepadID(SDL_Gamepad *gamepad);
833
834/**
835 * Get the implementation-dependent name for an opened gamepad.
836 *
837 * \param gamepad a gamepad identifier previously returned by
838 * SDL_OpenGamepad().
839 * \returns the implementation dependent name for the gamepad, or NULL if
840 * there is no name or the identifier passed is invalid.
841 *
842 * \threadsafety It is safe to call this function from any thread.
843 *
844 * \since This function is available since SDL 3.2.0.
845 *
846 * \sa SDL_GetGamepadNameForID
847 */
848extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadName(SDL_Gamepad *gamepad);
849
850/**
851 * Get the implementation-dependent path for an opened gamepad.
852 *
853 * \param gamepad a gamepad identifier previously returned by
854 * SDL_OpenGamepad().
855 * \returns the implementation dependent path for the gamepad, or NULL if
856 * there is no path or the identifier passed is invalid.
857 *
858 * \threadsafety It is safe to call this function from any thread.
859 *
860 * \since This function is available since SDL 3.2.0.
861 *
862 * \sa SDL_GetGamepadPathForID
863 */
864extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadPath(SDL_Gamepad *gamepad);
865
866/**
867 * Get the type of an opened gamepad.
868 *
869 * \param gamepad the gamepad object to query.
870 * \returns the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not
871 * available.
872 *
873 * \threadsafety It is safe to call this function from any thread.
874 *
875 * \since This function is available since SDL 3.2.0.
876 *
877 * \sa SDL_GetGamepadTypeForID
878 */
879extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadType(SDL_Gamepad *gamepad);
880
881/**
882 * Get the type of an opened gamepad, ignoring any mapping override.
883 *
884 * \param gamepad the gamepad object to query.
885 * \returns the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not
886 * available.
887 *
888 * \threadsafety It is safe to call this function from any thread.
889 *
890 * \since This function is available since SDL 3.2.0.
891 *
892 * \sa SDL_GetRealGamepadTypeForID
893 */
894extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetRealGamepadType(SDL_Gamepad *gamepad);
895
896/**
897 * Get the player index of an opened gamepad.
898 *
899 * For XInput gamepads this returns the XInput user index.
900 *
901 * \param gamepad the gamepad object to query.
902 * \returns the player index for gamepad, or -1 if it's not available.
903 *
904 * \threadsafety It is safe to call this function from any thread.
905 *
906 * \since This function is available since SDL 3.2.0.
907 *
908 * \sa SDL_SetGamepadPlayerIndex
909 */
910extern SDL_DECLSPEC int SDLCALL SDL_GetGamepadPlayerIndex(SDL_Gamepad *gamepad);
911
912/**
913 * Set the player index of an opened gamepad.
914 *
915 * \param gamepad the gamepad object to adjust.
916 * \param player_index player index to assign to this gamepad, or -1 to clear
917 * the player index and turn off player LEDs.
918 * \returns true on success or false on failure; call SDL_GetError() for more
919 * information.
920 *
921 * \threadsafety It is safe to call this function from any thread.
922 *
923 * \since This function is available since SDL 3.2.0.
924 *
925 * \sa SDL_GetGamepadPlayerIndex
926 */
927extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadPlayerIndex(SDL_Gamepad *gamepad, int player_index);
928
929/**
930 * Get the USB vendor ID of an opened gamepad, if available.
931 *
932 * If the vendor ID isn't available this function returns 0.
933 *
934 * \param gamepad the gamepad object to query.
935 * \returns the USB vendor ID, or zero if unavailable.
936 *
937 * \threadsafety It is safe to call this function from any thread.
938 *
939 * \since This function is available since SDL 3.2.0.
940 *
941 * \sa SDL_GetGamepadVendorForID
942 */
943extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadVendor(SDL_Gamepad *gamepad);
944
945/**
946 * Get the USB product ID of an opened gamepad, if available.
947 *
948 * If the product ID isn't available this function returns 0.
949 *
950 * \param gamepad the gamepad object to query.
951 * \returns the USB product ID, or zero if unavailable.
952 *
953 * \threadsafety It is safe to call this function from any thread.
954 *
955 * \since This function is available since SDL 3.2.0.
956 *
957 * \sa SDL_GetGamepadProductForID
958 */
959extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProduct(SDL_Gamepad *gamepad);
960
961/**
962 * Get the product version of an opened gamepad, if available.
963 *
964 * If the product version isn't available this function returns 0.
965 *
966 * \param gamepad the gamepad object to query.
967 * \returns the USB product version, or zero if unavailable.
968 *
969 * \threadsafety It is safe to call this function from any thread.
970 *
971 * \since This function is available since SDL 3.2.0.
972 *
973 * \sa SDL_GetGamepadProductVersionForID
974 */
975extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductVersion(SDL_Gamepad *gamepad);
976
977/**
978 * Get the firmware version of an opened gamepad, if available.
979 *
980 * If the firmware version isn't available this function returns 0.
981 *
982 * \param gamepad the gamepad object to query.
983 * \returns the gamepad firmware version, or zero if unavailable.
984 *
985 * \threadsafety It is safe to call this function from any thread.
986 *
987 * \since This function is available since SDL 3.2.0.
988 */
989extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadFirmwareVersion(SDL_Gamepad *gamepad);
990
991/**
992 * Get the serial number of an opened gamepad, if available.
993 *
994 * Returns the serial number of the gamepad, or NULL if it is not available.
995 *
996 * \param gamepad the gamepad object to query.
997 * \returns the serial number, or NULL if unavailable.
998 *
999 * \threadsafety It is safe to call this function from any thread.
1000 *
1001 * \since This function is available since SDL 3.2.0.
1002 */
1003extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadSerial(SDL_Gamepad *gamepad);
1004
1005/**
1006 * Get the Steam Input handle of an opened gamepad, if available.
1007 *
1008 * Returns an InputHandle_t for the gamepad that can be used with Steam Input
1009 * API: https://partner.steamgames.com/doc/api/ISteamInput
1010 *
1011 * \param gamepad the gamepad object to query.
1012 * \returns the gamepad handle, or 0 if unavailable.
1013 *
1014 * \threadsafety It is safe to call this function from any thread.
1015 *
1016 * \since This function is available since SDL 3.2.0.
1017 */
1018extern SDL_DECLSPEC Uint64 SDLCALL SDL_GetGamepadSteamHandle(SDL_Gamepad *gamepad);
1019
1020/**
1021 * Get the connection state of a gamepad.
1022 *
1023 * \param gamepad the gamepad object to query.
1024 * \returns the connection state on success or
1025 * `SDL_JOYSTICK_CONNECTION_INVALID` on failure; call SDL_GetError()
1026 * for more information.
1027 *
1028 * \threadsafety It is safe to call this function from any thread.
1029 *
1030 * \since This function is available since SDL 3.2.0.
1031 */
1033
1034/**
1035 * Get the battery state of a gamepad.
1036 *
1037 * You should never take a battery status as absolute truth. Batteries
1038 * (especially failing batteries) are delicate hardware, and the values
1039 * reported here are best estimates based on what that hardware reports. It's
1040 * not uncommon for older batteries to lose stored power much faster than it
1041 * reports, or completely drain when reporting it has 20 percent left, etc.
1042 *
1043 * \param gamepad the gamepad object to query.
1044 * \param percent a pointer filled in with the percentage of battery life
1045 * left, between 0 and 100, or NULL to ignore. This will be
1046 * filled in with -1 we can't determine a value or there is no
1047 * battery.
1048 * \returns the current battery state.
1049 *
1050 * \threadsafety It is safe to call this function from any thread.
1051 *
1052 * \since This function is available since SDL 3.2.0.
1053 */
1054extern SDL_DECLSPEC SDL_PowerState SDLCALL SDL_GetGamepadPowerInfo(SDL_Gamepad *gamepad, int *percent);
1055
1056/**
1057 * Check if a gamepad has been opened and is currently connected.
1058 *
1059 * \param gamepad a gamepad identifier previously returned by
1060 * SDL_OpenGamepad().
1061 * \returns true if the gamepad has been opened and is currently connected, or
1062 * false if not.
1063 *
1064 * \threadsafety It is safe to call this function from any thread.
1065 *
1066 * \since This function is available since SDL 3.2.0.
1067 */
1068extern SDL_DECLSPEC bool SDLCALL SDL_GamepadConnected(SDL_Gamepad *gamepad);
1069
1070/**
1071 * Get the underlying joystick from a gamepad.
1072 *
1073 * This function will give you a SDL_Joystick object, which allows you to use
1074 * the SDL_Joystick functions with a SDL_Gamepad object. This would be useful
1075 * for getting a joystick's position at any given time, even if it hasn't
1076 * moved (moving it would produce an event, which would have the axis' value).
1077 *
1078 * The pointer returned is owned by the SDL_Gamepad. You should not call
1079 * SDL_CloseJoystick() on it, for example, since doing so will likely cause
1080 * SDL to crash.
1081 *
1082 * \param gamepad the gamepad object that you want to get a joystick from.
1083 * \returns an SDL_Joystick object, or NULL on failure; call SDL_GetError()
1084 * for more information.
1085 *
1086 * \threadsafety It is safe to call this function from any thread.
1087 *
1088 * \since This function is available since SDL 3.2.0.
1089 */
1090extern SDL_DECLSPEC SDL_Joystick * SDLCALL SDL_GetGamepadJoystick(SDL_Gamepad *gamepad);
1091
1092/**
1093 * Set the state of gamepad event processing.
1094 *
1095 * If gamepad events are disabled, you must call SDL_UpdateGamepads() yourself
1096 * and check the state of the gamepad when you want gamepad information.
1097 *
1098 * \param enabled whether to process gamepad events or not.
1099 *
1100 * \threadsafety It is safe to call this function from any thread.
1101 *
1102 * \since This function is available since SDL 3.2.0.
1103 *
1104 * \sa SDL_GamepadEventsEnabled
1105 * \sa SDL_UpdateGamepads
1106 */
1107extern SDL_DECLSPEC void SDLCALL SDL_SetGamepadEventsEnabled(bool enabled);
1108
1109/**
1110 * Query the state of gamepad event processing.
1111 *
1112 * If gamepad events are disabled, you must call SDL_UpdateGamepads() yourself
1113 * and check the state of the gamepad when you want gamepad information.
1114 *
1115 * \returns true if gamepad events are being processed, false otherwise.
1116 *
1117 * \threadsafety It is safe to call this function from any thread.
1118 *
1119 * \since This function is available since SDL 3.2.0.
1120 *
1121 * \sa SDL_SetGamepadEventsEnabled
1122 */
1123extern SDL_DECLSPEC bool SDLCALL SDL_GamepadEventsEnabled(void);
1124
1125/**
1126 * Get the SDL joystick layer bindings for a gamepad.
1127 *
1128 * \param gamepad a gamepad.
1129 * \param count a pointer filled in with the number of bindings returned.
1130 * \returns a NULL terminated array of pointers to bindings or NULL on
1131 * failure; call SDL_GetError() for more information. This is a
1132 * single allocation that should be freed with SDL_free() when it is
1133 * no longer needed.
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 */
1139extern SDL_DECLSPEC SDL_GamepadBinding ** SDLCALL SDL_GetGamepadBindings(SDL_Gamepad *gamepad, int *count);
1140
1141/**
1142 * Manually pump gamepad updates if not using the loop.
1143 *
1144 * This function is called automatically by the event loop if events are
1145 * enabled. Under such circumstances, it will not be necessary to call this
1146 * function.
1147 *
1148 * \threadsafety It is safe to call this function from any thread.
1149 *
1150 * \since This function is available since SDL 3.2.0.
1151 */
1152extern SDL_DECLSPEC void SDLCALL SDL_UpdateGamepads(void);
1153
1154/**
1155 * Convert a string into SDL_GamepadType enum.
1156 *
1157 * This function is called internally to translate SDL_Gamepad mapping strings
1158 * for the underlying joystick device into the consistent SDL_Gamepad mapping.
1159 * You do not normally need to call this function unless you are parsing
1160 * SDL_Gamepad mappings in your own code.
1161 *
1162 * \param str string representing a SDL_GamepadType type.
1163 * \returns the SDL_GamepadType enum corresponding to the input string, or
1164 * `SDL_GAMEPAD_TYPE_UNKNOWN` if no match was found.
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 *
1170 * \sa SDL_GetGamepadStringForType
1171 */
1172extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadTypeFromString(const char *str);
1173
1174/**
1175 * Convert from an SDL_GamepadType enum to a string.
1176 *
1177 * \param type an enum value for a given SDL_GamepadType.
1178 * \returns a string for the given type, or NULL if an invalid type is
1179 * specified. The string returned is of the format used by
1180 * SDL_Gamepad mapping strings.
1181 *
1182 * \threadsafety It is safe to call this function from any thread.
1183 *
1184 * \since This function is available since SDL 3.2.0.
1185 *
1186 * \sa SDL_GetGamepadTypeFromString
1187 */
1188extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForType(SDL_GamepadType type);
1189
1190/**
1191 * Convert a string into SDL_GamepadAxis enum.
1192 *
1193 * This function is called internally to translate SDL_Gamepad mapping strings
1194 * for the underlying joystick device into the consistent SDL_Gamepad mapping.
1195 * You do not normally need to call this function unless you are parsing
1196 * SDL_Gamepad mappings in your own code.
1197 *
1198 * Note specially that "righttrigger" and "lefttrigger" map to
1199 * `SDL_GAMEPAD_AXIS_RIGHT_TRIGGER` and `SDL_GAMEPAD_AXIS_LEFT_TRIGGER`,
1200 * respectively.
1201 *
1202 * \param str string representing a SDL_Gamepad axis.
1203 * \returns the SDL_GamepadAxis enum corresponding to the input string, or
1204 * `SDL_GAMEPAD_AXIS_INVALID` if no match was found.
1205 *
1206 * \threadsafety It is safe to call this function from any thread.
1207 *
1208 * \since This function is available since SDL 3.2.0.
1209 *
1210 * \sa SDL_GetGamepadStringForAxis
1211 */
1212extern SDL_DECLSPEC SDL_GamepadAxis SDLCALL SDL_GetGamepadAxisFromString(const char *str);
1213
1214/**
1215 * Convert from an SDL_GamepadAxis enum to a string.
1216 *
1217 * \param axis an enum value for a given SDL_GamepadAxis.
1218 * \returns a string for the given axis, or NULL if an invalid axis is
1219 * specified. The string returned is of the format used by
1220 * SDL_Gamepad mapping strings.
1221 *
1222 * \threadsafety It is safe to call this function from any thread.
1223 *
1224 * \since This function is available since SDL 3.2.0.
1225 *
1226 * \sa SDL_GetGamepadAxisFromString
1227 */
1228extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForAxis(SDL_GamepadAxis axis);
1229
1230/**
1231 * Query whether a gamepad has a given axis.
1232 *
1233 * This merely reports whether the gamepad's mapping defined this axis, as
1234 * that is all the information SDL has about the physical device.
1235 *
1236 * \param gamepad a gamepad.
1237 * \param axis an axis enum value (an SDL_GamepadAxis value).
1238 * \returns true if the gamepad has this axis, false otherwise.
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_GamepadHasButton
1245 * \sa SDL_GetGamepadAxis
1246 */
1247extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis);
1248
1249/**
1250 * Get the current state of an axis control on a gamepad.
1251 *
1252 * The axis indices start at index 0.
1253 *
1254 * For thumbsticks, the state is a value ranging from -32768 (up/left) to
1255 * 32767 (down/right).
1256 *
1257 * Triggers range from 0 when released to 32767 when fully pressed, and never
1258 * return a negative value. Note that this differs from the value reported by
1259 * the lower-level SDL_GetJoystickAxis(), which normally uses the full range.
1260 *
1261 * Note that for invalid gamepads or axes, this will return 0. Zero is also a
1262 * valid value in normal operation; usually it means a centered axis.
1263 *
1264 * \param gamepad a gamepad.
1265 * \param axis an axis index (one of the SDL_GamepadAxis values).
1266 * \returns axis state.
1267 *
1268 * \threadsafety It is safe to call this function from any thread.
1269 *
1270 * \since This function is available since SDL 3.2.0.
1271 *
1272 * \sa SDL_GamepadHasAxis
1273 * \sa SDL_GetGamepadButton
1274 */
1275extern SDL_DECLSPEC Sint16 SDLCALL SDL_GetGamepadAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis);
1276
1277/**
1278 * Convert a string into an SDL_GamepadButton enum.
1279 *
1280 * This function is called internally to translate SDL_Gamepad mapping strings
1281 * for the underlying joystick device into the consistent SDL_Gamepad mapping.
1282 * You do not normally need to call this function unless you are parsing
1283 * SDL_Gamepad mappings in your own code.
1284 *
1285 * \param str string representing a SDL_Gamepad button.
1286 * \returns the SDL_GamepadButton enum corresponding to the input string, or
1287 * `SDL_GAMEPAD_BUTTON_INVALID` if no match was found.
1288 *
1289 * \threadsafety It is safe to call this function from any thread.
1290 *
1291 * \since This function is available since SDL 3.2.0.
1292 *
1293 * \sa SDL_GetGamepadStringForButton
1294 */
1295extern SDL_DECLSPEC SDL_GamepadButton SDLCALL SDL_GetGamepadButtonFromString(const char *str);
1296
1297/**
1298 * Convert from an SDL_GamepadButton enum to a string.
1299 *
1300 * \param button an enum value for a given SDL_GamepadButton.
1301 * \returns a string for the given button, or NULL if an invalid button is
1302 * specified. The string returned is of the format used by
1303 * SDL_Gamepad mapping strings.
1304 *
1305 * \threadsafety It is safe to call this function from any thread.
1306 *
1307 * \since This function is available since SDL 3.2.0.
1308 *
1309 * \sa SDL_GetGamepadButtonFromString
1310 */
1311extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForButton(SDL_GamepadButton button);
1312
1313/**
1314 * Query whether a gamepad has a given button.
1315 *
1316 * This merely reports whether the gamepad's mapping defined this button, as
1317 * that is all the information SDL has about the physical device.
1318 *
1319 * \param gamepad a gamepad.
1320 * \param button a button enum value (an SDL_GamepadButton value).
1321 * \returns true if the gamepad has this button, false otherwise.
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_GamepadHasAxis
1328 */
1329extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasButton(SDL_Gamepad *gamepad, SDL_GamepadButton button);
1330
1331/**
1332 * Get the current state of a button on a gamepad.
1333 *
1334 * \param gamepad a gamepad.
1335 * \param button a button index (one of the SDL_GamepadButton values).
1336 * \returns true if the button is pressed, false otherwise.
1337 *
1338 * \threadsafety It is safe to call this function from any thread.
1339 *
1340 * \since This function is available since SDL 3.2.0.
1341 *
1342 * \sa SDL_GamepadHasButton
1343 * \sa SDL_GetGamepadAxis
1344 */
1345extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadButton(SDL_Gamepad *gamepad, SDL_GamepadButton button);
1346
1347/**
1348 * Get the label of a button on a gamepad.
1349 *
1350 * \param type the type of gamepad to check.
1351 * \param button a button index (one of the SDL_GamepadButton values).
1352 * \returns the SDL_GamepadButtonLabel enum corresponding to the button label.
1353 *
1354 * \threadsafety It is safe to call this function from any thread.
1355 *
1356 * \since This function is available since SDL 3.2.0.
1357 *
1358 * \sa SDL_GetGamepadButtonLabel
1359 */
1361
1362/**
1363 * Get the label of a button on a gamepad.
1364 *
1365 * \param gamepad a gamepad.
1366 * \param button a button index (one of the SDL_GamepadButton values).
1367 * \returns the SDL_GamepadButtonLabel enum corresponding to the button label.
1368 *
1369 * \threadsafety It is safe to call this function from any thread.
1370 *
1371 * \since This function is available since SDL 3.2.0.
1372 *
1373 * \sa SDL_GetGamepadButtonLabelForType
1374 */
1376
1377/**
1378 * Get the number of touchpads on a gamepad.
1379 *
1380 * \param gamepad a gamepad.
1381 * \returns number of touchpads.
1382 *
1383 * \threadsafety It is safe to call this function from any thread.
1384 *
1385 * \since This function is available since SDL 3.2.0.
1386 *
1387 * \sa SDL_GetNumGamepadTouchpadFingers
1388 */
1389extern SDL_DECLSPEC int SDLCALL SDL_GetNumGamepadTouchpads(SDL_Gamepad *gamepad);
1390
1391/**
1392 * Get the number of supported simultaneous fingers on a touchpad on a game
1393 * gamepad.
1394 *
1395 * \param gamepad a gamepad.
1396 * \param touchpad a touchpad.
1397 * \returns number of supported simultaneous fingers.
1398 *
1399 * \threadsafety It is safe to call this function from any thread.
1400 *
1401 * \since This function is available since SDL 3.2.0.
1402 *
1403 * \sa SDL_GetGamepadTouchpadFinger
1404 * \sa SDL_GetNumGamepadTouchpads
1405 */
1406extern SDL_DECLSPEC int SDLCALL SDL_GetNumGamepadTouchpadFingers(SDL_Gamepad *gamepad, int touchpad);
1407
1408/**
1409 * Get the current state of a finger on a touchpad on a gamepad.
1410 *
1411 * \param gamepad a gamepad.
1412 * \param touchpad a touchpad.
1413 * \param finger a finger.
1414 * \param down a pointer filled with true if the finger is down, false
1415 * otherwise, may be NULL.
1416 * \param x a pointer filled with the x position, normalized 0 to 1, with the
1417 * origin in the upper left, may be NULL.
1418 * \param y a pointer filled with the y position, normalized 0 to 1, with the
1419 * origin in the upper left, may be NULL.
1420 * \param pressure a pointer filled with pressure value, may be NULL.
1421 * \returns true on success or false on failure; call SDL_GetError() for more
1422 * information.
1423 *
1424 * \threadsafety It is safe to call this function from any thread.
1425 *
1426 * \since This function is available since SDL 3.2.0.
1427 *
1428 * \sa SDL_GetNumGamepadTouchpadFingers
1429 */
1430extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadTouchpadFinger(SDL_Gamepad *gamepad, int touchpad, int finger, bool *down, float *x, float *y, float *pressure);
1431
1432/**
1433 * Return whether a gamepad has a particular sensor.
1434 *
1435 * \param gamepad the gamepad to query.
1436 * \param type the type of sensor to query.
1437 * \returns true if the sensor exists, false otherwise.
1438 *
1439 * \threadsafety It is safe to call this function from any thread.
1440 *
1441 * \since This function is available since SDL 3.2.0.
1442 *
1443 * \sa SDL_GetGamepadSensorData
1444 * \sa SDL_GetGamepadSensorDataRate
1445 * \sa SDL_SetGamepadSensorEnabled
1446 */
1447extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasSensor(SDL_Gamepad *gamepad, SDL_SensorType type);
1448
1449/**
1450 * Set whether data reporting for a gamepad sensor is enabled.
1451 *
1452 * \param gamepad the gamepad to update.
1453 * \param type the type of sensor to enable/disable.
1454 * \param enabled whether data reporting should be enabled.
1455 * \returns true on success or false on failure; call SDL_GetError() for more
1456 * information.
1457 *
1458 * \threadsafety It is safe to call this function from any thread.
1459 *
1460 * \since This function is available since SDL 3.2.0.
1461 *
1462 * \sa SDL_GamepadHasSensor
1463 * \sa SDL_GamepadSensorEnabled
1464 */
1465extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadSensorEnabled(SDL_Gamepad *gamepad, SDL_SensorType type, bool enabled);
1466
1467/**
1468 * Query whether sensor data reporting is enabled for a gamepad.
1469 *
1470 * \param gamepad the gamepad to query.
1471 * \param type the type of sensor to query.
1472 * \returns true if the sensor is enabled, false otherwise.
1473 *
1474 * \threadsafety It is safe to call this function from any thread.
1475 *
1476 * \since This function is available since SDL 3.2.0.
1477 *
1478 * \sa SDL_SetGamepadSensorEnabled
1479 */
1480extern SDL_DECLSPEC bool SDLCALL SDL_GamepadSensorEnabled(SDL_Gamepad *gamepad, SDL_SensorType type);
1481
1482/**
1483 * Get the data rate (number of events per second) of a gamepad sensor.
1484 *
1485 * \param gamepad the gamepad to query.
1486 * \param type the type of sensor to query.
1487 * \returns the data rate, or 0.0f if the data rate is not available.
1488 *
1489 * \threadsafety It is safe to call this function from any thread.
1490 *
1491 * \since This function is available since SDL 3.2.0.
1492 */
1493extern SDL_DECLSPEC float SDLCALL SDL_GetGamepadSensorDataRate(SDL_Gamepad *gamepad, SDL_SensorType type);
1494
1495/**
1496 * Get the current state of a gamepad sensor.
1497 *
1498 * The number of values and interpretation of the data is sensor dependent.
1499 * See the remarks in SDL_SensorType for details for each type of sensor.
1500 *
1501 * \param gamepad the gamepad to query.
1502 * \param type the type of sensor to query.
1503 * \param data a pointer filled with the current sensor state.
1504 * \param num_values the number of values to write to data.
1505 * \returns true on success or false on failure; call SDL_GetError() for more
1506 * information.
1507 *
1508 * \threadsafety It is safe to call this function from any thread.
1509 *
1510 * \since This function is available since SDL 3.2.0.
1511 */
1512extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadSensorData(SDL_Gamepad *gamepad, SDL_SensorType type, float *data, int num_values);
1513
1514/**
1515 * Start a rumble effect on a gamepad.
1516 *
1517 * Each call to this function cancels any previous rumble effect, and calling
1518 * it with 0 intensity stops any rumbling.
1519 *
1520 * This function requires you to process SDL events or call
1521 * SDL_UpdateJoysticks() to update rumble state.
1522 *
1523 * \param gamepad the gamepad to vibrate.
1524 * \param low_frequency_rumble the intensity of the low frequency (left)
1525 * rumble motor, from 0 to 0xFFFF.
1526 * \param high_frequency_rumble the intensity of the high frequency (right)
1527 * rumble motor, from 0 to 0xFFFF.
1528 * \param duration_ms the duration of the rumble effect, in milliseconds.
1529 * \returns true on success or false on failure; call SDL_GetError() for more
1530 * information.
1531 *
1532 * \threadsafety It is safe to call this function from any thread.
1533 *
1534 * \since This function is available since SDL 3.2.0.
1535 */
1536extern SDL_DECLSPEC bool SDLCALL SDL_RumbleGamepad(SDL_Gamepad *gamepad, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
1537
1538/**
1539 * Start a rumble effect in the gamepad's triggers.
1540 *
1541 * Each call to this function cancels any previous trigger rumble effect, and
1542 * calling it with 0 intensity stops any rumbling.
1543 *
1544 * Note that this is rumbling of the _triggers_ and not the gamepad as a
1545 * whole. This is currently only supported on Xbox One gamepads. If you want
1546 * the (more common) whole-gamepad rumble, use SDL_RumbleGamepad() instead.
1547 *
1548 * This function requires you to process SDL events or call
1549 * SDL_UpdateJoysticks() to update rumble state.
1550 *
1551 * \param gamepad the gamepad to vibrate.
1552 * \param left_rumble the intensity of the left trigger rumble motor, from 0
1553 * to 0xFFFF.
1554 * \param right_rumble the intensity of the right trigger rumble motor, from 0
1555 * to 0xFFFF.
1556 * \param duration_ms the duration of the rumble effect, in milliseconds.
1557 * \returns true on success or false on failure; call SDL_GetError() for more
1558 * information.
1559 *
1560 * \threadsafety It is safe to call this function from any thread.
1561 *
1562 * \since This function is available since SDL 3.2.0.
1563 *
1564 * \sa SDL_RumbleGamepad
1565 */
1566extern SDL_DECLSPEC bool SDLCALL SDL_RumbleGamepadTriggers(SDL_Gamepad *gamepad, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
1567
1568/**
1569 * Update a gamepad's LED color.
1570 *
1571 * An example of a joystick LED is the light on the back of a PlayStation 4's
1572 * DualShock 4 controller.
1573 *
1574 * For gamepads with a single color LED, the maximum of the RGB values will be
1575 * used as the LED brightness.
1576 *
1577 * \param gamepad the gamepad to update.
1578 * \param red the intensity of the red LED.
1579 * \param green the intensity of the green LED.
1580 * \param blue the intensity of the blue LED.
1581 * \returns true on success or false on failure; call SDL_GetError() for more
1582 * information.
1583 *
1584 * \threadsafety It is safe to call this function from any thread.
1585 *
1586 * \since This function is available since SDL 3.2.0.
1587 */
1588extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadLED(SDL_Gamepad *gamepad, Uint8 red, Uint8 green, Uint8 blue);
1589
1590/**
1591 * Send a gamepad specific effect packet.
1592 *
1593 * \param gamepad the gamepad to affect.
1594 * \param data the data to send to the gamepad.
1595 * \param size the size of the data to send to the gamepad.
1596 * \returns true on success or false on failure; call SDL_GetError() for more
1597 * information.
1598 *
1599 * \threadsafety It is safe to call this function from any thread.
1600 *
1601 * \since This function is available since SDL 3.2.0.
1602 */
1603extern SDL_DECLSPEC bool SDLCALL SDL_SendGamepadEffect(SDL_Gamepad *gamepad, const void *data, int size);
1604
1605/**
1606 * Close a gamepad previously opened with SDL_OpenGamepad().
1607 *
1608 * \param gamepad a gamepad identifier previously returned by
1609 * SDL_OpenGamepad().
1610 *
1611 * \threadsafety It is safe to call this function from any thread.
1612 *
1613 * \since This function is available since SDL 3.2.0.
1614 *
1615 * \sa SDL_OpenGamepad
1616 */
1617extern SDL_DECLSPEC void SDLCALL SDL_CloseGamepad(SDL_Gamepad *gamepad);
1618
1619/**
1620 * Return the sfSymbolsName for a given button on a gamepad on Apple
1621 * platforms.
1622 *
1623 * \param gamepad the gamepad to query.
1624 * \param button a button on the gamepad.
1625 * \returns the sfSymbolsName or NULL if the name can't be found.
1626 *
1627 * \threadsafety It is safe to call this function from any thread.
1628 *
1629 * \since This function is available since SDL 3.2.0.
1630 *
1631 * \sa SDL_GetGamepadAppleSFSymbolsNameForAxis
1632 */
1633extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadAppleSFSymbolsNameForButton(SDL_Gamepad *gamepad, SDL_GamepadButton button);
1634
1635/**
1636 * Return the sfSymbolsName for a given axis on a gamepad on Apple platforms.
1637 *
1638 * \param gamepad the gamepad to query.
1639 * \param axis an axis on the gamepad.
1640 * \returns the sfSymbolsName or NULL if the name can't be found.
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 *
1646 * \sa SDL_GetGamepadAppleSFSymbolsNameForButton
1647 */
1648extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadAppleSFSymbolsNameForAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis);
1649
1650
1651/* Ends C function definitions when using C++ */
1652#ifdef __cplusplus
1653}
1654#endif
1655#include <SDL3/SDL_close_code.h>
1656
1657#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)
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)
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)
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:446
uint16_t Uint16
Definition SDL_stdinc.h:464
SDL_MALLOC size_t size
int16_t Sint16
Definition SDL_stdinc.h:455
uint64_t Uint64
Definition SDL_stdinc.h:504
uint32_t Uint32
Definition SDL_stdinc.h:482
SDL_GamepadBindingType input_type
union SDL_GamepadBinding::@272216000375022054161014164102304274370011273020 input
SDL_GamepadBindingType output_type
union SDL_GamepadBinding::@123207161113251335264076224206106272344247236204 output