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