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