gosu 1.1.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (220) hide show
  1. checksums.yaml +4 -4
  2. data/COPYING +1 -1
  3. data/dependencies/SDL/include/SDL.h +108 -14
  4. data/dependencies/SDL/include/SDL_assert.h +81 -50
  5. data/dependencies/SDL/include/SDL_atomic.h +135 -35
  6. data/dependencies/SDL/include/SDL_audio.h +960 -355
  7. data/dependencies/SDL/include/SDL_bits.h +11 -6
  8. data/dependencies/SDL/include/SDL_blendmode.h +91 -14
  9. data/dependencies/SDL/include/SDL_clipboard.h +30 -7
  10. data/dependencies/SDL/include/SDL_config.h +277 -27
  11. data/dependencies/SDL/include/SDL_config_android.h +13 -38
  12. data/dependencies/SDL/include/SDL_config_iphoneos.h +21 -62
  13. data/dependencies/SDL/include/SDL_config_macosx.h +23 -92
  14. data/dependencies/SDL/include/SDL_config_minimal.h +1 -4
  15. data/dependencies/SDL/include/SDL_config_pandora.h +15 -22
  16. data/dependencies/SDL/include/SDL_config_psp.h +16 -37
  17. data/dependencies/SDL/include/SDL_config_windows.h +28 -91
  18. data/dependencies/SDL/include/SDL_config_winrt.h +33 -61
  19. data/dependencies/SDL/include/SDL_config_wiz.h +28 -56
  20. data/dependencies/SDL/include/SDL_copying.h +1 -1
  21. data/dependencies/SDL/include/SDL_cpuinfo.h +331 -71
  22. data/dependencies/SDL/include/SDL_egl.h +906 -280
  23. data/dependencies/SDL/include/SDL_endian.h +101 -47
  24. data/dependencies/SDL/include/SDL_error.h +70 -19
  25. data/dependencies/SDL/include/SDL_events.h +387 -79
  26. data/dependencies/SDL/include/SDL_filesystem.h +73 -64
  27. data/dependencies/SDL/include/SDL_gamecontroller.h +585 -125
  28. data/dependencies/SDL/include/SDL_gesture.h +36 -6
  29. data/dependencies/SDL/include/SDL_haptic.h +304 -210
  30. data/dependencies/SDL/include/SDL_hidapi.h +451 -0
  31. data/dependencies/SDL/include/SDL_hints.h +1286 -897
  32. data/dependencies/SDL/include/SDL_joystick.h +577 -130
  33. data/dependencies/SDL/include/SDL_keyboard.h +162 -63
  34. data/dependencies/SDL/include/SDL_keycode.h +7 -5
  35. data/dependencies/SDL/include/SDL_loadso.h +42 -8
  36. data/dependencies/SDL/include/SDL_locale.h +34 -32
  37. data/dependencies/SDL/include/SDL_log.h +212 -19
  38. data/dependencies/SDL/include/SDL_main.h +72 -17
  39. data/dependencies/SDL/include/SDL_messagebox.h +70 -23
  40. data/dependencies/SDL/include/SDL_metal.h +27 -32
  41. data/dependencies/SDL/include/SDL_misc.h +19 -15
  42. data/dependencies/SDL/include/SDL_mouse.h +262 -110
  43. data/dependencies/SDL/include/SDL_mutex.h +286 -66
  44. data/dependencies/SDL/include/SDL_name.h +1 -1
  45. data/dependencies/SDL/include/SDL_opengl.h +1 -1
  46. data/dependencies/SDL/include/SDL_opengles.h +1 -1
  47. data/dependencies/SDL/include/SDL_opengles2.h +2 -2
  48. data/dependencies/SDL/include/SDL_pixels.h +199 -34
  49. data/dependencies/SDL/include/SDL_platform.h +39 -2
  50. data/dependencies/SDL/include/SDL_power.h +23 -10
  51. data/dependencies/SDL/include/SDL_quit.h +1 -1
  52. data/dependencies/SDL/include/SDL_rect.h +78 -28
  53. data/dependencies/SDL/include/SDL_render.h +1204 -472
  54. data/dependencies/SDL/include/SDL_revision.h +2 -2
  55. data/dependencies/SDL/include/SDL_rwops.h +605 -33
  56. data/dependencies/SDL/include/SDL_scancode.h +1 -1
  57. data/dependencies/SDL/include/SDL_sensor.h +76 -42
  58. data/dependencies/SDL/include/SDL_shape.h +38 -27
  59. data/dependencies/SDL/include/SDL_stdinc.h +96 -24
  60. data/dependencies/SDL/include/SDL_surface.h +571 -139
  61. data/dependencies/SDL/include/SDL_system.h +339 -101
  62. data/dependencies/SDL/include/SDL_syswm.h +50 -20
  63. data/dependencies/SDL/include/SDL_test.h +1 -1
  64. data/dependencies/SDL/include/SDL_test_assert.h +2 -2
  65. data/dependencies/SDL/include/SDL_test_common.h +23 -6
  66. data/dependencies/SDL/include/SDL_test_compare.h +1 -1
  67. data/dependencies/SDL/include/SDL_test_crc32.h +1 -1
  68. data/dependencies/SDL/include/SDL_test_font.h +3 -3
  69. data/dependencies/SDL/include/SDL_test_fuzzer.h +28 -26
  70. data/dependencies/SDL/include/SDL_test_harness.h +6 -6
  71. data/dependencies/SDL/include/SDL_test_images.h +1 -1
  72. data/dependencies/SDL/include/SDL_test_log.h +1 -1
  73. data/dependencies/SDL/include/SDL_test_md5.h +1 -1
  74. data/dependencies/SDL/include/SDL_test_memory.h +1 -1
  75. data/dependencies/SDL/include/SDL_test_random.h +2 -2
  76. data/dependencies/SDL/include/SDL_thread.h +226 -128
  77. data/dependencies/SDL/include/SDL_timer.h +129 -22
  78. data/dependencies/SDL/include/SDL_touch.h +48 -8
  79. data/dependencies/SDL/include/SDL_types.h +1 -1
  80. data/dependencies/SDL/include/SDL_version.h +72 -46
  81. data/dependencies/SDL/include/SDL_video.h +1266 -460
  82. data/dependencies/SDL/include/SDL_vulkan.h +100 -161
  83. data/dependencies/SDL/include/begin_code.h +22 -1
  84. data/dependencies/SDL/include/close_code.h +1 -1
  85. data/dependencies/SDL/lib/x64/libSDL2.dll.a +0 -0
  86. data/dependencies/SDL/lib/x86/libSDL2.dll.a +0 -0
  87. data/dependencies/SDL_sound/SDL_sound.c +83 -7
  88. data/dependencies/SDL_sound/SDL_sound.h +4 -4
  89. data/dependencies/SDL_sound/SDL_sound_aiff.c +9 -12
  90. data/dependencies/SDL_sound/SDL_sound_au.c +7 -7
  91. data/dependencies/SDL_sound/SDL_sound_coreaudio.c +3 -3
  92. data/dependencies/SDL_sound/SDL_sound_flac.c +1 -1
  93. data/dependencies/SDL_sound/SDL_sound_internal.h +17 -10
  94. data/dependencies/SDL_sound/SDL_sound_modplug.c +25 -27
  95. data/dependencies/SDL_sound/SDL_sound_mp3.c +5 -17
  96. data/dependencies/SDL_sound/SDL_sound_raw.c +11 -11
  97. data/dependencies/SDL_sound/SDL_sound_shn.c +8 -7
  98. data/dependencies/SDL_sound/SDL_sound_voc.c +6 -4
  99. data/dependencies/SDL_sound/SDL_sound_vorbis.c +6 -11
  100. data/dependencies/SDL_sound/SDL_sound_wav.c +35 -29
  101. data/dependencies/SDL_sound/dr_flac.h +618 -220
  102. data/dependencies/SDL_sound/dr_mp3.h +263 -94
  103. data/dependencies/SDL_sound/libmodplug/fastmix.c +58 -64
  104. data/dependencies/SDL_sound/libmodplug/libmodplug.h +25 -103
  105. data/dependencies/SDL_sound/libmodplug/load_669.c +14 -17
  106. data/dependencies/SDL_sound/libmodplug/load_amf.c +11 -7
  107. data/dependencies/SDL_sound/libmodplug/load_ams.c +65 -22
  108. data/dependencies/SDL_sound/libmodplug/load_dbm.c +8 -4
  109. data/dependencies/SDL_sound/libmodplug/load_dmf.c +55 -25
  110. data/dependencies/SDL_sound/libmodplug/load_far.c +9 -13
  111. data/dependencies/SDL_sound/libmodplug/load_gdm.c +448 -0
  112. data/dependencies/SDL_sound/libmodplug/load_it.c +45 -49
  113. data/dependencies/SDL_sound/libmodplug/load_mdl.c +80 -53
  114. data/dependencies/SDL_sound/libmodplug/load_med.c +20 -12
  115. data/dependencies/SDL_sound/libmodplug/load_mod.c +40 -15
  116. data/dependencies/SDL_sound/libmodplug/load_mt2.c +29 -17
  117. data/dependencies/SDL_sound/libmodplug/load_okt.c +12 -8
  118. data/dependencies/SDL_sound/libmodplug/load_psm.c +101 -78
  119. data/dependencies/SDL_sound/libmodplug/load_ptm.c +18 -17
  120. data/dependencies/SDL_sound/libmodplug/load_s3m.c +9 -7
  121. data/dependencies/SDL_sound/libmodplug/load_stm.c +3 -2
  122. data/dependencies/SDL_sound/libmodplug/load_ult.c +2 -2
  123. data/dependencies/SDL_sound/libmodplug/load_umx.c +315 -35
  124. data/dependencies/SDL_sound/libmodplug/load_xm.c +25 -21
  125. data/dependencies/SDL_sound/libmodplug/mmcmp.c +295 -149
  126. data/dependencies/SDL_sound/libmodplug/modplug.c +7 -123
  127. data/dependencies/SDL_sound/libmodplug/modplug.h +32 -29
  128. data/dependencies/SDL_sound/libmodplug/snd_dsp.c +0 -1
  129. data/dependencies/SDL_sound/libmodplug/snd_flt.c +2 -2
  130. data/dependencies/SDL_sound/libmodplug/snd_fx.c +24 -18
  131. data/dependencies/SDL_sound/libmodplug/sndfile.c +55 -156
  132. data/dependencies/SDL_sound/libmodplug/sndmix.c +7 -12
  133. data/dependencies/SDL_sound/libmodplug/tables.h +10 -15
  134. data/dependencies/SDL_sound/stb_vorbis.h +508 -325
  135. data/dependencies/{al_soft → mojoAL}/AL/al.h +38 -30
  136. data/dependencies/{al_soft → mojoAL}/AL/alc.h +27 -56
  137. data/dependencies/mojoAL/mojoal.c +4594 -0
  138. data/ext/gosu/extconf.rb +33 -30
  139. data/include/Gosu/Audio.hpp +70 -85
  140. data/include/Gosu/Color.hpp +63 -107
  141. data/include/Gosu/Font.hpp +44 -50
  142. data/include/Gosu/Fwd.hpp +1 -1
  143. data/include/Gosu/Graphics.hpp +64 -75
  144. data/include/Gosu/GraphicsBase.hpp +32 -39
  145. data/include/Gosu/Image.hpp +56 -62
  146. data/include/Gosu/ImageData.hpp +23 -27
  147. data/include/Gosu/Inspection.hpp +1 -4
  148. data/include/Gosu/Math.hpp +4 -16
  149. data/include/Gosu/Platform.hpp +1 -51
  150. data/include/Gosu/Text.hpp +37 -40
  151. data/include/Gosu/TextInput.hpp +34 -40
  152. data/include/Gosu/Utility.hpp +10 -8
  153. data/include/Gosu/Version.hpp +1 -1
  154. data/include/Gosu/Window.hpp +73 -70
  155. data/lib/SDL2.dll +0 -0
  156. data/lib/gosu/compat.rb +28 -37
  157. data/lib/gosu/swig_patches.rb +31 -3
  158. data/lib/gosu.rb +2 -2
  159. data/lib64/SDL2.dll +0 -0
  160. data/rdoc/gosu.rb +9 -1
  161. data/src/Audio.cpp +86 -86
  162. data/src/AudioFile.hpp +6 -6
  163. data/src/AudioFileAudioToolbox.cpp +1 -1
  164. data/src/AudioFileSDLSound.cpp +1 -1
  165. data/src/AudioImpl.hpp +5 -5
  166. data/src/Bitmap.cpp +13 -13
  167. data/src/BitmapIO.cpp +0 -20
  168. data/src/BlockAllocator.cpp +2 -1
  169. data/src/Channel.cpp +22 -20
  170. data/src/Color.cpp +62 -55
  171. data/src/EmptyImageData.hpp +16 -18
  172. data/src/FileUnix.cpp +1 -1
  173. data/src/FileWin.cpp +1 -1
  174. data/src/Font.cpp +52 -57
  175. data/src/GosuViewController.cpp +2 -0
  176. data/src/Graphics.cpp +135 -143
  177. data/src/Image.cpp +42 -42
  178. data/src/Input.cpp +1 -1
  179. data/src/InputUIKit.cpp +1 -1
  180. data/src/LargeImageData.cpp +120 -113
  181. data/src/LargeImageData.hpp +18 -16
  182. data/src/Log.hpp +6 -6
  183. data/src/Macro.cpp +124 -169
  184. data/src/Macro.hpp +11 -11
  185. data/src/Math.cpp +8 -1
  186. data/src/RenderState.hpp +5 -5
  187. data/src/Resolution.cpp +114 -61
  188. data/src/RubyGosu.cxx +470 -501
  189. data/src/RubyGosu.h +3 -2
  190. data/src/TexChunk.cpp +50 -41
  191. data/src/TexChunk.hpp +22 -22
  192. data/src/Text.cpp +58 -59
  193. data/src/TextBuilder.cpp +60 -57
  194. data/src/TextBuilder.hpp +20 -20
  195. data/src/TextInput.cpp +127 -135
  196. data/src/TrueTypeFont.cpp +108 -108
  197. data/src/TrueTypeFont.hpp +39 -38
  198. data/src/TrueTypeFontApple.cpp +27 -23
  199. data/src/TrueTypeFontUnix.cpp +21 -26
  200. data/src/TrueTypeFontWin.cpp +30 -30
  201. data/src/Utility.cpp +82 -23
  202. data/src/WinUtility.hpp +2 -1
  203. data/src/Window.cpp +103 -86
  204. data/src/WindowUIKit.cpp +48 -51
  205. metadata +8 -20
  206. data/dependencies/SDL/include/SDL_config_os2.h +0 -188
  207. data/dependencies/SDL_sound/libmodplug/load_abc.c +0 -4725
  208. data/dependencies/SDL_sound/libmodplug/load_mid.c +0 -1405
  209. data/dependencies/SDL_sound/libmodplug/load_pat.c +0 -1143
  210. data/dependencies/SDL_sound/libmodplug/load_pat.h +0 -25
  211. data/dependencies/al_soft/AL/alext.h +0 -585
  212. data/dependencies/al_soft/AL/efx-creative.h +0 -3
  213. data/dependencies/al_soft/AL/efx-presets.h +0 -402
  214. data/dependencies/al_soft/AL/efx.h +0 -762
  215. data/dependencies/al_soft/x64/libOpenAL32.dll.a +0 -0
  216. data/dependencies/al_soft/x86/libOpenAL32.dll.a +0 -0
  217. data/lib/OpenAL32.dll +0 -0
  218. data/lib64/OpenAL32.dll +0 -0
  219. data/src/UtilityApple.cpp +0 -16
  220. data/src/UtilityWin.cpp +0 -17
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  Simple DirectMedia Layer
3
- Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
3
+ Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
4
4
 
