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