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,1074 @@
|
|
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_gamecontroller.h
|
24
|
+
*
|
25
|
+
* Include file for SDL game controller event handling
|
26
|
+
*/
|
27
|
+
|
28
|
+
#ifndef SDL_gamecontroller_h_
|
29
|
+
#define SDL_gamecontroller_h_
|
30
|
+
|
31
|
+
#include "SDL_stdinc.h"
|
32
|
+
#include "SDL_error.h"
|
33
|
+
#include "SDL_rwops.h"
|
34
|
+
#include "SDL_sensor.h"
|
35
|
+
#include "SDL_joystick.h"
|
36
|
+
|
37
|
+
#include "begin_code.h"
|
38
|
+
/* Set up for C function definitions, even when using C++ */
|
39
|
+
#ifdef __cplusplus
|
40
|
+
extern "C" {
|
41
|
+
#endif
|
42
|
+
|
43
|
+
/**
|
44
|
+
* \file SDL_gamecontroller.h
|
45
|
+
*
|
46
|
+
* In order to use these functions, SDL_Init() must have been called
|
47
|
+
* with the ::SDL_INIT_GAMECONTROLLER flag. This causes SDL to scan the system
|
48
|
+
* for game controllers, and load appropriate drivers.
|
49
|
+
*
|
50
|
+
* If you would like to receive controller updates while the application
|
51
|
+
* is in the background, you should set the following hint before calling
|
52
|
+
* SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS
|
53
|
+
*/
|
54
|
+
|
55
|
+
/**
|
56
|
+
* The gamecontroller structure used to identify an SDL game controller
|
57
|
+
*/
|
58
|
+
struct _SDL_GameController;
|
59
|
+
typedef struct _SDL_GameController SDL_GameController;
|
60
|
+
|
61
|
+
typedef enum
|
62
|
+
{
|
63
|
+
SDL_CONTROLLER_TYPE_UNKNOWN = 0,
|
64
|
+
SDL_CONTROLLER_TYPE_XBOX360,
|
65
|
+
SDL_CONTROLLER_TYPE_XBOXONE,
|
66
|
+
SDL_CONTROLLER_TYPE_PS3,
|
67
|
+
SDL_CONTROLLER_TYPE_PS4,
|
68
|
+
SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO,
|
69
|
+
SDL_CONTROLLER_TYPE_VIRTUAL,
|
70
|
+
SDL_CONTROLLER_TYPE_PS5,
|
71
|
+
SDL_CONTROLLER_TYPE_AMAZON_LUNA,
|
72
|
+
SDL_CONTROLLER_TYPE_GOOGLE_STADIA,
|
73
|
+
SDL_CONTROLLER_TYPE_NVIDIA_SHIELD,
|
74
|
+
SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT,
|
75
|
+
SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT,
|
76
|
+
SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR
|
77
|
+
} SDL_GameControllerType;
|
78
|
+
|
79
|
+
typedef enum
|
80
|
+
{
|
81
|
+
SDL_CONTROLLER_BINDTYPE_NONE = 0,
|
82
|
+
SDL_CONTROLLER_BINDTYPE_BUTTON,
|
83
|
+
SDL_CONTROLLER_BINDTYPE_AXIS,
|
84
|
+
SDL_CONTROLLER_BINDTYPE_HAT
|
85
|
+
} SDL_GameControllerBindType;
|
86
|
+
|
87
|
+
/**
|
88
|
+
* Get the SDL joystick layer binding for this controller button/axis mapping
|
89
|
+
*/
|
90
|
+
typedef struct SDL_GameControllerButtonBind
|
91
|
+
{
|
92
|
+
SDL_GameControllerBindType bindType;
|
93
|
+
union
|
94
|
+
{
|
95
|
+
int button;
|
96
|
+
int axis;
|
97
|
+
struct {
|
98
|
+
int hat;
|
99
|
+
int hat_mask;
|
100
|
+
} hat;
|
101
|
+
} value;
|
102
|
+
|
103
|
+
} SDL_GameControllerButtonBind;
|
104
|
+
|
105
|
+
|
106
|
+
/**
|
107
|
+
* To count the number of game controllers in the system for the following:
|
108
|
+
*
|
109
|
+
* ```c
|
110
|
+
* int nJoysticks = SDL_NumJoysticks();
|
111
|
+
* int nGameControllers = 0;
|
112
|
+
* for (int i = 0; i < nJoysticks; i++) {
|
113
|
+
* if (SDL_IsGameController(i)) {
|
114
|
+
* nGameControllers++;
|
115
|
+
* }
|
116
|
+
* }
|
117
|
+
* ```
|
118
|
+
*
|
119
|
+
* Using the SDL_HINT_GAMECONTROLLERCONFIG hint or the SDL_GameControllerAddMapping() you can add support for controllers SDL is unaware of or cause an existing controller to have a different binding. The format is:
|
120
|
+
* guid,name,mappings
|
121
|
+
*
|
122
|
+
* Where GUID is the string value from SDL_JoystickGetGUIDString(), name is the human readable string for the device and mappings are controller mappings to joystick ones.
|
123
|
+
* Under Windows there is a reserved GUID of "xinput" that covers any XInput devices.
|
124
|
+
* The mapping format for joystick is:
|
125
|
+
* bX - a joystick button, index X
|
126
|
+
* hX.Y - hat X with value Y
|
127
|
+
* aX - axis X of the joystick
|
128
|
+
* Buttons can be used as a controller axis and vice versa.
|
129
|
+
*
|
130
|
+
* This string shows an example of a valid mapping for a controller
|
131
|
+
*
|
132
|
+
* ```c
|
133
|
+
* "03000000341a00003608000000000000,PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7",
|
134
|
+
* ```
|
135
|
+
*/
|
136
|
+
|
137
|
+
/**
|
138
|
+
* Load a set of Game Controller mappings from a seekable SDL data stream.
|
139
|
+
*
|
140
|
+
* You can call this function several times, if needed, to load different
|
141
|
+
* database files.
|
142
|
+
*
|
143
|
+
* If a new mapping is loaded for an already known controller GUID, the later
|
144
|
+
* version will overwrite the one currently loaded.
|
145
|
+
*
|
146
|
+
* Mappings not belonging to the current platform or with no platform field
|
147
|
+
* specified will be ignored (i.e. mappings for Linux will be ignored in
|
148
|
+
* Windows, etc).
|
149
|
+
*
|
150
|
+
* This function will load the text database entirely in memory before
|
151
|
+
* processing it, so take this into consideration if you are in a memory
|
152
|
+
* constrained environment.
|
153
|
+
*
|
154
|
+
* \param rw the data stream for the mappings to be added
|
155
|
+
* \param freerw non-zero to close the stream after being read
|
156
|
+
* \returns the number of mappings added or -1 on error; call SDL_GetError()
|
157
|
+
* for more information.
|
158
|
+
*
|
159
|
+
* \since This function is available since SDL 2.0.2.
|
160
|
+
*
|
161
|
+
* \sa SDL_GameControllerAddMapping
|
162
|
+
* \sa SDL_GameControllerAddMappingsFromFile
|
163
|
+
* \sa SDL_GameControllerMappingForGUID
|
164
|
+
*/
|
165
|
+
extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw, int freerw);
|
166
|
+
|
167
|
+
/**
|
168
|
+
* Load a set of mappings from a file, filtered by the current SDL_GetPlatform()
|
169
|
+
*
|
170
|
+
* Convenience macro.
|
171
|
+
*/
|
172
|
+
#define SDL_GameControllerAddMappingsFromFile(file) SDL_GameControllerAddMappingsFromRW(SDL_RWFromFile(file, "rb"), 1)
|
173
|
+
|
174
|
+
/**
|
175
|
+
* Add support for controllers that SDL is unaware of or to cause an existing
|
176
|
+
* controller to have a different binding.
|
177
|
+
*
|
178
|
+
* The mapping string has the format "GUID,name,mapping", where GUID is the
|
179
|
+
* string value from SDL_JoystickGetGUIDString(), name is the human readable
|
180
|
+
* string for the device and mappings are controller mappings to joystick
|
181
|
+
* ones. Under Windows there is a reserved GUID of "xinput" that covers all
|
182
|
+
* XInput devices. The mapping format for joystick is: {| |bX |a joystick
|
183
|
+
* button, index X |- |hX.Y |hat X with value Y |- |aX |axis X of the joystick
|
184
|
+
* |} Buttons can be used as a controller axes and vice versa.
|
185
|
+
*
|
186
|
+
* This string shows an example of a valid mapping for a controller:
|
187
|
+
*
|
188
|
+
* ```c
|
189
|
+
* "341a3608000000000000504944564944,Afterglow PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7"
|
190
|
+
* ```
|
191
|
+
*
|
192
|
+
* \param mappingString the mapping string
|
193
|
+
* \returns 1 if a new mapping is added, 0 if an existing mapping is updated,
|
194
|
+
* -1 on error; call SDL_GetError() for more information.
|
195
|
+
*
|
196
|
+
* \since This function is available since SDL 2.0.0.
|
197
|
+
*
|
198
|
+
* \sa SDL_GameControllerMapping
|
199
|
+
* \sa SDL_GameControllerMappingForGUID
|
200
|
+
*/
|
201
|
+
extern DECLSPEC int SDLCALL SDL_GameControllerAddMapping(const char* mappingString);
|
202
|
+
|
203
|
+
/**
|
204
|
+
* Get the number of mappings installed.
|
205
|
+
*
|
206
|
+
* \returns the number of mappings.
|
207
|
+
*
|
208
|
+
* \since This function is available since SDL 2.0.6.
|
209
|
+
*/
|
210
|
+
extern DECLSPEC int SDLCALL SDL_GameControllerNumMappings(void);
|
211
|
+
|
212
|
+
/**
|
213
|
+
* Get the mapping at a particular index.
|
214
|
+
*
|
215
|
+
* \returns the mapping string. Must be freed with SDL_free(). Returns NULL if
|
216
|
+
* the index is out of range.
|
217
|
+
*
|
218
|
+
* \since This function is available since SDL 2.0.6.
|
219
|
+
*/
|
220
|
+
extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForIndex(int mapping_index);
|
221
|
+
|
222
|
+
/**
|
223
|
+
* Get the game controller mapping string for a given GUID.
|
224
|
+
*
|
225
|
+
* The returned string must be freed with SDL_free().
|
226
|
+
*
|
227
|
+
* \param guid a structure containing the GUID for which a mapping is desired
|
228
|
+
* \returns a mapping string or NULL on error; call SDL_GetError() for more
|
229
|
+
* information.
|
230
|
+
*
|
231
|
+
* \since This function is available since SDL 2.0.0.
|
232
|
+
*
|
233
|
+
* \sa SDL_JoystickGetDeviceGUID
|
234
|
+
* \sa SDL_JoystickGetGUID
|
235
|
+
*/
|
236
|
+
extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForGUID(SDL_JoystickGUID guid);
|
237
|
+
|
238
|
+
/**
|
239
|
+
* Get the current mapping of a Game Controller.
|
240
|
+
*
|
241
|
+
* The returned string must be freed with SDL_free().
|
242
|
+
*
|
243
|
+
* Details about mappings are discussed with SDL_GameControllerAddMapping().
|
244
|
+
*
|
245
|
+
* \param gamecontroller the game controller you want to get the current
|
246
|
+
* mapping for
|
247
|
+
* \returns a string that has the controller's mapping or NULL if no mapping
|
248
|
+
* is available; call SDL_GetError() for more information.
|
249
|
+
*
|
250
|
+
* \since This function is available since SDL 2.0.0.
|
251
|
+
*
|
252
|
+
* \sa SDL_GameControllerAddMapping
|
253
|
+
* \sa SDL_GameControllerMappingForGUID
|
254
|
+
*/
|
255
|
+
extern DECLSPEC char * SDLCALL SDL_GameControllerMapping(SDL_GameController *gamecontroller);
|
256
|
+
|
257
|
+
/**
|
258
|
+
* Check if the given joystick is supported by the game controller interface.
|
259
|
+
*
|
260
|
+
* `joystick_index` is the same as the `device_index` passed to
|
261
|
+
* SDL_JoystickOpen().
|
262
|
+
*
|
263
|
+
* \param joystick_index the device_index of a device, up to
|
264
|
+
* SDL_NumJoysticks()
|
265
|
+
* \returns SDL_TRUE if the given joystick is supported by the game controller
|
266
|
+
* interface, SDL_FALSE if it isn't or it's an invalid index.
|
267
|
+
*
|
268
|
+
* \since This function is available since SDL 2.0.0.
|
269
|
+
*
|
270
|
+
* \sa SDL_GameControllerNameForIndex
|
271
|
+
* \sa SDL_GameControllerOpen
|
272
|
+
*/
|
273
|
+
extern DECLSPEC SDL_bool SDLCALL SDL_IsGameController(int joystick_index);
|
274
|
+
|
275
|
+
/**
|
276
|
+
* Get the implementation dependent name for the game controller.
|
277
|
+
*
|
278
|
+
* This function can be called before any controllers are opened.
|
279
|
+
*
|
280
|
+
* `joystick_index` is the same as the `device_index` passed to
|
281
|
+
* SDL_JoystickOpen().
|
282
|
+
*
|
283
|
+
* \param joystick_index the device_index of a device, from zero to
|
284
|
+
* SDL_NumJoysticks()-1
|
285
|
+
* \returns the implementation-dependent name for the game controller, or NULL
|
286
|
+
* if there is no name or the index is invalid.
|
287
|
+
*
|
288
|
+
* \since This function is available since SDL 2.0.0.
|
289
|
+
*
|
290
|
+
* \sa SDL_GameControllerName
|
291
|
+
* \sa SDL_GameControllerOpen
|
292
|
+
* \sa SDL_IsGameController
|
293
|
+
*/
|
294
|
+
extern DECLSPEC const char *SDLCALL SDL_GameControllerNameForIndex(int joystick_index);
|
295
|
+
|
296
|
+
/**
|
297
|
+
* Get the implementation dependent path for the game controller.
|
298
|
+
*
|
299
|
+
* This function can be called before any controllers are opened.
|
300
|
+
*
|
301
|
+
* `joystick_index` is the same as the `device_index` passed to
|
302
|
+
* SDL_JoystickOpen().
|
303
|
+
*
|
304
|
+
* \param joystick_index the device_index of a device, from zero to
|
305
|
+
* SDL_NumJoysticks()-1
|
306
|
+
* \returns the implementation-dependent path for the game controller, or NULL
|
307
|
+
* if there is no path or the index is invalid.
|
308
|
+
*
|
309
|
+
* \since This function is available since SDL 2.24.0.
|
310
|
+
*
|
311
|
+
* \sa SDL_GameControllerPath
|
312
|
+
*/
|
313
|
+
extern DECLSPEC const char *SDLCALL SDL_GameControllerPathForIndex(int joystick_index);
|
314
|
+
|
315
|
+
/**
|
316
|
+
* Get the type of a game controller.
|
317
|
+
*
|
318
|
+
* This can be called before any controllers are opened.
|
319
|
+
*
|
320
|
+
* \param joystick_index the device_index of a device, from zero to
|
321
|
+
* SDL_NumJoysticks()-1
|
322
|
+
* \returns the controller type.
|
323
|
+
*
|
324
|
+
* \since This function is available since SDL 2.0.12.
|
325
|
+
*/
|
326
|
+
extern DECLSPEC SDL_GameControllerType SDLCALL SDL_GameControllerTypeForIndex(int joystick_index);
|
327
|
+
|
328
|
+
/**
|
329
|
+
* Get the mapping of a game controller.
|
330
|
+
*
|
331
|
+
* This can be called before any controllers are opened.
|
332
|
+
*
|
333
|
+
* \param joystick_index the device_index of a device, from zero to
|
334
|
+
* SDL_NumJoysticks()-1
|
335
|
+
* \returns the mapping string. Must be freed with SDL_free(). Returns NULL if
|
336
|
+
* no mapping is available.
|
337
|
+
*
|
338
|
+
* \since This function is available since SDL 2.0.9.
|
339
|
+
*/
|
340
|
+
extern DECLSPEC char *SDLCALL SDL_GameControllerMappingForDeviceIndex(int joystick_index);
|
341
|
+
|
342
|
+
/**
|
343
|
+
* Open a game controller for use.
|
344
|
+
*
|
345
|
+
* `joystick_index` is the same as the `device_index` passed to
|
346
|
+
* SDL_JoystickOpen().
|
347
|
+
*
|
348
|
+
* The index passed as an argument refers to the N'th game controller on the
|
349
|
+
* system. This index is not the value which will identify this controller in
|
350
|
+
* future controller events. The joystick's instance id (SDL_JoystickID) will
|
351
|
+
* be used there instead.
|
352
|
+
*
|
353
|
+
* \param joystick_index the device_index of a device, up to
|
354
|
+
* SDL_NumJoysticks()
|
355
|
+
* \returns a gamecontroller identifier or NULL if an error occurred; call
|
356
|
+
* SDL_GetError() for more information.
|
357
|
+
*
|
358
|
+
* \since This function is available since SDL 2.0.0.
|
359
|
+
*
|
360
|
+
* \sa SDL_GameControllerClose
|
361
|
+
* \sa SDL_GameControllerNameForIndex
|
362
|
+
* \sa SDL_IsGameController
|
363
|
+
*/
|
364
|
+
extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerOpen(int joystick_index);
|
365
|
+
|
366
|
+
/**
|
367
|
+
* Get the SDL_GameController associated with an instance id.
|
368
|
+
*
|
369
|
+
* \param joyid the instance id to get the SDL_GameController for
|
370
|
+
* \returns an SDL_GameController on success or NULL on failure; call
|
371
|
+
* SDL_GetError() for more information.
|
372
|
+
*
|
373
|
+
* \since This function is available since SDL 2.0.4.
|
374
|
+
*/
|
375
|
+
extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromInstanceID(SDL_JoystickID joyid);
|
376
|
+
|
377
|
+
/**
|
378
|
+
* Get the SDL_GameController associated with a player index.
|
379
|
+
*
|
380
|
+
* Please note that the player index is _not_ the device index, nor is it the
|
381
|
+
* instance id!
|
382
|
+
*
|
383
|
+
* \param player_index the player index, which is not the device index or the
|
384
|
+
* instance id!
|
385
|
+
* \returns the SDL_GameController associated with a player index.
|
386
|
+
*
|
387
|
+
* \since This function is available since SDL 2.0.12.
|
388
|
+
*
|
389
|
+
* \sa SDL_GameControllerGetPlayerIndex
|
390
|
+
* \sa SDL_GameControllerSetPlayerIndex
|
391
|
+
*/
|
392
|
+
extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromPlayerIndex(int player_index);
|
393
|
+
|
394
|
+
/**
|
395
|
+
* Get the implementation-dependent name for an opened game controller.
|
396
|
+
*
|
397
|
+
* This is the same name as returned by SDL_GameControllerNameForIndex(), but
|
398
|
+
* it takes a controller identifier instead of the (unstable) device index.
|
399
|
+
*
|
400
|
+
* \param gamecontroller a game controller identifier previously returned by
|
401
|
+
* SDL_GameControllerOpen()
|
402
|
+
* \returns the implementation dependent name for the game controller, or NULL
|
403
|
+
* if there is no name or the identifier passed is invalid.
|
404
|
+
*
|
405
|
+
* \since This function is available since SDL 2.0.0.
|
406
|
+
*
|
407
|
+
* \sa SDL_GameControllerNameForIndex
|
408
|
+
* \sa SDL_GameControllerOpen
|
409
|
+
*/
|
410
|
+
extern DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController *gamecontroller);
|
411
|
+
|
412
|
+
/**
|
413
|
+
* Get the implementation-dependent path for an opened game controller.
|
414
|
+
*
|
415
|
+
* This is the same path as returned by SDL_GameControllerNameForIndex(), but
|
416
|
+
* it takes a controller identifier instead of the (unstable) device index.
|
417
|
+
*
|
418
|
+
* \param gamecontroller a game controller identifier previously returned by
|
419
|
+
* SDL_GameControllerOpen()
|
420
|
+
* \returns the implementation dependent path for the game controller, or NULL
|
421
|
+
* if there is no path or the identifier passed is invalid.
|
422
|
+
*
|
423
|
+
* \since This function is available since SDL 2.24.0.
|
424
|
+
*
|
425
|
+
* \sa SDL_GameControllerPathForIndex
|
426
|
+
*/
|
427
|
+
extern DECLSPEC const char *SDLCALL SDL_GameControllerPath(SDL_GameController *gamecontroller);
|
428
|
+
|
429
|
+
/**
|
430
|
+
* Get the type of this currently opened controller
|
431
|
+
*
|
432
|
+
* This is the same name as returned by SDL_GameControllerTypeForIndex(), but
|
433
|
+
* it takes a controller identifier instead of the (unstable) device index.
|
434
|
+
*
|
435
|
+
* \param gamecontroller the game controller object to query.
|
436
|
+
* \returns the controller type.
|
437
|
+
*
|
438
|
+
* \since This function is available since SDL 2.0.12.
|
439
|
+
*/
|
440
|
+
extern DECLSPEC SDL_GameControllerType SDLCALL SDL_GameControllerGetType(SDL_GameController *gamecontroller);
|
441
|
+
|
442
|
+
/**
|
443
|
+
* Get the player index of an opened game controller.
|
444
|
+
*
|
445
|
+
* For XInput controllers this returns the XInput user index.
|
446
|
+
*
|
447
|
+
* \param gamecontroller the game controller object to query.
|
448
|
+
* \returns the player index for controller, or -1 if it's not available.
|
449
|
+
*
|
450
|
+
* \since This function is available since SDL 2.0.9.
|
451
|
+
*/
|
452
|
+
extern DECLSPEC int SDLCALL SDL_GameControllerGetPlayerIndex(SDL_GameController *gamecontroller);
|
453
|
+
|
454
|
+
/**
|
455
|
+
* Set the player index of an opened game controller.
|
456
|
+
*
|
457
|
+
* \param gamecontroller the game controller object to adjust.
|
458
|
+
* \param player_index Player index to assign to this controller, or -1 to
|
459
|
+
* clear the player index and turn off player LEDs.
|
460
|
+
*
|
461
|
+
* \since This function is available since SDL 2.0.12.
|
462
|
+
*/
|
463
|
+
extern DECLSPEC void SDLCALL SDL_GameControllerSetPlayerIndex(SDL_GameController *gamecontroller, int player_index);
|
464
|
+
|
465
|
+
/**
|
466
|
+
* Get the USB vendor ID of an opened controller, if available.
|
467
|
+
*
|
468
|
+
* If the vendor ID isn't available this function returns 0.
|
469
|
+
*
|
470
|
+
* \param gamecontroller the game controller object to query.
|
471
|
+
* \return the USB vendor ID, or zero if unavailable.
|
472
|
+
*
|
473
|
+
* \since This function is available since SDL 2.0.6.
|
474
|
+
*/
|
475
|
+
extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetVendor(SDL_GameController *gamecontroller);
|
476
|
+
|
477
|
+
/**
|
478
|
+
* Get the USB product ID of an opened controller, if available.
|
479
|
+
*
|
480
|
+
* If the product ID isn't available this function returns 0.
|
481
|
+
*
|
482
|
+
* \param gamecontroller the game controller object to query.
|
483
|
+
* \return the USB product ID, or zero if unavailable.
|
484
|
+
*
|
485
|
+
* \since This function is available since SDL 2.0.6.
|
486
|
+
*/
|
487
|
+
extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProduct(SDL_GameController *gamecontroller);
|
488
|
+
|
489
|
+
/**
|
490
|
+
* Get the product version of an opened controller, if available.
|
491
|
+
*
|
492
|
+
* If the product version isn't available this function returns 0.
|
493
|
+
*
|
494
|
+
* \param gamecontroller the game controller object to query.
|
495
|
+
* \return the USB product version, or zero if unavailable.
|
496
|
+
*
|
497
|
+
* \since This function is available since SDL 2.0.6.
|
498
|
+
*/
|
499
|
+
extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProductVersion(SDL_GameController *gamecontroller);
|
500
|
+
|
501
|
+
/**
|
502
|
+
* Get the firmware version of an opened controller, if available.
|
503
|
+
*
|
504
|
+
* If the firmware version isn't available this function returns 0.
|
505
|
+
*
|
506
|
+
* \param gamecontroller the game controller object to query.
|
507
|
+
* \return the controller firmware version, or zero if unavailable.
|
508
|
+
*
|
509
|
+
* \since This function is available since SDL 2.24.0.
|
510
|
+
*/
|
511
|
+
extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetFirmwareVersion(SDL_GameController *gamecontroller);
|
512
|
+
|
513
|
+
/**
|
514
|
+
* Get the serial number of an opened controller, if available.
|
515
|
+
*
|
516
|
+
* Returns the serial number of the controller, or NULL if it is not
|
517
|
+
* available.
|
518
|
+
*
|
519
|
+
* \param gamecontroller the game controller object to query.
|
520
|
+
* \return the serial number, or NULL if unavailable.
|
521
|
+
*
|
522
|
+
* \since This function is available since SDL 2.0.14.
|
523
|
+
*/
|
524
|
+
extern DECLSPEC const char * SDLCALL SDL_GameControllerGetSerial(SDL_GameController *gamecontroller);
|
525
|
+
|
526
|
+
/**
|
527
|
+
* Check if a controller has been opened and is currently connected.
|
528
|
+
*
|
529
|
+
* \param gamecontroller a game controller identifier previously returned by
|
530
|
+
* SDL_GameControllerOpen()
|
531
|
+
* \returns SDL_TRUE if the controller has been opened and is currently
|
532
|
+
* connected, or SDL_FALSE if not.
|
533
|
+
*
|
534
|
+
* \since This function is available since SDL 2.0.0.
|
535
|
+
*
|
536
|
+
* \sa SDL_GameControllerClose
|
537
|
+
* \sa SDL_GameControllerOpen
|
538
|
+
*/
|
539
|
+
extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerGetAttached(SDL_GameController *gamecontroller);
|
540
|
+
|
541
|
+
/**
|
542
|
+
* Get the Joystick ID from a Game Controller.
|
543
|
+
*
|
544
|
+
* This function will give you a SDL_Joystick object, which allows you to use
|
545
|
+
* the SDL_Joystick functions with a SDL_GameController object. This would be
|
546
|
+
* useful for getting a joystick's position at any given time, even if it
|
547
|
+
* hasn't moved (moving it would produce an event, which would have the axis'
|
548
|
+
* value).
|
549
|
+
*
|
550
|
+
* The pointer returned is owned by the SDL_GameController. You should not
|
551
|
+
* call SDL_JoystickClose() on it, for example, since doing so will likely
|
552
|
+
* cause SDL to crash.
|
553
|
+
*
|
554
|
+
* \param gamecontroller the game controller object that you want to get a
|
555
|
+
* joystick from
|
556
|
+
* \returns a SDL_Joystick object; call SDL_GetError() for more information.
|
557
|
+
*
|
558
|
+
* \since This function is available since SDL 2.0.0.
|
559
|
+
*/
|
560
|
+
extern DECLSPEC SDL_Joystick *SDLCALL SDL_GameControllerGetJoystick(SDL_GameController *gamecontroller);
|
561
|
+
|
562
|
+
/**
|
563
|
+
* Query or change current state of Game Controller events.
|
564
|
+
*
|
565
|
+
* If controller events are disabled, you must call SDL_GameControllerUpdate()
|
566
|
+
* yourself and check the state of the controller when you want controller
|
567
|
+
* information.
|
568
|
+
*
|
569
|
+
* Any number can be passed to SDL_GameControllerEventState(), but only -1, 0,
|
570
|
+
* and 1 will have any effect. Other numbers will just be returned.
|
571
|
+
*
|
572
|
+
* \param state can be one of `SDL_QUERY`, `SDL_IGNORE`, or `SDL_ENABLE`
|
573
|
+
* \returns the same value passed to the function, with exception to -1
|
574
|
+
* (SDL_QUERY), which will return the current state.
|
575
|
+
*
|
576
|
+
* \since This function is available since SDL 2.0.0.
|
577
|
+
*
|
578
|
+
* \sa SDL_JoystickEventState
|
579
|
+
*/
|
580
|
+
extern DECLSPEC int SDLCALL SDL_GameControllerEventState(int state);
|
581
|
+
|
582
|
+
/**
|
583
|
+
* Manually pump game controller updates if not using the loop.
|
584
|
+
*
|
585
|
+
* This function is called automatically by the event loop if events are
|
586
|
+
* enabled. Under such circumstances, it will not be necessary to call this
|
587
|
+
* function.
|
588
|
+
*
|
589
|
+
* \since This function is available since SDL 2.0.0.
|
590
|
+
*/
|
591
|
+
extern DECLSPEC void SDLCALL SDL_GameControllerUpdate(void);
|
592
|
+
|
593
|
+
|
594
|
+
/**
|
595
|
+
* The list of axes available from a controller
|
596
|
+
*
|
597
|
+
* Thumbstick axis values range from SDL_JOYSTICK_AXIS_MIN to SDL_JOYSTICK_AXIS_MAX,
|
598
|
+
* and are centered within ~8000 of zero, though advanced UI will allow users to set
|
599
|
+
* or autodetect the dead zone, which varies between controllers.
|
600
|
+
*
|
601
|
+
* Trigger axis values range from 0 to SDL_JOYSTICK_AXIS_MAX.
|
602
|
+
*/
|
603
|
+
typedef enum
|
604
|
+
{
|
605
|
+
SDL_CONTROLLER_AXIS_INVALID = -1,
|
606
|
+
SDL_CONTROLLER_AXIS_LEFTX,
|
607
|
+
SDL_CONTROLLER_AXIS_LEFTY,
|
608
|
+
SDL_CONTROLLER_AXIS_RIGHTX,
|
609
|
+
SDL_CONTROLLER_AXIS_RIGHTY,
|
610
|
+
SDL_CONTROLLER_AXIS_TRIGGERLEFT,
|
611
|
+
SDL_CONTROLLER_AXIS_TRIGGERRIGHT,
|
612
|
+
SDL_CONTROLLER_AXIS_MAX
|
613
|
+
} SDL_GameControllerAxis;
|
614
|
+
|
615
|
+
/**
|
616
|
+
* Convert a string into SDL_GameControllerAxis enum.
|
617
|
+
*
|
618
|
+
* This function is called internally to translate SDL_GameController mapping
|
619
|
+
* strings for the underlying joystick device into the consistent
|
620
|
+
* SDL_GameController mapping. You do not normally need to call this function
|
621
|
+
* unless you are parsing SDL_GameController mappings in your own code.
|
622
|
+
*
|
623
|
+
* Note specially that "righttrigger" and "lefttrigger" map to
|
624
|
+
* `SDL_CONTROLLER_AXIS_TRIGGERRIGHT` and `SDL_CONTROLLER_AXIS_TRIGGERLEFT`,
|
625
|
+
* respectively.
|
626
|
+
*
|
627
|
+
* \param str string representing a SDL_GameController axis
|
628
|
+
* \returns the SDL_GameControllerAxis enum corresponding to the input string,
|
629
|
+
* or `SDL_CONTROLLER_AXIS_INVALID` if no match was found.
|
630
|
+
*
|
631
|
+
* \since This function is available since SDL 2.0.0.
|
632
|
+
*
|
633
|
+
* \sa SDL_GameControllerGetStringForAxis
|
634
|
+
*/
|
635
|
+
extern DECLSPEC SDL_GameControllerAxis SDLCALL SDL_GameControllerGetAxisFromString(const char *str);
|
636
|
+
|
637
|
+
/**
|
638
|
+
* Convert from an SDL_GameControllerAxis enum to a string.
|
639
|
+
*
|
640
|
+
* The caller should not SDL_free() the returned string.
|
641
|
+
*
|
642
|
+
* \param axis an enum value for a given SDL_GameControllerAxis
|
643
|
+
* \returns a string for the given axis, or NULL if an invalid axis is
|
644
|
+
* specified. The string returned is of the format used by
|
645
|
+
* SDL_GameController mapping strings.
|
646
|
+
*
|
647
|
+
* \since This function is available since SDL 2.0.0.
|
648
|
+
*
|
649
|
+
* \sa SDL_GameControllerGetAxisFromString
|
650
|
+
*/
|
651
|
+
extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForAxis(SDL_GameControllerAxis axis);
|
652
|
+
|
653
|
+
/**
|
654
|
+
* Get the SDL joystick layer binding for a controller axis mapping.
|
655
|
+
*
|
656
|
+
* \param gamecontroller a game controller
|
657
|
+
* \param axis an axis enum value (one of the SDL_GameControllerAxis values)
|
658
|
+
* \returns a SDL_GameControllerButtonBind describing the bind. On failure
|
659
|
+
* (like the given Controller axis doesn't exist on the device), its
|
660
|
+
* `.bindType` will be `SDL_CONTROLLER_BINDTYPE_NONE`.
|
661
|
+
*
|
662
|
+
* \since This function is available since SDL 2.0.0.
|
663
|
+
*
|
664
|
+
* \sa SDL_GameControllerGetBindForButton
|
665
|
+
*/
|
666
|
+
extern DECLSPEC SDL_GameControllerButtonBind SDLCALL
|
667
|
+
SDL_GameControllerGetBindForAxis(SDL_GameController *gamecontroller,
|
668
|
+
SDL_GameControllerAxis axis);
|
669
|
+
|
670
|
+
/**
|
671
|
+
* Query whether a game controller has a given axis.
|
672
|
+
*
|
673
|
+
* This merely reports whether the controller's mapping defined this axis, as
|
674
|
+
* that is all the information SDL has about the physical device.
|
675
|
+
*
|
676
|
+
* \param gamecontroller a game controller
|
677
|
+
* \param axis an axis enum value (an SDL_GameControllerAxis value)
|
678
|
+
* \returns SDL_TRUE if the controller has this axis, SDL_FALSE otherwise.
|
679
|
+
*
|
680
|
+
* \since This function is available since SDL 2.0.14.
|
681
|
+
*/
|
682
|
+
extern DECLSPEC SDL_bool SDLCALL
|
683
|
+
SDL_GameControllerHasAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis);
|
684
|
+
|
685
|
+
/**
|
686
|
+
* Get the current state of an axis control on a game controller.
|
687
|
+
*
|
688
|
+
* The axis indices start at index 0.
|
689
|
+
*
|
690
|
+
* The state is a value ranging from -32768 to 32767. Triggers, however, range
|
691
|
+
* from 0 to 32767 (they never return a negative value).
|
692
|
+
*
|
693
|
+
* \param gamecontroller a game controller
|
694
|
+
* \param axis an axis index (one of the SDL_GameControllerAxis values)
|
695
|
+
* \returns axis state (including 0) on success or 0 (also) on failure; call
|
696
|
+
* SDL_GetError() for more information.
|
697
|
+
*
|
698
|
+
* \since This function is available since SDL 2.0.0.
|
699
|
+
*
|
700
|
+
* \sa SDL_GameControllerGetButton
|
701
|
+
*/
|
702
|
+
extern DECLSPEC Sint16 SDLCALL
|
703
|
+
SDL_GameControllerGetAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis);
|
704
|
+
|
705
|
+
/**
|
706
|
+
* The list of buttons available from a controller
|
707
|
+
*/
|
708
|
+
typedef enum
|
709
|
+
{
|
710
|
+
SDL_CONTROLLER_BUTTON_INVALID = -1,
|
711
|
+
SDL_CONTROLLER_BUTTON_A,
|
712
|
+
SDL_CONTROLLER_BUTTON_B,
|
713
|
+
SDL_CONTROLLER_BUTTON_X,
|
714
|
+
SDL_CONTROLLER_BUTTON_Y,
|
715
|
+
SDL_CONTROLLER_BUTTON_BACK,
|
716
|
+
SDL_CONTROLLER_BUTTON_GUIDE,
|
717
|
+
SDL_CONTROLLER_BUTTON_START,
|
718
|
+
SDL_CONTROLLER_BUTTON_LEFTSTICK,
|
719
|
+
SDL_CONTROLLER_BUTTON_RIGHTSTICK,
|
720
|
+
SDL_CONTROLLER_BUTTON_LEFTSHOULDER,
|
721
|
+
SDL_CONTROLLER_BUTTON_RIGHTSHOULDER,
|
722
|
+
SDL_CONTROLLER_BUTTON_DPAD_UP,
|
723
|
+
SDL_CONTROLLER_BUTTON_DPAD_DOWN,
|
724
|
+
SDL_CONTROLLER_BUTTON_DPAD_LEFT,
|
725
|
+
SDL_CONTROLLER_BUTTON_DPAD_RIGHT,
|
726
|
+
SDL_CONTROLLER_BUTTON_MISC1, /* Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button */
|
727
|
+
SDL_CONTROLLER_BUTTON_PADDLE1, /* Xbox Elite paddle P1 */
|
728
|
+
SDL_CONTROLLER_BUTTON_PADDLE2, /* Xbox Elite paddle P3 */
|
729
|
+
SDL_CONTROLLER_BUTTON_PADDLE3, /* Xbox Elite paddle P2 */
|
730
|
+
SDL_CONTROLLER_BUTTON_PADDLE4, /* Xbox Elite paddle P4 */
|
731
|
+
SDL_CONTROLLER_BUTTON_TOUCHPAD, /* PS4/PS5 touchpad button */
|
732
|
+
SDL_CONTROLLER_BUTTON_MAX
|
733
|
+
} SDL_GameControllerButton;
|
734
|
+
|
735
|
+
/**
|
736
|
+
* Convert a string into an SDL_GameControllerButton enum.
|
737
|
+
*
|
738
|
+
* This function is called internally to translate SDL_GameController mapping
|
739
|
+
* strings for the underlying joystick device into the consistent
|
740
|
+
* SDL_GameController mapping. You do not normally need to call this function
|
741
|
+
* unless you are parsing SDL_GameController mappings in your own code.
|
742
|
+
*
|
743
|
+
* \param str string representing a SDL_GameController axis
|
744
|
+
* \returns the SDL_GameControllerButton enum corresponding to the input
|
745
|
+
* string, or `SDL_CONTROLLER_AXIS_INVALID` if no match was found.
|
746
|
+
*
|
747
|
+
* \since This function is available since SDL 2.0.0.
|
748
|
+
*/
|
749
|
+
extern DECLSPEC SDL_GameControllerButton SDLCALL SDL_GameControllerGetButtonFromString(const char *str);
|
750
|
+
|
751
|
+
/**
|
752
|
+
* Convert from an SDL_GameControllerButton enum to a string.
|
753
|
+
*
|
754
|
+
* The caller should not SDL_free() the returned string.
|
755
|
+
*
|
756
|
+
* \param button an enum value for a given SDL_GameControllerButton
|
757
|
+
* \returns a string for the given button, or NULL if an invalid button is
|
758
|
+
* specified. The string returned is of the format used by
|
759
|
+
* SDL_GameController mapping strings.
|
760
|
+
*
|
761
|
+
* \since This function is available since SDL 2.0.0.
|
762
|
+
*
|
763
|
+
* \sa SDL_GameControllerGetButtonFromString
|
764
|
+
*/
|
765
|
+
extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForButton(SDL_GameControllerButton button);
|
766
|
+
|
767
|
+
/**
|
768
|
+
* Get the SDL joystick layer binding for a controller button mapping.
|
769
|
+
*
|
770
|
+
* \param gamecontroller a game controller
|
771
|
+
* \param button an button enum value (an SDL_GameControllerButton value)
|
772
|
+
* \returns a SDL_GameControllerButtonBind describing the bind. On failure
|
773
|
+
* (like the given Controller button doesn't exist on the device),
|
774
|
+
* its `.bindType` will be `SDL_CONTROLLER_BINDTYPE_NONE`.
|
775
|
+
*
|
776
|
+
* \since This function is available since SDL 2.0.0.
|
777
|
+
*
|
778
|
+
* \sa SDL_GameControllerGetBindForAxis
|
779
|
+
*/
|
780
|
+
extern DECLSPEC SDL_GameControllerButtonBind SDLCALL
|
781
|
+
SDL_GameControllerGetBindForButton(SDL_GameController *gamecontroller,
|
782
|
+
SDL_GameControllerButton button);
|
783
|
+
|
784
|
+
/**
|
785
|
+
* Query whether a game controller has a given button.
|
786
|
+
*
|
787
|
+
* This merely reports whether the controller's mapping defined this button,
|
788
|
+
* as that is all the information SDL has about the physical device.
|
789
|
+
*
|
790
|
+
* \param gamecontroller a game controller
|
791
|
+
* \param button a button enum value (an SDL_GameControllerButton value)
|
792
|
+
* \returns SDL_TRUE if the controller has this button, SDL_FALSE otherwise.
|
793
|
+
*
|
794
|
+
* \since This function is available since SDL 2.0.14.
|
795
|
+
*/
|
796
|
+
extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasButton(SDL_GameController *gamecontroller,
|
797
|
+
SDL_GameControllerButton button);
|
798
|
+
|
799
|
+
/**
|
800
|
+
* Get the current state of a button on a game controller.
|
801
|
+
*
|
802
|
+
* \param gamecontroller a game controller
|
803
|
+
* \param button a button index (one of the SDL_GameControllerButton values)
|
804
|
+
* \returns 1 for pressed state or 0 for not pressed state or error; call
|
805
|
+
* SDL_GetError() for more information.
|
806
|
+
*
|
807
|
+
* \since This function is available since SDL 2.0.0.
|
808
|
+
*
|
809
|
+
* \sa SDL_GameControllerGetAxis
|
810
|
+
*/
|
811
|
+
extern DECLSPEC Uint8 SDLCALL SDL_GameControllerGetButton(SDL_GameController *gamecontroller,
|
812
|
+
SDL_GameControllerButton button);
|
813
|
+
|
814
|
+
/**
|
815
|
+
* Get the number of touchpads on a game controller.
|
816
|
+
*
|
817
|
+
* \since This function is available since SDL 2.0.14.
|
818
|
+
*/
|
819
|
+
extern DECLSPEC int SDLCALL SDL_GameControllerGetNumTouchpads(SDL_GameController *gamecontroller);
|
820
|
+
|
821
|
+
/**
|
822
|
+
* Get the number of supported simultaneous fingers on a touchpad on a game
|
823
|
+
* controller.
|
824
|
+
*
|
825
|
+
* \since This function is available since SDL 2.0.14.
|
826
|
+
*/
|
827
|
+
extern DECLSPEC int SDLCALL SDL_GameControllerGetNumTouchpadFingers(SDL_GameController *gamecontroller, int touchpad);
|
828
|
+
|
829
|
+
/**
|
830
|
+
* Get the current state of a finger on a touchpad on a game controller.
|
831
|
+
*
|
832
|
+
* \since This function is available since SDL 2.0.14.
|
833
|
+
*/
|
834
|
+
extern DECLSPEC int SDLCALL SDL_GameControllerGetTouchpadFinger(SDL_GameController *gamecontroller, int touchpad, int finger, Uint8 *state, float *x, float *y, float *pressure);
|
835
|
+
|
836
|
+
/**
|
837
|
+
* Return whether a game controller has a particular sensor.
|
838
|
+
*
|
839
|
+
* \param gamecontroller The controller to query
|
840
|
+
* \param type The type of sensor to query
|
841
|
+
* \returns SDL_TRUE if the sensor exists, SDL_FALSE otherwise.
|
842
|
+
*
|
843
|
+
* \since This function is available since SDL 2.0.14.
|
844
|
+
*/
|
845
|
+
extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasSensor(SDL_GameController *gamecontroller, SDL_SensorType type);
|
846
|
+
|
847
|
+
/**
|
848
|
+
* Set whether data reporting for a game controller sensor is enabled.
|
849
|
+
*
|
850
|
+
* \param gamecontroller The controller to update
|
851
|
+
* \param type The type of sensor to enable/disable
|
852
|
+
* \param enabled Whether data reporting should be enabled
|
853
|
+
* \returns 0 or -1 if an error occurred.
|
854
|
+
*
|
855
|
+
* \since This function is available since SDL 2.0.14.
|
856
|
+
*/
|
857
|
+
extern DECLSPEC int SDLCALL SDL_GameControllerSetSensorEnabled(SDL_GameController *gamecontroller, SDL_SensorType type, SDL_bool enabled);
|
858
|
+
|
859
|
+
/**
|
860
|
+
* Query whether sensor data reporting is enabled for a game controller.
|
861
|
+
*
|
862
|
+
* \param gamecontroller The controller to query
|
863
|
+
* \param type The type of sensor to query
|
864
|
+
* \returns SDL_TRUE if the sensor is enabled, SDL_FALSE otherwise.
|
865
|
+
*
|
866
|
+
* \since This function is available since SDL 2.0.14.
|
867
|
+
*/
|
868
|
+
extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerIsSensorEnabled(SDL_GameController *gamecontroller, SDL_SensorType type);
|
869
|
+
|
870
|
+
/**
|
871
|
+
* Get the data rate (number of events per second) of a game controller
|
872
|
+
* sensor.
|
873
|
+
*
|
874
|
+
* \param gamecontroller The controller to query
|
875
|
+
* \param type The type of sensor to query
|
876
|
+
* \return the data rate, or 0.0f if the data rate is not available.
|
877
|
+
*
|
878
|
+
* \since This function is available since SDL 2.0.16.
|
879
|
+
*/
|
880
|
+
extern DECLSPEC float SDLCALL SDL_GameControllerGetSensorDataRate(SDL_GameController *gamecontroller, SDL_SensorType type);
|
881
|
+
|
882
|
+
/**
|
883
|
+
* Get the current state of a game controller sensor.
|
884
|
+
*
|
885
|
+
* The number of values and interpretation of the data is sensor dependent.
|
886
|
+
* See SDL_sensor.h for the details for each type of sensor.
|
887
|
+
*
|
888
|
+
* \param gamecontroller The controller to query
|
889
|
+
* \param type The type of sensor to query
|
890
|
+
* \param data A pointer filled with the current sensor state
|
891
|
+
* \param num_values The number of values to write to data
|
892
|
+
* \return 0 or -1 if an error occurred.
|
893
|
+
*
|
894
|
+
* \since This function is available since SDL 2.0.14.
|
895
|
+
*/
|
896
|
+
extern DECLSPEC int SDLCALL SDL_GameControllerGetSensorData(SDL_GameController *gamecontroller, SDL_SensorType type, float *data, int num_values);
|
897
|
+
|
898
|
+
/**
|
899
|
+
* Get the current state of a game controller sensor with the timestamp of the
|
900
|
+
* last update.
|
901
|
+
*
|
902
|
+
* The number of values and interpretation of the data is sensor dependent.
|
903
|
+
* See SDL_sensor.h for the details for each type of sensor.
|
904
|
+
*
|
905
|
+
* \param gamecontroller The controller to query
|
906
|
+
* \param type The type of sensor to query
|
907
|
+
* \param timestamp A pointer filled with the timestamp in microseconds of the
|
908
|
+
* current sensor reading if available, or 0 if not
|
909
|
+
* \param data A pointer filled with the current sensor state
|
910
|
+
* \param num_values The number of values to write to data
|
911
|
+
* \return 0 or -1 if an error occurred.
|
912
|
+
*
|
913
|
+
* \since This function is available since SDL 2.26.0.
|
914
|
+
*/
|
915
|
+
extern DECLSPEC int SDLCALL SDL_GameControllerGetSensorDataWithTimestamp(SDL_GameController *gamecontroller, SDL_SensorType type, Uint64 *timestamp, float *data, int num_values);
|
916
|
+
|
917
|
+
/**
|
918
|
+
* Start a rumble effect on a game controller.
|
919
|
+
*
|
920
|
+
* Each call to this function cancels any previous rumble effect, and calling
|
921
|
+
* it with 0 intensity stops any rumbling.
|
922
|
+
*
|
923
|
+
* \param gamecontroller The controller to vibrate
|
924
|
+
* \param low_frequency_rumble The intensity of the low frequency (left)
|
925
|
+
* rumble motor, from 0 to 0xFFFF
|
926
|
+
* \param high_frequency_rumble The intensity of the high frequency (right)
|
927
|
+
* rumble motor, from 0 to 0xFFFF
|
928
|
+
* \param duration_ms The duration of the rumble effect, in milliseconds
|
929
|
+
* \returns 0, or -1 if rumble isn't supported on this controller
|
930
|
+
*
|
931
|
+
* \since This function is available since SDL 2.0.9.
|
932
|
+
*
|
933
|
+
* \sa SDL_GameControllerHasRumble
|
934
|
+
*/
|
935
|
+
extern DECLSPEC int SDLCALL SDL_GameControllerRumble(SDL_GameController *gamecontroller, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
|
936
|
+
|
937
|
+
/**
|
938
|
+
* Start a rumble effect in the game controller's triggers.
|
939
|
+
*
|
940
|
+
* Each call to this function cancels any previous trigger rumble effect, and
|
941
|
+
* calling it with 0 intensity stops any rumbling.
|
942
|
+
*
|
943
|
+
* Note that this is rumbling of the _triggers_ and not the game controller as
|
944
|
+
* a whole. This is currently only supported on Xbox One controllers. If you
|
945
|
+
* want the (more common) whole-controller rumble, use
|
946
|
+
* SDL_GameControllerRumble() instead.
|
947
|
+
*
|
948
|
+
* \param gamecontroller The controller to vibrate
|
949
|
+
* \param left_rumble The intensity of the left trigger rumble motor, from 0
|
950
|
+
* to 0xFFFF
|
951
|
+
* \param right_rumble The intensity of the right trigger rumble motor, from 0
|
952
|
+
* to 0xFFFF
|
953
|
+
* \param duration_ms The duration of the rumble effect, in milliseconds
|
954
|
+
* \returns 0, or -1 if trigger rumble isn't supported on this controller
|
955
|
+
*
|
956
|
+
* \since This function is available since SDL 2.0.14.
|
957
|
+
*
|
958
|
+
* \sa SDL_GameControllerHasRumbleTriggers
|
959
|
+
*/
|
960
|
+
extern DECLSPEC int SDLCALL SDL_GameControllerRumbleTriggers(SDL_GameController *gamecontroller, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
|
961
|
+
|
962
|
+
/**
|
963
|
+
* Query whether a game controller has an LED.
|
964
|
+
*
|
965
|
+
* \param gamecontroller The controller to query
|
966
|
+
* \returns SDL_TRUE, or SDL_FALSE if this controller does not have a
|
967
|
+
* modifiable LED
|
968
|
+
*
|
969
|
+
* \since This function is available since SDL 2.0.14.
|
970
|
+
*/
|
971
|
+
extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasLED(SDL_GameController *gamecontroller);
|
972
|
+
|
973
|
+
/**
|
974
|
+
* Query whether a game controller has rumble support.
|
975
|
+
*
|
976
|
+
* \param gamecontroller The controller to query
|
977
|
+
* \returns SDL_TRUE, or SDL_FALSE if this controller does not have rumble
|
978
|
+
* support
|
979
|
+
*
|
980
|
+
* \since This function is available since SDL 2.0.18.
|
981
|
+
*
|
982
|
+
* \sa SDL_GameControllerRumble
|
983
|
+
*/
|
984
|
+
extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasRumble(SDL_GameController *gamecontroller);
|
985
|
+
|
986
|
+
/**
|
987
|
+
* Query whether a game controller has rumble support on triggers.
|
988
|
+
*
|
989
|
+
* \param gamecontroller The controller to query
|
990
|
+
* \returns SDL_TRUE, or SDL_FALSE if this controller does not have trigger
|
991
|
+
* rumble support
|
992
|
+
*
|
993
|
+
* \since This function is available since SDL 2.0.18.
|
994
|
+
*
|
995
|
+
* \sa SDL_GameControllerRumbleTriggers
|
996
|
+
*/
|
997
|
+
extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasRumbleTriggers(SDL_GameController *gamecontroller);
|
998
|
+
|
999
|
+
/**
|
1000
|
+
* Update a game controller's LED color.
|
1001
|
+
*
|
1002
|
+
* \param gamecontroller The controller to update
|
1003
|
+
* \param red The intensity of the red LED
|
1004
|
+
* \param green The intensity of the green LED
|
1005
|
+
* \param blue The intensity of the blue LED
|
1006
|
+
* \returns 0, or -1 if this controller does not have a modifiable LED
|
1007
|
+
*
|
1008
|
+
* \since This function is available since SDL 2.0.14.
|
1009
|
+
*/
|
1010
|
+
extern DECLSPEC int SDLCALL SDL_GameControllerSetLED(SDL_GameController *gamecontroller, Uint8 red, Uint8 green, Uint8 blue);
|
1011
|
+
|
1012
|
+
/**
|
1013
|
+
* Send a controller specific effect packet
|
1014
|
+
*
|
1015
|
+
* \param gamecontroller The controller to affect
|
1016
|
+
* \param data The data to send to the controller
|
1017
|
+
* \param size The size of the data to send to the controller
|
1018
|
+
* \returns 0, or -1 if this controller or driver doesn't support effect
|
1019
|
+
* packets
|
1020
|
+
*
|
1021
|
+
* \since This function is available since SDL 2.0.16.
|
1022
|
+
*/
|
1023
|
+
extern DECLSPEC int SDLCALL SDL_GameControllerSendEffect(SDL_GameController *gamecontroller, const void *data, int size);
|
1024
|
+
|
1025
|
+
/**
|
1026
|
+
* Close a game controller previously opened with SDL_GameControllerOpen().
|
1027
|
+
*
|
1028
|
+
* \param gamecontroller a game controller identifier previously returned by
|
1029
|
+
* SDL_GameControllerOpen()
|
1030
|
+
*
|
1031
|
+
* \since This function is available since SDL 2.0.0.
|
1032
|
+
*
|
1033
|
+
* \sa SDL_GameControllerOpen
|
1034
|
+
*/
|
1035
|
+
extern DECLSPEC void SDLCALL SDL_GameControllerClose(SDL_GameController *gamecontroller);
|
1036
|
+
|
1037
|
+
/**
|
1038
|
+
* Return the sfSymbolsName for a given button on a game controller on Apple
|
1039
|
+
* platforms.
|
1040
|
+
*
|
1041
|
+
* \param gamecontroller the controller to query
|
1042
|
+
* \param button a button on the game controller
|
1043
|
+
* \returns the sfSymbolsName or NULL if the name can't be found
|
1044
|
+
*
|
1045
|
+
* \since This function is available since SDL 2.0.18.
|
1046
|
+
*
|
1047
|
+
* \sa SDL_GameControllerGetAppleSFSymbolsNameForAxis
|
1048
|
+
*/
|
1049
|
+
extern DECLSPEC const char* SDLCALL SDL_GameControllerGetAppleSFSymbolsNameForButton(SDL_GameController *gamecontroller, SDL_GameControllerButton button);
|
1050
|
+
|
1051
|
+
/**
|
1052
|
+
* Return the sfSymbolsName for a given axis on a game controller on Apple
|
1053
|
+
* platforms.
|
1054
|
+
*
|
1055
|
+
* \param gamecontroller the controller to query
|
1056
|
+
* \param axis an axis on the game controller
|
1057
|
+
* \returns the sfSymbolsName or NULL if the name can't be found
|
1058
|
+
*
|
1059
|
+
* \since This function is available since SDL 2.0.18.
|
1060
|
+
*
|
1061
|
+
* \sa SDL_GameControllerGetAppleSFSymbolsNameForButton
|
1062
|
+
*/
|
1063
|
+
extern DECLSPEC const char* SDLCALL SDL_GameControllerGetAppleSFSymbolsNameForAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis);
|
1064
|
+
|
1065
|
+
|
1066
|
+
/* Ends C function definitions when using C++ */
|
1067
|
+
#ifdef __cplusplus
|
1068
|
+
}
|
1069
|
+
#endif
|
1070
|
+
#include "close_code.h"
|
1071
|
+
|
1072
|
+
#endif /* SDL_gamecontroller_h_ */
|
1073
|
+
|
1074
|
+
/* vi: set ts=4 sw=4 expandtab: */
|