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