SDL 3.0
SDL_joystick.h
Go to the documentation of this file.
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 "instance_id" is the current instantiation of a joystick device in the system, if the joystick is removed and then re-inserted
28 * then it will get a new instance_id, instance_id's are monotonically increasing identifiers of a joystick plugged in.
29 *
30 * The term "player_index" is the number assigned to a player on a specific
31 * controller. For XInput controllers this returns the XInput user index.
32 * Many joysticks will not be able to supply this information.
33 *
34 * The term JoystickGUID is a stable 128-bit identifier for a joystick device that does not change over time, it identifies class of
35 * the device (a X360 wired controller for example). This identifier is platform dependent.
36 */
37
38#ifndef SDL_joystick_h_
39#define SDL_joystick_h_
40
41#include <SDL3/SDL_stdinc.h>
42#include <SDL3/SDL_error.h>
43#include <SDL3/SDL_guid.h>
44#include <SDL3/SDL_mutex.h>
45#include <SDL3/SDL_power.h>
46#include <SDL3/SDL_properties.h>
47
48#include <SDL3/SDL_begin_code.h>
49/* Set up for C function definitions, even when using C++ */
50#ifdef __cplusplus
51extern "C" {
52#endif
53
54/**
55 * \file SDL_joystick.h
56 *
57 * In order to use these functions, SDL_Init() must have been called
58 * with the ::SDL_INIT_JOYSTICK flag. This causes SDL to scan the system
59 * for joysticks, and load appropriate drivers.
60 *
61 * If you would like to receive joystick updates while the application
62 * is in the background, you should set the following hint before calling
63 * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS
64 */
65
66/**
67 * The joystick structure used to identify an SDL joystick
68 */
69#ifdef SDL_THREAD_SAFETY_ANALYSIS
70extern SDL_Mutex *SDL_joystick_lock;
71#endif
72struct SDL_Joystick;
74
75/* A structure that encodes the stable unique id for a joystick device */
77
78/**
79 * This is a unique ID for a joystick for the time it is connected to the
80 * system, and is never reused for the lifetime of the application.
81 *
82 * If the joystick is disconnected and reconnected, it will get a new ID.
83 *
84 * The ID value starts at 1 and increments from there. The value 0 is an
85 * invalid ID.
86 *
87 * \since This datatype is available since SDL 3.0.0.
88 */
90
104
112
113#define SDL_JOYSTICK_AXIS_MAX 32767
114#define SDL_JOYSTICK_AXIS_MIN -32768
115
116/* Set max recognized G-force from accelerometer
117 See src/joystick/uikit/SDL_sysjoystick.m for notes on why this is needed
118 */
119#define SDL_IPHONE_MAX_GFORCE 5.0
120
121
122/* Function prototypes */
123
124/**
125 * Locking for atomic access to the joystick API.
126 *
127 * The SDL joystick functions are thread-safe, however you can lock the
128 * joysticks while processing to guarantee that the joystick list won't change
129 * and joystick and gamepad events will not be delivered.
130 *
131 * \since This function is available since SDL 3.0.0.
132 */
133extern DECLSPEC void SDLCALL SDL_LockJoysticks(void) SDL_ACQUIRE(SDL_joystick_lock);
134
135/**
136 * Unlocking for atomic access to the joystick API.
137 *
138 * \since This function is available since SDL 3.0.0.
139 */
140extern DECLSPEC void SDLCALL SDL_UnlockJoysticks(void) SDL_RELEASE(SDL_joystick_lock);
141
142/**
143 * Return whether a joystick is currently connected.
144 *
145 * \returns SDL_TRUE if a joystick is connected, SDL_FALSE otherwise.
146 *
147 * \since This function is available since SDL 3.0.0.
148 *
149 * \sa SDL_GetJoysticks
150 */
151extern DECLSPEC SDL_bool SDLCALL SDL_HasJoystick(void);
152
153/**
154 * Get a list of currently connected joysticks.
155 *
156 * \param count a pointer filled in with the number of joysticks returned
157 * \returns a 0 terminated array of joystick instance IDs which should be
158 * freed with SDL_free(), or NULL on error; call SDL_GetError() for
159 * more details.
160 *
161 * \since This function is available since SDL 3.0.0.
162 *
163 * \sa SDL_HasJoystick
164 * \sa SDL_OpenJoystick
165 */
166extern DECLSPEC SDL_JoystickID *SDLCALL SDL_GetJoysticks(int *count);
167
168/**
169 * Get the implementation dependent name of a joystick.
170 *
171 * This can be called before any joysticks are opened.
172 *
173 * \param instance_id the joystick instance ID
174 * \returns the name of the selected joystick. If no name can be found, this
175 * function returns NULL; call SDL_GetError() for more information.
176 *
177 * \since This function is available since SDL 3.0.0.
178 *
179 * \sa SDL_GetJoystickName
180 * \sa SDL_GetJoysticks
181 */
182extern DECLSPEC const char *SDLCALL SDL_GetJoystickInstanceName(SDL_JoystickID instance_id);
183
184/**
185 * Get the implementation dependent path of a joystick.
186 *
187 * This can be called before any joysticks are opened.
188 *
189 * \param instance_id the joystick instance ID
190 * \returns the path of the selected joystick. If no path can be found, this
191 * function returns NULL; call SDL_GetError() for more information.
192 *
193 * \since This function is available since SDL 3.0.0.
194 *
195 * \sa SDL_GetJoystickPath
196 * \sa SDL_GetJoysticks
197 */
198extern DECLSPEC const char *SDLCALL SDL_GetJoystickInstancePath(SDL_JoystickID instance_id);
199
200/**
201 * Get the player index of a joystick.
202 *
203 * This can be called before any joysticks are opened.
204 *
205 * \param instance_id the joystick instance ID
206 * \returns the player index of a joystick, or -1 if it's not available
207 *
208 * \since This function is available since SDL 3.0.0.
209 *
210 * \sa SDL_GetJoystickPlayerIndex
211 * \sa SDL_GetJoysticks
212 */
213extern DECLSPEC int SDLCALL SDL_GetJoystickInstancePlayerIndex(SDL_JoystickID instance_id);
214
215/**
216 * Get the implementation-dependent GUID of a joystick.
217 *
218 * This can be called before any joysticks are opened.
219 *
220 * \param instance_id the joystick instance ID
221 * \returns the GUID of the selected joystick. If called with an invalid
222 * instance_id, this function returns a zero GUID.
223 *
224 * \since This function is available since SDL 3.0.0.
225 *
226 * \sa SDL_GetJoystickGUID
227 * \sa SDL_GetJoystickGUIDString
228 */
230
231/**
232 * Get the USB vendor ID of a joystick, if available.
233 *
234 * This can be called before any joysticks are opened. If the vendor ID isn't
235 * available this function returns 0.
236 *
237 * \param instance_id the joystick instance ID
238 * \returns the USB vendor ID of the selected joystick. If called with an
239 * invalid instance_id, this function returns 0.
240 *
241 * \since This function is available since SDL 3.0.0.
242 *
243 * \sa SDL_GetJoystickVendor
244 * \sa SDL_GetJoysticks
245 */
246extern DECLSPEC Uint16 SDLCALL SDL_GetJoystickInstanceVendor(SDL_JoystickID instance_id);
247
248/**
249 * Get the USB product ID of a joystick, if available.
250 *
251 * This can be called before any joysticks are opened. If the product ID isn't
252 * available this function returns 0.
253 *
254 * \param instance_id the joystick instance ID
255 * \returns the USB product ID of the selected joystick. If called with an
256 * invalid instance_id, this function returns 0.
257 *
258 * \since This function is available since SDL 3.0.0.
259 *
260 * \sa SDL_GetJoystickProduct
261 * \sa SDL_GetJoysticks
262 */
263extern DECLSPEC Uint16 SDLCALL SDL_GetJoystickInstanceProduct(SDL_JoystickID instance_id);
264
265/**
266 * Get the product version of a joystick, if available.
267 *
268 * This can be called before any joysticks are opened. If the product version
269 * isn't available this function returns 0.
270 *
271 * \param instance_id the joystick instance ID
272 * \returns the product version of the selected joystick. If called with an
273 * invalid instance_id, this function returns 0.
274 *
275 * \since This function is available since SDL 3.0.0.
276 *
277 * \sa SDL_GetJoystickProductVersion
278 * \sa SDL_GetJoysticks
279 */
281
282/**
283 * Get the type of a joystick, if available.
284 *
285 * This can be called before any joysticks are opened.
286 *
287 * \param instance_id the joystick instance ID
288 * \returns the SDL_JoystickType of the selected joystick. If called with an
289 * invalid instance_id, this function returns
290 * `SDL_JOYSTICK_TYPE_UNKNOWN`.
291 *
292 * \since This function is available since SDL 3.0.0.
293 *
294 * \sa SDL_GetJoystickType
295 * \sa SDL_GetJoysticks
296 */
298
299/**
300 * Open a joystick for use.
301 *
302 * The joystick subsystem must be initialized before a joystick can be opened
303 * for use.
304 *
305 * \param instance_id the joystick instance ID
306 * \returns a joystick identifier or NULL if an error occurred; call
307 * SDL_GetError() for more information.
308 *
309 * \since This function is available since SDL 3.0.0.
310 *
311 * \sa SDL_CloseJoystick
312 */
313extern DECLSPEC SDL_Joystick *SDLCALL SDL_OpenJoystick(SDL_JoystickID instance_id);
314
315/**
316 * Get the SDL_Joystick associated with an instance ID, if it has been opened.
317 *
318 * \param instance_id the instance ID to get the SDL_Joystick for
319 * \returns an SDL_Joystick on success or NULL on failure or if it hasn't been
320 * opened yet; call SDL_GetError() for more information.
321 *
322 * \since This function is available since SDL 3.0.0.
323 */
324extern DECLSPEC SDL_Joystick *SDLCALL SDL_GetJoystickFromInstanceID(SDL_JoystickID instance_id);
325
326/**
327 * Get the SDL_Joystick associated with a player index.
328 *
329 * \param player_index the player index to get the SDL_Joystick for
330 * \returns an SDL_Joystick on success or NULL on failure; call SDL_GetError()
331 * for more information.
332 *
333 * \since This function is available since SDL 3.0.0.
334 *
335 * \sa SDL_GetJoystickPlayerIndex
336 * \sa SDL_SetJoystickPlayerIndex
337 */
338extern DECLSPEC SDL_Joystick *SDLCALL SDL_GetJoystickFromPlayerIndex(int player_index);
339
340/**
341 * Attach a new virtual joystick.
342 *
343 * \param type type of joystick
344 * \param naxes number of axes
345 * \param nbuttons number of buttons
346 * \param nhats number of hats
347 * \returns the joystick instance ID, or 0 if an error occurred; call
348 * SDL_GetError() for more information.
349 *
350 * \since This function is available since SDL 3.0.0.
351 *
352 * \sa SDL_AttachVirtualJoystickEx
353 * \sa SDL_DetachVirtualJoystick
354 */
356 int naxes,
357 int nbuttons,
358 int nhats);
359
360/**
361 * The structure that defines an extended virtual joystick description
362 *
363 * All elements of this structure are optional and can be left 0.
364 *
365 * \since This struct is available since SDL 3.0.0.
366 *
367 * \sa SDL_AttachVirtualJoystickEx
368 */
370{
371 Uint16 type; /**< `SDL_JoystickType` */
372 Uint16 naxes; /**< the number of axes on this joystick */
373 Uint16 nbuttons; /**< the number of buttons on this joystick */
374 Uint16 nhats; /**< the number of hats on this joystick */
375 Uint16 vendor_id; /**< the USB vendor ID of this joystick */
376 Uint16 product_id; /**< the USB product ID of this joystick */
377 Uint16 padding; /**< unused */
378 Uint32 button_mask; /**< A mask of which buttons are valid for this controller
379 e.g. (1 << SDL_GAMEPAD_BUTTON_SOUTH) */
380 Uint32 axis_mask; /**< A mask of which axes are valid for this controller
381 e.g. (1 << SDL_GAMEPAD_AXIS_LEFTX) */
382 const char *name; /**< the name of the joystick */
383
384 void *userdata; /**< User data pointer passed to callbacks */
385 void (SDLCALL *Update)(void *userdata); /**< Called when the joystick state should be updated */
386 void (SDLCALL *SetPlayerIndex)(void *userdata, int player_index); /**< Called when the player index is set */
387 int (SDLCALL *Rumble)(void *userdata, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble); /**< Implements SDL_RumbleJoystick() */
388 int (SDLCALL *RumbleTriggers)(void *userdata, Uint16 left_rumble, Uint16 right_rumble); /**< Implements SDL_RumbleJoystickTriggers() */
389 int (SDLCALL *SetLED)(void *userdata, Uint8 red, Uint8 green, Uint8 blue); /**< Implements SDL_SetJoystickLED() */
390 int (SDLCALL *SendEffect)(void *userdata, const void *data, int size); /**< Implements SDL_SendJoystickEffect() */
392
393/**
394 * Attach a new virtual joystick with extended properties.
395 *
396 * \param desc Joystick description
397 * \returns the joystick instance ID, or 0 if an error occurred; call
398 * SDL_GetError() for more information.
399 *
400 * \since This function is available since SDL 3.0.0.
401 *
402 * \sa SDL_AttachVirtualJoystick
403 * \sa SDL_DetachVirtualJoystick
404 */
406
407/**
408 * Detach a virtual joystick.
409 *
410 * \param instance_id the joystick instance ID, previously returned from
411 * SDL_AttachVirtualJoystick()
412 * \returns 0 on success or a negative error code on failure; call
413 * SDL_GetError() for more information.
414 *
415 * \since This function is available since SDL 3.0.0.
416 *
417 * \sa SDL_AttachVirtualJoystick
418 * \sa SDL_AttachVirtualJoystickEx
419 */
420extern DECLSPEC int SDLCALL SDL_DetachVirtualJoystick(SDL_JoystickID instance_id);
421
422/**
423 * Query whether or not a joystick is virtual.
424 *
425 * \param instance_id the joystick instance ID
426 * \returns SDL_TRUE if the joystick is virtual, SDL_FALSE otherwise.
427 *
428 * \since This function is available since SDL 3.0.0.
429 */
430extern DECLSPEC SDL_bool SDLCALL SDL_IsJoystickVirtual(SDL_JoystickID instance_id);
431
432/**
433 * Set values on an opened, virtual-joystick's axis.
434 *
435 * Please note that values set here will not be applied until the next call to
436 * SDL_UpdateJoysticks, which can either be called directly, or can be called
437 * indirectly through various other SDL APIs, including, but not limited to
438 * the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout,
439 * SDL_WaitEvent.
440 *
441 * Note that when sending trigger axes, you should scale the value to the full
442 * range of Sint16. For example, a trigger at rest would have the value of
443 * `SDL_JOYSTICK_AXIS_MIN`.
444 *
445 * \param joystick the virtual joystick on which to set state.
446 * \param axis the specific axis on the virtual joystick to set.
447 * \param value the new value for the specified axis.
448 * \returns 0 on success or a negative error code on failure; call
449 * SDL_GetError() for more information.
450 *
451 * \since This function is available since SDL 3.0.0.
452 */
453extern DECLSPEC int SDLCALL SDL_SetJoystickVirtualAxis(SDL_Joystick *joystick, int axis, Sint16 value);
454
455/**
456 * Set values on an opened, virtual-joystick's button.
457 *
458 * Please note that values set here will not be applied until the next call to
459 * SDL_UpdateJoysticks, which can either be called directly, or can be called
460 * indirectly through various other SDL APIs, including, but not limited to
461 * the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout,
462 * SDL_WaitEvent.
463 *
464 * \param joystick the virtual joystick on which to set state.
465 * \param button the specific button on the virtual joystick to set.
466 * \param value the new value for the specified button.
467 * \returns 0 on success or a negative error code on failure; call
468 * SDL_GetError() for more information.
469 *
470 * \since This function is available since SDL 3.0.0.
471 */
472extern DECLSPEC int SDLCALL SDL_SetJoystickVirtualButton(SDL_Joystick *joystick, int button, Uint8 value);
473
474/**
475 * Set values on an opened, virtual-joystick's hat.
476 *
477 * Please note that values set here will not be applied until the next call to
478 * SDL_UpdateJoysticks, which can either be called directly, or can be called
479 * indirectly through various other SDL APIs, including, but not limited to
480 * the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout,
481 * SDL_WaitEvent.
482 *
483 * \param joystick the virtual joystick on which to set state.
484 * \param hat the specific hat on the virtual joystick to set.
485 * \param value the new value for the specified hat.
486 * \returns 0 on success or a negative error code on failure; call
487 * SDL_GetError() for more information.
488 *
489 * \since This function is available since SDL 3.0.0.
490 */
491extern DECLSPEC int SDLCALL SDL_SetJoystickVirtualHat(SDL_Joystick *joystick, int hat, Uint8 value);
492
493/**
494 * Get the properties associated with a joystick.
495 *
496 * The following read-only properties are provided by SDL:
497 *
498 * - `SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN`: true if this joystick has an
499 * LED that has adjustable brightness
500 * - `SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN`: true if this joystick has an LED
501 * that has adjustable color
502 * - `SDL_PROP_JOYSTICK_CAP_PLAYER_LED_BOOLEAN`: true if this joystick has a
503 * player LED
504 * - `SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN`: true if this joystick has
505 * left/right rumble
506 * - `SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN`: true if this joystick has
507 * simple trigger rumble
508 *
509 * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
510 * \returns a valid property ID on success or 0 on failure; call
511 * SDL_GetError() for more information.
512 *
513 * \since This function is available since SDL 3.0.0.
514 *
515 * \sa SDL_GetProperty
516 * \sa SDL_SetProperty
517 */
518extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetJoystickProperties(SDL_Joystick *joystick);
519
520#define SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN "SDL.joystick.cap.mono_led"
521#define SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN "SDL.joystick.cap.rgb_led"
522#define SDL_PROP_JOYSTICK_CAP_PLAYER_LED_BOOLEAN "SDL.joystick.cap.player_led"
523#define SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN "SDL.joystick.cap.rumble"
524#define SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN "SDL.joystick.cap.trigger_rumble"
525
526/**
527 * Get the implementation dependent name of a joystick.
528 *
529 * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
530 * \returns the name of the selected joystick. If no name can be found, this
531 * function returns NULL; call SDL_GetError() for more information.
532 *
533 * \since This function is available since SDL 3.0.0.
534 *
535 * \sa SDL_GetJoystickInstanceName
536 */
537extern DECLSPEC const char *SDLCALL SDL_GetJoystickName(SDL_Joystick *joystick);
538
539/**
540 * Get the implementation dependent path of a joystick.
541 *
542 * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
543 * \returns the path of the selected joystick. If no path can be found, this
544 * function returns NULL; call SDL_GetError() for more information.
545 *
546 * \since This function is available since SDL 3.0.0.
547 *
548 * \sa SDL_GetJoystickInstancePath
549 */
550extern DECLSPEC const char *SDLCALL SDL_GetJoystickPath(SDL_Joystick *joystick);
551
552/**
553 * Get the player index of an opened joystick.
554 *
555 * For XInput controllers this returns the XInput user index. Many joysticks
556 * will not be able to supply this information.
557 *
558 * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
559 * \returns the player index, or -1 if it's not available.
560 *
561 * \since This function is available since SDL 3.0.0.
562 *
563 * \sa SDL_SetJoystickPlayerIndex
564 */
565extern DECLSPEC int SDLCALL SDL_GetJoystickPlayerIndex(SDL_Joystick *joystick);
566
567/**
568 * Set the player index of an opened joystick.
569 *
570 * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
571 * \param player_index Player index to assign to this joystick, or -1 to clear
572 * the player index and turn off player LEDs.
573 * \returns 0 on success or a negative error code on failure; call
574 * SDL_GetError() for more information.
575 *
576 * \since This function is available since SDL 3.0.0.
577 *
578 * \sa SDL_GetJoystickPlayerIndex
579 */
580extern DECLSPEC int SDLCALL SDL_SetJoystickPlayerIndex(SDL_Joystick *joystick, int player_index);
581
582/**
583 * Get the implementation-dependent GUID for the joystick.
584 *
585 * This function requires an open joystick.
586 *
587 * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
588 * \returns the GUID of the given joystick. If called on an invalid index,
589 * this function returns a zero GUID; call SDL_GetError() for more
590 * information.
591 *
592 * \since This function is available since SDL 3.0.0.
593 *
594 * \sa SDL_GetJoystickInstanceGUID
595 * \sa SDL_GetJoystickGUIDString
596 */
597extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_GetJoystickGUID(SDL_Joystick *joystick);
598
599/**
600 * Get the USB vendor ID of an opened joystick, if available.
601 *
602 * If the vendor ID isn't available this function returns 0.
603 *
604 * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
605 * \returns the USB vendor ID of the selected joystick, or 0 if unavailable.
606 *
607 * \since This function is available since SDL 3.0.0.
608 *
609 * \sa SDL_GetJoystickInstanceVendor
610 */
611extern DECLSPEC Uint16 SDLCALL SDL_GetJoystickVendor(SDL_Joystick *joystick);
612
613/**
614 * Get the USB product ID of an opened joystick, if available.
615 *
616 * If the product ID isn't available this function returns 0.
617 *
618 * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
619 * \returns the USB product ID of the selected joystick, or 0 if unavailable.
620 *
621 * \since This function is available since SDL 3.0.0.
622 *
623 * \sa SDL_GetJoystickInstanceProduct
624 */
625extern DECLSPEC Uint16 SDLCALL SDL_GetJoystickProduct(SDL_Joystick *joystick);
626
627/**
628 * Get the product version of an opened joystick, if available.
629 *
630 * If the product version isn't available this function returns 0.
631 *
632 * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
633 * \returns the product version of the selected joystick, or 0 if unavailable.
634 *
635 * \since This function is available since SDL 3.0.0.
636 *
637 * \sa SDL_GetJoystickInstanceProductVersion
638 */
639extern DECLSPEC Uint16 SDLCALL SDL_GetJoystickProductVersion(SDL_Joystick *joystick);
640
641/**
642 * Get the firmware version of an opened joystick, if available.
643 *
644 * If the firmware version isn't available this function returns 0.
645 *
646 * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
647 * \returns the firmware version of the selected joystick, or 0 if
648 * unavailable.
649 *
650 * \since This function is available since SDL 3.0.0.
651 */
652extern DECLSPEC Uint16 SDLCALL SDL_GetJoystickFirmwareVersion(SDL_Joystick *joystick);
653
654/**
655 * Get the serial number of an opened joystick, if available.
656 *
657 * Returns the serial number of the joystick, or NULL if it is not available.
658 *
659 * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
660 * \returns the serial number of the selected joystick, or NULL if
661 * unavailable.
662 *
663 * \since This function is available since SDL 3.0.0.
664 */
665extern DECLSPEC const char * SDLCALL SDL_GetJoystickSerial(SDL_Joystick *joystick);
666
667/**
668 * Get the type of an opened joystick.
669 *
670 * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
671 * \returns the SDL_JoystickType of the selected joystick.
672 *
673 * \since This function is available since SDL 3.0.0.
674 *
675 * \sa SDL_GetJoystickInstanceType
676 */
677extern DECLSPEC SDL_JoystickType SDLCALL SDL_GetJoystickType(SDL_Joystick *joystick);
678
679/**
680 * Get an ASCII string representation for a given SDL_JoystickGUID.
681 *
682 * You should supply at least 33 bytes for pszGUID.
683 *
684 * \param guid the SDL_JoystickGUID you wish to convert to string
685 * \param pszGUID buffer in which to write the ASCII string
686 * \param cbGUID the size of pszGUID
687 * \returns 0 on success or a negative error code on failure; call
688 * SDL_GetError() for more information.
689 *
690 * \since This function is available since SDL 3.0.0.
691 *
692 * \sa SDL_GetJoystickInstanceGUID
693 * \sa SDL_GetJoystickGUID
694 * \sa SDL_GetJoystickGUIDFromString
695 */
696extern DECLSPEC int SDLCALL SDL_GetJoystickGUIDString(SDL_JoystickGUID guid, char *pszGUID, int cbGUID);
697
698/**
699 * Convert a GUID string into a SDL_JoystickGUID structure.
700 *
701 * Performs no error checking. If this function is given a string containing
702 * an invalid GUID, the function will silently succeed, but the GUID generated
703 * will not be useful.
704 *
705 * \param pchGUID string containing an ASCII representation of a GUID
706 * \returns a SDL_JoystickGUID structure.
707 *
708 * \since This function is available since SDL 3.0.0.
709 *
710 * \sa SDL_GetJoystickGUIDString
711 */
712extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_GetJoystickGUIDFromString(const char *pchGUID);
713
714/**
715 * Get the device information encoded in a SDL_JoystickGUID structure.
716 *
717 * \param guid the SDL_JoystickGUID you wish to get info about
718 * \param vendor A pointer filled in with the device VID, or 0 if not
719 * available
720 * \param product A pointer filled in with the device PID, or 0 if not
721 * available
722 * \param version A pointer filled in with the device version, or 0 if not
723 * available
724 * \param crc16 A pointer filled in with a CRC used to distinguish different
725 * products with the same VID/PID, or 0 if not available
726 *
727 * \since This function is available since SDL 3.0.0.
728 *
729 * \sa SDL_GetJoystickInstanceGUID
730 */
731extern DECLSPEC void SDLCALL SDL_GetJoystickGUIDInfo(SDL_JoystickGUID guid, Uint16 *vendor, Uint16 *product, Uint16 *version, Uint16 *crc16);
732
733/**
734 * Get the status of a specified joystick.
735 *
736 * \param joystick the joystick to query
737 * \returns SDL_TRUE if the joystick has been opened, SDL_FALSE if it has not;
738 * call SDL_GetError() for more information.
739 *
740 * \since This function is available since SDL 3.0.0.
741 */
742extern DECLSPEC SDL_bool SDLCALL SDL_JoystickConnected(SDL_Joystick *joystick);
743
744/**
745 * Get the instance ID of an opened joystick.
746 *
747 * \param joystick an SDL_Joystick structure containing joystick information
748 * \returns the instance ID of the specified joystick on success or 0 on
749 * failure; call SDL_GetError() for more information.
750 *
751 * \since This function is available since SDL 3.0.0.
752 */
753extern DECLSPEC SDL_JoystickID SDLCALL SDL_GetJoystickInstanceID(SDL_Joystick *joystick);
754
755/**
756 * Get the number of general axis controls on a joystick.
757 *
758 * Often, the directional pad on a game controller will either look like 4
759 * separate buttons or a POV hat, and not axes, but all of this is up to the
760 * device and platform.
761 *
762 * \param joystick an SDL_Joystick structure containing joystick information
763 * \returns the number of axis controls/number of axes on success or a
764 * negative error code on failure; call SDL_GetError() for more
765 * information.
766 *
767 * \since This function is available since SDL 3.0.0.
768 *
769 * \sa SDL_GetJoystickAxis
770 * \sa SDL_GetNumJoystickBalls
771 * \sa SDL_GetNumJoystickButtons
772 * \sa SDL_GetNumJoystickHats
773 */
774extern DECLSPEC int SDLCALL SDL_GetNumJoystickAxes(SDL_Joystick *joystick);
775
776/**
777 * Get the number of trackballs on a joystick.
778 *
779 * Joystick trackballs have only relative motion events associated with them
780 * and their state cannot be polled.
781 *
782 * Most joysticks do not have trackballs.
783 *
784 * \param joystick an SDL_Joystick structure containing joystick information
785 * \returns the number of trackballs on success or a negative error code on
786 * failure; call SDL_GetError() for more information.
787 *
788 * \since This function is available since SDL 3.0.0.
789 *
790 * \sa SDL_GetJoystickBall
791 * \sa SDL_GetNumJoystickAxes
792 * \sa SDL_GetNumJoystickButtons
793 * \sa SDL_GetNumJoystickHats
794 */
795extern DECLSPEC int SDLCALL SDL_GetNumJoystickBalls(SDL_Joystick *joystick);
796
797/**
798 * Get the number of POV hats on a joystick.
799 *
800 * \param joystick an SDL_Joystick structure containing joystick information
801 * \returns the number of POV hats on success or a negative error code on
802 * failure; call SDL_GetError() for more information.
803 *
804 * \since This function is available since SDL 3.0.0.
805 *
806 * \sa SDL_GetJoystickHat
807 * \sa SDL_GetNumJoystickAxes
808 * \sa SDL_GetNumJoystickBalls
809 * \sa SDL_GetNumJoystickButtons
810 */
811extern DECLSPEC int SDLCALL SDL_GetNumJoystickHats(SDL_Joystick *joystick);
812
813/**
814 * Get the number of buttons on a joystick.
815 *
816 * \param joystick an SDL_Joystick structure containing joystick information
817 * \returns the number of buttons on success or a negative error code on
818 * failure; call SDL_GetError() for more information.
819 *
820 * \since This function is available since SDL 3.0.0.
821 *
822 * \sa SDL_GetJoystickButton
823 * \sa SDL_GetNumJoystickAxes
824 * \sa SDL_GetNumJoystickBalls
825 * \sa SDL_GetNumJoystickHats
826 */
827extern DECLSPEC int SDLCALL SDL_GetNumJoystickButtons(SDL_Joystick *joystick);
828
829/**
830 * Set the state of joystick event processing.
831 *
832 * If joystick events are disabled, you must call SDL_UpdateJoysticks()
833 * yourself and check the state of the joystick when you want joystick
834 * information.
835 *
836 * \param enabled whether to process joystick events or not
837 *
838 * \since This function is available since SDL 3.0.0.
839 *
840 * \sa SDL_JoystickEventsEnabled
841 * \sa SDL_UpdateJoysticks
842 */
843extern DECLSPEC void SDLCALL SDL_SetJoystickEventsEnabled(SDL_bool enabled);
844
845/**
846 * Query the state of joystick event processing.
847 *
848 * If joystick events are disabled, you must call SDL_UpdateJoysticks()
849 * yourself and check the state of the joystick when you want joystick
850 * information.
851 *
852 * \returns SDL_TRUE if joystick events are being processed, SDL_FALSE
853 * otherwise.
854 *
855 * \since This function is available since SDL 3.0.0.
856 *
857 * \sa SDL_SetJoystickEventsEnabled
858 */
859extern DECLSPEC SDL_bool SDLCALL SDL_JoystickEventsEnabled(void);
860
861/**
862 * Update the current state of the open joysticks.
863 *
864 * This is called automatically by the event loop if any joystick events are
865 * enabled.
866 *
867 * \since This function is available since SDL 3.0.0.
868 */
869extern DECLSPEC void SDLCALL SDL_UpdateJoysticks(void);
870
871/**
872 * Get the current state of an axis control on a joystick.
873 *
874 * SDL makes no promises about what part of the joystick any given axis refers
875 * to. Your game should have some sort of configuration UI to let users
876 * specify what each axis should be bound to. Alternately, SDL's higher-level
877 * Game Controller API makes a great effort to apply order to this lower-level
878 * interface, so you know that a specific axis is the "left thumb stick," etc.
879 *
880 * The value returned by SDL_GetJoystickAxis() is a signed integer (-32768 to
881 * 32767) representing the current position of the axis. It may be necessary
882 * to impose certain tolerances on these values to account for jitter.
883 *
884 * \param joystick an SDL_Joystick structure containing joystick information
885 * \param axis the axis to query; the axis indices start at index 0
886 * \returns a 16-bit signed integer representing the current position of the
887 * axis or 0 on failure; call SDL_GetError() for more information.
888 *
889 * \since This function is available since SDL 3.0.0.
890 *
891 * \sa SDL_GetNumJoystickAxes
892 */
893extern DECLSPEC Sint16 SDLCALL SDL_GetJoystickAxis(SDL_Joystick *joystick, int axis);
894
895/**
896 * Get the initial state of an axis control on a joystick.
897 *
898 * The state is a value ranging from -32768 to 32767.
899 *
900 * The axis indices start at index 0.
901 *
902 * \param joystick an SDL_Joystick structure containing joystick information
903 * \param axis the axis to query; the axis indices start at index 0
904 * \param state Upon return, the initial value is supplied here.
905 * \returns SDL_TRUE if this axis has any initial value, or SDL_FALSE if not.
906 *
907 * \since This function is available since SDL 3.0.0.
908 */
909extern DECLSPEC SDL_bool SDLCALL SDL_GetJoystickAxisInitialState(SDL_Joystick *joystick, int axis, Sint16 *state);
910
911/**
912 * Get the ball axis change since the last poll.
913 *
914 * Trackballs can only return relative motion since the last call to
915 * SDL_GetJoystickBall(), these motion deltas are placed into `dx` and `dy`.
916 *
917 * Most joysticks do not have trackballs.
918 *
919 * \param joystick the SDL_Joystick to query
920 * \param ball the ball index to query; ball indices start at index 0
921 * \param dx stores the difference in the x axis position since the last poll
922 * \param dy stores the difference in the y axis position since the last poll
923 * \returns 0 on success or a negative error code on failure; call
924 * SDL_GetError() for more information.
925 *
926 * \since This function is available since SDL 3.0.0.
927 *
928 * \sa SDL_GetNumJoystickBalls
929 */
930extern DECLSPEC int SDLCALL SDL_GetJoystickBall(SDL_Joystick *joystick, int ball, int *dx, int *dy);
931
932/**
933 * \name Hat positions
934 */
935/* @{ */
936#define SDL_HAT_CENTERED 0x00
937#define SDL_HAT_UP 0x01
938#define SDL_HAT_RIGHT 0x02
939#define SDL_HAT_DOWN 0x04
940#define SDL_HAT_LEFT 0x08
941#define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP)
942#define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN)
943#define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP)
944#define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN)
945/* @} */
946
947/**
948 * Get the current state of a POV hat on a joystick.
949 *
950 * The returned value will be one of the following positions:
951 *
952 * - `SDL_HAT_CENTERED`
953 * - `SDL_HAT_UP`
954 * - `SDL_HAT_RIGHT`
955 * - `SDL_HAT_DOWN`
956 * - `SDL_HAT_LEFT`
957 * - `SDL_HAT_RIGHTUP`
958 * - `SDL_HAT_RIGHTDOWN`
959 * - `SDL_HAT_LEFTUP`
960 * - `SDL_HAT_LEFTDOWN`
961 *
962 * \param joystick an SDL_Joystick structure containing joystick information
963 * \param hat the hat index to get the state from; indices start at index 0
964 * \returns the current hat position.
965 *
966 * \since This function is available since SDL 3.0.0.
967 *
968 * \sa SDL_GetNumJoystickHats
969 */
970extern DECLSPEC Uint8 SDLCALL SDL_GetJoystickHat(SDL_Joystick *joystick, int hat);
971
972/**
973 * Get the current state of a button on a joystick.
974 *
975 * \param joystick an SDL_Joystick structure containing joystick information
976 * \param button the button index to get the state from; indices start at
977 * index 0
978 * \returns 1 if the specified button is pressed, 0 otherwise.
979 *
980 * \since This function is available since SDL 3.0.0.
981 *
982 * \sa SDL_GetNumJoystickButtons
983 */
984extern DECLSPEC Uint8 SDLCALL SDL_GetJoystickButton(SDL_Joystick *joystick, int button);
985
986/**
987 * Start a rumble effect.
988 *
989 * Each call to this function cancels any previous rumble effect, and calling
990 * it with 0 intensity stops any rumbling.
991 *
992 * This function requires you to process SDL events or call
993 * SDL_UpdateJoysticks() to update rumble state.
994 *
995 * \param joystick The joystick to vibrate
996 * \param low_frequency_rumble The intensity of the low frequency (left)
997 * rumble motor, from 0 to 0xFFFF
998 * \param high_frequency_rumble The intensity of the high frequency (right)
999 * rumble motor, from 0 to 0xFFFF
1000 * \param duration_ms The duration of the rumble effect, in milliseconds
1001 * \returns 0, or -1 if rumble isn't supported on this joystick
1002 *
1003 * \since This function is available since SDL 3.0.0.
1004 */
1005extern DECLSPEC int SDLCALL SDL_RumbleJoystick(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
1006
1007/**
1008 * Start a rumble effect in the joystick's triggers.
1009 *
1010 * Each call to this function cancels any previous trigger rumble effect, and
1011 * calling it with 0 intensity stops any rumbling.
1012 *
1013 * Note that this is rumbling of the _triggers_ and not the game controller as
1014 * a whole. This is currently only supported on Xbox One controllers. If you
1015 * want the (more common) whole-controller rumble, use SDL_RumbleJoystick()
1016 * instead.
1017 *
1018 * This function requires you to process SDL events or call
1019 * SDL_UpdateJoysticks() to update rumble state.
1020 *
1021 * \param joystick The joystick to vibrate
1022 * \param left_rumble The intensity of the left trigger rumble motor, from 0
1023 * to 0xFFFF
1024 * \param right_rumble The intensity of the right trigger rumble motor, from 0
1025 * to 0xFFFF
1026 * \param duration_ms The duration of the rumble effect, in milliseconds
1027 * \returns 0 on success or a negative error code on failure; call
1028 * SDL_GetError() for more information.
1029 *
1030 * \since This function is available since SDL 3.0.0.
1031 *
1032 * \sa SDL_RumbleJoystick
1033 */
1034extern DECLSPEC int SDLCALL SDL_RumbleJoystickTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
1035
1036/**
1037 * Update a joystick's LED color.
1038 *
1039 * An example of a joystick LED is the light on the back of a PlayStation 4's
1040 * DualShock 4 controller.
1041 *
1042 * For joysticks with a single color LED, the maximum of the RGB values will
1043 * be used as the LED brightness.
1044 *
1045 * \param joystick The joystick to update
1046 * \param red The intensity of the red LED
1047 * \param green The intensity of the green LED
1048 * \param blue The intensity of the blue LED
1049 * \returns 0 on success or a negative error code on failure; call
1050 * SDL_GetError() for more information.
1051 *
1052 * \since This function is available since SDL 3.0.0.
1053 */
1054extern DECLSPEC int SDLCALL SDL_SetJoystickLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue);
1055
1056/**
1057 * Send a joystick specific effect packet.
1058 *
1059 * \param joystick The joystick to affect
1060 * \param data The data to send to the joystick
1061 * \param size The size of the data to send to the joystick
1062 * \returns 0 on success or a negative error code on failure; call
1063 * SDL_GetError() for more information.
1064 *
1065 * \since This function is available since SDL 3.0.0.
1066 */
1067extern DECLSPEC int SDLCALL SDL_SendJoystickEffect(SDL_Joystick *joystick, const void *data, int size);
1068
1069/**
1070 * Close a joystick previously opened with SDL_OpenJoystick().
1071 *
1072 * \param joystick The joystick device to close
1073 *
1074 * \since This function is available since SDL 3.0.0.
1075 *
1076 * \sa SDL_OpenJoystick
1077 */
1078extern DECLSPEC void SDLCALL SDL_CloseJoystick(SDL_Joystick *joystick);
1079
1080/**
1081 * Get the connection state of a joystick.
1082 *
1083 * \param joystick The joystick to query
1084 * \returns the connection state on success or
1085 * `SDL_JOYSTICK_CONNECTION_INVALID` on failure; call SDL_GetError()
1086 * for more information.
1087 *
1088 * \since This function is available since SDL 3.0.0.
1089 */
1091
1092/**
1093 * Get the battery state of a joystick.
1094 *
1095 * You should never take a battery status as absolute truth. Batteries
1096 * (especially failing batteries) are delicate hardware, and the values
1097 * reported here are best estimates based on what that hardware reports. It's
1098 * not uncommon for older batteries to lose stored power much faster than it
1099 * reports, or completely drain when reporting it has 20 percent left, etc.
1100 *
1101 * \param joystick The joystick to query
1102 * \param percent a pointer filled in with the percentage of battery life
1103 * left, between 0 and 100, or NULL to ignore. This will be
1104 * filled in with -1 we can't determine a value or there is no
1105 * battery.
1106 * \returns the current battery state or `SDL_POWERSTATE_ERROR` on failure;
1107 * call SDL_GetError() for more information.
1108 *
1109 * \since This function is available since SDL 3.0.0.
1110 */
1111extern DECLSPEC SDL_PowerState SDLCALL SDL_GetJoystickPowerInfo(SDL_Joystick *joystick, int *percent);
1112
1113/* Ends C function definitions when using C++ */
1114#ifdef __cplusplus
1115}
1116#endif
1117#include <SDL3/SDL_close_code.h>
1118
1119#endif /* SDL_joystick_h_ */
int SDL_SetJoystickVirtualAxis(SDL_Joystick *joystick, int axis, Sint16 value)
SDL_JoystickType
@ SDL_JOYSTICK_TYPE_DANCE_PAD
@ SDL_JOYSTICK_TYPE_GAMEPAD
@ SDL_JOYSTICK_TYPE_ARCADE_PAD
@ SDL_JOYSTICK_TYPE_UNKNOWN
@ SDL_JOYSTICK_TYPE_ARCADE_STICK
@ SDL_JOYSTICK_TYPE_WHEEL
@ SDL_JOYSTICK_TYPE_THROTTLE
@ SDL_JOYSTICK_TYPE_GUITAR
@ SDL_JOYSTICK_TYPE_FLIGHT_STICK
@ SDL_JOYSTICK_TYPE_DRUM_KIT
void SDL_UnlockJoysticks(void) SDL_RELEASE(SDL_joystick_lock)
SDL_Joystick * SDL_OpenJoystick(SDL_JoystickID instance_id)
void SDL_UpdateJoysticks(void)
int SDL_GetJoystickInstancePlayerIndex(SDL_JoystickID instance_id)
Uint32 SDL_JoystickID
Uint8 SDL_GetJoystickButton(SDL_Joystick *joystick, int button)
Uint16 SDL_GetJoystickInstanceProduct(SDL_JoystickID instance_id)
const char * SDL_GetJoystickInstanceName(SDL_JoystickID instance_id)
Uint16 SDL_GetJoystickVendor(SDL_Joystick *joystick)
SDL_PowerState SDL_GetJoystickPowerInfo(SDL_Joystick *joystick, int *percent)
const char * SDL_GetJoystickInstancePath(SDL_JoystickID instance_id)
SDL_JoystickGUID SDL_GetJoystickGUID(SDL_Joystick *joystick)
SDL_JoystickID * SDL_GetJoysticks(int *count)
SDL_JoystickID SDL_AttachVirtualJoystickEx(const SDL_VirtualJoystickDesc *desc)
int SDL_SetJoystickVirtualButton(SDL_Joystick *joystick, int button, Uint8 value)
Uint16 SDL_GetJoystickProductVersion(SDL_Joystick *joystick)
SDL_Joystick * SDL_GetJoystickFromInstanceID(SDL_JoystickID instance_id)
const char * SDL_GetJoystickPath(SDL_Joystick *joystick)
int SDL_DetachVirtualJoystick(SDL_JoystickID instance_id)
SDL_bool SDL_IsJoystickVirtual(SDL_JoystickID instance_id)
int SDL_SetJoystickLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
void SDL_SetJoystickEventsEnabled(SDL_bool enabled)
SDL_JoystickType SDL_GetJoystickInstanceType(SDL_JoystickID instance_id)
int SDL_SetJoystickVirtualHat(SDL_Joystick *joystick, int hat, Uint8 value)
struct SDL_Joystick SDL_Joystick
int SDL_RumbleJoystick(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
int SDL_GetNumJoystickHats(SDL_Joystick *joystick)
SDL_PropertiesID SDL_GetJoystickProperties(SDL_Joystick *joystick)
int SDL_GetJoystickBall(SDL_Joystick *joystick, int ball, int *dx, int *dy)
Uint16 SDL_GetJoystickProduct(SDL_Joystick *joystick)
SDL_JoystickType SDL_GetJoystickType(SDL_Joystick *joystick)
SDL_bool SDL_JoystickEventsEnabled(void)
SDL_JoystickConnectionState SDL_GetJoystickConnectionState(SDL_Joystick *joystick)
int SDL_GetNumJoystickBalls(SDL_Joystick *joystick)
SDL_JoystickGUID SDL_GetJoystickGUIDFromString(const char *pchGUID)
SDL_GUID SDL_JoystickGUID
Uint16 SDL_GetJoystickInstanceVendor(SDL_JoystickID instance_id)
int SDL_RumbleJoystickTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms)
int SDL_GetNumJoystickButtons(SDL_Joystick *joystick)
int SDL_SendJoystickEffect(SDL_Joystick *joystick, const void *data, int size)
void SDL_CloseJoystick(SDL_Joystick *joystick)
int SDL_GetNumJoystickAxes(SDL_Joystick *joystick)
SDL_JoystickGUID SDL_GetJoystickInstanceGUID(SDL_JoystickID instance_id)
void SDL_LockJoysticks(void) SDL_ACQUIRE(SDL_joystick_lock)
SDL_JoystickConnectionState
@ SDL_JOYSTICK_CONNECTION_INVALID
@ SDL_JOYSTICK_CONNECTION_UNKNOWN
@ SDL_JOYSTICK_CONNECTION_WIRELESS
@ SDL_JOYSTICK_CONNECTION_WIRED
SDL_JoystickID SDL_AttachVirtualJoystick(SDL_JoystickType type, int naxes, int nbuttons, int nhats)
void SDL_GetJoystickGUIDInfo(SDL_JoystickGUID guid, Uint16 *vendor, Uint16 *product, Uint16 *version, Uint16 *crc16)
int SDL_SetJoystickPlayerIndex(SDL_Joystick *joystick, int player_index)
Uint16 SDL_GetJoystickInstanceProductVersion(SDL_JoystickID instance_id)
const char * SDL_GetJoystickSerial(SDL_Joystick *joystick)
SDL_bool SDL_GetJoystickAxisInitialState(SDL_Joystick *joystick, int axis, Sint16 *state)
Uint8 SDL_GetJoystickHat(SDL_Joystick *joystick, int hat)
SDL_bool SDL_JoystickConnected(SDL_Joystick *joystick)
Uint16 SDL_GetJoystickFirmwareVersion(SDL_Joystick *joystick)
Sint16 SDL_GetJoystickAxis(SDL_Joystick *joystick, int axis)
int SDL_GetJoystickPlayerIndex(SDL_Joystick *joystick)
SDL_bool SDL_HasJoystick(void)
SDL_JoystickID SDL_GetJoystickInstanceID(SDL_Joystick *joystick)
const char * SDL_GetJoystickName(SDL_Joystick *joystick)
SDL_Joystick * SDL_GetJoystickFromPlayerIndex(int player_index)
int SDL_GetJoystickGUIDString(SDL_JoystickGUID guid, char *pszGUID, int cbGUID)
#define SDL_ACQUIRE(x)
Definition SDL_mutex.h:73
struct SDL_Mutex SDL_Mutex
Definition SDL_mutex.h:134
#define SDL_RELEASE(x)
Definition SDL_mutex.h:79
SDL_PowerState
Definition SDL_power.h:48
Uint32 SDL_PropertiesID
uint8_t Uint8
Definition SDL_stdinc.h:188
uint16_t Uint16
Definition SDL_stdinc.h:206
SDL_MALLOC size_t size
Definition SDL_stdinc.h:469
int SDL_bool
Definition SDL_stdinc.h:170
int16_t Sint16
Definition SDL_stdinc.h:197
uint32_t Uint32
Definition SDL_stdinc.h:224
void(* SetPlayerIndex)(void *userdata, int player_index)
int(* SetLED)(void *userdata, Uint8 red, Uint8 green, Uint8 blue)
void(* Update)(void *userdata)
int(* SendEffect)(void *userdata, const void *data, int size)
int(* RumbleTriggers)(void *userdata, Uint16 left_rumble, Uint16 right_rumble)
int(* Rumble)(void *userdata, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)