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