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