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