5
5
  This software is provided 'as-is', without any express or implied
6
6
  warranty. In no event will the authors be held liable for any damages
@@ -30,10 +30,12 @@
30
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
31
  * then it will get a new instance_id, instance_id's are monotonically increasing identifiers of a joystick plugged in.
32
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
+ *
33
37
  * The term JoystickGUID is a stable 128-bit identifier for a joystick device that does not change over time, it identifies class of
34
38
  * the device (a X360 wired controller for example). This identifier is platform dependent.
35
- *
36
- *
37
39
  */
38
40
 
39
41
  #ifndef SDL_joystick_h_
@@ -122,92 +124,206 @@ typedef enum
122
124
  * In particular, you are guaranteed that the joystick list won't change, so
123
125
  * the API functions that take a joystick index will be valid, and joystick
124
126
  * and game controller events will not be delivered.
127
+ *
128
+ * \since This function is available since SDL 2.0.7.
125
129
  */
126
130
  extern DECLSPEC void SDLCALL SDL_LockJoysticks(void);
131
+
132
+
133
+ /**
134
+ * Unlocking for multi-threaded access to the joystick API
135
+ *
136
+ * If you are using the joystick API or handling events from multiple threads
137
+ * you should use these locking functions to protect access to the joysticks.
138
+ *
139
+ * In particular, you are guaranteed that the joystick list won't change, so
140
+ * the API functions that take a joystick index will be valid, and joystick
141
+ * and game controller events will not be delivered.
142
+ *
143
+ * \since This function is available since SDL 2.0.7.
144
+ */
127
145
  extern DECLSPEC void SDLCALL SDL_UnlockJoysticks(void);
