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