summary refs log tree commit diff stats
path: root/vendor/SDL2/include/SDL_gamecontroller.h
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/SDL2/include/SDL_gamecontroller.h')
-rw-r--r--vendor/SDL2/include/SDL_gamecontroller.h1001
1 files changed, 1001 insertions, 0 deletions
diff --git a/vendor/SDL2/include/SDL_gamecontroller.h b/vendor/SDL2/include/SDL_gamecontroller.h new file mode 100644 index 0000000..bdd9b89 --- /dev/null +++ b/vendor/SDL2/include/SDL_gamecontroller.h
@@ -0,0 +1,1001 @@
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2022 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_gamecontroller.h
24 *
25 * Include file for SDL game controller event handling
26 */
27
28#ifndef SDL_gamecontroller_h_
29#define SDL_gamecontroller_h_
30
31#include "SDL_stdinc.h"
32#include "SDL_error.h"
33#include "SDL_rwops.h"
34#include "SDL_sensor.h"
35#include "SDL_joystick.h"
36
37#include "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_gamecontroller.h
45 *
46 * In order to use these functions, SDL_Init() must have been called
47 * with the ::SDL_INIT_GAMECONTROLLER flag. This causes SDL to scan the system
48 * for game controllers, and load appropriate drivers.
49 *
50 * If you would like to receive controller 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 gamecontroller structure used to identify an SDL game controller
57 */
58struct _SDL_GameController;
59typedef struct _SDL_GameController SDL_GameController;
60
61typedef enum
62{
63 SDL_CONTROLLER_TYPE_UNKNOWN = 0,
64 SDL_CONTROLLER_TYPE_XBOX360,
65 SDL_CONTROLLER_TYPE_XBOXONE,
66 SDL_CONTROLLER_TYPE_PS3,
67 SDL_CONTROLLER_TYPE_PS4,
68 SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO,
69 SDL_CONTROLLER_TYPE_VIRTUAL,
70 SDL_CONTROLLER_TYPE_PS5,
71 SDL_CONTROLLER_TYPE_AMAZON_LUNA,
72 SDL_CONTROLLER_TYPE_GOOGLE_STADIA
73} SDL_GameControllerType;
74
75typedef enum
76{
77 SDL_CONTROLLER_BINDTYPE_NONE = 0,
78 SDL_CONTROLLER_BINDTYPE_BUTTON,
79 SDL_CONTROLLER_BINDTYPE_AXIS,
80 SDL_CONTROLLER_BINDTYPE_HAT
81} SDL_GameControllerBindType;
82
83/**
84 * Get the SDL joystick layer binding for this controller button/axis mapping
85 */
86typedef struct SDL_GameControllerButtonBind
87{
88 SDL_GameControllerBindType bindType;
89 union
90 {
91 int button;
92 int axis;
93 struct {
94 int hat;
95 int hat_mask;
96 } hat;
97 } value;
98
99} SDL_GameControllerButtonBind;
100
101
102/**
103 * To count the number of game controllers in the system for the following:
104 *
105 * ```c
106 * int nJoysticks = SDL_NumJoysticks();
107 * int nGameControllers = 0;
108 * for (int i = 0; i < nJoysticks; i++) {
109 * if (SDL_IsGameController(i)) {
110 * nGameControllers++;
111 * }
112 * }
113 * ```
114 *
115 * Using the SDL_HINT_GAMECONTROLLERCONFIG hint or the SDL_GameControllerAddMapping() you can add support for controllers SDL is unaware of or cause an existing controller to have a different binding. The format is:
116 * guid,name,mappings
117 *
118 * Where GUID is the string value from SDL_JoystickGetGUIDString(), name is the human readable string for the device and mappings are controller mappings to joystick ones.
119 * Under Windows there is a reserved GUID of "xinput" that covers any XInput devices.
120 * The mapping format for joystick is:
121 * bX - a joystick button, index X
122 * hX.Y - hat X with value Y
123 * aX - axis X of the joystick
124 * Buttons can be used as a controller axis and vice versa.
125 *
126 * This string shows an example of a valid mapping for a controller
127 *
128 * ```c
129 * "03000000341a00003608000000000000,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",
130 * ```
131 */
132
133/**
134 * Load a set of Game Controller mappings from a seekable SDL data stream.
135 *
136 * You can call this function several times, if needed, to load different
137 * database files.
138 *
139 * If a new mapping is loaded for an already known controller GUID, the later
140 * version will overwrite the one currently loaded.
141 *
142 * Mappings not belonging to the current platform or with no platform field
143 * specified will be ignored (i.e. mappings for Linux will be ignored in
144 * Windows, etc).
145 *
146 * This function will load the text database entirely in memory before
147 * processing it, so take this into consideration if you are in a memory
148 * constrained environment.
149 *
150 * \param rw the data stream for the mappings to be added
151 * \param freerw non-zero to close the stream after being read
152 * \returns the number of mappings added or -1 on error; call SDL_GetError()
153 * for more information.
154 *
155 * \since This function is available since SDL 2.0.2.
156 *
157 * \sa SDL_GameControllerAddMapping
158 * \sa SDL_GameControllerAddMappingsFromFile
159 * \sa SDL_GameControllerMappingForGUID
160 */
161extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw, int freerw);
162
163/**
164 * Load a set of mappings from a file, filtered by the current SDL_GetPlatform()
165 *
166 * Convenience macro.
167 */
168#define SDL_GameControllerAddMappingsFromFile(file) SDL_GameControllerAddMappingsFromRW(SDL_RWFromFile(file, "rb"), 1)
169
170/**
171 * Add support for controllers that SDL is unaware of or to cause an existing
172 * controller to have a different binding.
173 *
174 * The mapping string has the format "GUID,name,mapping", where GUID is the
175 * string value from SDL_JoystickGetGUIDString(), name is the human readable
176 * string for the device and mappings are controller mappings to joystick
177 * ones. Under Windows there is a reserved GUID of "xinput" that covers all
178 * XInput devices. The mapping format for joystick is: {| |bX |a joystick
179 * button, index X |- |hX.Y |hat X with value Y |- |aX |axis X of the joystick
180 * |} Buttons can be used as a controller axes and vice versa.
181 *
182 * This string shows an example of a valid mapping for a controller:
183 *
184 * ```c
185 * "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"
186 * ```
187 *
188 * \param mappingString the mapping string
189 * \returns 1 if a new mapping is added, 0 if an existing mapping is updated,
190 * -1 on error; call SDL_GetError() for more information.
191 *
192 * \since This function is available since SDL 2.0.0.
193 *
194 * \sa SDL_GameControllerMapping
195 * \sa SDL_GameControllerMappingForGUID
196 */
197extern DECLSPEC int SDLCALL SDL_GameControllerAddMapping(const char* mappingString);
198
199/**
200 * Get the number of mappings installed.
201 *
202 * \returns the number of mappings.
203 *
204 * \since This function is available since SDL 2.0.6.
205 */
206extern DECLSPEC int SDLCALL SDL_GameControllerNumMappings(void);
207
208/**
209 * Get the mapping at a particular index.
210 *
211 * \returns the mapping string. Must be freed with SDL_free(). Returns NULL if
212 * the index is out of range.
213 *
214 * \since This function is available since SDL 2.0.6.
215 */
216extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForIndex(int mapping_index);
217
218/**
219 * Get the game controller mapping string for a given GUID.
220 *
221 * The returned string must be freed with SDL_free().
222 *
223 * \param guid a structure containing the GUID for which a mapping is desired
224 * \returns a mapping string or NULL on error; call SDL_GetError() for more
225 * information.
226 *
227 * \since This function is available since SDL 2.0.0.
228 *
229 * \sa SDL_JoystickGetDeviceGUID
230 * \sa SDL_JoystickGetGUID
231 */
232extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForGUID(SDL_JoystickGUID guid);
233
234/**
235 * Get the current mapping of a Game Controller.
236 *
237 * The returned string must be freed with SDL_free().
238 *
239 * Details about mappings are discussed with SDL_GameControllerAddMapping().
240 *
241 * \param gamecontroller the game controller you want to get the current
242 * mapping for
243 * \returns a string that has the controller's mapping or NULL if no mapping
244 * is available; call SDL_GetError() for more information.
245 *
246 * \since This function is available since SDL 2.0.0.
247 *
248 * \sa SDL_GameControllerAddMapping
249 * \sa SDL_GameControllerMappingForGUID
250 */
251extern DECLSPEC char * SDLCALL SDL_GameControllerMapping(SDL_GameController *gamecontroller);
252
253/**
254 * Check if the given joystick is supported by the game controller interface.
255 *
256 * `joystick_index` is the same as the `device_index` passed to
257 * SDL_JoystickOpen().
258 *
259 * \param joystick_index the device_index of a device, up to
260 * SDL_NumJoysticks()
261 * \returns SDL_TRUE if the given joystick is supported by the game controller
262 * interface, SDL_FALSE if it isn't or it's an invalid index.
263 *
264 * \since This function is available since SDL 2.0.0.
265 *
266 * \sa SDL_GameControllerNameForIndex
267 * \sa SDL_GameControllerOpen
268 */
269extern DECLSPEC SDL_bool SDLCALL SDL_IsGameController(int joystick_index);
270
271/**
272 * Get the implementation dependent name for the game controller.
273 *
274 * This function can be called before any controllers are opened.
275 *
276 * `joystick_index` is the same as the `device_index` passed to
277 * SDL_JoystickOpen().
278 *
279 * \param joystick_index the device_index of a device, from zero to
280 * SDL_NumJoysticks()-1
281 * \returns the implementation-dependent name for the game controller, or NULL
282 * if there is no name or the index is invalid.
283 *
284 * \since This function is available since SDL 2.0.0.
285 *
286 * \sa SDL_GameControllerName
287 * \sa SDL_GameControllerOpen
288 * \sa SDL_IsGameController
289 */
290extern DECLSPEC const char *SDLCALL SDL_GameControllerNameForIndex(int joystick_index);
291
292/**
293 * Get the type of a game controller.
294 *
295 * This can be called before any controllers are opened.
296 *
297 * \param joystick_index the device_index of a device, from zero to
298 * SDL_NumJoysticks()-1
299 * \returns the controller type.
300 *
301 * \since This function is available since SDL 2.0.12.
302 */
303extern DECLSPEC SDL_GameControllerType SDLCALL SDL_GameControllerTypeForIndex(int joystick_index);
304
305/**
306 * Get the mapping of a game controller.
307 *
308 * This can be called before any controllers are opened.
309 *
310 * \param joystick_index the device_index of a device, from zero to
311 * SDL_NumJoysticks()-1
312 * \returns the mapping string. Must be freed with SDL_free(). Returns NULL if
313 * no mapping is available.
314 *
315 * \since This function is available since SDL 2.0.9.
316 */
317extern DECLSPEC char *SDLCALL SDL_GameControllerMappingForDeviceIndex(int joystick_index);
318
319/**
320 * Open a game controller for use.
321 *
322 * `joystick_index` is the same as the `device_index` passed to
323 * SDL_JoystickOpen().
324 *
325 * The index passed as an argument refers to the N'th game controller on the
326 * system. This index is not the value which will identify this controller in
327 * future controller events. The joystick's instance id (SDL_JoystickID) will
328 * be used there instead.
329 *
330 * \param joystick_index the device_index of a device, up to
331 * SDL_NumJoysticks()
332 * \returns a gamecontroller identifier or NULL if an error occurred; call
333 * SDL_GetError() for more information.
334 *
335 * \since This function is available since SDL 2.0.0.
336 *
337 * \sa SDL_GameControllerClose
338 * \sa SDL_GameControllerNameForIndex
339 * \sa SDL_IsGameController
340 */
341extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerOpen(int joystick_index);
342
343/**
344 * Get the SDL_GameController associated with an instance id.
345 *
346 * \param joyid the instance id to get the SDL_GameController for
347 * \returns an SDL_GameController on success or NULL on failure; call
348 * SDL_GetError() for more information.
349 *
350 * \since This function is available since SDL 2.0.4.
351 */
352extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromInstanceID(SDL_JoystickID joyid);
353
354/**
355 * Get the SDL_GameController associated with a player index.
356 *
357 * Please note that the player index is _not_ the device index, nor is it the
358 * instance id!
359 *
360 * \param player_index the player index, which is not the device index or the
361 * instance id!
362 * \returns the SDL_GameController associated with a player index.
363 *
364 * \since This function is available since SDL 2.0.12.
365 *
366 * \sa SDL_GameControllerGetPlayerIndex
367 * \sa SDL_GameControllerSetPlayerIndex
368 */
369extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromPlayerIndex(int player_index);
370
371/**
372 * Get the implementation-dependent name for an opened game controller.
373 *
374 * This is the same name as returned by SDL_GameControllerNameForIndex(), but
375 * it takes a controller identifier instead of the (unstable) device index.
376 *
377 * \param gamecontroller a game controller identifier previously returned by
378 * SDL_GameControllerOpen()
379 * \returns the implementation dependent name for the game controller, or NULL
380 * if there is no name or the identifier passed is invalid.
381 *
382 * \since This function is available since SDL 2.0.0.
383 *
384 * \sa SDL_GameControllerNameForIndex
385 * \sa SDL_GameControllerOpen
386 */
387extern DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController *gamecontroller);
388
389/**
390 * Get the type of this currently opened controller
391 *
392 * This is the same name as returned by SDL_GameControllerTypeForIndex(), but
393 * it takes a controller identifier instead of the (unstable) device index.
394 *
395 * \param gamecontroller the game controller object to query.
396 * \returns the controller type.
397 *
398 * \since This function is available since SDL 2.0.12.
399 */
400extern DECLSPEC SDL_GameControllerType SDLCALL SDL_GameControllerGetType(SDL_GameController *gamecontroller);
401
402/**
403 * Get the player index of an opened game controller.
404 *
405 * For XInput controllers this returns the XInput user index.
406 *
407 * \param gamecontroller the game controller object to query.
408 * \returns the player index for controller, or -1 if it's not available.
409 *
410 * \since This function is available since SDL 2.0.9.
411 */
412extern DECLSPEC int SDLCALL SDL_GameControllerGetPlayerIndex(SDL_GameController *gamecontroller);
413
414/**
415 * Set the player index of an opened game controller.
416 *
417 * \param gamecontroller the game controller object to adjust.
418 * \param player_index Player index to assign to this controller.
419 *
420 * \since This function is available since SDL 2.0.12.
421 */
422extern DECLSPEC void SDLCALL SDL_GameControllerSetPlayerIndex(SDL_GameController *gamecontroller, int player_index);
423
424/**
425 * Get the USB vendor ID of an opened controller, if available.
426 *
427 * If the vendor ID isn't available this function returns 0.
428 *
429 * \param gamecontroller the game controller object to query.
430 * \return the USB vendor ID, or zero if unavailable.
431 *
432 * \since This function is available since SDL 2.0.6.
433 */
434extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetVendor(SDL_GameController *gamecontroller);
435
436/**
437 * Get the USB product ID of an opened controller, if available.
438 *
439 * If the product ID isn't available this function returns 0.
440 *
441 * \param gamecontroller the game controller object to query.
442 * \return the USB product ID, or zero if unavailable.
443 *
444 * \since This function is available since SDL 2.0.6.
445 */
446extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProduct(SDL_GameController *gamecontroller);
447
448/**
449 * Get the product version of an opened controller, if available.
450 *
451 * If the product version isn't available this function returns 0.
452 *
453 * \param gamecontroller the game controller object to query.
454 * \return the USB product version, or zero if unavailable.
455 *
456 * \since This function is available since SDL 2.0.6.
457 */
458extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProductVersion(SDL_GameController *gamecontroller);
459
460/**
461 * Get the serial number of an opened controller, if available.
462 *
463 * Returns the serial number of the controller, or NULL if it is not
464 * available.
465 *
466 * \param gamecontroller the game controller object to query.
467 * \return the serial number, or NULL if unavailable.
468 *
469 * \since This function is available since SDL 2.0.14.
470 */
471extern DECLSPEC const char * SDLCALL SDL_GameControllerGetSerial(SDL_GameController *gamecontroller);
472
473/**
474 * Check if a controller has been opened and is currently connected.
475 *
476 * \param gamecontroller a game controller identifier previously returned by
477 * SDL_GameControllerOpen()
478 * \returns SDL_TRUE if the controller has been opened and is currently
479 * connected, or SDL_FALSE if not.
480 *
481 * \since This function is available since SDL 2.0.0.
482 *
483 * \sa SDL_GameControllerClose
484 * \sa SDL_GameControllerOpen
485 */
486extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerGetAttached(SDL_GameController *gamecontroller);
487
488/**
489 * Get the Joystick ID from a Game Controller.
490 *
491 * This function will give you a SDL_Joystick object, which allows you to use
492 * the SDL_Joystick functions with a SDL_GameController object. This would be
493 * useful for getting a joystick's position at any given time, even if it
494 * hasn't moved (moving it would produce an event, which would have the axis'
495 * value).
496 *
497 * The pointer returned is owned by the SDL_GameController. You should not
498 * call SDL_JoystickClose() on it, for example, since doing so will likely
499 * cause SDL to crash.
500 *
501 * \param gamecontroller the game controller object that you want to get a
502 * joystick from
503 * \returns a SDL_Joystick object; call SDL_GetError() for more information.
504 *
505 * \since This function is available since SDL 2.0.0.
506 */
507extern DECLSPEC SDL_Joystick *SDLCALL SDL_GameControllerGetJoystick(SDL_GameController *gamecontroller);
508
509/**
510 * Query or change current state of Game Controller events.
511 *
512 * If controller events are disabled, you must call SDL_GameControllerUpdate()
513 * yourself and check the state of the controller when you want controller
514 * information.
515 *
516 * Any number can be passed to SDL_GameControllerEventState(), but only -1, 0,
517 * and 1 will have any effect. Other numbers will just be returned.
518 *
519 * \param state can be one of `SDL_QUERY`, `SDL_IGNORE`, or `SDL_ENABLE`
520 * \returns the same value passed to the function, with exception to -1
521 * (SDL_QUERY), which will return the current state.
522 *
523 * \since This function is available since SDL 2.0.0.
524 *
525 * \sa SDL_JoystickEventState
526 */
527extern DECLSPEC int SDLCALL SDL_GameControllerEventState(int state);
528
529/**
530 * Manually pump game controller updates if not using the loop.
531 *
532 * This function is called automatically by the event loop if events are
533 * enabled. Under such circumstances, it will not be necessary to call this
534 * function.
535 *
536 * \since This function is available since SDL 2.0.0.
537 */
538extern DECLSPEC void SDLCALL SDL_GameControllerUpdate(void);
539
540
541/**
542 * The list of axes available from a controller
543 *
544 * Thumbstick axis values range from SDL_JOYSTICK_AXIS_MIN to SDL_JOYSTICK_AXIS_MAX,
545 * and are centered within ~8000 of zero, though advanced UI will allow users to set
546 * or autodetect the dead zone, which varies between controllers.
547 *
548 * Trigger axis values range from 0 to SDL_JOYSTICK_AXIS_MAX.
549 */
550typedef enum
551{
552 SDL_CONTROLLER_AXIS_INVALID = -1,
553 SDL_CONTROLLER_AXIS_LEFTX,
554 SDL_CONTROLLER_AXIS_LEFTY,
555 SDL_CONTROLLER_AXIS_RIGHTX,
556 SDL_CONTROLLER_AXIS_RIGHTY,
557 SDL_CONTROLLER_AXIS_TRIGGERLEFT,
558 SDL_CONTROLLER_AXIS_TRIGGERRIGHT,
559 SDL_CONTROLLER_AXIS_MAX
560} SDL_GameControllerAxis;
561
562/**
563 * Convert a string into SDL_GameControllerAxis enum.
564 *
565 * This function is called internally to translate SDL_GameController mapping
566 * strings for the underlying joystick device into the consistent
567 * SDL_GameController mapping. You do not normally need to call this function
568 * unless you are parsing SDL_GameController mappings in your own code.
569 *
570 * Note specially that "righttrigger" and "lefttrigger" map to
571 * `SDL_CONTROLLER_AXIS_TRIGGERRIGHT` and `SDL_CONTROLLER_AXIS_TRIGGERLEFT`,
572 * respectively.
573 *
574 * \param str string representing a SDL_GameController axis
575 * \returns the SDL_GameControllerAxis enum corresponding to the input string,
576 * or `SDL_CONTROLLER_AXIS_INVALID` if no match was found.
577 *
578 * \since This function is available since SDL 2.0.0.
579 *
580 * \sa SDL_GameControllerGetStringForAxis
581 */
582extern DECLSPEC SDL_GameControllerAxis SDLCALL SDL_GameControllerGetAxisFromString(const char *str);
583
584/**
585 * Convert from an SDL_GameControllerAxis enum to a string.
586 *
587 * The caller should not SDL_free() the returned string.
588 *
589 * \param axis an enum value for a given SDL_GameControllerAxis
590 * \returns a string for the given axis, or NULL if an invalid axis is
591 * specified. The string returned is of the format used by
592 * SDL_GameController mapping strings.
593 *
594 * \since This function is available since SDL 2.0.0.
595 *
596 * \sa SDL_GameControllerGetAxisFromString
597 */
598extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForAxis(SDL_GameControllerAxis axis);
599
600/**
601 * Get the SDL joystick layer binding for a controller axis mapping.
602 *
603 * \param gamecontroller a game controller
604 * \param axis an axis enum value (one of the SDL_GameControllerAxis values)
605 * \returns a SDL_GameControllerButtonBind describing the bind. On failure
606 * (like the given Controller axis doesn't exist on the device), its
607 * `.bindType` will be `SDL_CONTROLLER_BINDTYPE_NONE`.
608 *
609 * \since This function is available since SDL 2.0.0.
610 *
611 * \sa SDL_GameControllerGetBindForButton
612 */
613extern DECLSPEC SDL_GameControllerButtonBind SDLCALL
614SDL_GameControllerGetBindForAxis(SDL_GameController *gamecontroller,
615 SDL_GameControllerAxis axis);
616
617/**
618 * Query whether a game controller has a given axis.
619 *
620 * This merely reports whether the controller's mapping defined this axis, as
621 * that is all the information SDL has about the physical device.
622 *
623 * \param gamecontroller a game controller
624 * \param axis an axis enum value (an SDL_GameControllerAxis value)
625 * \returns SDL_TRUE if the controller has this axis, SDL_FALSE otherwise.
626 *
627 * \since This function is available since SDL 2.0.14.
628 */
629extern DECLSPEC SDL_bool SDLCALL
630SDL_GameControllerHasAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis);
631
632/**
633 * Get the current state of an axis control on a game controller.
634 *
635 * The axis indices start at index 0.
636 *
637 * The state is a value ranging from -32768 to 32767. Triggers, however, range
638 * from 0 to 32767 (they never return a negative value).
639 *
640 * \param gamecontroller a game controller
641 * \param axis an axis index (one of the SDL_GameControllerAxis values)
642 * \returns axis state (including 0) on success or 0 (also) on failure; call
643 * SDL_GetError() for more information.
644 *
645 * \since This function is available since SDL 2.0.0.
646 *
647 * \sa SDL_GameControllerGetButton
648 */
649extern DECLSPEC Sint16 SDLCALL
650SDL_GameControllerGetAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis);
651
652/**
653 * The list of buttons available from a controller
654 */
655typedef enum
656{
657 SDL_CONTROLLER_BUTTON_INVALID = -1,
658 SDL_CONTROLLER_BUTTON_A,
659 SDL_CONTROLLER_BUTTON_B,
660 SDL_CONTROLLER_BUTTON_X,
661 SDL_CONTROLLER_BUTTON_Y,
662 SDL_CONTROLLER_BUTTON_BACK,
663 SDL_CONTROLLER_BUTTON_GUIDE,
664 SDL_CONTROLLER_BUTTON_START,
665 SDL_CONTROLLER_BUTTON_LEFTSTICK,
666 SDL_CONTROLLER_BUTTON_RIGHTSTICK,
667 SDL_CONTROLLER_BUTTON_LEFTSHOULDER,
668 SDL_CONTROLLER_BUTTON_RIGHTSHOULDER,
669 SDL_CONTROLLER_BUTTON_DPAD_UP,
670 SDL_CONTROLLER_BUTTON_DPAD_DOWN,
671 SDL_CONTROLLER_BUTTON_DPAD_LEFT,
672 SDL_CONTROLLER_BUTTON_DPAD_RIGHT,
673 SDL_CONTROLLER_BUTTON_MISC1, /* Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button */
674 SDL_CONTROLLER_BUTTON_PADDLE1, /* Xbox Elite paddle P1 */
675 SDL_CONTROLLER_BUTTON_PADDLE2, /* Xbox Elite paddle P3 */
676 SDL_CONTROLLER_BUTTON_PADDLE3, /* Xbox Elite paddle P2 */
677 SDL_CONTROLLER_BUTTON_PADDLE4, /* Xbox Elite paddle P4 */
678 SDL_CONTROLLER_BUTTON_TOUCHPAD, /* PS4/PS5 touchpad button */
679 SDL_CONTROLLER_BUTTON_MAX
680} SDL_GameControllerButton;
681
682/**
683 * Convert a string into an SDL_GameControllerButton enum.
684 *
685 * This function is called internally to translate SDL_GameController mapping
686 * strings for the underlying joystick device into the consistent
687 * SDL_GameController mapping. You do not normally need to call this function
688 * unless you are parsing SDL_GameController mappings in your own code.
689 *
690 * \param str string representing a SDL_GameController axis
691 * \returns the SDL_GameControllerButton enum corresponding to the input
692 * string, or `SDL_CONTROLLER_AXIS_INVALID` if no match was found.
693 *
694 * \since This function is available since SDL 2.0.0.
695 */
696extern DECLSPEC SDL_GameControllerButton SDLCALL SDL_GameControllerGetButtonFromString(const char *str);
697
698/**
699 * Convert from an SDL_GameControllerButton enum to a string.
700 *
701 * The caller should not SDL_free() the returned string.
702 *
703 * \param button an enum value for a given SDL_GameControllerButton
704 * \returns a string for the given button, or NULL if an invalid axis is
705 * specified. The string returned is of the format used by
706 * SDL_GameController mapping strings.
707 *
708 * \since This function is available since SDL 2.0.0.
709 *
710 * \sa SDL_GameControllerGetButtonFromString
711 */
712extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForButton(SDL_GameControllerButton button);
713
714/**
715 * Get the SDL joystick layer binding for a controller button mapping.
716 *
717 * \param gamecontroller a game controller
718 * \param button an button enum value (an SDL_GameControllerButton value)
719 * \returns a SDL_GameControllerButtonBind describing the bind. On failure
720 * (like the given Controller button doesn't exist on the device),
721 * its `.bindType` will be `SDL_CONTROLLER_BINDTYPE_NONE`.
722 *
723 * \since This function is available since SDL 2.0.0.
724 *
725 * \sa SDL_GameControllerGetBindForAxis
726 */
727extern DECLSPEC SDL_GameControllerButtonBind SDLCALL
728SDL_GameControllerGetBindForButton(SDL_GameController *gamecontroller,
729 SDL_GameControllerButton button);
730
731/**
732 * Query whether a game controller has a given button.
733 *
734 * This merely reports whether the controller's mapping defined this button,
735 * as that is all the information SDL has about the physical device.
736 *
737 * \param gamecontroller a game controller
738 * \param button a button enum value (an SDL_GameControllerButton value)
739 * \returns SDL_TRUE if the controller has this button, SDL_FALSE otherwise.
740 *
741 * \since This function is available since SDL 2.0.14.
742 */
743extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasButton(SDL_GameController *gamecontroller,
744 SDL_GameControllerButton button);
745
746/**
747 * Get the current state of a button on a game controller.
748 *
749 * \param gamecontroller a game controller
750 * \param button a button index (one of the SDL_GameControllerButton values)
751 * \returns 1 for pressed state or 0 for not pressed state or error; call
752 * SDL_GetError() for more information.
753 *
754 * \since This function is available since SDL 2.0.0.
755 *
756 * \sa SDL_GameControllerGetAxis
757 */
758extern DECLSPEC Uint8 SDLCALL SDL_GameControllerGetButton(SDL_GameController *gamecontroller,
759 SDL_GameControllerButton button);
760
761/**
762 * Get the number of touchpads on a game controller.
763 *
764 * \since This function is available since SDL 2.0.14.
765 */
766extern DECLSPEC int SDLCALL SDL_GameControllerGetNumTouchpads(SDL_GameController *gamecontroller);
767
768/**
769 * Get the number of supported simultaneous fingers on a touchpad on a game
770 * controller.
771 *
772 * \since This function is available since SDL 2.0.14.
773 */
774extern DECLSPEC int SDLCALL SDL_GameControllerGetNumTouchpadFingers(SDL_GameController *gamecontroller, int touchpad);
775
776/**
777 * Get the current state of a finger on a touchpad on a game controller.
778 *
779 * \since This function is available since SDL 2.0.14.
780 */
781extern DECLSPEC int SDLCALL SDL_GameControllerGetTouchpadFinger(SDL_GameController *gamecontroller, int touchpad, int finger, Uint8 *state, float *x, float *y, float *pressure);
782
783/**
784 * Return whether a game controller has a particular sensor.
785 *
786 * \param gamecontroller The controller to query
787 * \param type The type of sensor to query
788 * \returns SDL_TRUE if the sensor exists, SDL_FALSE otherwise.
789 *
790 * \since This function is available since SDL 2.0.14.
791 */
792extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasSensor(SDL_GameController *gamecontroller, SDL_SensorType type);
793
794/**
795 * Set whether data reporting for a game controller sensor is enabled.
796 *
797 * \param gamecontroller The controller to update
798 * \param type The type of sensor to enable/disable
799 * \param enabled Whether data reporting should be enabled
800 * \returns 0 or -1 if an error occurred.
801 *
802 * \since This function is available since SDL 2.0.14.
803 */
804extern DECLSPEC int SDLCALL SDL_GameControllerSetSensorEnabled(SDL_GameController *gamecontroller, SDL_SensorType type, SDL_bool enabled);
805
806/**
807 * Query whether sensor data reporting is enabled for a game controller.
808 *
809 * \param gamecontroller The controller to query
810 * \param type The type of sensor to query
811 * \returns SDL_TRUE if the sensor is enabled, SDL_FALSE otherwise.
812 *
813 * \since This function is available since SDL 2.0.14.
814 */
815extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerIsSensorEnabled(SDL_GameController *gamecontroller, SDL_SensorType type);
816
817/**
818 * Get the data rate (number of events per second) of a game controller
819 * sensor.
820 *
821 * \param gamecontroller The controller to query
822 * \param type The type of sensor to query
823 * \return the data rate, or 0.0f if the data rate is not available.
824 *
825 * \since This function is available since SDL 2.0.16.
826 */
827extern DECLSPEC float SDLCALL SDL_GameControllerGetSensorDataRate(SDL_GameController *gamecontroller, SDL_SensorType type);
828
829/**
830 * Get the current state of a game controller sensor.
831 *
832 * The number of values and interpretation of the data is sensor dependent.
833 * See SDL_sensor.h for the details for each type of sensor.
834 *
835 * \param gamecontroller The controller to query
836 * \param type The type of sensor to query
837 * \param data A pointer filled with the current sensor state
838 * \param num_values The number of values to write to data
839 * \return 0 or -1 if an error occurred.
840 *
841 * \since This function is available since SDL 2.0.14.
842 */
843extern DECLSPEC int SDLCALL SDL_GameControllerGetSensorData(SDL_GameController *gamecontroller, SDL_SensorType type, float *data, int num_values);
844
845/**
846 * Start a rumble effect on a game controller.
847 *
848 * Each call to this function cancels any previous rumble effect, and calling
849 * it with 0 intensity stops any rumbling.
850 *
851 * \param gamecontroller The controller to vibrate
852 * \param low_frequency_rumble The intensity of the low frequency (left)
853 * rumble motor, from 0 to 0xFFFF
854 * \param high_frequency_rumble The intensity of the high frequency (right)
855 * rumble motor, from 0 to 0xFFFF
856 * \param duration_ms The duration of the rumble effect, in milliseconds
857 * \returns 0, or -1 if rumble isn't supported on this controller
858 *
859 * \since This function is available since SDL 2.0.9.
860 *
861 * \sa SDL_GameControllerHasRumble
862 */
863extern DECLSPEC int SDLCALL SDL_GameControllerRumble(SDL_GameController *gamecontroller, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
864
865/**
866 * Start a rumble effect in the game controller's triggers.
867 *
868 * Each call to this function cancels any previous trigger rumble effect, and
869 * calling it with 0 intensity stops any rumbling.
870 *
871 * Note that this is rumbling of the _triggers_ and not the game controller as
872 * a whole. The first controller to offer this feature was the PlayStation 5's
873 * DualShock 5.
874 *
875 * \param gamecontroller The controller to vibrate
876 * \param left_rumble The intensity of the left trigger rumble motor, from 0
877 * to 0xFFFF
878 * \param right_rumble The intensity of the right trigger rumble motor, from 0
879 * to 0xFFFF
880 * \param duration_ms The duration of the rumble effect, in milliseconds
881 * \returns 0, or -1 if trigger rumble isn't supported on this controller
882 *
883 * \since This function is available since SDL 2.0.14.
884 *
885 * \sa SDL_GameControllerHasRumbleTriggers
886 */
887extern DECLSPEC int SDLCALL SDL_GameControllerRumbleTriggers(SDL_GameController *gamecontroller, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
888
889/**
890 * Query whether a game controller has an LED.
891 *
892 * \param gamecontroller The controller to query
893 * \returns SDL_TRUE, or SDL_FALSE if this controller does not have a
894 * modifiable LED
895 *
896 * \since This function is available since SDL 2.0.14.
897 */
898extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasLED(SDL_GameController *gamecontroller);
899
900/**
901 * Query whether a game controller has rumble support.
902 *
903 * \param gamecontroller The controller to query
904 * \returns SDL_TRUE, or SDL_FALSE if this controller does not have rumble
905 * support
906 *
907 * \since This function is available since SDL 2.0.18.
908 *
909 * \sa SDL_GameControllerRumble
910 */
911extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasRumble(SDL_GameController *gamecontroller);
912
913/**
914 * Query whether a game controller has rumble support on triggers.
915 *
916 * \param gamecontroller The controller to query
917 * \returns SDL_TRUE, or SDL_FALSE if this controller does not have trigger
918 * rumble support
919 *
920 * \since This function is available since SDL 2.0.18.
921 *
922 * \sa SDL_GameControllerRumbleTriggers
923 */
924extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasRumbleTriggers(SDL_GameController *gamecontroller);
925
926/**
927 * Update a game controller's LED color.
928 *
929 * \param gamecontroller The controller to update
930 * \param red The intensity of the red LED
931 * \param green The intensity of the green LED
932 * \param blue The intensity of the blue LED
933 * \returns 0, or -1 if this controller does not have a modifiable LED
934 *
935 * \since This function is available since SDL 2.0.14.
936 */
937extern DECLSPEC int SDLCALL SDL_GameControllerSetLED(SDL_GameController *gamecontroller, Uint8 red, Uint8 green, Uint8 blue);
938
939/**
940 * Send a controller specific effect packet
941 *
942 * \param gamecontroller The controller to affect
943 * \param data The data to send to the controller
944 * \param size The size of the data to send to the controller
945 * \returns 0, or -1 if this controller or driver doesn't support effect
946 * packets
947 *
948 * \since This function is available since SDL 2.0.16.
949 */
950extern DECLSPEC int SDLCALL SDL_GameControllerSendEffect(SDL_GameController *gamecontroller, const void *data, int size);
951
952/**
953 * Close a game controller previously opened with SDL_GameControllerOpen().
954 *
955 * \param gamecontroller a game controller identifier previously returned by
956 * SDL_GameControllerOpen()
957 *
958 * \since This function is available since SDL 2.0.0.
959 *
960 * \sa SDL_GameControllerOpen
961 */
962extern DECLSPEC void SDLCALL SDL_GameControllerClose(SDL_GameController *gamecontroller);
963
964/**
965 * Return the sfSymbolsName for a given button on a game controller on Apple
966 * platforms.
967 *
968 * \param gamecontroller the controller to query
969 * \param button a button on the game controller
970 * \returns the sfSymbolsName or NULL if the name can't be found
971 *
972 * \since This function is available since SDL 2.0.18.
973 *
974 * \sa SDL_GameControllerGetAppleSFSymbolsNameForAxis
975 */
976extern DECLSPEC const char* SDLCALL SDL_GameControllerGetAppleSFSymbolsNameForButton(SDL_GameController *gamecontroller, SDL_GameControllerButton button);
977
978/**
979 * Return the sfSymbolsName for a given axis on a game controller on Apple
980 * platforms.
981 *
982 * \param gamecontroller the controller to query
983 * \param axis an axis on the game controller
984 * \returns the sfSymbolsName or NULL if the name can't be found
985 *
986 * \since This function is available since SDL 2.0.18.
987 *
988 * \sa SDL_GameControllerGetAppleSFSymbolsNameForButton
989 */
990extern DECLSPEC const char* SDLCALL SDL_GameControllerGetAppleSFSymbolsNameForAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis);
991
992
993/* Ends C function definitions when using C++ */
994#ifdef __cplusplus
995}
996#endif
997#include "close_code.h"
998
999#endif /* SDL_gamecontroller_h_ */
1000
1001/* vi: set ts=4 sw=4 expandtab: */