128
146
 
129
147
  /**
130
- * Count the number of joysticks attached to the system right now
148
+ * Count the number of joysticks attached to the system.
149
+ *
150
+ * \returns the number of attached joysticks on success or a negative error
151
+ * code on failure; call SDL_GetError() for more information.
152
+ *
153
+ * \since This function is available since SDL 2.0.0.
154
+ *
155
+ * \sa SDL_JoystickName
156
+ * \sa SDL_JoystickOpen
131
157
  */
132
158
  extern DECLSPEC int SDLCALL SDL_NumJoysticks(void);
133
159
 
134
160
  /**
135
- * Get the implementation dependent name of a joystick.
136
- * This can be called before any joysticks are opened.
137
- * If no name can be found, this function returns NULL.
161
+ * Get the implementation dependent name of a joystick.
162
+ *
163
+ * This can be called before any joysticks are opened.
164
+ *
165
+ * \param device_index the index of the joystick to query (the N'th joystick
166
+ * on the system)
167
+ * \returns the name of the selected joystick. If no name can be found, this
168
+ * function returns NULL; call SDL_GetError() for more information.
169
+ *
170
+ * \since This function is available since SDL 2.0.0.
171
+ *
172
+ * \sa SDL_JoystickName
173
+ * \sa SDL_JoystickOpen
138
174
  */
139
175
  extern DECLSPEC const char *SDLCALL SDL_JoystickNameForIndex(int device_index);
140
176
 
141
177
  /**
142
- * Get the player index of a joystick, or -1 if it's not available
143
- * This can be called before any joysticks are opened.
178
+ * Get the player index of a joystick, or -1 if it's not available This can be
179
+ * called before any joysticks are opened.
180
+ *
181
+ * \since This function is available since SDL 2.0.9.
144
182
  */
145
183
  extern DECLSPEC int SDLCALL SDL_JoystickGetDevicePlayerIndex(int device_index);
146
184
 
147
185
  /**
148
- * Return the GUID for the joystick at this index
149
- * This can be called before any joysticks are opened.
186
+ * Get the implementation-dependent GUID for the joystick at a given device
187
+ * index.
188
+ *
189
+ * This function can be called before any joysticks are opened.
190
+ *
191
+ * \param device_index the index of the joystick to query (the N'th joystick
192
+ * on the system
193
+ * \returns the GUID of the selected joystick. If called on an invalid index,
194
+ * this function returns a zero GUID
195
+ *
196
+ * \since This function is available since SDL 2.0.0.
197
+ *
198
+ * \sa SDL_JoystickGetGUID
199
+ * \sa SDL_JoystickGetGUIDString
150
200
  */
151
201
  extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetDeviceGUID(int device_index);
152
202
 
153
203
  /**
154
- * Get the USB vendor ID of a joystick, if available.
155
- * This can be called before any joysticks are opened.
156
- * If the vendor ID isn't available this function returns 0.
204
+ * Get the USB vendor ID of a joystick, if available.
205
+ *
206
+ * This can be called before any joysticks are opened. If the vendor ID isn't
207
+ * available this function returns 0.
208
+ *
209
+ * \param device_index the index of the joystick to query (the N'th joystick
210
+ * on the system
211
+ * \returns the USB vendor ID of the selected joystick. If called on an
212
+ * invalid index, this function returns zero
213
+ *
214
+ * \since This function is available since SDL 2.0.6.
157
215
  */
158
216
  extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceVendor(int device_index);
159
217
 
160
218
  /**
161
- * Get the USB product ID of a joystick, if available.
162
- * This can be called before any joysticks are opened.
163
- * If the product ID isn't available this function returns 0.
219
+ * Get the USB product ID of a joystick, if available.
220
+ *
221
+ * This can be called before any joysticks are opened. If the product ID isn't
222
+ * available this function returns 0.
223
+ *
224
+ * \param device_index the index of the joystick to query (the N'th joystick
225
+ * on the system
226
+ * \returns the USB product ID of the selected joystick. If called on an
227
+ * invalid index, this function returns zero
228
+ *
229
+ * \since This function is available since SDL 2.0.6.
164
230
  */
