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