summaryrefslogtreecommitdiff
path: root/src/contrib/SDL-2.30.2/include/SDL_joystick.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/contrib/SDL-2.30.2/include/SDL_joystick.h')
-rw-r--r--src/contrib/SDL-2.30.2/include/SDL_joystick.h1069
1 files changed, 1069 insertions, 0 deletions
diff --git a/src/contrib/SDL-2.30.2/include/SDL_joystick.h b/src/contrib/SDL-2.30.2/include/SDL_joystick.h
new file mode 100644
index 0000000..561e010
--- /dev/null
+++ b/src/contrib/SDL-2.30.2/include/SDL_joystick.h
@@ -0,0 +1,1069 @@
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_joystick.h
24 *
25 * Include file for SDL joystick event handling
26 *
27 * The term "device_index" identifies currently plugged in joystick devices between 0 and SDL_NumJoysticks(), with the exact joystick
28 * behind a device_index changing as joysticks are plugged and unplugged.
29 *
30 * The term "instance_id" is the current instantiation of a joystick device in the system, if the joystick is removed and then re-inserted
31 * then it will get a new instance_id, instance_id's are monotonically increasing identifiers of a joystick plugged in.
32 *
33 * The term "player_index" is the number assigned to a player on a specific
34 * controller. For XInput controllers this returns the XInput user index.
35 * Many joysticks will not be able to supply this information.
36 *
37 * The term JoystickGUID is a stable 128-bit identifier for a joystick device that does not change over time, it identifies class of
38 * the device (a X360 wired controller for example). This identifier is platform dependent.
39 */
40
41#ifndef SDL_joystick_h_
42#define SDL_joystick_h_
43
44#include "SDL_stdinc.h"
45#include "SDL_error.h"
46#include "SDL_guid.h"
47#include "SDL_mutex.h"
48
49#include "begin_code.h"
50/* Set up for C function definitions, even when using C++ */
51#ifdef __cplusplus
52extern "C" {
53#endif
54
55/**
56 * \file SDL_joystick.h
57 *
58 * In order to use these functions, SDL_Init() must have been called
59 * with the ::SDL_INIT_JOYSTICK flag. This causes SDL to scan the system
60 * for joysticks, and load appropriate drivers.
61 *
62 * If you would like to receive joystick updates while the application
63 * is in the background, you should set the following hint before calling
64 * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS
65 */
66
67/**
68 * The joystick structure used to identify an SDL joystick
69 */
70#ifdef SDL_THREAD_SAFETY_ANALYSIS
71extern SDL_mutex *SDL_joystick_lock;
72#endif
73struct _SDL_Joystick;
74typedef struct _SDL_Joystick SDL_Joystick;
75
76/* A structure that encodes the stable unique id for a joystick device */
77typedef SDL_GUID SDL_JoystickGUID;
78
79/**
80 * This is a unique ID for a joystick for the time it is connected to the system,
81 * and is never reused for the lifetime of the application. If the joystick is
82 * disconnected and reconnected, it will get a new ID.
83 *
84 * The ID value starts at 0 and increments from there. The value -1 is an invalid ID.
85 */
86typedef Sint32 SDL_JoystickID;
87
88typedef enum
89{
90 SDL_JOYSTICK_TYPE_UNKNOWN,
91 SDL_JOYSTICK_TYPE_GAMECONTROLLER,
92 SDL_JOYSTICK_TYPE_WHEEL,
93 SDL_JOYSTICK_TYPE_ARCADE_STICK,
94 SDL_JOYSTICK_TYPE_FLIGHT_STICK,
95 SDL_JOYSTICK_TYPE_DANCE_PAD,
96 SDL_JOYSTICK_TYPE_GUITAR,
97 SDL_JOYSTICK_TYPE_DRUM_KIT,
98 SDL_JOYSTICK_TYPE_ARCADE_PAD,
99 SDL_JOYSTICK_TYPE_THROTTLE
100} SDL_JoystickType;
101
102typedef enum
103{
104 SDL_JOYSTICK_POWER_UNKNOWN = -1,
105 SDL_JOYSTICK_POWER_EMPTY, /* <= 5% */
106 SDL_JOYSTICK_POWER_LOW, /* <= 20% */
107 SDL_JOYSTICK_POWER_MEDIUM, /* <= 70% */
108 SDL_JOYSTICK_POWER_FULL, /* <= 100% */
109 SDL_JOYSTICK_POWER_WIRED,
110 SDL_JOYSTICK_POWER_MAX
111} SDL_JoystickPowerLevel;
112
113/* Set max recognized G-force from accelerometer
114 See src/joystick/uikit/SDL_sysjoystick.m for notes on why this is needed
115 */
116#define SDL_IPHONE_MAX_GFORCE 5.0
117
118
119/* Function prototypes */
120
121/**
122 * Locking for multi-threaded access to the joystick API
123 *
124 * If you are using the joystick API or handling events from multiple threads
125 * you should use these locking functions to protect access to the joysticks.
126 *
127 * In particular, you are guaranteed that the joystick list won't change, so
128 * the API functions that take a joystick index will be valid, and joystick
129 * and game controller events will not be delivered.
130 *
131 * As of SDL 2.26.0, you can take the joystick lock around reinitializing the
132 * joystick subsystem, to prevent other threads from seeing joysticks in an
133 * uninitialized state. However, all open joysticks will be closed and SDL
134 * functions called with them will fail.
135 *
136 * \since This function is available since SDL 2.0.7.
137 */
138extern DECLSPEC void SDLCALL SDL_LockJoysticks(void) SDL_ACQUIRE(SDL_joystick_lock);
139
140
141/**
142 * Unlocking for multi-threaded access to the joystick API
143 *
144 * If you are using the joystick API or handling events from multiple threads
145 * you should use these locking functions to protect access to the joysticks.
146 *
147 * In particular, you are guaranteed that the joystick list won't change, so
148 * the API functions that take a joystick index will be valid, and joystick
149 * and game controller events will not be delivered.
150 *
151 * \since This function is available since SDL 2.0.7.
152 */
153extern DECLSPEC void SDLCALL SDL_UnlockJoysticks(void) SDL_RELEASE(SDL_joystick_lock);
154
155/**
156 * Count the number of joysticks attached to the system.
157 *
158 * \returns the number of attached joysticks on success or a negative error
159 * code on failure; call SDL_GetError() for more information.
160 *
161 * \since This function is available since SDL 2.0.0.
162 *
163 * \sa SDL_JoystickName
164 * \sa SDL_JoystickPath
165 * \sa SDL_JoystickOpen
166 */
167extern DECLSPEC int SDLCALL SDL_NumJoysticks(void);
168
169/**
170 * Get the implementation dependent name of a joystick.
171 *
172 * This can be called before any joysticks are opened.
173 *
174 * \param device_index the index of the joystick to query (the N'th joystick
175 * on the system)
176 * \returns the name of the selected joystick. If no name can be found, this
177 * function returns NULL; call SDL_GetError() for more information.
178 *
179 * \since This function is available since SDL 2.0.0.
180 *
181 * \sa SDL_JoystickName
182 * \sa SDL_JoystickOpen
183 */
184extern DECLSPEC const char *SDLCALL SDL_JoystickNameForIndex(int device_index);
185
186/**
187 * Get the implementation dependent path of a joystick.
188 *
189 * This can be called before any joysticks are opened.
190 *
191 * \param device_index the index of the joystick to query (the N'th joystick
192 * on the system)
193 * \returns the path of the selected joystick. If no path can be found, this
194 * function returns NULL; call SDL_GetError() for more information.
195 *
196 * \since This function is available since SDL 2.24.0.
197 *
198 * \sa SDL_JoystickPath
199 * \sa SDL_JoystickOpen
200 */
201extern DECLSPEC const char *SDLCALL SDL_JoystickPathForIndex(int device_index);
202
203/**
204 * Get the player index of a joystick, or -1 if it's not available This can be
205 * called before any joysticks are opened.
206 *
207 * \since This function is available since SDL 2.0.9.
208 */
209extern DECLSPEC int SDLCALL SDL_JoystickGetDevicePlayerIndex(int device_index);
210
211/**
212 * Get the implementation-dependent GUID for the joystick at a given device
213 * index.
214 *
215 * This function can be called before any joysticks are opened.
216 *
217 * \param device_index the index of the joystick to query (the N'th joystick
218 * on the system
219 * \returns the GUID of the selected joystick. If called on an invalid index,
220 * this function returns a zero GUID
221 *
222 * \since This function is available since SDL 2.0.0.
223 *
224 * \sa SDL_JoystickGetGUID
225 * \sa SDL_JoystickGetGUIDString
226 */
227extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetDeviceGUID(int device_index);
228
229/**
230 * Get the USB vendor ID of a joystick, if available.
231 *
232 * This can be called before any joysticks are opened. If the vendor ID isn't
233 * available this function returns 0.
234 *
235 * \param device_index the index of the joystick to query (the N'th joystick
236 * on the system
237 * \returns the USB vendor ID of the selected joystick. If called on an
238 * invalid index, this function returns zero
239 *
240 * \since This function is available since SDL 2.0.6.
241 */
242extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceVendor(int device_index);
243
244/**
245 * Get the USB product ID of a joystick, if available.
246 *
247 * This can be called before any joysticks are opened. If the product ID isn't
248 * available this function returns 0.
249 *
250 * \param device_index the index of the joystick to query (the N'th joystick
251 * on the system
252 * \returns the USB product ID of the selected joystick. If called on an
253 * invalid index, this function returns zero
254 *
255 * \since This function is available since SDL 2.0.6.
256 */
257extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceProduct(int device_index);
258
259/**
260 * Get the product version of a joystick, if available.
261 *
262 * This can be called before any joysticks are opened. If the product version
263 * isn't available this function returns 0.
264 *
265 * \param device_index the index of the joystick to query (the N'th joystick
266 * on the system
267 * \returns the product version of the selected joystick. If called on an
268 * invalid index, this function returns zero
269 *
270 * \since This function is available since SDL 2.0.6.
271 */
272extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceProductVersion(int device_index);
273
274/**
275 * Get the type of a joystick, if available.
276 *
277 * This can be called before any joysticks are opened.
278 *
279 * \param device_index the index of the joystick to query (the N'th joystick
280 * on the system
281 * \returns the SDL_JoystickType of the selected joystick. If called on an
282 * invalid index, this function returns `SDL_JOYSTICK_TYPE_UNKNOWN`
283 *
284 * \since This function is available since SDL 2.0.6.
285 */
286extern DECLSPEC SDL_JoystickType SDLCALL SDL_JoystickGetDeviceType(int device_index);
287
288/**
289 * Get the instance ID of a joystick.
290 *
291 * This can be called before any joysticks are opened.
292 *
293 * \param device_index the index of the joystick to query (the N'th joystick
294 * on the system
295 * \returns the instance id of the selected joystick. If called on an invalid
296 * index, this function returns -1.
297 *
298 * \since This function is available since SDL 2.0.6.
299 */
300extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickGetDeviceInstanceID(int device_index);
301
302/**
303 * Open a joystick for use.
304 *
305 * The `device_index` argument refers to the N'th joystick presently
306 * recognized by SDL on the system. It is **NOT** the same as the instance ID
307 * used to identify the joystick in future events. See
308 * SDL_JoystickInstanceID() for more details about instance IDs.
309 *
310 * The joystick subsystem must be initialized before a joystick can be opened
311 * for use.
312 *
313 * \param device_index the index of the joystick to query
314 * \returns a joystick identifier or NULL if an error occurred; call
315 * SDL_GetError() for more information.
316 *
317 * \since This function is available since SDL 2.0.0.
318 *
319 * \sa SDL_JoystickClose
320 * \sa SDL_JoystickInstanceID
321 */
322extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickOpen(int device_index);
323
324/**
325 * Get the SDL_Joystick associated with an instance id.
326 *
327 * \param instance_id the instance id to get the SDL_Joystick for
328 * \returns an SDL_Joystick on success or NULL on failure; call SDL_GetError()
329 * for more information.
330 *
331 * \since This function is available since SDL 2.0.4.
332 */
333extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickFromInstanceID(SDL_JoystickID instance_id);
334
335/**
336 * Get the SDL_Joystick associated with a player index.
337 *
338 * \param player_index the player index to get the SDL_Joystick for
339 * \returns an SDL_Joystick on success or NULL on failure; call SDL_GetError()
340 * for more information.
341 *
342 * \since This function is available since SDL 2.0.12.
343 */
344extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickFromPlayerIndex(int player_index);
345
346/**
347 * Attach a new virtual joystick.
348 *
349 * \returns the joystick's device index, or -1 if an error occurred.
350 *
351 * \since This function is available since SDL 2.0.14.
352 */
353extern DECLSPEC int SDLCALL SDL_JoystickAttachVirtual(SDL_JoystickType type,
354 int naxes,
355 int nbuttons,
356 int nhats);
357
358/**
359 * The structure that defines an extended virtual joystick description
360 *
361 * The caller must zero the structure and then initialize the version with `SDL_VIRTUAL_JOYSTICK_DESC_VERSION` before passing it to SDL_JoystickAttachVirtualEx()
362 * All other elements of this structure are optional and can be left 0.
363 *
364 * \sa SDL_JoystickAttachVirtualEx
365 */
366typedef struct SDL_VirtualJoystickDesc
367{
368 Uint16 version; /**< `SDL_VIRTUAL_JOYSTICK_DESC_VERSION` */
369 Uint16 type; /**< `SDL_JoystickType` */
370 Uint16 naxes; /**< the number of axes on this joystick */
371 Uint16 nbuttons; /**< the number of buttons on this joystick */
372 Uint16 nhats; /**< the number of hats on this joystick */
373 Uint16 vendor_id; /**< the USB vendor ID of this joystick */
374 Uint16 product_id; /**< the USB product ID of this joystick */
375 Uint16 padding; /**< unused */
376 Uint32 button_mask; /**< A mask of which buttons are valid for this controller
377 e.g. (1 << SDL_CONTROLLER_BUTTON_A) */
378 Uint32 axis_mask; /**< A mask of which axes are valid for this controller
379 e.g. (1 << SDL_CONTROLLER_AXIS_LEFTX) */
380 const char *name; /**< the name of the joystick */
381
382 void *userdata; /**< User data pointer passed to callbacks */
383 void (SDLCALL *Update)(void *userdata); /**< Called when the joystick state should be updated */
384 void (SDLCALL *SetPlayerIndex)(void *userdata, int player_index); /**< Called when the player index is set */
385 int (SDLCALL *Rumble)(void *userdata, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble); /**< Implements SDL_JoystickRumble() */
386 int (SDLCALL *RumbleTriggers)(void *userdata, Uint16 left_rumble, Uint16 right_rumble); /**< Implements SDL_JoystickRumbleTriggers() */
387 int (SDLCALL *SetLED)(void *userdata, Uint8 red, Uint8 green, Uint8 blue); /**< Implements SDL_JoystickSetLED() */
388 int (SDLCALL *SendEffect)(void *userdata, const void *data, int size); /**< Implements SDL_JoystickSendEffect() */
389
390} SDL_VirtualJoystickDesc;
391
392/**
393 * \brief The current version of the SDL_VirtualJoystickDesc structure
394 */
395#define SDL_VIRTUAL_JOYSTICK_DESC_VERSION 1
396
397/**
398 * Attach a new virtual joystick with extended properties.
399 *
400 * \returns the joystick's device index, or -1 if an error occurred.
401 *
402 * \since This function is available since SDL 2.24.0.
403 */
404extern DECLSPEC int SDLCALL SDL_JoystickAttachVirtualEx(const SDL_VirtualJoystickDesc *desc);
405
406/**
407 * Detach a virtual joystick.
408 *
409 * \param device_index a value previously returned from
410 * SDL_JoystickAttachVirtual()
411 * \returns 0 on success, or -1 if an error occurred.
412 *
413 * \since This function is available since SDL 2.0.14.
414 */
415extern DECLSPEC int SDLCALL SDL_JoystickDetachVirtual(int device_index);
416
417/**
418 * Query whether or not the joystick at a given device index is virtual.
419 *
420 * \param device_index a joystick device index.
421 * \returns SDL_TRUE if the joystick is virtual, SDL_FALSE otherwise.
422 *
423 * \since This function is available since SDL 2.0.14.
424 */
425extern DECLSPEC SDL_bool SDLCALL SDL_JoystickIsVirtual(int device_index);
426
427/**
428 * Set values on an opened, virtual-joystick's axis.
429 *
430 * Please note that values set here will not be applied until the next call to
431 * SDL_JoystickUpdate, which can either be called directly, or can be called
432 * indirectly through various other SDL APIs, including, but not limited to
433 * the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout,
434 * SDL_WaitEvent.
435 *
436 * Note that when sending trigger axes, you should scale the value to the full
437 * range of Sint16. For example, a trigger at rest would have the value of
438 * `SDL_JOYSTICK_AXIS_MIN`.
439 *
440 * \param joystick the virtual joystick on which to set state.
441 * \param axis the specific axis on the virtual joystick to set.
442 * \param value the new value for the specified axis.
443 * \returns 0 on success, -1 on error.
444 *
445 * \since This function is available since SDL 2.0.14.
446 */
447extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualAxis(SDL_Joystick *joystick, int axis, Sint16 value);
448
449/**
450 * Set values on an opened, virtual-joystick's button.
451 *
452 * Please note that values set here will not be applied until the next call to
453 * SDL_JoystickUpdate, which can either be called directly, or can be called
454 * indirectly through various other SDL APIs, including, but not limited to
455 * the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout,
456 * SDL_WaitEvent.
457 *
458 * \param joystick the virtual joystick on which to set state.
459 * \param button the specific button on the virtual joystick to set.
460 * \param value the new value for the specified button.
461 * \returns 0 on success, -1 on error.
462 *
463 * \since This function is available since SDL 2.0.14.
464 */
465extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualButton(SDL_Joystick *joystick, int button, Uint8 value);
466
467/**
468 * Set values on an opened, virtual-joystick's hat.
469 *
470 * Please note that values set here will not be applied until the next call to
471 * SDL_JoystickUpdate, which can either be called directly, or can be called
472 * indirectly through various other SDL APIs, including, but not limited to
473 * the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout,
474 * SDL_WaitEvent.
475 *
476 * \param joystick the virtual joystick on which to set state.
477 * \param hat the specific hat on the virtual joystick to set.
478 * \param value the new value for the specified hat.
479 * \returns 0 on success, -1 on error.
480 *
481 * \since This function is available since SDL 2.0.14.
482 */
483extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualHat(SDL_Joystick *joystick, int hat, Uint8 value);
484
485/**
486 * Get the implementation dependent name of a joystick.
487 *
488 * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
489 * \returns the name of the selected joystick. If no name can be found, this
490 * function returns NULL; call SDL_GetError() for more information.
491 *
492 * \since This function is available since SDL 2.0.0.
493 *
494 * \sa SDL_JoystickNameForIndex
495 * \sa SDL_JoystickOpen
496 */
497extern DECLSPEC const char *SDLCALL SDL_JoystickName(SDL_Joystick *joystick);
498
499/**
500 * Get the implementation dependent path of a joystick.
501 *
502 * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
503 * \returns the path of the selected joystick. If no path can be found, this
504 * function returns NULL; call SDL_GetError() for more information.
505 *
506 * \since This function is available since SDL 2.24.0.
507 *
508 * \sa SDL_JoystickPathForIndex
509 */
510extern DECLSPEC const char *SDLCALL SDL_JoystickPath(SDL_Joystick *joystick);
511
512/**
513 * Get the player index of an opened joystick.
514 *
515 * For XInput controllers this returns the XInput user index. Many joysticks
516 * will not be able to supply this information.
517 *
518 * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
519 * \returns the player index, or -1 if it's not available.
520 *
521 * \since This function is available since SDL 2.0.9.
522 */
523extern DECLSPEC int SDLCALL SDL_JoystickGetPlayerIndex(SDL_Joystick *joystick);
524
525/**
526 * Set the player index of an opened joystick.
527 *
528 * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
529 * \param player_index Player index to assign to this joystick, or -1 to clear
530 * the player index and turn off player LEDs.
531 *
532 * \since This function is available since SDL 2.0.12.
533 */
534extern DECLSPEC void SDLCALL SDL_JoystickSetPlayerIndex(SDL_Joystick *joystick, int player_index);
535
536/**
537 * Get the implementation-dependent GUID for the joystick.
538 *
539 * This function requires an open joystick.
540 *
541 * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
542 * \returns the GUID of the given joystick. If called on an invalid index,
543 * this function returns a zero GUID; call SDL_GetError() for more
544 * information.
545 *
546 * \since This function is available since SDL 2.0.0.
547 *
548 * \sa SDL_JoystickGetDeviceGUID
549 * \sa SDL_JoystickGetGUIDString
550 */
551extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUID(SDL_Joystick *joystick);
552
553/**
554 * Get the USB vendor ID of an opened joystick, if available.
555 *
556 * If the vendor ID isn't available this function returns 0.
557 *
558 * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
559 * \returns the USB vendor ID of the selected joystick, or 0 if unavailable.
560 *
561 * \since This function is available since SDL 2.0.6.
562 */
563extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetVendor(SDL_Joystick *joystick);
564
565/**
566 * Get the USB product ID of an opened joystick, if available.
567 *
568 * If the product ID isn't available this function returns 0.
569 *
570 * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
571 * \returns the USB product ID of the selected joystick, or 0 if unavailable.
572 *
573 * \since This function is available since SDL 2.0.6.
574 */
575extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetProduct(SDL_Joystick *joystick);
576
577/**
578 * Get the product version of an opened joystick, if available.
579 *
580 * If the product version isn't available this function returns 0.
581 *
582 * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
583 * \returns the product version of the selected joystick, or 0 if unavailable.
584 *
585 * \since This function is available since SDL 2.0.6.
586 */
587extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetProductVersion(SDL_Joystick *joystick);
588
589/**
590 * Get the firmware version of an opened joystick, if available.
591 *
592 * If the firmware version isn't available this function returns 0.
593 *
594 * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
595 * \returns the firmware version of the selected joystick, or 0 if
596 * unavailable.
597 *
598 * \since This function is available since SDL 2.24.0.
599 */
600extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetFirmwareVersion(SDL_Joystick *joystick);
601
602/**
603 * Get the serial number of an opened joystick, if available.
604 *
605 * Returns the serial number of the joystick, or NULL if it is not available.
606 *
607 * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
608 * \returns the serial number of the selected joystick, or NULL if
609 * unavailable.
610 *
611 * \since This function is available since SDL 2.0.14.
612 */
613extern DECLSPEC const char * SDLCALL SDL_JoystickGetSerial(SDL_Joystick *joystick);
614
615/**
616 * Get the type of an opened joystick.
617 *
618 * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
619 * \returns the SDL_JoystickType of the selected joystick.
620 *
621 * \since This function is available since SDL 2.0.6.
622 */
623extern DECLSPEC SDL_JoystickType SDLCALL SDL_JoystickGetType(SDL_Joystick *joystick);
624
625/**
626 * Get an ASCII string representation for a given SDL_JoystickGUID.
627 *
628 * You should supply at least 33 bytes for pszGUID.
629 *
630 * \param guid the SDL_JoystickGUID you wish to convert to string
631 * \param pszGUID buffer in which to write the ASCII string
632 * \param cbGUID the size of pszGUID
633 *
634 * \since This function is available since SDL 2.0.0.
635 *
636 * \sa SDL_JoystickGetDeviceGUID
637 * \sa SDL_JoystickGetGUID
638 * \sa SDL_JoystickGetGUIDFromString
639 */
640extern DECLSPEC void SDLCALL SDL_JoystickGetGUIDString(SDL_JoystickGUID guid, char *pszGUID, int cbGUID);
641
642/**
643 * Convert a GUID string into a SDL_JoystickGUID structure.
644 *
645 * Performs no error checking. If this function is given a string containing
646 * an invalid GUID, the function will silently succeed, but the GUID generated
647 * will not be useful.
648 *
649 * \param pchGUID string containing an ASCII representation of a GUID
650 * \returns a SDL_JoystickGUID structure.
651 *
652 * \since This function is available since SDL 2.0.0.
653 *
654 * \sa SDL_JoystickGetGUIDString
655 */
656extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUIDFromString(const char *pchGUID);
657
658/**
659 * Get the device information encoded in a SDL_JoystickGUID structure
660 *
661 * \param guid the SDL_JoystickGUID you wish to get info about
662 * \param vendor A pointer filled in with the device VID, or 0 if not
663 * available
664 * \param product A pointer filled in with the device PID, or 0 if not
665 * available
666 * \param version A pointer filled in with the device version, or 0 if not
667 * available
668 * \param crc16 A pointer filled in with a CRC used to distinguish different
669 * products with the same VID/PID, or 0 if not available
670 *
671 * \since This function is available since SDL 2.26.0.
672 *
673 * \sa SDL_JoystickGetDeviceGUID
674 */
675extern DECLSPEC void SDLCALL SDL_GetJoystickGUIDInfo(SDL_JoystickGUID guid, Uint16 *vendor, Uint16 *product, Uint16 *version, Uint16 *crc16);
676
677/**
678 * Get the status of a specified joystick.
679 *
680 * \param joystick the joystick to query
681 * \returns SDL_TRUE if the joystick has been opened, SDL_FALSE if it has not;
682 * call SDL_GetError() for more information.
683 *
684 * \since This function is available since SDL 2.0.0.
685 *
686 * \sa SDL_JoystickClose
687 * \sa SDL_JoystickOpen
688 */
689extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAttached(SDL_Joystick *joystick);
690
691/**
692 * Get the instance ID of an opened joystick.
693 *
694 * \param joystick an SDL_Joystick structure containing joystick information
695 * \returns the instance ID of the specified joystick on success or a negative
696 * error code on failure; call SDL_GetError() for more information.
697 *
698 * \since This function is available since SDL 2.0.0.
699 *
700 * \sa SDL_JoystickOpen
701 */
702extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickInstanceID(SDL_Joystick *joystick);
703
704/**
705 * Get the number of general axis controls on a joystick.
706 *
707 * Often, the directional pad on a game controller will either look like 4
708 * separate buttons or a POV hat, and not axes, but all of this is up to the
709 * device and platform.
710 *
711 * \param joystick an SDL_Joystick structure containing joystick information
712 * \returns the number of axis controls/number of axes on success or a
713 * negative error code on failure; call SDL_GetError() for more
714 * information.
715 *
716 * \since This function is available since SDL 2.0.0.
717 *
718 * \sa SDL_JoystickGetAxis
719 * \sa SDL_JoystickOpen
720 */
721extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick *joystick);
722
723/**
724 * Get the number of trackballs on a joystick.
725 *
726 * Joystick trackballs have only relative motion events associated with them
727 * and their state cannot be polled.
728 *
729 * Most joysticks do not have trackballs.
730 *
731 * \param joystick an SDL_Joystick structure containing joystick information
732 * \returns the number of trackballs on success or a negative error code on
733 * failure; call SDL_GetError() for more information.
734 *
735 * \since This function is available since SDL 2.0.0.
736 *
737 * \sa SDL_JoystickGetBall
738 */
739extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick *joystick);
740
741/**
742 * Get the number of POV hats on a joystick.
743 *
744 * \param joystick an SDL_Joystick structure containing joystick information
745 * \returns the number of POV hats on success or a negative error code on
746 * failure; call SDL_GetError() for more information.
747 *
748 * \since This function is available since SDL 2.0.0.
749 *
750 * \sa SDL_JoystickGetHat
751 * \sa SDL_JoystickOpen
752 */
753extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick *joystick);
754
755/**
756 * Get the number of buttons on a joystick.
757 *
758 * \param joystick an SDL_Joystick structure containing joystick information
759 * \returns the number of buttons on success or a negative error code on
760 * failure; call SDL_GetError() for more information.
761 *
762 * \since This function is available since SDL 2.0.0.
763 *
764 * \sa SDL_JoystickGetButton
765 * \sa SDL_JoystickOpen
766 */
767extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick *joystick);
768
769/**
770 * Update the current state of the open joysticks.
771 *
772 * This is called automatically by the event loop if any joystick events are
773 * enabled.
774 *
775 * \since This function is available since SDL 2.0.0.
776 *
777 * \sa SDL_JoystickEventState
778 */
779extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void);
780
781/**
782 * Enable/disable joystick event polling.
783 *
784 * If joystick events are disabled, you must call SDL_JoystickUpdate()
785 * yourself and manually check the state of the joystick when you want
786 * joystick information.
787 *
788 * It is recommended that you leave joystick event handling enabled.
789 *
790 * **WARNING**: Calling this function may delete all events currently in SDL's
791 * event queue.
792 *
793 * \param state can be one of `SDL_QUERY`, `SDL_IGNORE`, or `SDL_ENABLE`
794 * \returns 1 if enabled, 0 if disabled, or a negative error code on failure;
795 * call SDL_GetError() for more information.
796 *
797 * If `state` is `SDL_QUERY` then the current state is returned,
798 * otherwise the new processing state is returned.
799 *
800 * \since This function is available since SDL 2.0.0.
801 *
802 * \sa SDL_GameControllerEventState
803 */
804extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state);
805
806#define SDL_JOYSTICK_AXIS_MAX 32767
807#define SDL_JOYSTICK_AXIS_MIN -32768
808
809/**
810 * Get the current state of an axis control on a joystick.
811 *
812 * SDL makes no promises about what part of the joystick any given axis refers
813 * to. Your game should have some sort of configuration UI to let users
814 * specify what each axis should be bound to. Alternately, SDL's higher-level
815 * Game Controller API makes a great effort to apply order to this lower-level
816 * interface, so you know that a specific axis is the "left thumb stick," etc.
817 *
818 * The value returned by SDL_JoystickGetAxis() is a signed integer (-32768 to
819 * 32767) representing the current position of the axis. It may be necessary
820 * to impose certain tolerances on these values to account for jitter.
821 *
822 * \param joystick an SDL_Joystick structure containing joystick information
823 * \param axis the axis to query; the axis indices start at index 0
824 * \returns a 16-bit signed integer representing the current position of the
825 * axis or 0 on failure; call SDL_GetError() for more information.
826 *
827 * \since This function is available since SDL 2.0.0.
828 *
829 * \sa SDL_JoystickNumAxes
830 */
831extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick *joystick,
832 int axis);
833
834/**
835 * Get the initial state of an axis control on a joystick.
836 *
837 * The state is a value ranging from -32768 to 32767.
838 *
839 * The axis indices start at index 0.
840 *
841 * \param joystick an SDL_Joystick structure containing joystick information
842 * \param axis the axis to query; the axis indices start at index 0
843 * \param state Upon return, the initial value is supplied here.
844 * \return SDL_TRUE if this axis has any initial value, or SDL_FALSE if not.
845 *
846 * \since This function is available since SDL 2.0.6.
847 */
848extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAxisInitialState(SDL_Joystick *joystick,
849 int axis, Sint16 *state);
850
851/**
852 * \name Hat positions
853 */
854/* @{ */
855#define SDL_HAT_CENTERED 0x00
856#define SDL_HAT_UP 0x01
857#define SDL_HAT_RIGHT 0x02
858#define SDL_HAT_DOWN 0x04
859#define SDL_HAT_LEFT 0x08
860#define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP)
861#define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN)
862#define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP)
863#define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN)
864/* @} */
865
866/**
867 * Get the current state of a POV hat on a joystick.
868 *
869 * The returned value will be one of the following positions:
870 *
871 * - `SDL_HAT_CENTERED`
872 * - `SDL_HAT_UP`
873 * - `SDL_HAT_RIGHT`
874 * - `SDL_HAT_DOWN`
875 * - `SDL_HAT_LEFT`
876 * - `SDL_HAT_RIGHTUP`
877 * - `SDL_HAT_RIGHTDOWN`
878 * - `SDL_HAT_LEFTUP`
879 * - `SDL_HAT_LEFTDOWN`
880 *
881 * \param joystick an SDL_Joystick structure containing joystick information
882 * \param hat the hat index to get the state from; indices start at index 0
883 * \returns the current hat position.
884 *
885 * \since This function is available since SDL 2.0.0.
886 *
887 * \sa SDL_JoystickNumHats
888 */
889extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick *joystick,
890 int hat);
891
892/**
893 * Get the ball axis change since the last poll.
894 *
895 * Trackballs can only return relative motion since the last call to
896 * SDL_JoystickGetBall(), these motion deltas are placed into `dx` and `dy`.
897 *
898 * Most joysticks do not have trackballs.
899 *
900 * \param joystick the SDL_Joystick to query
901 * \param ball the ball index to query; ball indices start at index 0
902 * \param dx stores the difference in the x axis position since the last poll
903 * \param dy stores the difference in the y axis position since the last poll
904 * \returns 0 on success or a negative error code on failure; call
905 * SDL_GetError() for more information.
906 *
907 * \since This function is available since SDL 2.0.0.
908 *
909 * \sa SDL_JoystickNumBalls
910 */
911extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick *joystick,
912 int ball, int *dx, int *dy);
913
914/**
915 * Get the current state of a button on a joystick.
916 *
917 * \param joystick an SDL_Joystick structure containing joystick information
918 * \param button the button index to get the state from; indices start at
919 * index 0
920 * \returns 1 if the specified button is pressed, 0 otherwise.
921 *
922 * \since This function is available since SDL 2.0.0.
923 *
924 * \sa SDL_JoystickNumButtons
925 */
926extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick *joystick,
927 int button);
928
929/**
930 * Start a rumble effect.
931 *
932 * Each call to this function cancels any previous rumble effect, and calling
933 * it with 0 intensity stops any rumbling.
934 *
935 * \param joystick The joystick to vibrate
936 * \param low_frequency_rumble The intensity of the low frequency (left)
937 * rumble motor, from 0 to 0xFFFF
938 * \param high_frequency_rumble The intensity of the high frequency (right)
939 * rumble motor, from 0 to 0xFFFF
940 * \param duration_ms The duration of the rumble effect, in milliseconds
941 * \returns 0, or -1 if rumble isn't supported on this joystick
942 *
943 * \since This function is available since SDL 2.0.9.
944 *
945 * \sa SDL_JoystickHasRumble
946 */
947extern DECLSPEC int SDLCALL SDL_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
948
949/**
950 * Start a rumble effect in the joystick's triggers
951 *
952 * Each call to this function cancels any previous trigger rumble effect, and
953 * calling it with 0 intensity stops any rumbling.
954 *
955 * Note that this is rumbling of the _triggers_ and not the game controller as
956 * a whole. This is currently only supported on Xbox One controllers. If you
957 * want the (more common) whole-controller rumble, use SDL_JoystickRumble()
958 * instead.
959 *
960 * \param joystick The joystick to vibrate
961 * \param left_rumble The intensity of the left trigger rumble motor, from 0
962 * to 0xFFFF
963 * \param right_rumble The intensity of the right trigger rumble motor, from 0
964 * to 0xFFFF
965 * \param duration_ms The duration of the rumble effect, in milliseconds
966 * \returns 0, or -1 if trigger rumble isn't supported on this joystick
967 *
968 * \since This function is available since SDL 2.0.14.
969 *
970 * \sa SDL_JoystickHasRumbleTriggers
971 */
972extern DECLSPEC int SDLCALL SDL_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
973
974/**
975 * Query whether a joystick has an LED.
976 *
977 * An example of a joystick LED is the light on the back of a PlayStation 4's
978 * DualShock 4 controller.
979 *
980 * \param joystick The joystick to query
981 * \return SDL_TRUE if the joystick has a modifiable LED, SDL_FALSE otherwise.
982 *
983 * \since This function is available since SDL 2.0.14.
984 */
985extern DECLSPEC SDL_bool SDLCALL SDL_JoystickHasLED(SDL_Joystick *joystick);
986
987/**
988 * Query whether a joystick has rumble support.
989 *
990 * \param joystick The joystick to query
991 * \return SDL_TRUE if the joystick has rumble, SDL_FALSE otherwise.
992 *
993 * \since This function is available since SDL 2.0.18.
994 *
995 * \sa SDL_JoystickRumble
996 */
997extern DECLSPEC SDL_bool SDLCALL SDL_JoystickHasRumble(SDL_Joystick *joystick);
998
999/**
1000 * Query whether a joystick has rumble support on triggers.
1001 *
1002 * \param joystick The joystick to query
1003 * \return SDL_TRUE if the joystick has trigger rumble, SDL_FALSE otherwise.
1004 *
1005 * \since This function is available since SDL 2.0.18.
1006 *
1007 * \sa SDL_JoystickRumbleTriggers
1008 */
1009extern DECLSPEC SDL_bool SDLCALL SDL_JoystickHasRumbleTriggers(SDL_Joystick *joystick);
1010
1011/**
1012 * Update a joystick's LED color.
1013 *
1014 * An example of a joystick LED is the light on the back of a PlayStation 4's
1015 * DualShock 4 controller.
1016 *
1017 * \param joystick The joystick to update
1018 * \param red The intensity of the red LED
1019 * \param green The intensity of the green LED
1020 * \param blue The intensity of the blue LED
1021 * \returns 0 on success, -1 if this joystick does not have a modifiable LED
1022 *
1023 * \since This function is available since SDL 2.0.14.
1024 */
1025extern DECLSPEC int SDLCALL SDL_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue);
1026
1027/**
1028 * Send a joystick specific effect packet
1029 *
1030 * \param joystick The joystick to affect
1031 * \param data The data to send to the joystick
1032 * \param size The size of the data to send to the joystick
1033 * \returns 0, or -1 if this joystick or driver doesn't support effect packets
1034 *
1035 * \since This function is available since SDL 2.0.16.
1036 */
1037extern DECLSPEC int SDLCALL SDL_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size);
1038
1039/**
1040 * Close a joystick previously opened with SDL_JoystickOpen().
1041 *
1042 * \param joystick The joystick device to close
1043 *
1044 * \since This function is available since SDL 2.0.0.
1045 *
1046 * \sa SDL_JoystickOpen
1047 */
1048extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick *joystick);
1049
1050/**
1051 * Get the battery level of a joystick as SDL_JoystickPowerLevel.
1052 *
1053 * \param joystick the SDL_Joystick to query
1054 * \returns the current battery level as SDL_JoystickPowerLevel on success or
1055 * `SDL_JOYSTICK_POWER_UNKNOWN` if it is unknown
1056 *
1057 * \since This function is available since SDL 2.0.4.
1058 */
1059extern DECLSPEC SDL_JoystickPowerLevel SDLCALL SDL_JoystickCurrentPowerLevel(SDL_Joystick *joystick);
1060
1061/* Ends C function definitions when using C++ */
1062#ifdef __cplusplus
1063}
1064#endif
1065#include "close_code.h"
1066
1067#endif /* SDL_joystick_h_ */
1068
1069/* vi: set ts=4 sw=4 expandtab: */