165
231
  extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceProduct(int device_index);
166
232
 
167
233
  /**
168
- * Get the product version of a joystick, if available.
169
- * This can be called before any joysticks are opened.
170
- * If the product version isn't available this function returns 0.
234
+ * Get the product version of a joystick, if available.
235
+ *
236
+ * This can be called before any joysticks are opened. If the product version
237
+ * isn't available this function returns 0.
238
+ *
239
+ * \param device_index the index of the joystick to query (the N'th joystick
240
+ * on the system
241
+ * \returns the product version of the selected joystick. If called on an
242
+ * invalid index, this function returns zero
243
+ *
244
+ * \since This function is available since SDL 2.0.6.
171
245
  */
172
246
  extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceProductVersion(int device_index);
173
247
 
174
248
  /**
175
- * Get the type of a joystick, if available.
176
- * This can be called before any joysticks are opened.
249
+ * Get the type of a joystick, if available.
250
+ *
251
+ * This can be called before any joysticks are opened.
252
+ *
253
+ * \param device_index the index of the joystick to query (the N'th joystick
254
+ * on the system
255
+ * \returns the SDL_JoystickType of the selected joystick. If called on an
256
+ * invalid index, this function returns `SDL_JOYSTICK_TYPE_UNKNOWN`
257
+ *
258
+ * \since This function is available since SDL 2.0.6.
177
259
  */
178
260
  extern DECLSPEC SDL_JoystickType SDLCALL SDL_JoystickGetDeviceType(int device_index);
179
261
 
180
262
  /**
181
- * Get the instance ID of a joystick.
182
- * This can be called before any joysticks are opened.
183
- * If the index is out of range, this function will return -1.
263
+ * Get the instance ID of a joystick.
264
+ *
265
+ * This can be called before any joysticks are opened. If the index is out of
266
+ * range, this function will return -1.
267
+ *
268
+ * \param device_index the index of the joystick to query (the N'th joystick
269
+ * on the system
270
+ * \returns the instance id of the selected joystick. If called on an invalid
271
+ * index, this function returns zero
272
+ *
273
+ * \since This function is available since SDL 2.0.6.
184
274
  */
185
275
  extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickGetDeviceInstanceID(int device_index);
186
276
 
187
277
  /**
188
- * Open a joystick for use.
189
- * The index passed as an argument refers to the N'th joystick on the system.
190
- * This index is not the value which will identify this joystick in future
191
- * joystick events. The joystick's instance id (::SDL_JoystickID) will be used
192
- * there instead.
278
+ * Open a joystick for use.
279
+ *
280
+ * The `device_index` argument refers to the N'th joystick presently
281
+ * recognized by SDL on the system. It is **NOT** the same as the instance ID
282
+ * used to identify the joystick in future events. See
283
+ * SDL_JoystickInstanceID() for more details about instance IDs.
193
284
  *
194
- * \return A joystick identifier, or NULL if an error occurred.
285
+ * The joystick subsystem must be initialized before a joystick can be opened
286
+ * for use.
287
+ *
288
+ * \param device_index the index of the joystick to query
289
+ * \returns a joystick identifier or NULL if an error occurred; call
290
+ * SDL_GetError() for more information.
291
+ *
292
+ * \since This function is available since SDL 2.0.0.
293
+ *
294
+ * \sa SDL_JoystickClose
295
+ * \sa SDL_JoystickInstanceID
195
296
  */
196
297
  extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickOpen(int device_index);
197
298
 
198
299
  /**
199
- * Return the SDL_Joystick associated with an instance id.
300
+ * Get the SDL_Joystick associated with an instance id.
301
+ *
302
+ * \param instance_id the instance id to get the SDL_Joystick for
303
+ * \returns an SDL_Joystick on success or NULL on failure; call SDL_GetError()
304
+ * for more information.
305
+ *
306
+ * \since This function is available since SDL 2.0.4.
200
307
  */
201
308
  extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickFromInstanceID(SDL_JoystickID instance_id);
202
309
 
203
310
  /**
204
- * Return the SDL_Joystick associated with a player index.
311
+ * Get the SDL_Joystick associated with a player index.
312
+ *
313
+ * \param player_index the player index to get the SDL_Joystick for
314
+ * \returns an SDL_Joystick on success or NULL on failure; call SDL_GetError()
315
+ * for more information.
316
+ *
317
+ * \since This function is available since SDL 2.0.12.
205
318
  */
206
319
  extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickFromPlayerIndex(int player_index);
207
320
 
208
321
  /**
209
- * Attaches a new virtual joystick.
210
- * Returns the joystick's device index, or -1 if an error occurred.
322
+ * Attach a new virtual joystick.
323
+ *
324
+ * \returns the joystick's device index, or -1 if an error occurred.
325
+ *
326
+ * \since This function is available since SDL 2.0.14.
211
327
  */
