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