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 ID value starts at 1 and increments from there. The value 0 is an
95 * invalid ID.
96 *
97 * \since This datatype is available since SDL 3.0.0.
98 */
100
101/**
102 * An enum of some common joystick types.
103 *
104 * In some cases, SDL can identify a low-level joystick as being a certain
105 * type of device, and will report it through SDL_GetJoystickType (or
106 * SDL_GetJoystickTypeForID).
107 *
108 * This is by no means a complete list of everything that can be plugged into
109 * a computer.
110 *
111 * \since This enum is available since SDL 3.0.0.
112 */
126
127/**
128 * Possible connection states for a joystick device.
129 *
130 * This is used by SDL_GetJoystickConnectionState to report how a device is
131 * connected to the system.
132 *
133 * \since This enum is available since SDL 3.0.0.
134 */
142
143/**
144 * The largest value an SDL_Joystick's axis can report.
145 *
146 * \since This macro is available since SDL 3.0.0.
147 *
148 * \sa SDL_JOYSTICK_AXIS_MIN
149 */
150#define SDL_JOYSTICK_AXIS_MAX 32767
151
152/**
153 * The smallest value an SDL_Joystick's axis can report.
154 *
155 * This is a negative number!
156 *
157 * \since This macro is available since SDL 3.0.0.
158 *
159 * \sa SDL_JOYSTICK_AXIS_MAX
160 */
161#define SDL_JOYSTICK_AXIS_MIN -32768
162
163
164/* Set max recognized G-force from accelerometer
165 See src/joystick/uikit/SDL_sysjoystick.m for notes on why this is needed
166 */
167#define SDL_IPHONE_MAX_GFORCE 5.0
168
169
170/* Function prototypes */
171
172/**
173 * Locking for atomic access to the joystick API.
174 *
175 * The SDL joystick functions are thread-safe, however you can lock the
176 * joysticks while processing to guarantee that the joystick list won't change
177 * and joystick and gamepad events will not be delivered.
178 *
179 * \since This function is available since SDL 3.0.0.
180 */
181extern SDL_DECLSPEC void SDLCALL SDL_LockJoysticks(void) SDL_ACQUIRE(SDL_joystick_lock);
182
183/**
184 * Unlocking for atomic access to the joystick API.
185 *
186 * \since This function is available since SDL 3.0.0.
187 */
188extern SDL_DECLSPEC void SDLCALL SDL_UnlockJoysticks(void) SDL_RELEASE(SDL_joystick_lock);
189
190/**
191 * Return whether a joystick is currently connected.
192 *
193 * \returns SDL_TRUE if a joystick is connected, SDL_FALSE otherwise.
194 *
195 * \since This function is available since SDL 3.0.0.
196 *
197 * \sa SDL_GetJoysticks
198 */
199extern SDL_DECLSPEC SDL_bool SDLCALL SDL_HasJoystick(void);
200
201/**
202 * Get a list of currently connected joysticks.
203 *
204 * \param count a pointer filled in with the number of joysticks returned, may
205 * be NULL.
206 * \returns a 0 terminated array of joystick instance IDs or NULL on failure;
207 * call SDL_GetError() for more information. This should be freed
208 * with SDL_free() when it is no longer needed.
209 *
210 * \since This function is available since SDL 3.0.0.
211 *
212 * \sa SDL_HasJoystick
213 * \sa SDL_OpenJoystick
214 */
215extern SDL_DECLSPEC SDL_JoystickID * SDLCALL SDL_GetJoysticks(int *count);
216
217/**
218 * Get the implementation dependent name of a joystick.
219 *
220 * This can be called before any joysticks are opened.
221 *
222 * \param instance_id the joystick instance ID.
223 * \returns the name of the selected joystick. If no name can be found, this
224 * function returns NULL; call SDL_GetError() for more information.
225 *
226 * \since This function is available since SDL 3.0.0.
227 *
228 * \sa SDL_GetJoystickName
229 * \sa SDL_GetJoysticks
230 */
231extern SDL_DECLSPEC const char * SDLCALL SDL_GetJoystickNameForID(SDL_JoystickID instance_id);
232
233/**
234 * Get the implementation dependent path of a joystick.
235 *
236 * This can be called before any joysticks are opened.
237 *
238 * \param instance_id the joystick instance ID.
239 * \returns the path of the selected joystick. If no path can be found, this
240 * function returns NULL; call SDL_GetError() for more information.
241 *
242 * \since This function is available since SDL 3.0.0.
243 *
244 * \sa SDL_GetJoystickPath
245 * \sa SDL_GetJoysticks
246 */
247extern SDL_DECLSPEC const char * SDLCALL SDL_GetJoystickPathForID(SDL_JoystickID instance_id);
248
249/**
250 * Get the player index of a joystick.
251 *
252 * This can be called before any joysticks are opened.
253 *
254 * \param instance_id the joystick instance ID.
255 * \returns the player index of a joystick, or -1 if it's not available.
256 *
257 * \since This function is available since SDL 3.0.0.
258 *
259 * \sa SDL_GetJoystickPlayerIndex
260 * \sa SDL_GetJoysticks
261 */
262extern SDL_DECLSPEC int SDLCALL SDL_GetJoystickPlayerIndexForID(SDL_JoystickID instance_id);
263
264/**
265 * Get the implementation-dependent GUID of a joystick.
266 *
267 * This can be called before any joysticks are opened.
268 *
269 * \param instance_id the joystick instance ID.
270 * \returns the GUID of the selected joystick. If called with an invalid
271 * instance_id, this function returns a zero GUID.
272 *
273 * \since This function is available since SDL 3.0.0.
274 *
275 * \sa SDL_GetJoystickGUID
276 * \sa SDL_GUIDToString
277 */
278extern SDL_DECLSPEC SDL_GUID SDLCALL SDL_GetJoystickGUIDForID(SDL_JoystickID instance_id);
279
280/**
281 * Get the USB vendor ID of a joystick, if available.
282 *
283 * This can be called before any joysticks are opened. If the vendor ID isn't
284 * available this function returns 0.
285 *
286 * \param instance_id the joystick instance ID.
287 * \returns the USB vendor ID of the selected joystick. If called with an
288 * invalid instance_id, this function returns 0.
289 *
290 * \since This function is available since SDL 3.0.0.
291 *
292 * \sa SDL_GetJoystickVendor
293 * \sa SDL_GetJoysticks
294 */
295extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickVendorForID(SDL_JoystickID instance_id);
296
297/**
298 * Get the USB product ID of a joystick, if available.
299 *
300 * This can be called before any joysticks are opened. If the product ID isn't
301 * available this function returns 0.
302 *
303 * \param instance_id the joystick instance ID.
304 * \returns the USB product ID of the selected joystick. If called with an
305 * invalid instance_id, this function returns 0.
306 *
307 * \since This function is available since SDL 3.0.0.
308 *
309 * \sa SDL_GetJoystickProduct
310 * \sa SDL_GetJoysticks
311 */
312extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickProductForID(SDL_JoystickID instance_id);
313
314/**
315 * Get the product version of a joystick, if available.
316 *
317 * This can be called before any joysticks are opened. If the product version
318 * isn't available this function returns 0.
319 *
320 * \param instance_id the joystick instance ID.
321 * \returns the product version of the selected joystick. If called with an
322 * invalid instance_id, this function returns 0.
323 *
324 * \since This function is available since SDL 3.0.0.
325 *
326 * \sa SDL_GetJoystickProductVersion
327 * \sa SDL_GetJoysticks
328 */
329extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickProductVersionForID(SDL_JoystickID instance_id);
330
331/**
332 * Get the type of a joystick, if available.
333 *
334 * This can be called before any joysticks are opened.
335 *
336 * \param instance_id the joystick instance ID.
337 * \returns the SDL_JoystickType of the selected joystick. If called with an
338 * invalid instance_id, this function returns
339 * `SDL_JOYSTICK_TYPE_UNKNOWN`.
340 *
341 * \since This function is available since SDL 3.0.0.
342 *
343 * \sa SDL_GetJoystickType
344 * \sa SDL_GetJoysticks
345 */
346extern SDL_DECLSPEC SDL_JoystickType SDLCALL SDL_GetJoystickTypeForID(SDL_JoystickID instance_id);
347
348/**
349 * Open a joystick for use.
350 *
351 * The joystick subsystem must be initialized before a joystick can be opened
352 * for use.
353 *
354 * \param instance_id the joystick instance ID.
355 * \returns a joystick identifier or NULL on failure; call SDL_GetError() for
356 * more information.
357 *
358 * \since This function is available since SDL 3.0.0.
359 *
360 * \sa SDL_CloseJoystick
361 */
362extern SDL_DECLSPEC SDL_Joystick * SDLCALL SDL_OpenJoystick(SDL_JoystickID instance_id);
363
364/**
365 * Get the SDL_Joystick associated with an instance ID, if it has been opened.
366 *
367 * \param instance_id the instance ID to get the SDL_Joystick for.
368 * \returns an SDL_Joystick on success or NULL on failure or if it hasn't been
369 * opened yet; call SDL_GetError() for more information.
370 *
371 * \since This function is available since SDL 3.0.0.
372 */
373extern SDL_DECLSPEC SDL_Joystick * SDLCALL SDL_GetJoystickFromID(SDL_JoystickID instance_id);
374
375/**
376 * Get the SDL_Joystick associated with a player index.
377 *
378 * \param player_index the player index to get the SDL_Joystick for.
379 * \returns an SDL_Joystick on success or NULL on failure; call SDL_GetError()
380 * for more information.
381 *
382 * \since This function is available since SDL 3.0.0.
383 *
384 * \sa SDL_GetJoystickPlayerIndex
385 * \sa SDL_SetJoystickPlayerIndex
386 */
387extern SDL_DECLSPEC SDL_Joystick * SDLCALL SDL_GetJoystickFromPlayerIndex(int player_index);
388
389/**
390 * The structure that describes a virtual joystick touchpad.
391 *
392 * \since This struct is available since SDL 3.0.0.
393 *
394 * \sa SDL_VirtualJoystickDesc
395 */
397{
398 Uint16 nfingers; /**< the number of simultaneous fingers on this touchpad */
401
402/**
403 * The structure that describes a virtual joystick sensor.
404 *
405 * \since This struct is available since SDL 3.0.0.
406 *
407 * \sa SDL_VirtualJoystickDesc
408 */
410{
411 SDL_SensorType type; /**< the type of this sensor */
412 float rate; /**< the update frequency of this sensor, may be 0.0f */
414
415/**
416 * The structure that describes a virtual joystick.
417 *
418 * All elements of this structure are optional and can be left 0.
419 *
420 * \since This struct is available since SDL 3.0.0.
421 *
422 * \sa SDL_AttachVirtualJoystick
423 * \sa SDL_VirtualJoystickSensorDesc
424 * \sa SDL_VirtualJoystickTouchpadDesc
425 */
427{
428 Uint16 type; /**< `SDL_JoystickType` */
429 Uint16 padding; /**< unused */
430 Uint16 vendor_id; /**< the USB vendor ID of this joystick */
431 Uint16 product_id; /**< the USB product ID of this joystick */
432 Uint16 naxes; /**< the number of axes on this joystick */
433 Uint16 nbuttons; /**< the number of buttons on this joystick */
434 Uint16 nballs; /**< the number of balls on this joystick */
435 Uint16 nhats; /**< the number of hats on this joystick */
436 Uint16 ntouchpads; /**< the number of touchpads on this joystick, requires `touchpads` to point at valid descriptions */
437 Uint16 nsensors; /**< the number of sensors on this joystick, requires `sensors` to point at valid descriptions */
438 Uint16 padding2[2]; /**< unused */
439 Uint32 button_mask; /**< A mask of which buttons are valid for this controller
440 e.g. (1 << SDL_GAMEPAD_BUTTON_SOUTH) */
441 Uint32 axis_mask; /**< A mask of which axes are valid for this controller
442 e.g. (1 << SDL_GAMEPAD_AXIS_LEFTX) */
443 const char *name; /**< the name of the joystick */
444 const SDL_VirtualJoystickTouchpadDesc *touchpads; /**< A pointer to an array of touchpad descriptions, required if `ntouchpads` is > 0 */
445 const SDL_VirtualJoystickSensorDesc *sensors; /**< A pointer to an array of sensor descriptions, required if `nsensors` is > 0 */
446
447 void *userdata; /**< User data pointer passed to callbacks */
448 void (SDLCALL *Update)(void *userdata); /**< Called when the joystick state should be updated */
449 void (SDLCALL *SetPlayerIndex)(void *userdata, int player_index); /**< Called when the player index is set */
450 int (SDLCALL *Rumble)(void *userdata, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble); /**< Implements SDL_RumbleJoystick() */
451 int (SDLCALL *RumbleTriggers)(void *userdata, Uint16 left_rumble, Uint16 right_rumble); /**< Implements SDL_RumbleJoystickTriggers() */
452 int (SDLCALL *SetLED)(void *userdata, Uint8 red, Uint8 green, Uint8 blue); /**< Implements SDL_SetJoystickLED() */
453 int (SDLCALL *SendEffect)(void *userdata, const void *data, int size); /**< Implements SDL_SendJoystickEffect() */
454 int (SDLCALL *SetSensorsEnabled)(void *userdata, SDL_bool enabled); /**< Implements SDL_SetGamepadSensorEnabled() */
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 0 on success or a negative error code on failure; call
476 * SDL_GetError() for more information.
477 *
478 * \since This function is available since SDL 3.0.0.
479 *
480 * \sa SDL_AttachVirtualJoystick
481 */
482extern SDL_DECLSPEC int 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 0 on success or a negative error code on failure; call
511 * SDL_GetError() for more information.
512 *
513 * \since This function is available since SDL 3.0.0.
514 */
515extern SDL_DECLSPEC int 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 0 on success or a negative error code on failure; call
531 * SDL_GetError() for more information.
532 *
533 * \since This function is available since SDL 3.0.0.
534 */
535extern SDL_DECLSPEC int 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 0 on success or a negative error code on failure; call
550 * SDL_GetError() for more information.
551 *
552 * \since This function is available since SDL 3.0.0.
553 */
554extern SDL_DECLSPEC int 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 0 on success or a negative error code on failure; call
569 * SDL_GetError() for more information.
570 *
571 * \since This function is available since SDL 3.0.0.
572 */
573extern SDL_DECLSPEC int 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 0 on success or a negative error code on failure; call
596 * SDL_GetError() for more information.
597 *
598 * \since This function is available since SDL 3.0.0.
599 */
600extern SDL_DECLSPEC int 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 0 on success or a negative error code on failure; call
618 * SDL_GetError() for more information.
619 *
620 * \since This function is available since SDL 3.0.0.
621 */
622extern SDL_DECLSPEC int 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 0 on success or a negative error code on failure; call
702 * SDL_GetError() for more information.
703 *
704 * \since This function is available since SDL 3.0.0.
705 *
706 * \sa SDL_GetJoystickPlayerIndex
707 */
708extern SDL_DECLSPEC int 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 a
857 * negative error code on failure; call SDL_GetError() for more
858 * information.
859 *
860 * \since This function is available since SDL 3.0.0.
861 *
862 * \sa SDL_GetJoystickAxis
863 * \sa SDL_GetNumJoystickBalls
864 * \sa SDL_GetNumJoystickButtons
865 * \sa SDL_GetNumJoystickHats
866 */
867extern SDL_DECLSPEC int SDLCALL SDL_GetNumJoystickAxes(SDL_Joystick *joystick);
868
869/**
870 * Get the number of trackballs on a joystick.
871 *
872 * Joystick trackballs have only relative motion events associated with them
873 * and their state cannot be polled.
874 *
875 * Most joysticks do not have trackballs.
876 *
877 * \param joystick an SDL_Joystick structure containing joystick information.
878 * \returns the number of trackballs on success or a negative error code on
879 * failure; call SDL_GetError() for more information.
880 *
881 * \since This function is available since SDL 3.0.0.
882 *
883 * \sa SDL_GetJoystickBall
884 * \sa SDL_GetNumJoystickAxes
885 * \sa SDL_GetNumJoystickButtons
886 * \sa SDL_GetNumJoystickHats
887 */
888extern SDL_DECLSPEC int SDLCALL SDL_GetNumJoystickBalls(SDL_Joystick *joystick);
889
890/**
891 * Get the number of POV hats on a joystick.
892 *
893 * \param joystick an SDL_Joystick structure containing joystick information.
894 * \returns the number of POV hats on success or a negative error code on
895 * failure; call SDL_GetError() for more information.
896 *
897 * \since This function is available since SDL 3.0.0.
898 *
899 * \sa SDL_GetJoystickHat
900 * \sa SDL_GetNumJoystickAxes
901 * \sa SDL_GetNumJoystickBalls
902 * \sa SDL_GetNumJoystickButtons
903 */
904extern SDL_DECLSPEC int SDLCALL SDL_GetNumJoystickHats(SDL_Joystick *joystick);
905
906/**
907 * Get the number of buttons on a joystick.
908 *
909 * \param joystick an SDL_Joystick structure containing joystick information.
910 * \returns the number of buttons on success or a negative error code on
911 * failure; call SDL_GetError() for more information.
912 *
913 * \since This function is available since SDL 3.0.0.
914 *
915 * \sa SDL_GetJoystickButton
916 * \sa SDL_GetNumJoystickAxes
917 * \sa SDL_GetNumJoystickBalls
918 * \sa SDL_GetNumJoystickHats
919 */
920extern SDL_DECLSPEC int SDLCALL SDL_GetNumJoystickButtons(SDL_Joystick *joystick);
921
922/**
923 * Set the state of joystick event processing.
924 *
925 * If joystick events are disabled, you must call SDL_UpdateJoysticks()
926 * yourself and check the state of the joystick when you want joystick
927 * information.
928 *
929 * \param enabled whether to process joystick events or not.
930 *
931 * \since This function is available since SDL 3.0.0.
932 *
933 * \sa SDL_JoystickEventsEnabled
934 * \sa SDL_UpdateJoysticks
935 */
936extern SDL_DECLSPEC void SDLCALL SDL_SetJoystickEventsEnabled(SDL_bool enabled);
937
938/**
939 * Query the state of joystick event processing.
940 *
941 * If joystick events are disabled, you must call SDL_UpdateJoysticks()
942 * yourself and check the state of the joystick when you want joystick
943 * information.
944 *
945 * \returns SDL_TRUE if joystick events are being processed, SDL_FALSE
946 * otherwise.
947 *
948 * \since This function is available since SDL 3.0.0.
949 *
950 * \sa SDL_SetJoystickEventsEnabled
951 */
952extern SDL_DECLSPEC SDL_bool SDLCALL SDL_JoystickEventsEnabled(void);
953
954/**
955 * Update the current state of the open joysticks.
956 *
957 * This is called automatically by the event loop if any joystick events are
958 * enabled.
959 *
960 * \since This function is available since SDL 3.0.0.
961 */
962extern SDL_DECLSPEC void SDLCALL SDL_UpdateJoysticks(void);
963
964/**
965 * Get the current state of an axis control on a joystick.
966 *
967 * SDL makes no promises about what part of the joystick any given axis refers
968 * to. Your game should have some sort of configuration UI to let users
969 * specify what each axis should be bound to. Alternately, SDL's higher-level
970 * Game Controller API makes a great effort to apply order to this lower-level
971 * interface, so you know that a specific axis is the "left thumb stick," etc.
972 *
973 * The value returned by SDL_GetJoystickAxis() is a signed integer (-32768 to
974 * 32767) representing the current position of the axis. It may be necessary
975 * to impose certain tolerances on these values to account for jitter.
976 *
977 * \param joystick an SDL_Joystick structure containing joystick information.
978 * \param axis the axis to query; the axis indices start at index 0.
979 * \returns a 16-bit signed integer representing the current position of the
980 * axis or 0 on failure; call SDL_GetError() for more information.
981 *
982 * \since This function is available since SDL 3.0.0.
983 *
984 * \sa SDL_GetNumJoystickAxes
985 */
986extern SDL_DECLSPEC Sint16 SDLCALL SDL_GetJoystickAxis(SDL_Joystick *joystick, int axis);
987
988/**
989 * Get the initial state of an axis control on a joystick.
990 *
991 * The state is a value ranging from -32768 to 32767.
992 *
993 * The axis indices start at index 0.
994 *
995 * \param joystick an SDL_Joystick structure containing joystick information.
996 * \param axis the axis to query; the axis indices start at index 0.
997 * \param state upon return, the initial value is supplied here.
998 * \returns SDL_TRUE if this axis has any initial value, or SDL_FALSE if not.
999 *
1000 * \since This function is available since SDL 3.0.0.
1001 */
1002extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetJoystickAxisInitialState(SDL_Joystick *joystick, int axis, Sint16 *state);
1003
1004/**
1005 * Get the ball axis change since the last poll.
1006 *
1007 * Trackballs can only return relative motion since the last call to
1008 * SDL_GetJoystickBall(), these motion deltas are placed into `dx` and `dy`.
1009 *
1010 * Most joysticks do not have trackballs.
1011 *
1012 * \param joystick the SDL_Joystick to query.
1013 * \param ball the ball index to query; ball indices start at index 0.
1014 * \param dx stores the difference in the x axis position since the last poll.
1015 * \param dy stores the difference in the y axis position since the last poll.
1016 * \returns 0 on success or a negative error code on failure; call
1017 * SDL_GetError() for more information.
1018 *
1019 * \since This function is available since SDL 3.0.0.
1020 *
1021 * \sa SDL_GetNumJoystickBalls
1022 */
1023extern SDL_DECLSPEC int SDLCALL SDL_GetJoystickBall(SDL_Joystick *joystick, int ball, int *dx, int *dy);
1024
1025/**
1026 * Get the current state of a POV hat on a joystick.
1027 *
1028 * The returned value will be one of the `SDL_HAT_*` values.
1029 *
1030 * \param joystick an SDL_Joystick structure containing joystick information.
1031 * \param hat the hat index to get the state from; indices start at index 0.
1032 * \returns the current hat position.
1033 *
1034 * \since This function is available since SDL 3.0.0.
1035 *
1036 * \sa SDL_GetNumJoystickHats
1037 */
1038extern SDL_DECLSPEC Uint8 SDLCALL SDL_GetJoystickHat(SDL_Joystick *joystick, int hat);
1039
1040#define SDL_HAT_CENTERED 0x00u
1041#define SDL_HAT_UP 0x01u
1042#define SDL_HAT_RIGHT 0x02u
1043#define SDL_HAT_DOWN 0x04u
1044#define SDL_HAT_LEFT 0x08u
1045#define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP)
1046#define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN)
1047#define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP)
1048#define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN)
1049
1050/**
1051 * Get the current state of a button on a joystick.
1052 *
1053 * \param joystick an SDL_Joystick structure containing joystick information.
1054 * \param button the button index to get the state from; indices start at
1055 * index 0.
1056 * \returns 1 if the specified button is pressed, 0 otherwise.
1057 *
1058 * \since This function is available since SDL 3.0.0.
1059 *
1060 * \sa SDL_GetNumJoystickButtons
1061 */
1062extern SDL_DECLSPEC Uint8 SDLCALL SDL_GetJoystickButton(SDL_Joystick *joystick, int button);
1063
1064/**
1065 * Start a rumble effect.
1066 *
1067 * Each call to this function cancels any previous rumble effect, and calling
1068 * it with 0 intensity stops any rumbling.
1069 *
1070 * This function requires you to process SDL events or call
1071 * SDL_UpdateJoysticks() to update rumble state.
1072 *
1073 * \param joystick the joystick to vibrate.
1074 * \param low_frequency_rumble the intensity of the low frequency (left)
1075 * rumble motor, from 0 to 0xFFFF.
1076 * \param high_frequency_rumble the intensity of the high frequency (right)
1077 * rumble motor, from 0 to 0xFFFF.
1078 * \param duration_ms the duration of the rumble effect, in milliseconds.
1079 * \returns 0, or -1 if rumble isn't supported on this joystick.
1080 *
1081 * \since This function is available since SDL 3.0.0.
1082 */
1083extern SDL_DECLSPEC int SDLCALL SDL_RumbleJoystick(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
1084
1085/**
1086 * Start a rumble effect in the joystick's triggers.
1087 *
1088 * Each call to this function cancels any previous trigger rumble effect, and
1089 * calling it with 0 intensity stops any rumbling.
1090 *
1091 * Note that this is rumbling of the _triggers_ and not the game controller as
1092 * a whole. This is currently only supported on Xbox One controllers. If you
1093 * want the (more common) whole-controller rumble, use SDL_RumbleJoystick()
1094 * instead.
1095 *
1096 * This function requires you to process SDL events or call
1097 * SDL_UpdateJoysticks() to update rumble state.
1098 *
1099 * \param joystick the joystick to vibrate.
1100 * \param left_rumble the intensity of the left trigger rumble motor, from 0
1101 * to 0xFFFF.
1102 * \param right_rumble the intensity of the right trigger rumble motor, from 0
1103 * to 0xFFFF.
1104 * \param duration_ms the duration of the rumble effect, in milliseconds.
1105 * \returns 0 on success or a negative error code on failure; call
1106 * SDL_GetError() for more information.
1107 *
1108 * \since This function is available since SDL 3.0.0.
1109 *
1110 * \sa SDL_RumbleJoystick
1111 */
1112extern SDL_DECLSPEC int SDLCALL SDL_RumbleJoystickTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
1113
1114/**
1115 * Update a joystick's LED color.
1116 *
1117 * An example of a joystick LED is the light on the back of a PlayStation 4's
1118 * DualShock 4 controller.
1119 *
1120 * For joysticks with a single color LED, the maximum of the RGB values will
1121 * be used as the LED brightness.
1122 *
1123 * \param joystick the joystick to update.
1124 * \param red the intensity of the red LED.
1125 * \param green the intensity of the green LED.
1126 * \param blue the intensity of the blue LED.
1127 * \returns 0 on success or a negative error code on failure; call
1128 * SDL_GetError() for more information.
1129 *
1130 * \since This function is available since SDL 3.0.0.
1131 */
1132extern SDL_DECLSPEC int SDLCALL SDL_SetJoystickLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue);
1133
1134/**
1135 * Send a joystick specific effect packet.
1136 *
1137 * \param joystick the joystick to affect.
1138 * \param data the data to send to the joystick.
1139 * \param size the size of the data to send to the joystick.
1140 * \returns 0 on success or a negative error code on failure; call
1141 * SDL_GetError() for more information.
1142 *
1143 * \since This function is available since SDL 3.0.0.
1144 */
1145extern SDL_DECLSPEC int SDLCALL SDL_SendJoystickEffect(SDL_Joystick *joystick, const void *data, int size);
1146
1147/**
1148 * Close a joystick previously opened with SDL_OpenJoystick().
1149 *
1150 * \param joystick the joystick device to close.
1151 *
1152 * \since This function is available since SDL 3.0.0.
1153 *
1154 * \sa SDL_OpenJoystick
1155 */
1156extern SDL_DECLSPEC void SDLCALL SDL_CloseJoystick(SDL_Joystick *joystick);
1157
1158/**
1159 * Get the connection state of a joystick.
1160 *
1161 * \param joystick the joystick to query.
1162 * \returns the connection state on success or
1163 * `SDL_JOYSTICK_CONNECTION_INVALID` on failure; call SDL_GetError()
1164 * for more information.
1165 *
1166 * \since This function is available since SDL 3.0.0.
1167 */
1169
1170/**
1171 * Get the battery state of a joystick.
1172 *
1173 * You should never take a battery status as absolute truth. Batteries
1174 * (especially failing batteries) are delicate hardware, and the values
1175 * reported here are best estimates based on what that hardware reports. It's
1176 * not uncommon for older batteries to lose stored power much faster than it
1177 * reports, or completely drain when reporting it has 20 percent left, etc.
1178 *
1179 * \param joystick the joystick to query.
1180 * \param percent a pointer filled in with the percentage of battery life
1181 * left, between 0 and 100, or NULL to ignore. This will be
1182 * filled in with -1 we can't determine a value or there is no
1183 * battery.
1184 * \returns the current battery state or `SDL_POWERSTATE_ERROR` on failure;
1185 * call SDL_GetError() for more information.
1186 *
1187 * \since This function is available since SDL 3.0.0.
1188 */
1189extern SDL_DECLSPEC SDL_PowerState SDLCALL SDL_GetJoystickPowerInfo(SDL_Joystick *joystick, int *percent);
1190
1191/* Ends C function definitions when using C++ */
1192#ifdef __cplusplus
1193}
1194#endif
1195#include <SDL3/SDL_close_code.h>
1196
1197#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)
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_PowerState SDL_GetJoystickPowerInfo(SDL_Joystick *joystick, int *percent)
SDL_JoystickID * SDL_GetJoysticks(int *count)
int SDL_SetJoystickVirtualButton(SDL_Joystick *joystick, int button, Uint8 value)
const char * SDL_GetJoystickPathForID(SDL_JoystickID instance_id)
Uint16 SDL_GetJoystickProductForID(SDL_JoystickID instance_id)
Uint16 SDL_GetJoystickProductVersion(SDL_Joystick *joystick)
const char * SDL_GetJoystickPath(SDL_Joystick *joystick)
SDL_JoystickID SDL_AttachVirtualJoystick(const SDL_VirtualJoystickDesc *desc)
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)
SDL_JoystickID SDL_GetJoystickID(SDL_Joystick *joystick)
int SDL_SetJoystickVirtualBall(SDL_Joystick *joystick, int ball, Sint16 xrel, Sint16 yrel)
void SDL_SetJoystickEventsEnabled(SDL_bool enabled)
int SDL_SetJoystickVirtualHat(SDL_Joystick *joystick, int hat, Uint8 value)
int SDL_GetJoystickPlayerIndexForID(SDL_JoystickID instance_id)
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_GUID SDL_GetJoystickGUID(SDL_Joystick *joystick)
SDL_PropertiesID SDL_GetJoystickProperties(SDL_Joystick *joystick)
int SDL_GetJoystickBall(SDL_Joystick *joystick, int ball, int *dx, int *dy)
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)
int SDL_GetNumJoystickBalls(SDL_Joystick *joystick)
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)
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_JoystickType SDL_GetJoystickTypeForID(SDL_JoystickID instance_id)
int SDL_SetJoystickPlayerIndex(SDL_Joystick *joystick, int player_index)
const char * SDL_GetJoystickSerial(SDL_Joystick *joystick)
int SDL_SendJoystickVirtualSensorData(SDL_Joystick *joystick, SDL_SensorType type, Uint64 sensor_timestamp, const float *data, int num_values)
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)
int SDL_SetJoystickVirtualTouchpad(SDL_Joystick *joystick, int touchpad, int finger, Uint8 state, float x, float y, float pressure)
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)
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:145
#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:132
uint8_t Uint8
Definition SDL_stdinc.h:229
uint16_t Uint16
Definition SDL_stdinc.h:247
SDL_MALLOC size_t size
Definition SDL_stdinc.h:531
int SDL_bool
Definition SDL_stdinc.h:213
int16_t Sint16
Definition SDL_stdinc.h:238
uint64_t Uint64
Definition SDL_stdinc.h:287
uint32_t Uint32
Definition SDL_stdinc.h:265
const SDL_VirtualJoystickTouchpadDesc * touchpads
void(* SetPlayerIndex)(void *userdata, int player_index)
const SDL_VirtualJoystickSensorDesc * sensors
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(* SetSensorsEnabled)(void *userdata, SDL_bool enabled)
int(* Rumble)(void *userdata, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)