212
328
  extern DECLSPEC int SDLCALL SDL_JoystickAttachVirtual(SDL_JoystickType type,
213
329
  int naxes,
@@ -215,166 +331,396 @@ extern DECLSPEC int SDLCALL SDL_JoystickAttachVirtual(SDL_JoystickType type,
215
331
  int nhats);
216
332
 
217
333
  /**
218
- * Detaches a virtual joystick
219
- * Returns 0 on success, or -1 if an error occurred.
334
+ * Detach a virtual joystick.
335
+ *
336
+ * \param device_index a value previously returned from
337
+ * SDL_JoystickAttachVirtual()
338
+ * \returns 0 on success, or -1 if an error occurred.
339
+ *
340
+ * \since This function is available since SDL 2.0.14.
220
341
  */
221
342
  extern DECLSPEC int SDLCALL SDL_JoystickDetachVirtual(int device_index);
222
343
 
223
344
  /**
224
- * Indicates whether or not a virtual-joystick is at a given device index.
345
+ * Query whether or not the joystick at a given device index is virtual.
346
+ *
347
+ * \param device_index a joystick device index.
348
+ * \returns SDL_TRUE if the joystick is virtual, SDL_FALSE otherwise.
349
+ *
350
+ * \since This function is available since SDL 2.0.14.
225
351
  */
226
352
  extern DECLSPEC SDL_bool SDLCALL SDL_JoystickIsVirtual(int device_index);
227
353
 
228
354
  /**
229
- * Set values on an opened, virtual-joystick's controls.
230
- * Please note that values set here will not be applied until the next
231
- * call to SDL_JoystickUpdate, which can either be called directly,
232
- * or can be called indirectly through various other SDL APIS,
233
- * including, but not limited to the following: SDL_PollEvent,
234
- * SDL_PumpEvents, SDL_WaitEventTimeout, SDL_WaitEvent.
235
- *
236
- * Returns 0 on success, -1 on error.
355
+ * Set values on an opened, virtual-joystick's axis.
356
+ *
357
+ * Please note that values set here will not be applied until the next call to
358
+ * SDL_JoystickUpdate, which can either be called directly, or can be called
359
+ * indirectly through various other SDL APIs, including, but not limited to
360
+ * the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout,
361
+ * SDL_WaitEvent.
362
+ *
363
+ * \param joystick the virtual joystick on which to set state.
364
+ * \param axis the specific axis on the virtual joystick to set.
365
+ * \param value the new value for the specified axis.
366
+ * \returns 0 on success, -1 on error.
367
+ *
368
+ * \since This function is available since SDL 2.0.14.
237
369
  */
238
370
  extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualAxis(SDL_Joystick *joystick, int axis, Sint16 value);
371
+
372
+ /**
373
+ * Set values on an opened, virtual-joystick's button.
374
+ *
375
+ * Please note that values set here will not be applied until the next call to
376
+ * SDL_JoystickUpdate, which can either be called directly, or can be called
377
+ * indirectly through various other SDL APIs, including, but not limited to
378
+ * the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout,
379
+ * SDL_WaitEvent.
380
+ *
381
+ * \param joystick the virtual joystick on which to set state.
382
+ * \param button the specific button on the virtual joystick to set.
383
+ * \param value the new value for the specified button.
384
+ * \returns 0 on success, -1 on error.
385
+ *
386
+ * \since This function is available since SDL 2.0.14.
387
+ */
239
388
  extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualButton(SDL_Joystick *joystick, int button, Uint8 value);
389
+
390
+ /**
391
+ * Set values on an opened, virtual-joystick's hat.
392
+ *
393
+ * Please note that values set here will not be applied until the next call to
394
+ * SDL_JoystickUpdate, which can either be called directly, or can be called
395
+ * indirectly through various other SDL APIs, including, but not limited to
396
+ * the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout,
397
+ * SDL_WaitEvent.
398
+ *
399
+ * \param joystick the virtual joystick on which to set state.
400
+ * \param hat the specific hat on the virtual joystick to set.
401
+ * \param value the new value for the specified hat.
402
+ * \returns 0 on success, -1 on error.
403
+ *
404
+ * \since This function is available since SDL 2.0.14.
405
+ */
240
406
  extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualHat(SDL_Joystick *joystick, int hat, Uint8 value);
241
407
 
242
408
  /**
243
- * Return the name for this currently opened joystick.
244
- * If no name can be found, this function returns NULL.
409
+ * Get the implementation dependent name of a joystick.
410
+ *
411
+ * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
412
+ * \returns the name of the selected joystick. If no name can be found, this
413
+ * function returns NULL; call SDL_GetError() for more information.
414
+ *
415
+ * \since This function is available since SDL 2.0.0.
416
+ *
417
+ * \sa SDL_JoystickNameForIndex
418
+ * \sa SDL_JoystickOpen
245
419
  */
246
420
  extern DECLSPEC const char *SDLCALL SDL_JoystickName(SDL_Joystick *joystick);
247
421
 
248
422
  /**
249
- * Get the player index of an opened joystick, or -1 if it's not available
423
+ * Get the player index of an opened joystick.
424
+ *
425
+ * For XInput controllers this returns the XInput user index. Many joysticks
426
+ * will not be able to supply this information.
427
+ *
428
+ * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
429
+ * \returns the player index, or -1 if it's not available.
250
430
  *
251
- * For XInput controllers this returns the XInput user index.
431
+ * \since This function is available since SDL 2.0.9.
252
432
  */
253
433
  extern DECLSPEC int SDLCALL SDL_JoystickGetPlayerIndex(SDL_Joystick *joystick);
254
434
 
255
435
  /**
256
- * Set the player index of an opened joystick
436
+ * Set the player index of an opened joystick.
437
+ *
438
+ * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
439
+ * \param player_index the player index to set.
440
+ *
441
+ * \since This function is available since SDL 2.0.12.
257
442
  */
258
443
  extern DECLSPEC void SDLCALL SDL_JoystickSetPlayerIndex(SDL_Joystick *joystick, int player_index);
259
444
 
260
445
  /**
261
- * Return the GUID for this opened joystick
446
+ * Get the implementation-dependent GUID for the joystick.
447
+ *
448
+ * This function requires an open joystick.
449
+ *
450
+ * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
451
+ * \returns the GUID of the given joystick. If called on an invalid index,
452
+ * this function returns a zero GUID; call SDL_GetError() for more
453
+ * information.
454
+ *
455
+ * \since This function is available since SDL 2.0.0.
456
+ *
457
+ * \sa SDL_JoystickGetDeviceGUID
458
+ * \sa SDL_JoystickGetGUIDString
262
459
  */
263
460
  extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUID(SDL_Joystick *joystick);
264
461
 
265
462
  /**
266
- * Get the USB vendor ID of an opened joystick, if available.
267
- * If the vendor ID isn't available this function returns 0.
463
+ * Get the USB vendor ID of an opened joystick, if available.
464
+ *
465
+ * If the vendor ID isn't available this function returns 0.
466
+ *
467
+ * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
468
+ * \returns the USB vendor ID of the selected joystick, or 0 if unavailable.
469
+ *
470
+ * \since This function is available since SDL 2.0.6.
268
471
  */
269
472
  extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetVendor(SDL_Joystick *joystick);
270
473
 
271
474
  /**
272
- * Get the USB product ID of an opened joystick, if available.
273
- * If the product ID isn't available this function returns 0.
475
+ * Get the USB product ID of an opened joystick, if available.
476
+ *
477
+ * If the product ID isn't available this function returns 0.
478
+ *
479
+ * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
480
+ * \returns the USB product ID of the selected joystick, or 0 if unavailable.
481
+ *
482
+ * \since This function is available since SDL 2.0.6.
274
483
  */
275
484
  extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetProduct(SDL_Joystick *joystick);
276
485
 
277
486
  /**
278
- * Get the product version of an opened joystick, if available.
279
- * If the product version isn't available this function returns 0.
487
+ * Get the product version of an opened joystick, if available.
488
+ *
489
+ * If the product version isn't available this function returns 0.
490
+ *
491
+ * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
492
+ * \returns the product version of the selected joystick, or 0 if unavailable.
493
+ *
494
+ * \since This function is available since SDL 2.0.6.
280
495
  */
281
496
  extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetProductVersion(SDL_Joystick *joystick);
282
497
 
283
498
  /**
284
- * Get the serial number of an opened joystick, if available.
285
- *
286
- * Returns the serial number of the joystick, or NULL if it is not available.
499
+ * Get the serial number of an opened joystick, if available.
500
+ *
501
+ * Returns the serial number of the joystick, or NULL if it is not available.
502
+ *
503
+ * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
504
+ * \returns the serial number of the selected joystick, or NULL if
505
+ * unavailable.
506
+ *
507
+ * \since This function is available since SDL 2.0.14.
287
508
  */
288
509
  extern DECLSPEC const char * SDLCALL SDL_JoystickGetSerial(SDL_Joystick *joystick);
289
510
 
290
511
  /**
291
- * Get the type of an opened joystick.
512
+ * Get the type of an opened joystick.
513
+ *
514
+ * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
515
+ * \returns the SDL_JoystickType of the selected joystick.
516
+ *
517
+ * \since This function is available since SDL 2.0.6.
292
518
  */
293
519
  extern DECLSPEC SDL_JoystickType SDLCALL SDL_JoystickGetType(SDL_Joystick *joystick);
294
520
 
295
521
  /**
296
- * Return a string representation for this guid. pszGUID must point to at least 33 bytes
297
- * (32 for the string plus a NULL terminator).
522
+ * Get an ASCII string representation for a given SDL_JoystickGUID.
523
+ *
524
+ * You should supply at least 33 bytes for pszGUID.
525
+ *
526
+ * \param guid the SDL_JoystickGUID you wish to convert to string
527
+ * \param pszGUID buffer in which to write the ASCII string
528
+ * \param cbGUID the size of pszGUID
529
+ *
530
+ * \since This function is available since SDL 2.0.0.
531
+ *
532
+ * \sa SDL_JoystickGetDeviceGUID
533
+ * \sa SDL_JoystickGetGUID
534
+ * \sa SDL_JoystickGetGUIDFromString
298
535
  */
299
536
  extern DECLSPEC void SDLCALL SDL_JoystickGetGUIDString(SDL_JoystickGUID guid, char *pszGUID, int cbGUID);
300
537
 
301
538
  /**
302
- * Convert a string into a joystick guid
539
+ * Convert a GUID string into a SDL_JoystickGUID structure.
540
+ *
541
+ * Performs no error checking. If this function is given a string containing
542
+ * an invalid GUID, the function will silently succeed, but the GUID generated
543
+ * will not be useful.
544
+ *
545
+ * \param pchGUID string containing an ASCII representation of a GUID
546
+ * \returns a SDL_JoystickGUID structure.
547
+ *
548
+ * \since This function is available since SDL 2.0.0.
549
+ *
550
+ * \sa SDL_JoystickGetGUIDString
303
551
  */
304
552
  extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUIDFromString(const char *pchGUID);
305
553
 
306
554
  /**
307
- * Returns SDL_TRUE if the joystick has been opened and currently connected, or SDL_FALSE if it has not.
555
+ * Get the status of a specified joystick.
556
+ *
557
+ * \param joystick the joystick to query
558
+ * \returns SDL_TRUE if the joystick has been opened, SDL_FALSE if it has not;
559
+ * call SDL_GetError() for more information.
560
+ *
561
+ * \since This function is available since SDL 2.0.0.
562
+ *
563
+ * \sa SDL_JoystickClose
564
+ * \sa SDL_JoystickOpen
308
565
  */
309
566
  extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAttached(SDL_Joystick *joystick);
310
567
 
311
568
  /**
312
- * Get the instance ID of an opened joystick or -1 if the joystick is invalid.
569
+ * Get the instance ID of an opened joystick.
570
+ *
571
+ * \param joystick an SDL_Joystick structure containing joystick information
572
+ * \returns the instance ID of the specified joystick on success or a negative
573
+ * error code on failure; call SDL_GetError() for more information.
574
+ *
575
+ * \since This function is available since SDL 2.0.0.
576
+ *
577
+ * \sa SDL_JoystickOpen
313
578
  */
314
579
  extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickInstanceID(SDL_Joystick *joystick);
315
580
 
316
581
  /**
317
- * Get the number of general axis controls on a joystick.
582
+ * Get the number of general axis controls on a joystick.
583
+ *
584
+ * Often, the directional pad on a game controller will either look like 4
585
+ * separate buttons or a POV hat, and not axes, but all of this is up to the
586
+ * device and platform.
587
+ *
588
+ * \param joystick an SDL_Joystick structure containing joystick information
589
+ * \returns the number of axis controls/number of axes on success or a
590
+ * negative error code on failure; call SDL_GetError() for more
591
+ * information.
592
+ *
593
+ * \since This function is available since SDL 2.0.0.
594
+ *
595
+ * \sa SDL_JoystickGetAxis
596
+ * \sa SDL_JoystickOpen
318
597
  */
319
598
  extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick *joystick);
