1 /*
2     DSDL
3     Copyright (C) 2025 Inochi2D Project <luna@foxgirls.gay>
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     Simple DirectMedia Layer
24     Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
25 
26     This software is provided 'as-is', without any express or implied
27     warranty.  In no event will the authors be held liable for any damages
28     arising from the use of this software.
29 
30     Permission is granted to anyone to use this software for any purpose,
31     including commercial applications, and to alter it and redistribute it
32     freely, subject to the following restrictions:
33 
34     1. The origin of this software must not be misrepresented; you must not
35         claim that you wrote the original software. If you use this software
36         in a product, an acknowledgment in the product documentation would be
37         appreciated but is not required.
38     2. Altered source versions must be plainly marked as such, and must not be
39         misrepresented as being the original software.
40     3. This notice may not be removed or altered from any source distribution.
41 */
42 
43 /**
44     SDL Gamepad
45 
46     See_Also:
47         $(LINK2 https://wiki.libsdl.org/SDL3/CategoryGamepad, SDL3 Gamepad Documentation)
48     
49     Copyright: © 2025 Inochi2D Project, © 1997-2025 Sam Lantinga
50     License: Subject to the terms of the Zlib License, as written in the LICENSE file.
51     Authors: 
52         Luna Nielsen
53 */
54 module sdl.gamepad;
55 import sdl.joystick;
56 import sdl.properties;
57 import sdl.iostream;
58 import sdl.guid;
59 import sdl.power;
60 import sdl.sensor;
61 import sdl.stdc;
62 
63 extern (C) nothrow @nogc:
64 
65 /**
66     The structure used to identify an SDL gamepad
67 */
68 struct SDL_Gamepad;
69 
70 /**
71     Standard gamepad types.
72 
73     This type does not necessarily map to first-party controllers from
74     Microsoft/Sony/Nintendo; in many cases, third-party controllers can report
75     as these, either because they were designed for a specific console, or they
76     simply most closely match that console's controllers (does it have A/B/X/Y
77     buttons or X/O/Square/Triangle? Does it have a touchpad? etc).
78 */
79 enum SDL_GamepadType {
80     SDL_GAMEPAD_TYPE_UNKNOWN = 0,
81     SDL_GAMEPAD_TYPE_STANDARD,
82     SDL_GAMEPAD_TYPE_XBOX360,
83     SDL_GAMEPAD_TYPE_XBOXONE,
84     SDL_GAMEPAD_TYPE_PS3,
85     SDL_GAMEPAD_TYPE_PS4,
86     SDL_GAMEPAD_TYPE_PS5,
87     SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO,
88     SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT,
89     SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT,
90     SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR,
91     SDL_GAMEPAD_TYPE_COUNT
92 }
93 
94 /**
95     The list of buttons available on a gamepad
96 
97     For controllers that use a diamond pattern for the face buttons, the
98     south/east/west/north buttons below correspond to the locations in the
99     diamond pattern. For Xbox controllers, this would be A/B/X/Y, for Nintendo
100     Switch controllers, this would be B/A/Y/X, for PlayStation controllers this
101     would be Cross/Circle/Square/Triangle.
102 
103     For controllers that don't use a diamond pattern for the face buttons, the
104     south/east/west/north buttons indicate the buttons labeled A, B, C, D, or
105     1, 2, 3, 4, or for controllers that aren't labeled, they are the primary,
106     secondary, etc. buttons.
107 
108     The activate action is often the south button and the cancel action is
109     often the east button, but in some regions this is reversed, so your game
110     should allow remapping actions based on user preferences.
111 
112     You can query the labels for the face buttons using
113     SDL_GetGamepadButtonLabel()
114 */
115 enum SDL_GamepadButton {
116     SDL_GAMEPAD_BUTTON_INVALID = -1,
117     SDL_GAMEPAD_BUTTON_SOUTH, /**< Bottom face button (e.g. Xbox A button) */
118     SDL_GAMEPAD_BUTTON_EAST, /**< Right face button (e.g. Xbox B button) */
119     SDL_GAMEPAD_BUTTON_WEST, /**< Left face button (e.g. Xbox X button) */
120     SDL_GAMEPAD_BUTTON_NORTH, /**< Top face button (e.g. Xbox Y button) */
121     SDL_GAMEPAD_BUTTON_BACK,
122     SDL_GAMEPAD_BUTTON_GUIDE,
123     SDL_GAMEPAD_BUTTON_START,
124     SDL_GAMEPAD_BUTTON_LEFT_STICK,
125     SDL_GAMEPAD_BUTTON_RIGHT_STICK,
126     SDL_GAMEPAD_BUTTON_LEFT_SHOULDER,
127     SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER,
128     SDL_GAMEPAD_BUTTON_DPAD_UP,
129     SDL_GAMEPAD_BUTTON_DPAD_DOWN,
130     SDL_GAMEPAD_BUTTON_DPAD_LEFT,
131     SDL_GAMEPAD_BUTTON_DPAD_RIGHT,
132     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, Google Stadia capture button) */
133     SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1, /**< Upper or primary paddle, under your right hand (e.g. Xbox Elite paddle P1) */
134     SDL_GAMEPAD_BUTTON_LEFT_PADDLE1, /**< Upper or primary paddle, under your left hand (e.g. Xbox Elite paddle P3) */
135     SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2, /**< Lower or secondary paddle, under your right hand (e.g. Xbox Elite paddle P2) */
136     SDL_GAMEPAD_BUTTON_LEFT_PADDLE2, /**< Lower or secondary paddle, under your left hand (e.g. Xbox Elite paddle P4) */
137     SDL_GAMEPAD_BUTTON_TOUCHPAD, /**< PS4/PS5 touchpad button */
138     SDL_GAMEPAD_BUTTON_MISC2, /**< Additional button */
139     SDL_GAMEPAD_BUTTON_MISC3, /**< Additional button */
140     SDL_GAMEPAD_BUTTON_MISC4, /**< Additional button */
141     SDL_GAMEPAD_BUTTON_MISC5, /**< Additional button */
142     SDL_GAMEPAD_BUTTON_MISC6, /**< Additional button */
143     SDL_GAMEPAD_BUTTON_COUNT
144 }
145 
146 /**
147     The set of gamepad button labels
148 
149     This isn't a complete set, just the face buttons to make it easy to show
150     button prompts.
151 
152     For a complete set, you should look at the button and gamepad type and have
153     a set of symbols that work well with your art style.
154 */
155 enum SDL_GamepadButtonLabel {
156     SDL_GAMEPAD_BUTTON_LABEL_UNKNOWN,
157     SDL_GAMEPAD_BUTTON_LABEL_A,
158     SDL_GAMEPAD_BUTTON_LABEL_B,
159     SDL_GAMEPAD_BUTTON_LABEL_X,
160     SDL_GAMEPAD_BUTTON_LABEL_Y,
161     SDL_GAMEPAD_BUTTON_LABEL_CROSS,
162     SDL_GAMEPAD_BUTTON_LABEL_CIRCLE,
163     SDL_GAMEPAD_BUTTON_LABEL_SQUARE,
164     SDL_GAMEPAD_BUTTON_LABEL_TRIANGLE
165 }
166 
167 /**
168     The list of axes available on a gamepad
169 
170     Thumbstick axis values range from SDL_JOYSTICK_AXIS_MIN to
171     SDL_JOYSTICK_AXIS_MAX, and are centered within ~8000 of zero, though
172     advanced UI will allow users to set or autodetect the dead zone, which
173     varies between gamepads.
174 
175     Trigger axis values range from 0 (released) to SDL_JOYSTICK_AXIS_MAX (fully
176     pressed) when reported by SDL_GetGamepadAxis(). Note that this is not the
177     same range that will be reported by the lower-level SDL_GetJoystickAxis().
178 */
179 enum SDL_GamepadAxis {
180     SDL_GAMEPAD_AXIS_INVALID = -1,
181     SDL_GAMEPAD_AXIS_LEFTX,
182     SDL_GAMEPAD_AXIS_LEFTY,
183     SDL_GAMEPAD_AXIS_RIGHTX,
184     SDL_GAMEPAD_AXIS_RIGHTY,
185     SDL_GAMEPAD_AXIS_LEFT_TRIGGER,
186     SDL_GAMEPAD_AXIS_RIGHT_TRIGGER,
187     SDL_GAMEPAD_AXIS_COUNT
188 }
189 
190 /**
191     Types of gamepad control bindings.
192 
193     A gamepad is a collection of bindings that map arbitrary joystick buttons,
194     axes and hat switches to specific positions on a generic console-style
195     gamepad. This enum is used as part of SDL_GamepadBinding to specify those
196     mappings.
197 */
198 enum SDL_GamepadBindingType {
199     SDL_GAMEPAD_BINDTYPE_NONE = 0,
200     SDL_GAMEPAD_BINDTYPE_BUTTON,
201     SDL_GAMEPAD_BINDTYPE_AXIS,
202     SDL_GAMEPAD_BINDTYPE_HAT
203 }
204 
205 /**
206     A mapping between one joystick input to a gamepad control.
207 
208     A gamepad has a collection of several bindings, to say, for example, when
209     joystick button number 5 is pressed, that should be treated like the
210     gamepad's "start" button.
211 
212     SDL has these bindings built-in for many popular controllers, and can add
213     more with a simple text string. Those strings are parsed into a collection
214     of these structs to make it easier to operate on the data.
215 
216     See_Also:
217         $(D SDL_GetGamepadBindings)
218 */
219 struct SDL_GamepadBinding {
220     SDL_GamepadBindingType input_type;
221     SDL_GamepadBindingInput input;
222     SDL_GamepadBindingType output_type;
223     SDL_GamepadBindingOutput output;
224 
225     static
226     union SDL_GamepadBindingInput {
227         int button;
228 
229         struct {
230             int axis;
231             int axis_min;
232             int axis_max;
233         }
234 
235         struct {
236             int hat;
237             int hat_mask;
238         }
239     }
240 
241     static
242     union SDL_GamepadBindingOutput {
243         SDL_GamepadButton button;
244 
245         struct {
246             SDL_GamepadAxis axis;
247             int axis_min;
248             int axis_max;
249         }
250 
251     }
252 }
253 
254 /**
255     Add support for gamepads that SDL is unaware of or change the binding of an
256     existing gamepad.
257     
258     The mapping string has the format "GUID,name,mapping", where GUID is the
259     string value from SDL_GUIDToString(), name is the human readable string for
260     the device and mappings are gamepad mappings to joystick ones. Under
261     Windows there is a reserved GUID of "xinput" that covers all XInput
262     devices. The mapping format for joystick is:
263     
264     - `bX`: a joystick button, index X
265     - `hX.Y`: hat X with value Y
266     - `aX`: axis X of the joystick
267     
268     Buttons can be used as a gamepad axes and vice versa.
269     
270     If a device with this GUID is already plugged in, SDL will generate an
271     SDL_EVENT_GAMEPAD_ADDED event.
272     
273     This string shows an example of a valid mapping for a gamepad:
274     
275     ---
276     "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"
277     ---
278     
279     Params:
280         mapping = the mapping string.
281     
282     Returns:
283         1 if a new mapping is added, 0 if an existing mapping is updated,
284         -1 on failure; call SDL_GetError() for more information.
285     
286     Threadsafety:
287         It is safe to call this function from any thread.
288 
289     See_Also:
290         $(D SDL_AddGamepadMappingsFromFile)
291         $(D SDL_AddGamepadMappingsFromIO)
292         $(D SDL_GetGamepadMapping)
293         $(D SDL_GetGamepadMappingForGUID)
294         $(D SDL_HINT_GAMECONTROLLERCONFIG)
295         $(D SDL_HINT_GAMECONTROLLERCONFIG_FILE)
296         $(D SDL_EVENT_GAMEPAD_ADDED)
297 */
298 extern int SDL_AddGamepadMapping(const(char)** mapping);
299 
300 /**
301     Load a set of gamepad mappings from an SDL_IOStream.
302 
303     You can call this function several times, if needed, to load different
304     database files.
305 
306     If a new mapping is loaded for an already known gamepad GUID, the later
307     version will overwrite the one currently loaded.
308 
309     Any new mappings for already plugged in controllers will generate
310     SDL_EVENT_GAMEPAD_ADDED events.
311 
312     Mappings not belonging to the current platform or with no platform field
313     specified will be ignored (i.e. mappings for Linux will be ignored in
314     Windows, etc).
315 
316     This function will load the text database entirely in memory before
317     processing it, so take this into consideration if you are in a memory
318     constrained environment.
319 
320     Params:
321         src =       the data stream for the mappings to be added.
322         closeio =   if true, calls SDL_CloseIO() on `src` before returning, even
323                     in the case of an error.
324     
325     Returns:
326         the number of mappings added or -1 on failure; call SDL_GetError()
327             for more information.
328 
329     Threadsafety:
330         It is safe to call this function from any thread.
331 
332     See_Also:
333         $(D SDL_AddGamepadMapping)
334         $(D SDL_AddGamepadMappingsFromFile)
335         $(D SDL_GetGamepadMapping)
336         $(D SDL_GetGamepadMappingForGUID)
337         $(D SDL_HINT_GAMECONTROLLERCONFIG)
338         $(D SDL_HINT_GAMECONTROLLERCONFIG_FILE)
339         $(D SDL_EVENT_GAMEPAD_ADDED)
340 */
341 extern int SDL_AddGamepadMappingsFromIO(SDL_IOStream* src, bool closeio);
342 
343 /**
344     Load a set of gamepad mappings from a file.
345 
346     You can call this function several times, if needed, to load different
347     database files.
348 
349     If a new mapping is loaded for an already known gamepad GUID, the later
350     version will overwrite the one currently loaded.
351 
352     Any new mappings for already plugged in controllers will generate
353     SDL_EVENT_GAMEPAD_ADDED events.
354 
355     Mappings not belonging to the current platform or with no platform field
356     specified will be ignored (i.e. mappings for Linux will be ignored in
357     Windows, etc).
358 
359     Params:
360         file = the mappings file to load.
361     
362     Returns:
363         the number of mappings added or -1 on failure; call SDL_GetError()
364         for more information.
365 
366     Threadsafety:
367         It is safe to call this function from any thread.
368 
369     See_Also:
370         $(D SDL_AddGamepadMapping)
371         $(D SDL_AddGamepadMappingsFromIO)
372         $(D SDL_GetGamepadMapping)
373         $(D SDL_GetGamepadMappingForGUID)
374         $(D SDL_HINT_GAMECONTROLLERCONFIG)
375         $(D SDL_HINT_GAMECONTROLLERCONFIG_FILE)
376         $(D SDL_EVENT_GAMEPAD_ADDED)
377 */
378 extern int SDL_AddGamepadMappingsFromFile(const(char)** file);
379 
380 /**
381     Reinitialize the SDL mapping database to its initial state.
382 
383     This will generate gamepad events as needed if device mappings change.
384 
385     Returns:
386         true on success or false on failure; call SDL_GetError() for more
387         information.
388 */
389 extern bool SDL_ReloadGamepadMappings();
390 
391 /**
392     Get the current gamepad mappings.
393 
394     Params:
395         count = a pointer filled in with the number of mappings returned, can
396                 be NULL.
397     
398     Returns:
399         an array of the mapping strings, NULL-terminated, or NULL on
400         failure; call SDL_GetError() for more information. This is a
401         single allocation that should be freed with SDL_free() when it is
402         no longer needed.
403 */
404 extern char** SDL_GetGamepadMappings(int* count);
405 
406 /**
407     Get the gamepad mapping string for a given GUID.
408 
409     Params:
410         guid =  a structure containing the GUID for which a mapping is desired.
411     
412     Returns:
413         a mapping string or NULL on failure; call SDL_GetError() for more
414         information. This should be freed with SDL_free() when it is no
415         longer needed.
416 
417     See_Also:
418         $(D SDL_GetJoystickGUIDForID)
419         $(D SDL_GetJoystickGUID)
420 */
421 extern char* SDL_GetGamepadMappingForGUID(SDL_GUID guid);
422 
423 /**
424     Get the current mapping of a gamepad.
425 
426     Details about mappings are discussed with SDL_AddGamepadMapping().
427 
428     Params:
429         gamepad =   the gamepad you want to get the current mapping for.
430     
431     Returns:
432         a string that has the gamepad's mapping or NULL if no mapping is
433         available; call SDL_GetError() for more information. This should
434         be freed with SDL_free() when it is no longer needed.
435 
436     See_Also:
437         $(D SDL_AddGamepadMapping)
438         $(D SDL_GetGamepadMappingForID)
439         $(D SDL_GetGamepadMappingForGUID)
440         $(D SDL_SetGamepadMapping)
441 */
442 extern char* SDL_GetGamepadMapping(SDL_Gamepad* gamepad);
443 
444 /**
445     Set the current mapping of a joystick or gamepad.
446     
447     Details about mappings are discussed with SDL_AddGamepadMapping().
448     
449     Params:
450         instance_id =   the joystick instance ID.
451         mapping =       the mapping to use for this device, or NULL to clear the
452                         mapping.
453     
454     Returns:
455         true on success or false on failure; call SDL_GetError() for more
456         information.
457 
458     See_Also:
459         $(D SDL_AddGamepadMapping)
460         $(D SDL_GetGamepadMapping)
461 */
462 extern bool SDL_SetGamepadMapping(SDL_JoystickID instance_id, const(char)** mapping);
463 
464 /**
465     Return whether a gamepad is currently connected.
466     
467     Returns:
468         true if a gamepad is connected, false otherwise.
469 
470     See_Also:
471         $(D SDL_GetGamepads)
472 */
473 extern bool SDL_HasGamepad();
474 
475 /**
476     Get a list of currently connected gamepads.
477     
478     Params:
479         count = a pointer filled in with the number of gamepads returned, may
480                 be NULL.
481     
482     Returns:
483         a 0 terminated array of joystick instance IDs or NULL on failure;
484         call SDL_GetError() for more information. This should be freed
485         with SDL_free() when it is no longer needed.
486 
487     See_Also:
488         $(D SDL_HasGamepad)
489         $(D SDL_OpenGamepad)
490 */
491 extern SDL_JoystickID* SDL_GetGamepads(int* count);
492 
493 /**
494     Check if the given joystick is supported by the gamepad interface.
495     
496     Params:
497         instance_id = the joystick instance ID.
498     
499     Returns:
500         true if the given joystick is supported by the gamepad interface,
501         false if it isn't or it's an invalid index.
502 
503     See_Also:
504         $(D SDL_GetJoysticks)
505         $(D SDL_OpenGamepad)
506 */
507 extern bool SDL_IsGamepad(SDL_JoystickID instance_id);
508 
509 /**
510     Get the implementation dependent name of a gamepad.
511     
512     This can be called before any gamepads are opened.
513     
514     Params:
515         instance_id = the joystick instance ID.
516     
517     Returns:
518         the name of the selected gamepad. If no name can be found, this
519         function returns NULL; call SDL_GetError() for more information.
520 
521     See_Also:
522         $(D SDL_GetGamepadName)
523         $(D SDL_GetGamepads)
524 */
525 extern const(char)** SDL_GetGamepadNameForID(SDL_JoystickID instance_id);
526 
527 /**
528     Get the implementation dependent path of a gamepad.
529     
530     This can be called before any gamepads are opened.
531     
532     Params:
533         instance_id = the joystick instance ID.
534     
535     Returns:
536         the path of the selected gamepad. If no path can be found, this
537         function returns NULL; call SDL_GetError() for more information.
538 
539     See_Also:
540         $(D SDL_GetGamepadPath)
541         $(D SDL_GetGamepads)
542 */
543 extern const(char)** SDL_GetGamepadPathForID(SDL_JoystickID instance_id);
544 
545 /**
546     Get the player index of a gamepad.
547     
548     This can be called before any gamepads are opened.
549     
550     Params:
551         instance_id = the joystick instance ID.
552     
553     Returns:
554         the player index of a gamepad, or -1 if it's not available.
555 
556     See_Also:
557         $(D SDL_GetGamepadPlayerIndex)
558         $(D SDL_GetGamepads)
559 */
560 extern int SDL_GetGamepadPlayerIndexForID(SDL_JoystickID instance_id);
561 
562 /**
563     Get the implementation-dependent GUID of a gamepad.
564     
565     This can be called before any gamepads are opened.
566     
567     Params:
568         instance_id = the joystick instance ID.
569     
570     Returns:
571         the GUID of the selected gamepad. If called on an invalid index,
572         this function returns a zero GUID.
573 
574     See_Also:
575         $(D SDL_GUIDToString)
576         $(D SDL_GetGamepads)
577 */
578 extern SDL_GUID SDL_GetGamepadGUIDForID(SDL_JoystickID instance_id);
579 
580 /**
581     Get the USB vendor ID of a gamepad, if available.
582     
583     This can be called before any gamepads are opened. If the vendor ID isn't
584     available this function returns 0.
585     
586     Params:
587         instance_id = the joystick instance ID.
588     
589     Returns:
590         The USB vendor ID of the selected gamepad. If called on an invalid
591         index, this function returns zero.
592 
593     See_Also:
594         $(D SDL_GetGamepadVendor)
595         $(D SDL_GetGamepads)
596 */
597 extern Uint16 SDL_GetGamepadVendorForID(SDL_JoystickID instance_id);
598 
599 /**
600     Get the USB product ID of a gamepad, if available.
601     
602     This can be called before any gamepads are opened. If the product ID isn't
603     available this function returns 0.
604     
605     Params:
606         instance_id = the joystick instance ID.
607     
608     Returns:
609         The USB product ID of the selected gamepad. If called on an
610         invalid index, this function returns zero.
611 
612     See_Also:
613         $(D SDL_GetGamepadProduct)
614         $(D SDL_GetGamepads)
615 */
616 extern Uint16 SDL_GetGamepadProductForID(SDL_JoystickID instance_id);
617 
618 /**
619     Get the product version of a gamepad, if available.
620     
621     This can be called before any gamepads are opened. If the product version
622     isn't available this function returns 0.
623     
624     Params:
625         instance_id = the joystick instance ID.
626     
627     Returns:
628         The product version of the selected gamepad. If called on an
629         invalid index, this function returns zero.
630 
631     See_Also:
632         $(D SDL_GetGamepadProductVersion)
633         $(D SDL_GetGamepads)
634 */
635 extern Uint16 SDL_GetGamepadProductVersionForID(SDL_JoystickID instance_id);
636 
637 /**
638     Get the type of a gamepad.
639     
640     This can be called before any gamepads are opened.
641     
642     Params:
643         instance_id = the joystick instance ID.
644     
645     Returns:
646         The gamepad type.
647 
648     See_Also:
649         $(D SDL_GetGamepadType)
650         $(D SDL_GetGamepads)
651         $(D SDL_GetRealGamepadTypeForID)
652 */
653 extern SDL_GamepadType SDL_GetGamepadTypeForID(SDL_JoystickID instance_id);
654 
655 /**
656     Get the type of a gamepad, ignoring any mapping override.
657     
658     This can be called before any gamepads are opened.
659     
660     Params:
661         instance_id = the joystick instance ID.
662     
663     Returns:
664         The gamepad type.
665 
666     See_Also:
667         $(D SDL_GetGamepadTypeForID)
668         $(D SDL_GetGamepads)
669         $(D SDL_GetRealGamepadType)
670 */
671 extern SDL_GamepadType SDL_GetRealGamepadTypeForID(SDL_JoystickID instance_id);
672 
673 /**
674     Get the mapping of a gamepad.
675     
676     This can be called before any gamepads are opened.
677     
678     Params:
679         instance_id = the joystick instance ID.
680     
681     Returns:
682         The mapping string. Returns NULL if no mapping is available. This
683         should be freed with SDL_free() when it is no longer needed.
684 
685     See_Also:
686         $(D SDL_GetGamepads)
687         $(D SDL_GetGamepadMapping)
688 */
689 extern char* SDL_GetGamepadMappingForID(SDL_JoystickID instance_id);
690 
691 /**
692     Open a gamepad for use.
693     
694     Params:
695         instance_id = the joystick instance ID.
696     
697     Returns:
698         A gamepad identifier or NULL if an error occurred; call
699         SDL_GetError() for more information.
700 
701     See_Also:
702         $(D SDL_CloseGamepad)
703         $(D SDL_IsGamepad)
704 */
705 extern SDL_Gamepad* SDL_OpenGamepad(SDL_JoystickID instance_id);
706 
707 /**
708     Get the SDL_Gamepad associated with a joystick instance ID, if it has been
709     opened.
710     
711     Params:
712         instance_id = the joystick instance ID of the gamepad.
713     
714     Returns:
715         An SDL_Gamepad on success or NULL on failure or if it hasn't been
716         opened yet; call SDL_GetError() for more information.
717 */
718 extern SDL_Gamepad* SDL_GetGamepadFromID(SDL_JoystickID instance_id);
719 
720 /**
721     Get the SDL_Gamepad associated with a player index.
722     
723     Params:
724         player_index = the player index, which different from the instance ID.
725     
726     Returns:
727         The SDL_Gamepad associated with a player index.
728 
729     See_Also:
730         $(D SDL_GetGamepadPlayerIndex)
731         $(D SDL_SetGamepadPlayerIndex)
732 */
733 extern SDL_Gamepad* SDL_GetGamepadFromPlayerIndex(int player_index);
734 
735 /**
736     Get the properties associated with an opened gamepad.
737     
738     These properties are shared with the underlying joystick object.
739     
740     The following read-only properties are provided by SDL:
741     
742     -   `SDL_PROP_GAMEPAD_CAP_MONO_LED_BOOLEAN`: true if this gamepad has an LED
743         that has adjustable brightness
744     -   `SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN`: true if this gamepad has an LED
745         that has adjustable color
746     -   `SDL_PROP_GAMEPAD_CAP_PLAYER_LED_BOOLEAN`: true if this gamepad has a
747         player LED
748     -   `SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN`: true if this gamepad has
749         left/right rumble
750     -   `SDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN`: true if this gamepad has
751         simple trigger rumble
752     
753     Params:
754         gamepad =   a gamepad identifier previously returned by
755                     SDL_OpenGamepad().
756     
757     Returns:
758         a valid property ID on success or 0 on failure; call
759         SDL_GetError() for more information.
760 */
761 extern SDL_PropertiesID SDL_GetGamepadProperties(SDL_Gamepad* gamepad);
762 
763 enum SDL_PROP_GAMEPAD_CAP_MONO_LED_BOOLEAN = SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN;
764 enum SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN = SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN;
765 enum SDL_PROP_GAMEPAD_CAP_PLAYER_LED_BOOLEAN = SDL_PROP_JOYSTICK_CAP_PLAYER_LED_BOOLEAN;
766 enum SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN = SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN;
767 enum SDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN = SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN;
768 
769 /**
770     Get the instance ID of an opened gamepad.
771     
772     Params:
773         gamepad =   a gamepad identifier previously returned by
774                     SDL_OpenGamepad().
775     
776     Returns:
777         the instance ID of the specified gamepad on success or 0 on
778         failure; call SDL_GetError() for more information.
779 */
780 extern SDL_JoystickID SDL_GetGamepadID(SDL_Gamepad* gamepad);
781 
782 /**
783     Get the implementation-dependent name for an opened gamepad.
784     
785     Params:
786         gamepad =   a gamepad identifier previously returned by
787                     SDL_OpenGamepad().
788     
789     Returns:
790         the implementation dependent name for the gamepad, or NULL if
791         there is no name or the identifier passed is invalid.
792 
793     See_Also:
794         $(D SDL_GetGamepadNameForID)
795 */
796 extern const(char)** SDL_GetGamepadName(SDL_Gamepad* gamepad);
797 
798 /**
799     Get the implementation-dependent path for an opened gamepad.
800     
801     Params:
802         gamepad =   a gamepad identifier previously returned by
803                     SDL_OpenGamepad().
804     
805     Returns:
806         the implementation dependent path for the gamepad, or NULL if
807         there is no path or the identifier passed is invalid.
808 
809     See_Also:
810         $(D SDL_GetGamepadPathForID)
811 */
812 extern const(char)** SDL_GetGamepadPath(SDL_Gamepad* gamepad);
813 
814 /**
815     Get the type of an opened gamepad.
816     
817     Params:
818         gamepad = the gamepad object to query.
819     
820     Returns:
821         the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not
822         available.
823 
824     See_Also:
825         $(D SDL_GetGamepadTypeForID)
826 */
827 extern SDL_GamepadType SDL_GetGamepadType(SDL_Gamepad* gamepad);
828 
829 /**
830     Get the type of an opened gamepad, ignoring any mapping override.
831     
832     Params:
833         gamepad = the gamepad object to query.
834     
835     Returns:
836         the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not
837         available.
838 
839     See_Also:
840         $(D SDL_GetRealGamepadTypeForID)
841 */
842 extern SDL_GamepadType SDL_GetRealGamepadType(SDL_Gamepad* gamepad);
843 
844 /**
845     Get the player index of an opened gamepad.
846     
847     For XInput gamepads this returns the XInput user index.
848     
849     Params:
850         gamepad = the gamepad object to query.
851     
852     Returns:
853         the player index for gamepad, or -1 if it's not available.
854 
855     See_Also:
856         $(D SDL_SetGamepadPlayerIndex)
857 */
858 extern int SDL_GetGamepadPlayerIndex(SDL_Gamepad* gamepad);
859 
860 /**
861     Set the player index of an opened gamepad.
862     
863     Params:
864         gamepad =       the gamepad object to adjust.
865         player_index =  player index to assign to this gamepad, or -1 to clear
866                         the player index and turn off player LEDs.
867     
868     Returns:
869         true on success or false on failure; call SDL_GetError() for more
870         information.
871 
872     See_Also:
873         $(D SDL_GetGamepadPlayerIndex)
874 */
875 extern bool SDL_SetGamepadPlayerIndex(SDL_Gamepad* gamepad, int player_index);
876 
877 /**
878     Get the USB vendor ID of an opened gamepad, if available.
879     
880     If the vendor ID isn't available this function returns 0.
881     
882     Params:
883         gamepad = the gamepad object to query.
884     
885     Returns:
886         the USB vendor ID, or zero if unavailable.
887 
888     See_Also:
889         $(D SDL_GetGamepadVendorForID)
890 */
891 extern Uint16 SDL_GetGamepadVendor(SDL_Gamepad* gamepad);
892 
893 /**
894     Get the USB product ID of an opened gamepad, if available.
895     
896     If the product ID isn't available this function returns 0.
897     
898     Params:
899         gamepad = the gamepad object to query.
900     
901     Returns:
902         the USB product ID, or zero if unavailable.
903 
904     See_Also:
905         $(D SDL_GetGamepadProductForID)
906 */
907 extern Uint16 SDL_GetGamepadProduct(SDL_Gamepad* gamepad);
908 
909 /**
910     Get the product version of an opened gamepad, if available.
911     
912     If the product version isn't available this function returns 0.
913     
914     Params:
915         gamepad = the gamepad object to query.
916     
917     Returns:
918         the USB product version, or zero if unavailable.
919 
920     See_Also:
921         $(D SDL_GetGamepadProductVersionForID)
922 */
923 extern Uint16 SDL_GetGamepadProductVersion(SDL_Gamepad* gamepad);
924 
925 /**
926     Get the firmware version of an opened gamepad, if available.
927     
928     If the firmware version isn't available this function returns 0.
929     
930     Params:
931         gamepad = the gamepad object to query.
932     
933     Returns:
934         the gamepad firmware version, or zero if unavailable.
935 */
936 extern Uint16 SDL_GetGamepadFirmwareVersion(SDL_Gamepad* gamepad);
937 
938 /**
939     Get the serial number of an opened gamepad, if available.
940     
941     Returns the serial number of the gamepad, or NULL if it is not available.
942     
943     Params:
944         gamepad = the gamepad object to query.
945     
946     Returns:
947         the serial number, or NULL if unavailable.
948 */
949 extern const(char)** SDL_GetGamepadSerial(SDL_Gamepad* gamepad);
950 
951 /**
952     Get the Steam Input handle of an opened gamepad, if available.
953     
954     Returns an InputHandle_t for the gamepad that can be used with Steam Input
955     API: https://partner.steamgames.com/doc/api/ISteamInput
956     
957     Params:
958         gamepad = the gamepad object to query.
959     
960     Returns:
961         the gamepad handle, or 0 if unavailable.
962 */
963 extern Uint64 SDL_GetGamepadSteamHandle(SDL_Gamepad* gamepad);
964 
965 /**
966     Get the connection state of a gamepad.
967     
968     Params:
969         gamepad = the gamepad object to query.
970     
971     Returns:
972         the connection state on success or
973         `SDL_JOYSTICK_CONNECTION_INVALID` on failure; call SDL_GetError()
974         for more information.
975 
976 */
977 extern SDL_JoystickConnectionState SDL_GetGamepadConnectionState(SDL_Gamepad* gamepad);
978 
979 /**
980     Get the battery state of a gamepad.
981     
982     You should never take a battery status as absolute truth. Batteries
983     (especially failing batteries) are delicate hardware, and the values
984     reported here are best estimates based on what that hardware reports. It's
985     not uncommon for older batteries to lose stored power much faster than it
986     reports, or completely drain when reporting it has 20 percent left, etc.
987     
988     Params:
989         gamepad =   the gamepad object to query.
990         percent =   a pointer filled in with the percentage of battery life
991                     left, between 0 and 100, or NULL to ignore. This will be
992                     filled in with -1 we can't determine a value or there is no
993                     battery.
994     
995     Returns:
996         the current battery state.
997 */
998 extern SDL_PowerState SDL_GetGamepadPowerInfo(SDL_Gamepad* gamepad, int* percent);
999 
1000 /**
1001     Check if a gamepad has been opened and is currently connected.
1002     
1003     Params:
1004         gamepad =   a gamepad identifier previously returned by
1005                     SDL_OpenGamepad().
1006     
1007     Returns:
1008         true if the gamepad has been opened and is currently connected, or
1009         false if not.
1010 
1011 */
1012 extern bool SDL_GamepadConnected(SDL_Gamepad* gamepad);
1013 
1014 /**
1015     Get the underlying joystick from a gamepad.
1016     
1017     This function will give you a SDL_Joystick object, which allows you to use
1018     the SDL_Joystick functions with a SDL_Gamepad object. This would be useful
1019     for getting a joystick's position at any given time, even if it hasn't
1020     moved (moving it would produce an event, which would have the axis' value).
1021     
1022     The pointer returned is owned by the SDL_Gamepad. You should not call
1023     SDL_CloseJoystick() on it, for example, since doing so will likely cause
1024     SDL to crash.
1025     
1026     Params:
1027         gamepad = the gamepad object that you want to get a joystick from.
1028     
1029     Returns:
1030         an SDL_Joystick object, or NULL on failure; call SDL_GetError()
1031         for more information.
1032 
1033 */
1034 extern SDL_Joystick* SDL_GetGamepadJoystick(SDL_Gamepad* gamepad);
1035 
1036 /**
1037     Set the state of gamepad event processing.
1038     
1039     If gamepad events are disabled, you must call SDL_UpdateGamepads() yourself
1040     and check the state of the gamepad when you want gamepad information.
1041     
1042     Params:
1043         enabled = whether to process gamepad events or not.
1044 
1045     See_Also:
1046         $(D SDL_GamepadEventsEnabled)
1047         $(D SDL_UpdateGamepads)
1048 */
1049 extern void SDL_SetGamepadEventsEnabled(bool enabled);
1050 
1051 /**
1052     Query the state of gamepad event processing.
1053     
1054     If gamepad events are disabled, you must call SDL_UpdateGamepads() yourself
1055     and check the state of the gamepad when you want gamepad information.
1056     
1057     Returns:
1058         true if gamepad events are being processed, false otherwise.
1059 
1060     See_Also:
1061         $(D SDL_SetGamepadEventsEnabled)
1062 */
1063 extern bool SDL_GamepadEventsEnabled();
1064 
1065 /**
1066     Get the SDL joystick layer bindings for a gamepad.
1067     
1068     Params:
1069         gamepad =   a gamepad.
1070         count =     a pointer filled in with the number of bindings returned.
1071     
1072     Returns:
1073         a NULL terminated array of pointers to bindings or NULL on
1074         failure; call SDL_GetError() for more information. This is a
1075         single allocation that should be freed with SDL_free() when it is
1076         no longer needed.
1077 
1078 */
1079 extern SDL_GamepadBinding** SDL_GetGamepadBindings(SDL_Gamepad* gamepad, int* count);
1080 
1081 /**
1082     Manually pump gamepad updates if not using the loop.
1083     
1084     This function is called automatically by the event loop if events are
1085     enabled. Under such circumstances, it will not be necessary to call this
1086     function.
1087 */
1088 extern void SDL_UpdateGamepads();
1089 
1090 /**
1091     Convert a string into SDL_GamepadType enum.
1092     
1093     This function is called internally to translate SDL_Gamepad mapping strings
1094     for the underlying joystick device into the consistent SDL_Gamepad mapping.
1095     You do not normally need to call this function unless you are parsing
1096     SDL_Gamepad mappings in your own code.
1097     
1098     Params:
1099         str = string representing a SDL_GamepadType type.
1100     
1101     Returns:
1102         the SDL_GamepadType enum corresponding to the input string, or
1103         `SDL_GAMEPAD_TYPE_UNKNOWN` if no match was found.
1104 
1105     See_Also:
1106         $(D SDL_GetGamepadStringForType)
1107 */
1108 extern SDL_GamepadType SDL_GetGamepadTypeFromString(const(char)** str);
1109 
1110 /**
1111     Convert from an SDL_GamepadType enum to a string.
1112     
1113     Params:
1114         type = an enum value for a given SDL_GamepadType.
1115     
1116     Returns:
1117         a string for the given type, or NULL if an invalid type is
1118         specified. The string returned is of the format used by
1119         SDL_Gamepad mapping strings.
1120 
1121     See_Also:
1122         $(D SDL_GetGamepadTypeFromString)
1123 */
1124 extern const(char)** SDL_GetGamepadStringForType(SDL_GamepadType type);
1125 
1126 /**
1127     Convert a string into SDL_GamepadAxis enum.
1128     
1129     This function is called internally to translate SDL_Gamepad mapping strings
1130     for the underlying joystick device into the consistent SDL_Gamepad mapping.
1131     You do not normally need to call this function unless you are parsing
1132     SDL_Gamepad mappings in your own code.
1133     
1134     Note specially that "righttrigger" and "lefttrigger" map to
1135     `SDL_GAMEPAD_AXIS_RIGHT_TRIGGER` and `SDL_GAMEPAD_AXIS_LEFT_TRIGGER`,
1136     respectively.
1137     
1138     Params:
1139         str = string representing a SDL_Gamepad axis.
1140     
1141     Returns:
1142         the SDL_GamepadAxis enum corresponding to the input string, or
1143         `SDL_GAMEPAD_AXIS_INVALID` if no match was found.
1144 
1145     See_Also:
1146         $(D SDL_GetGamepadStringForAxis)
1147 */
1148 extern SDL_GamepadAxis SDL_GetGamepadAxisFromString(const(char)** str);
1149 
1150 /**
1151     Convert from an SDL_GamepadAxis enum to a string.
1152     
1153     Params:
1154         axis = an enum value for a given SDL_GamepadAxis.
1155     
1156     Returns:
1157         a string for the given axis, or NULL if an invalid axis is
1158              specified. The string returned is of the format used by
1159              SDL_Gamepad mapping strings.
1160 
1161     See_Also:
1162         $(D SDL_GetGamepadAxisFromString)
1163 */
1164 extern const(char)** SDL_GetGamepadStringForAxis(SDL_GamepadAxis axis);
1165 
1166 /**
1167     Query whether a gamepad has a given axis.
1168     
1169     This merely reports whether the gamepad's mapping defined this axis, as
1170     that is all the information SDL has about the physical device.
1171     
1172     Params:
1173         gamepad =   a gamepad.
1174         axis =      an axis enum value (an SDL_GamepadAxis value).
1175     
1176     Returns:
1177         true if the gamepad has this axis, false otherwise.
1178 
1179     See_Also:
1180         $(D SDL_GamepadHasButton)
1181         $(D SDL_GetGamepadAxis)
1182 */
1183 extern bool SDL_GamepadHasAxis(SDL_Gamepad* gamepad, SDL_GamepadAxis axis);
1184 
1185 /**
1186     Get the current state of an axis control on a gamepad.
1187     
1188     The axis indices start at index 0.
1189     
1190     For thumbsticks, the state is a value ranging from -32768 (up/left) to
1191     32767 (down/right).
1192     
1193     Triggers range from 0 when released to 32767 when fully pressed, and never
1194     return a negative value. Note that this differs from the value reported by
1195     the lower-level SDL_GetJoystickAxis(), which normally uses the full range.
1196     
1197     Params:
1198         gamepad =   a gamepad.
1199         axis =      an axis index (one of the SDL_GamepadAxis values).
1200     
1201     Returns:
1202         axis state (including 0) on success or 0 (also) on failure; call
1203         SDL_GetError() for more information.
1204 
1205     See_Also:
1206         $(D SDL_GamepadHasAxis)
1207         $(D SDL_GetGamepadButton)
1208 */
1209 extern Sint16 SDL_GetGamepadAxis(SDL_Gamepad* gamepad, SDL_GamepadAxis axis);
1210 
1211 /**
1212     Convert a string into an SDL_GamepadButton enum.
1213     
1214     This function is called internally to translate SDL_Gamepad mapping strings
1215     for the underlying joystick device into the consistent SDL_Gamepad mapping.
1216     You do not normally need to call this function unless you are parsing
1217     SDL_Gamepad mappings in your own code.
1218     
1219     Params:
1220         str = string representing a SDL_Gamepad axis.
1221     
1222     Returns:
1223         the SDL_GamepadButton enum corresponding to the input string, or
1224         `SDL_GAMEPAD_BUTTON_INVALID` if no match was found.
1225 
1226     See_Also:
1227         $(D SDL_GetGamepadStringForButton)
1228 */
1229 extern SDL_GamepadButton SDL_GetGamepadButtonFromString(const(char)** str);
1230 
1231 /**
1232     Convert from an SDL_GamepadButton enum to a string.
1233     
1234     Params:
1235         button = an enum value for a given SDL_GamepadButton.
1236     
1237     Returns:
1238         a string for the given button, or NULL if an invalid button is
1239         specified. The string returned is of the format used by
1240         SDL_Gamepad mapping strings.
1241 
1242     See_Also:
1243         $(D SDL_GetGamepadButtonFromString)
1244 */
1245 extern const(char)** SDL_GetGamepadStringForButton(SDL_GamepadButton button);
1246 
1247 /**
1248     Query whether a gamepad has a given button.
1249     
1250     This merely reports whether the gamepad's mapping defined this button, as
1251     that is all the information SDL has about the physical device.
1252     
1253     Params:
1254         gamepad =   a gamepad.
1255         button =    a button enum value (an SDL_GamepadButton value).
1256     
1257     Returns:
1258         true if the gamepad has this button, false otherwise.
1259 
1260     See_Also:
1261         $(D SDL_GamepadHasAxis)
1262 */
1263 extern bool SDL_GamepadHasButton(SDL_Gamepad* gamepad, SDL_GamepadButton button);
1264 
1265 /**
1266     Get the current state of a button on a gamepad.
1267     
1268     Params:
1269         gamepad =   a gamepad.
1270         button =    a button index (one of the SDL_GamepadButton values).
1271     
1272     Returns:
1273         true if the button is pressed, false otherwise.
1274 
1275     See_Also:
1276         $(D SDL_GamepadHasButton)
1277         $(D SDL_GetGamepadAxis)
1278 */
1279 extern bool SDL_GetGamepadButton(SDL_Gamepad* gamepad, SDL_GamepadButton button);
1280 
1281 /**
1282     Get the label of a button on a gamepad.
1283     
1284     Params:
1285         type =      the type of gamepad to check.
1286         button =    a button index (one of the SDL_GamepadButton values).
1287     
1288     Returns:
1289         the SDL_GamepadButtonLabel enum corresponding to the button label.
1290 
1291     See_Also:
1292         $(D SDL_GetGamepadButtonLabel)
1293 */
1294 extern SDL_GamepadButtonLabel SDL_GetGamepadButtonLabelForType(SDL_GamepadType type, SDL_GamepadButton button);
1295 
1296 /**
1297     Get the label of a button on a gamepad.
1298     
1299     Params:
1300         gamepad =   a gamepad.
1301         button =    a button index (one of the SDL_GamepadButton values).
1302     
1303     Returns:
1304         the SDL_GamepadButtonLabel enum corresponding to the button label.
1305 
1306     See_Also:
1307         $(D SDL_GetGamepadButtonLabelForType)
1308 */
1309 extern SDL_GamepadButtonLabel SDL_GetGamepadButtonLabel(SDL_Gamepad* gamepad, SDL_GamepadButton button);
1310 
1311 /**
1312     Get the number of touchpads on a gamepad.
1313     
1314     Params:
1315         gamepad = a gamepad.
1316     
1317     Returns:
1318         number of touchpads.
1319 
1320     See_Also:
1321         $(D SDL_GetNumGamepadTouchpadFingers)
1322 */
1323 extern int SDL_GetNumGamepadTouchpads(SDL_Gamepad* gamepad);
1324 
1325 /**
1326     Get the number of supported simultaneous fingers on a touchpad on a game
1327     gamepad.
1328     
1329     Params:
1330         gamepad =   a gamepad.
1331         touchpad =  a touchpad.
1332     
1333     Returns:
1334         number of supported simultaneous fingers.
1335 
1336     See_Also:
1337         $(D SDL_GetGamepadTouchpadFinger)
1338         $(D SDL_GetNumGamepadTouchpads)
1339 */
1340 extern int SDL_GetNumGamepadTouchpadFingers(SDL_Gamepad* gamepad, int touchpad);
1341 
1342 /**
1343     Get the current state of a finger on a touchpad on a gamepad.
1344     
1345     Params:
1346         gamepad =   a gamepad.
1347         touchpad =  a touchpad.
1348         finger =    a finger.
1349         down =      a pointer filled with true if the finger is down, false
1350                     otherwise, may be NULL.
1351         x =         a pointer filled with the x position, normalized 0 to 1, with the
1352                     origin in the upper left, may be NULL.
1353         y =         a pointer filled with the y position, normalized 0 to 1, with the
1354                     origin in the upper left, may be NULL.
1355         pressure =  a pointer filled with pressure value, may be NULL.
1356     
1357     Returns:
1358         true on success or false on failure; call SDL_GetError() for more
1359         information.
1360 
1361     See_Also:
1362         $(D SDL_GetNumGamepadTouchpadFingers)
1363 */
1364 extern bool SDL_GetGamepadTouchpadFinger(SDL_Gamepad* gamepad, int touchpad, int finger, bool* down, float* x, float* y, float* pressure);
1365 
1366 /**
1367     Return whether a gamepad has a particular sensor.
1368     
1369     Params:
1370         gamepad =   the gamepad to query.
1371         type =      the type of sensor to query.
1372     
1373     Returns:
1374         true if the sensor exists, false otherwise.
1375     
1376     See_Also:
1377         $(D SDL_GetGamepadSensorData)
1378         $(D SDL_GetGamepadSensorDataRate)
1379         $(D SDL_SetGamepadSensorEnabled)
1380 */
1381 extern bool SDL_GamepadHasSensor(SDL_Gamepad* gamepad, SDL_SensorType type);
1382 
1383 /**
1384     Set whether data reporting for a gamepad sensor is enabled.
1385     
1386     Params:
1387         gamepad =   the gamepad to update.
1388         type =      the type of sensor to enable/disable.
1389         enabled =   whether data reporting should be enabled.
1390     
1391     Returns:
1392         true on success or false on failure; call SDL_GetError() for more
1393         information.
1394 
1395     See_Also:
1396         $(D SDL_GamepadHasSensor)
1397         $(D SDL_GamepadSensorEnabled)
1398 */
1399 extern bool SDL_SetGamepadSensorEnabled(SDL_Gamepad* gamepad, SDL_SensorType type, bool enabled);
1400 
1401 /**
1402     Query whether sensor data reporting is enabled for a gamepad.
1403     
1404     Params:
1405         gamepad =   the gamepad to query.
1406         type =      the type of sensor to query.
1407     
1408     Returns:
1409         true if the sensor is enabled, false otherwise.
1410 
1411     See_Also:
1412         $(D SDL_SetGamepadSensorEnabled)
1413 */
1414 extern bool SDL_GamepadSensorEnabled(SDL_Gamepad* gamepad, SDL_SensorType type);
1415 
1416 /**
1417     Get the data rate (number of events per second) of a gamepad sensor.
1418     
1419     Params:
1420         gamepad =   the gamepad to query.
1421         type =      the type of sensor to query.
1422     
1423     Returns:
1424         the data rate, or 0.0f if the data rate is not available.
1425 
1426 */
1427 extern float SDL_GetGamepadSensorDataRate(SDL_Gamepad* gamepad, SDL_SensorType type);
1428 
1429 /**
1430     Get the current state of a gamepad sensor.
1431     
1432     The number of values and interpretation of the data is sensor dependent.
1433     See SDL_sensor.h for the details for each type of sensor.
1434     
1435     Params:
1436         gamepad =       the gamepad to query.
1437         type =          the type of sensor to query.
1438         data =          a pointer filled with the current sensor state.
1439         num_values =    the number of values to write to data.
1440     
1441     Returns:
1442         true on success or false on failure; call SDL_GetError() for more
1443         information.
1444 
1445 */
1446 extern bool SDL_GetGamepadSensorData(SDL_Gamepad* gamepad, SDL_SensorType type, float* data, int num_values);
1447 
1448 /**
1449     Start a rumble effect on a gamepad.
1450     
1451     Each call to this function cancels any previous rumble effect, and calling
1452     it with 0 intensity stops any rumbling.
1453     
1454     This function requires you to process SDL events or call
1455     SDL_UpdateJoysticks() to update rumble state.
1456     
1457     Params:
1458         gamepad =               the gamepad to vibrate.
1459         low_frequency_rumble =  the intensity of the low frequency (left)
1460                                 rumble motor, from 0 to 0xFFFF.
1461         high_frequency_rumble = the intensity of the high frequency (right)
1462                                 rumble motor, from 0 to 0xFFFF.
1463         duration_ms =           the duration of the rumble effect, in milliseconds.
1464     
1465     Returns:
1466         true on success or false on failure; call SDL_GetError() for more
1467         information.
1468 
1469 */
1470 extern bool SDL_RumbleGamepad(SDL_Gamepad* gamepad, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
1471 
1472 /**
1473     Start a rumble effect in the gamepad's triggers.
1474     
1475     Each call to this function cancels any previous trigger rumble effect, and
1476     calling it with 0 intensity stops any rumbling.
1477     
1478     Note that this is rumbling of the _triggers_ and not the gamepad as a
1479     whole. This is currently only supported on Xbox One gamepads. If you want
1480     the (more common) whole-gamepad rumble, use SDL_RumbleGamepad() instead.
1481     
1482     This function requires you to process SDL events or call
1483     SDL_UpdateJoysticks() to update rumble state.
1484     
1485     Params:
1486         gamepad =       the gamepad to vibrate.
1487         left_rumble =   the intensity of the left trigger rumble motor, from 0
1488                         to 0xFFFF.
1489         right_rumble =  the intensity of the right trigger rumble motor, from 0
1490                         to 0xFFFF.
1491         duration_ms =   the duration of the rumble effect, in milliseconds.
1492     
1493     Returns:
1494         true on success or false on failure; call SDL_GetError() for more
1495         information.
1496 
1497     See_Also:
1498         $(D SDL_RumbleGamepad)
1499 */
1500 extern bool SDL_RumbleGamepadTriggers(SDL_Gamepad* gamepad, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
1501 
1502 /**
1503     Update a gamepad's LED color.
1504     
1505     An example of a joystick LED is the light on the back of a PlayStation 4's
1506     DualShock 4 controller.
1507     
1508     For gamepads with a single color LED, the maximum of the RGB values will be
1509     used as the LED brightness.
1510     
1511     Params:
1512         gamepad =   the gamepad to update.
1513         red =       the intensity of the red LED.
1514         green =     the intensity of the green LED.
1515         blue =      the intensity of the blue LED.
1516     
1517     Returns:
1518         true on success or false on failure; call SDL_GetError() for more
1519         information.
1520 
1521 */
1522 extern bool SDL_SetGamepadLED(SDL_Gamepad* gamepad, Uint8 red, Uint8 green, Uint8 blue);
1523 
1524 /**
1525     Send a gamepad specific effect packet.
1526     
1527     Params:
1528         gamepad =   the gamepad to affect.
1529         data =      the data to send to the gamepad.
1530         size =      the size of the data to send to the gamepad.
1531     
1532     Returns:
1533         true on success or false on failure; call SDL_GetError() for more
1534         information.
1535 
1536 */
1537 extern bool SDL_SendGamepadEffect(SDL_Gamepad* gamepad, const(void)** data, int size);
1538 
1539 /**
1540     Close a gamepad previously opened with SDL_OpenGamepad().
1541     
1542     Params:
1543         gamepad =   a gamepad identifier previously returned by
1544                     SDL_OpenGamepad().
1545     
1546     See_Also:
1547         $(D SDL_OpenGamepad)
1548 */
1549 extern void SDL_CloseGamepad(SDL_Gamepad* gamepad);
1550 
1551 /**
1552     Return the sfSymbolsName for a given button on a gamepad on Apple
1553     platforms.
1554     
1555     Params:
1556         gamepad =   the gamepad to query.
1557         button =    a button on the gamepad.
1558     
1559     Returns:
1560         the sfSymbolsName or NULL if the name can't be found.
1561     
1562     See_Also:
1563         $(D SDL_GetGamepadAppleSFSymbolsNameForAxis)
1564 */
1565 extern const(char)** SDL_GetGamepadAppleSFSymbolsNameForButton(
1566     SDL_Gamepad* gamepad, SDL_GamepadButton button);
1567 
1568 /**
1569     Return the sfSymbolsName for a given axis on a gamepad on Apple platforms.
1570     
1571     Params:
1572         gamepad =   the gamepad to query.
1573         axis =      an axis on the gamepad.
1574     
1575     Returns:
1576         the sfSymbolsName or NULL if the name can't be found.
1577 
1578     See_Also:
1579         $(D SDL_GetGamepadAppleSFSymbolsNameForButton)
1580 */
1581 extern const(char)** SDL_GetGamepadAppleSFSymbolsNameForAxis(SDL_Gamepad* gamepad, SDL_GamepadAxis axis);