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