320
599
 
321
600
  /**
322
- * Get the number of trackballs on a joystick.
601
+ * Get the number of trackballs on a joystick.
323
602
  *
324
- * Joystick trackballs have only relative motion events associated
325
- * with them and their state cannot be polled.
603
+ * Joystick trackballs have only relative motion events associated with them
604
+ * and their state cannot be polled.
605
+ *
606
+ * Most joysticks do not have trackballs.
607
+ *
608
+ * \param joystick an SDL_Joystick structure containing joystick information
609
+ * \returns the number of trackballs on success or a negative error code on
610
+ * failure; call SDL_GetError() for more information.
611
+ *
612
+ * \since This function is available since SDL 2.0.0.
613
+ *
614
+ * \sa SDL_JoystickGetBall
326
615
  */
327
616
  extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick *joystick);
328
617
 
329
618
  /**
330
- * Get the number of POV hats on a joystick.
619
+ * Get the number of POV hats on a joystick.
620
+ *
621
+ * \param joystick an SDL_Joystick structure containing joystick information
622
+ * \returns the number of POV hats on success or a negative error code on
623
+ * failure; call SDL_GetError() for more information.
624
+ *
625
+ * \since This function is available since SDL 2.0.0.
626
+ *
627
+ * \sa SDL_JoystickGetHat
628
+ * \sa SDL_JoystickOpen
331
629
  */
332
630
  extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick *joystick);
333
631
 
334
632
  /**
335
- * Get the number of buttons on a joystick.
633
+ * Get the number of buttons on a joystick.
634
+ *
635
+ * \param joystick an SDL_Joystick structure containing joystick information
636
+ * \returns the number of buttons on success or a negative error code on
637
+ * failure; call SDL_GetError() for more information.
638
+ *
639
+ * \since This function is available since SDL 2.0.0.
640
+ *
641
+ * \sa SDL_JoystickGetButton
642
+ * \sa SDL_JoystickOpen
336
643
  */
337
644
  extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick *joystick);
338
645
 
339
646
  /**
340
- * Update the current state of the open joysticks.
647
+ * Update the current state of the open joysticks.
648
+ *
649
+ * This is called automatically by the event loop if any joystick events are
650
+ * enabled.
341
651
  *
342
- * This is called automatically by the event loop if any joystick
343
- * events are enabled.
652
+ * \since This function is available since SDL 2.0.0.
653
+ *
654
+ * \sa SDL_JoystickEventState
344
655
  */
345
656
  extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void);
346
657
 
347
658
  /**
348
- * Enable/disable joystick event polling.
659
+ * Enable/disable joystick event polling.
660
+ *
661
+ * If joystick events are disabled, you must call SDL_JoystickUpdate()
662
+ * yourself and manually check the state of the joystick when you want
663
+ * joystick information.
664
+ *
665
+ * It is recommended that you leave joystick event handling enabled.
666
+ *
667
+ * **WARNING**: Calling this function may delete all events currently in SDL's
668
+ * event queue.
669
+ *
670
+ * \param state can be one of `SDL_QUERY`, `SDL_IGNORE`, or `SDL_ENABLE`
671
+ * \returns 1 if enabled, 0 if disabled, or a negative error code on failure;
672
+ * call SDL_GetError() for more information.
349
673
  *
350
- * If joystick events are disabled, you must call SDL_JoystickUpdate()
351
- * yourself and check the state of the joystick when you want joystick
352
- * information.
674
+ * If `state` is `SDL_QUERY` then the current state is returned,
675
+ * otherwise the new processing state is returned.
353
676
  *
354
- * The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE.
677
+ * \since This function is available since SDL 2.0.0.
678
+ *
679
+ * \sa SDL_GameControllerEventState
355
680
  */
