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