356
681
  extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state);
357
682
 
358
683
  #define SDL_JOYSTICK_AXIS_MAX 32767
359
684
  #define SDL_JOYSTICK_AXIS_MIN -32768
685
+
360
686
  /**
361
- * Get the current state of an axis control on a joystick.
687
+ * Get the current state of an axis control on a joystick.
688
+ *
689
+ * SDL makes no promises about what part of the joystick any given axis refers
690
+ * to. Your game should have some sort of configuration UI to let users
691
+ * specify what each axis should be bound to. Alternately, SDL's higher-level
692
+ * Game Controller API makes a great effort to apply order to this lower-level
693
+ * interface, so you know that a specific axis is the "left thumb stick," etc.
362
694
  *
363
- * The state is a value ranging from -32768 to 32767.
695
+ * The value returned by SDL_JoystickGetAxis() is a signed integer (-32768 to
696
+ * 32767) representing the current position of the axis. It may be necessary
697
+ * to impose certain tolerances on these values to account for jitter.
364
698
  *
365
- * The axis indices start at index 0.
699
+ * \param joystick an SDL_Joystick structure containing joystick information
700
+ * \param axis the axis to query; the axis indices start at index 0
701
+ * \returns a 16-bit signed integer representing the current position of the
702
+ * axis or 0 on failure; call SDL_GetError() for more information.
703
+ *
704
+ * \since This function is available since SDL 2.0.0.
705
+ *
706
+ * \sa SDL_JoystickNumAxes
366
707
  */
367
708
  extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick *joystick,
368
709
  int axis);
369
710
 
370
711
  /**
371
- * Get the initial state of an axis control on a joystick.
712
+ * Get the initial state of an axis control on a joystick.
713
+ *
714
+ * The state is a value ranging from -32768 to 32767.
372
715
  *
373
- * The state is a value ranging from -32768 to 32767.
716
+ * The axis indices start at index 0.
374
717
  *
375
- * The axis indices start at index 0.
718
+ * \param joystick an SDL_Joystick structure containing joystick information
719
+ * \param axis the axis to query; the axis indices start at index 0
720
+ * \param state Upon return, the initial value is supplied here.
721
+ * \return SDL_TRUE if this axis has any initial value, or SDL_FALSE if not.
376
722
  *
377
- * \return SDL_TRUE if this axis has any initial value, or SDL_FALSE if not.
723
+ * \since This function is available since SDL 2.0.6.
378
724
  */
379
725
  extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAxisInitialState(SDL_Joystick *joystick,
380
726
  int axis, Sint16 *state);
@@ -395,96 +741,197 @@ extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAxisInitialState(SDL_Joystick *j
395
741
  /* @} */
396
742
 
397
743
  /**
398
- * Get the current state of a POV hat on a joystick.
744
+ * Get the current state of a POV hat on a joystick.
399
745
  *
400
- * The hat indices start at index 0.
746
+ * The returned value will be one of the following positions:
401
747
  *
402
- * \return The return value is one of the following positions:
403
- * - ::SDL_HAT_CENTERED
404
- * - ::SDL_HAT_UP
405
- * - ::SDL_HAT_RIGHT
406
- * - ::SDL_HAT_DOWN
407
- * - ::SDL_HAT_LEFT
408
- * - ::SDL_HAT_RIGHTUP
409
- * - ::SDL_HAT_RIGHTDOWN
410
- * - ::SDL_HAT_LEFTUP
411
- * - ::SDL_HAT_LEFTDOWN
748
+ * - `SDL_HAT_CENTERED`
749
+ * - `SDL_HAT_UP`
750
+ * - `SDL_HAT_RIGHT`
751
+ * - `SDL_HAT_DOWN`
752
+ * - `SDL_HAT_LEFT`
753
+ * - `SDL_HAT_RIGHTUP`
754
+ * - `SDL_HAT_RIGHTDOWN`
755
+ * - `SDL_HAT_LEFTUP`
756
+ * - `SDL_HAT_LEFTDOWN`
757
+ *
758
+ * \param joystick an SDL_Joystick structure containing joystick information
759
+ * \param hat the hat index to get the state from; indices start at index 0
760
+ * \returns the current hat position.
761
+ *
762
+ * \since This function is available since SDL 2.0.0.
763
+ *
764
+ * \sa SDL_JoystickNumHats
412
765
  */
413
766
  extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick *joystick,
414
767
  int hat);
415
768
 
416
769
  /**
417
- * Get the ball axis change since the last poll.
770
+ * Get the ball axis change since the last poll.
771
+ *
772
+ * Trackballs can only return relative motion since the last call to
773
+ * SDL_JoystickGetBall(), these motion deltas are placed into `dx` and `dy`.
774
+ *
775
+ * Most joysticks do not have trackballs.
418
776
  *
419
- * \return 0, or -1 if you passed it invalid parameters.
777
+ * \param joystick the SDL_Joystick to query
778
+ * \param ball the ball index to query; ball indices start at index 0
779
+ * \param dx stores the difference in the x axis position since the last poll
780
+ * \param dy stores the difference in the y axis position since the last poll
781
+ * \returns 0 on success or a negative error code on failure; call
782
+ * SDL_GetError() for more information.
420
783
  *
421
- * The ball indices start at index 0.
784
+ * \since This function is available since SDL 2.0.0.
785
+ *
786
+ * \sa SDL_JoystickNumBalls
422
787
  */
423
788
  extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick *joystick,
424
789
  int ball, int *dx, int *dy);
425
790
 
426
791
  /**
427
- * Get the current state of a button on a joystick.
792
+ * Get the current state of a button on a joystick.
793
+ *
794
+ * \param joystick an SDL_Joystick structure containing joystick information
795
+ * \param button the button index to get the state from; indices start at
796
+ * index 0
797
+ * \returns 1 if the specified button is pressed, 0 otherwise.
798
+ *
799
+ * \since This function is available since SDL 2.0.0.
428
800
  *
429
- * The button indices start at index 0.
801
+ * \sa SDL_JoystickNumButtons
430
802
  */
431
803
  extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick *joystick,
432
804
  int button);
433
805
 
434
806
  /**
435
- * Start a rumble effect
436
- * Each call to this function cancels any previous rumble effect, and calling it with 0 intensity stops any rumbling.
807
+ * Start a rumble effect.
437
808
  *
438
- * \param joystick The joystick to vibrate
439
- * \param low_frequency_rumble The intensity of the low frequency (left) rumble motor, from 0 to 0xFFFF
440
- * \param high_frequency_rumble The intensity of the high frequency (right) rumble motor, from 0 to 0xFFFF
441
- * \param duration_ms The duration of the rumble effect, in milliseconds
809
+ * Each call to this function cancels any previous rumble effect, and calling
810
+ * it with 0 intensity stops any rumbling.
442
811
  *
443
- * \return 0, or -1 if rumble isn't supported on this joystick
812
+ * \param joystick The joystick to vibrate
813
+ * \param low_frequency_rumble The intensity of the low frequency (left)
814
+ * rumble motor, from 0 to 0xFFFF
815
+ * \param high_frequency_rumble The intensity of the high frequency (right)
816
+ * rumble motor, from 0 to 0xFFFF
817
+ * \param duration_ms The duration of the rumble effect, in milliseconds
818
+ * \returns 0, or -1 if rumble isn't supported on this joystick
819
+ *
820
+ * \since This function is available since SDL 2.0.9.
821
+ *
822
+ * \sa SDL_JoystickHasRumble
444
823
  */
445
824
  extern DECLSPEC int SDLCALL SDL_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
446
825
 
447
826
  /**
448
- * Start a rumble effect in the joystick's triggers
449
- * Each call to this function cancels any previous trigger rumble effect, and calling it with 0 intensity stops any rumbling.
827
+ * Start a rumble effect in the joystick's triggers
828
+ *
829
+ * Each call to this function cancels any previous trigger rumble effect, and
830
+ * calling it with 0 intensity stops any rumbling.
450
831
  *
451
- * \param joystick The joystick to vibrate
452
- * \param left_rumble The intensity of the left trigger rumble motor, from 0 to 0xFFFF
453
- * \param right_rumble The intensity of the right trigger rumble motor, from 0 to 0xFFFF
454
- * \param duration_ms The duration of the rumble effect, in milliseconds
832
+ * Note that this function is for _trigger_ rumble; the first joystick to
833
+ * support this was the PlayStation 5's DualShock 5 controller. If you want
834
+ * the (more common) whole-controller rumble, use SDL_JoystickRumble()
835
+ * instead.
455
836
  *
456
- * \return 0, or -1 if trigger rumble isn't supported on this joystick
837
+ * \param joystick The joystick to vibrate
838
+ * \param left_rumble The intensity of the left trigger rumble motor, from 0
839
+ * to 0xFFFF
840
+ * \param right_rumble The intensity of the right trigger rumble motor, from 0
841
+ * to 0xFFFF
842
+ * \param duration_ms The duration of the rumble effect, in milliseconds
843
+ * \returns 0, or -1 if trigger rumble isn't supported on this joystick
844
+ *
845
+ * \since This function is available since SDL 2.0.14.
846
+ *
847
+ * \sa SDL_JoystickHasRumbleTriggers
457
848
  */
458
849
  extern DECLSPEC int SDLCALL SDL_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
459
850
 
460
851
  /**
461
- * Return whether a joystick has an LED
852
+ * Query whether a joystick has an LED.
853
+ *
854
+ * An example of a joystick LED is the light on the back of a PlayStation 4's
855
+ * DualShock 4 controller.
462
856
  *
463
- * \param joystick The joystick to query
857
+ * \param joystick The joystick to query
858
+ * \return SDL_TRUE if the joystick has a modifiable LED, SDL_FALSE otherwise.
464
859
  *
465
- * \return SDL_TRUE, or SDL_FALSE if this joystick does not have a modifiable LED
860
+ * \since This function is available since SDL 2.0.14.
466
861
  */
467
862
  extern DECLSPEC SDL_bool SDLCALL SDL_JoystickHasLED(SDL_Joystick *joystick);
468
863
 
469
864
  /**
470
- * Update a joystick's LED color.
865
+ * Query whether a joystick has rumble support.
471
866
  *
472
- * \param joystick The joystick to update
473
- * \param red The intensity of the red LED
474
- * \param green The intensity of the green LED
475
- * \param blue The intensity of the blue LED
867
+ * \param joystick The joystick to query
868
+ * \return SDL_TRUE if the joystick has rumble, SDL_FALSE otherwise.
476
869
  *
477
- * \return 0, or -1 if this joystick does not have a modifiable LED
870
+ * \since This function is available since SDL 2.0.18.
871
+ *
872
+ * \sa SDL_JoystickRumble
873
+ */
874
+ extern DECLSPEC SDL_bool SDLCALL SDL_JoystickHasRumble(SDL_Joystick *joystick);
875
+
876
+ /**
877
+ * Query whether a joystick has rumble support on triggers.
878
+ *
879
+ * \param joystick The joystick to query
880
+ * \return SDL_TRUE if the joystick has trigger rumble, SDL_FALSE otherwise.
881
+ *
882
+ * \since This function is available since SDL 2.0.18.
883
+ *
884
+ * \sa SDL_JoystickRumbleTriggers
885
+ */
886
+ extern DECLSPEC SDL_bool SDLCALL SDL_JoystickHasRumbleTriggers(SDL_Joystick *joystick);
887
+
888
+ /**
889
+ * Update a joystick's LED color.
890
+ *
891
+ * An example of a joystick LED is the light on the back of a PlayStation 4's
892
+ * DualShock 4 controller.
893
+ *
894
+ * \param joystick The joystick to update
895
+ * \param red The intensity of the red LED
896
+ * \param green The intensity of the green LED
897
+ * \param blue The intensity of the blue LED
898
+ * \returns 0 on success, -1 if this joystick does not have a modifiable LED
899
+ *
900
+ * \since This function is available since SDL 2.0.14.
478
901
  */
479
902
  extern DECLSPEC int SDLCALL SDL_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue);
480
903
 
481
904
  /**
482
- * Close a joystick previously opened with SDL_JoystickOpen().
905
+ * Send a joystick specific effect packet
906
+ *
907
+ * \param joystick The joystick to affect
908
+ * \param data The data to send to the joystick
909
+ * \param size The size of the data to send to the joystick
910
+ * \returns 0, or -1 if this joystick or driver doesn't support effect packets
911
+ *
912
+ * \since This function is available since SDL 2.0.16.
913
+ */
914
+ extern DECLSPEC int SDLCALL SDL_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size);
915
+
916
+ /**
917
+ * Close a joystick previously opened with SDL_JoystickOpen().
918
+ *
919
+ * \param joystick The joystick device to close
920
+ *
921
+ * \since This function is available since SDL 2.0.0.
922
+ *
923
+ * \sa SDL_JoystickOpen
483
924
  */
484
925
  extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick *joystick);
485
926
 
486
927
  /**
487
- * Return the battery level of this joystick
928
+ * Get the battery level of a joystick as SDL_JoystickPowerLevel.
929
+ *
930
+ * \param joystick the SDL_Joystick to query
931
+ * \returns the current battery level as SDL_JoystickPowerLevel on success or
932
+ * `SDL_JOYSTICK_POWER_UNKNOWN` if it is unknown
933
+ *
934
+ * \since This function is available since SDL 2.0.4.
488
935
  */
489
936
  extern DECLSPEC SDL_JoystickPowerLevel SDLCALL SDL_JoystickCurrentPowerLevel(SDL_Joystick *joystick);
490
937