gosu 1.4.6 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (320) hide show
  1. checksums.yaml +4 -4
  2. data/COPYING +2 -1
  3. data/dependencies/SDL/include/SDL3/SDL.h +91 -0
  4. data/dependencies/SDL/include/SDL3/SDL_assert.h +710 -0
  5. data/dependencies/SDL/include/SDL3/SDL_asyncio.h +550 -0
  6. data/dependencies/SDL/include/SDL3/SDL_atomic.h +692 -0
  7. data/dependencies/SDL/include/SDL3/SDL_audio.h +2382 -0
  8. data/dependencies/SDL/include/SDL3/SDL_begin_code.h +553 -0
  9. data/dependencies/SDL/include/{SDL_bits.h → SDL3/SDL_bits.h} +47 -27
  10. data/dependencies/SDL/include/{SDL_blendmode.h → SDL3/SDL_blendmode.h} +59 -55
  11. data/dependencies/SDL/include/SDL3/SDL_camera.h +535 -0
  12. data/dependencies/SDL/include/SDL3/SDL_clipboard.h +331 -0
  13. data/dependencies/SDL/include/{close_code.h → SDL3/SDL_close_code.h} +9 -8
  14. data/dependencies/SDL/include/{SDL_types.h → SDL3/SDL_copying.h} +2 -9
  15. data/dependencies/SDL/include/SDL3/SDL_cpuinfo.h +374 -0
  16. data/dependencies/SDL/include/SDL3/SDL_dialog.h +343 -0
  17. data/dependencies/SDL/include/SDL3/SDL_dlopennote.h +234 -0
  18. data/dependencies/SDL/include/{SDL_egl.h → SDL3/SDL_egl.h} +11 -8
  19. data/dependencies/SDL/include/SDL3/SDL_endian.h +645 -0
  20. data/dependencies/SDL/include/SDL3/SDL_error.h +226 -0
  21. data/dependencies/SDL/include/SDL3/SDL_events.h +1651 -0
  22. data/dependencies/SDL/include/SDL3/SDL_filesystem.h +537 -0
  23. data/dependencies/SDL/include/SDL3/SDL_gamepad.h +1657 -0
  24. data/dependencies/SDL/include/SDL3/SDL_gpu.h +4637 -0
  25. data/dependencies/SDL/include/SDL3/SDL_guid.h +106 -0
  26. data/dependencies/SDL/include/SDL3/SDL_haptic.h +1461 -0
  27. data/dependencies/SDL/include/SDL3/SDL_hidapi.h +571 -0
  28. data/dependencies/SDL/include/SDL3/SDL_hints.h +5041 -0
  29. data/dependencies/SDL/include/SDL3/SDL_init.h +508 -0
  30. data/dependencies/SDL/include/SDL3/SDL_intrin.h +410 -0
  31. data/dependencies/SDL/include/SDL3/SDL_iostream.h +1379 -0
  32. data/dependencies/SDL/include/SDL3/SDL_joystick.h +1385 -0
  33. data/dependencies/SDL/include/SDL3/SDL_keyboard.h +615 -0
  34. data/dependencies/SDL/include/SDL3/SDL_keycode.h +348 -0
  35. data/dependencies/SDL/include/SDL3/SDL_loadso.h +145 -0
  36. data/dependencies/SDL/include/{SDL_locale.h → SDL3/SDL_locale.h} +40 -24
  37. data/dependencies/SDL/include/SDL3/SDL_log.h +541 -0
  38. data/dependencies/SDL/include/SDL3/SDL_main.h +704 -0
  39. data/dependencies/SDL/include/SDL3/SDL_main_impl.h +149 -0
  40. data/dependencies/SDL/include/{SDL_messagebox.h → SDL3/SDL_messagebox.h} +85 -48
  41. data/dependencies/SDL/include/{SDL_metal.h → SDL3/SDL_metal.h} +29 -29
  42. data/dependencies/SDL/include/{SDL_misc.h → SDL3/SDL_misc.h} +13 -12
  43. data/dependencies/SDL/include/SDL3/SDL_mouse.h +813 -0
  44. data/dependencies/SDL/include/SDL3/SDL_mutex.h +1117 -0
  45. data/dependencies/SDL/include/SDL3/SDL_oldnames.h +1339 -0
  46. data/dependencies/SDL/include/{SDL_opengl.h → SDL3/SDL_opengl.h} +1247 -278
  47. data/dependencies/SDL/include/{SDL_opengl_glext.h → SDL3/SDL_opengl_glext.h} +5 -1
  48. data/dependencies/SDL/include/{SDL_opengles.h → SDL3/SDL_opengles.h} +6 -7
  49. data/dependencies/SDL/include/{SDL_opengles2.h → SDL3/SDL_opengles2.h} +10 -11
  50. data/dependencies/SDL/include/SDL3/SDL_pen.h +198 -0
  51. data/dependencies/SDL/include/SDL3/SDL_pixels.h +1441 -0
  52. data/dependencies/SDL/include/{SDL_test_log.h → SDL3/SDL_platform.h} +25 -26
  53. data/dependencies/SDL/include/SDL3/SDL_platform_defines.h +497 -0
  54. data/dependencies/SDL/include/{SDL_power.h → SDL3/SDL_power.h} +40 -20
  55. data/dependencies/SDL/include/SDL3/SDL_process.h +441 -0
  56. data/dependencies/SDL/include/SDL3/SDL_properties.h +572 -0
  57. data/dependencies/SDL/include/SDL3/SDL_rect.h +528 -0
  58. data/dependencies/SDL/include/SDL3/SDL_render.h +3034 -0
  59. data/dependencies/SDL/include/SDL3/SDL_revision.h +56 -0
  60. data/dependencies/SDL/include/{SDL_scancode.h → SDL3/SDL_scancode.h} +60 -68
  61. data/dependencies/SDL/include/SDL3/SDL_sensor.h +321 -0
  62. data/dependencies/SDL/include/SDL3/SDL_stdinc.h +6186 -0
  63. data/dependencies/SDL/include/SDL3/SDL_storage.h +686 -0
  64. data/dependencies/SDL/include/SDL3/SDL_surface.h +1769 -0
  65. data/dependencies/SDL/include/SDL3/SDL_system.h +840 -0
  66. data/dependencies/SDL/include/{SDL_test.h → SDL3/SDL_test.h} +16 -22
  67. data/dependencies/SDL/include/{SDL_test_assert.h → SDL3/SDL_test_assert.h} +27 -34
  68. data/dependencies/SDL/include/{SDL_test_common.h → SDL3/SDL_test_common.h} +109 -52
  69. data/dependencies/SDL/include/{SDL_test_compare.h → SDL3/SDL_test_compare.h} +22 -14
  70. data/dependencies/SDL/include/{SDL_test_crc32.h → SDL3/SDL_test_crc32.h} +27 -30
  71. data/dependencies/SDL/include/{SDL_test_font.h → SDL3/SDL_test_font.h} +50 -49
  72. data/dependencies/SDL/include/{SDL_test_fuzzer.h → SDL3/SDL_test_fuzzer.h} +64 -79
  73. data/dependencies/SDL/include/{SDL_test_harness.h → SDL3/SDL_test_harness.h} +47 -30
  74. data/dependencies/SDL/include/SDL3/SDL_test_log.h +83 -0
  75. data/dependencies/SDL/include/{SDL_test_md5.h → SDL3/SDL_test_md5.h} +21 -28
  76. data/dependencies/SDL/include/{SDL_test_memory.h → SDL3/SDL_test_memory.h} +19 -16
  77. data/dependencies/SDL/include/SDL3/SDL_thread.h +602 -0
  78. data/dependencies/SDL/include/SDL3/SDL_time.h +249 -0
  79. data/dependencies/SDL/include/SDL3/SDL_timer.h +454 -0
  80. data/dependencies/SDL/include/SDL3/SDL_touch.h +184 -0
  81. data/dependencies/SDL/include/SDL3/SDL_tray.h +544 -0
  82. data/dependencies/SDL/include/SDL3/SDL_version.h +198 -0
  83. data/dependencies/SDL/include/SDL3/SDL_video.h +3497 -0
  84. data/dependencies/SDL/include/SDL3/SDL_vulkan.h +287 -0
  85. data/dependencies/SDL/lib/x64/libSDL3.dll.a +0 -0
  86. data/dependencies/SDL/lib/x86/libSDL3.dll.a +0 -0
  87. data/dependencies/SDL_sound/SDL3_sound/SDL_sound.h +755 -0
  88. data/dependencies/SDL_sound/SDL_sound.c +136 -215
  89. data/dependencies/SDL_sound/SDL_sound_aiff.c +55 -54
  90. data/dependencies/SDL_sound/SDL_sound_au.c +32 -32
  91. data/dependencies/SDL_sound/SDL_sound_coreaudio.c +24 -41
  92. data/dependencies/SDL_sound/SDL_sound_flac.c +32 -12
  93. data/dependencies/SDL_sound/SDL_sound_internal.h +33 -48
  94. data/dependencies/SDL_sound/SDL_sound_modplug.c +21 -29
  95. data/dependencies/SDL_sound/SDL_sound_mp3.c +35 -13
  96. data/dependencies/SDL_sound/SDL_sound_raw.c +14 -15
  97. data/dependencies/SDL_sound/SDL_sound_shn.c +82 -82
  98. data/dependencies/SDL_sound/SDL_sound_voc.c +30 -30
  99. data/dependencies/SDL_sound/SDL_sound_vorbis.c +34 -25
  100. data/dependencies/SDL_sound/SDL_sound_wav.c +86 -82
  101. data/dependencies/SDL_sound/dr_flac.h +1890 -1301
  102. data/dependencies/SDL_sound/dr_mp3.h +1098 -660
  103. data/dependencies/SDL_sound/libmodplug/fastmix.c +1 -1
  104. data/dependencies/SDL_sound/libmodplug/libmodplug.h +5 -4
  105. data/dependencies/SDL_sound/libmodplug/load_ams.c +6 -3
  106. data/dependencies/SDL_sound/libmodplug/load_dsm.c +2 -1
  107. data/dependencies/SDL_sound/libmodplug/load_mt2.c +2 -2
  108. data/dependencies/SDL_sound/libmodplug/modplug.h +2 -1
  109. data/dependencies/SDL_sound/libmodplug/snd_fx.c +3 -3
  110. data/dependencies/SDL_sound/libmodplug/sndfile.c +3 -0
  111. data/dependencies/SDL_sound/libmodplug/sndmix.c +7 -3
  112. data/dependencies/SDL_sound/stb_vorbis.h +397 -342
  113. data/dependencies/mojoAL/AL/alc.h +2 -2
  114. data/dependencies/mojoAL/mojoal.c +2120 -1885
  115. data/dependencies/stb/stb_image.h +1190 -1379
  116. data/dependencies/stb/stb_image_write.h +329 -129
  117. data/dependencies/stb/stb_truetype.h +304 -60
  118. data/dependencies/utf8proc/utf8proc.c +133 -75
  119. data/dependencies/utf8proc/utf8proc.h +131 -50
  120. data/dependencies/utf8proc/utf8proc_data.h +16213 -15658
  121. data/ext/gosu-ffi/extconf.rb +103 -0
  122. data/ext/gosu-ffi/gosu-ffi.def +467 -0
  123. data/ffi/Gosu.cpp +330 -0
  124. data/ffi/Gosu.h +84 -0
  125. data/ffi/Gosu_Channel.cpp +62 -0
  126. data/ffi/Gosu_Channel.h +17 -0
  127. data/ffi/Gosu_Color.cpp +176 -0
  128. data/ffi/Gosu_Color.h +31 -0
  129. data/ffi/Gosu_Constants.cpp +334 -0
  130. data/ffi/Gosu_FFI.h +34 -0
  131. data/ffi/Gosu_FFI_internal.h +160 -0
  132. data/ffi/Gosu_Font.cpp +97 -0
  133. data/ffi/Gosu_Font.h +32 -0
  134. data/ffi/Gosu_Image.cpp +239 -0
  135. data/ffi/Gosu_Image.h +71 -0
  136. data/ffi/Gosu_Sample.cpp +29 -0
  137. data/ffi/Gosu_Sample.h +14 -0
  138. data/ffi/Gosu_Song.cpp +69 -0
  139. data/ffi/Gosu_Song.h +18 -0
  140. data/ffi/Gosu_TextInput.cpp +94 -0
  141. data/ffi/Gosu_TextInput.h +25 -0
  142. data/ffi/Gosu_Window.cpp +314 -0
  143. data/ffi/Gosu_Window.h +78 -0
  144. data/include/Gosu/Audio.hpp +6 -11
  145. data/include/Gosu/Bitmap.hpp +38 -53
  146. data/include/Gosu/Buffer.hpp +54 -0
  147. data/include/Gosu/Color.hpp +29 -36
  148. data/include/Gosu/Directories.hpp +25 -28
  149. data/include/Gosu/Drawable.hpp +58 -0
  150. data/include/Gosu/Font.hpp +6 -5
  151. data/include/Gosu/Fwd.hpp +4 -6
  152. data/include/Gosu/Gosu.hpp +5 -5
  153. data/include/Gosu/Graphics.hpp +53 -61
  154. data/include/Gosu/GraphicsBase.hpp +1 -11
  155. data/include/Gosu/Image.hpp +12 -15
  156. data/include/Gosu/Math.hpp +50 -72
  157. data/include/Gosu/Transform.hpp +32 -0
  158. data/include/Gosu/Utility.hpp +77 -1
  159. data/include/Gosu/Version.hpp +2 -2
  160. data/include/Gosu/Window.hpp +15 -9
  161. data/lib/SDL3.dll +0 -0
  162. data/lib/gosu/channel.rb +50 -0
  163. data/lib/gosu/color.rb +173 -0
  164. data/lib/gosu/compat.rb +130 -17
  165. data/lib/gosu/constants.rb +386 -0
  166. data/lib/gosu/ffi.rb +269 -0
  167. data/lib/gosu/font.rb +62 -0
  168. data/lib/gosu/gl_tex_info.rb +33 -0
  169. data/lib/gosu/gosu.rb +250 -0
  170. data/lib/gosu/image.rb +179 -0
  171. data/lib/gosu/numeric.rb +17 -0
  172. data/lib/gosu/preview.rb +6 -6
  173. data/lib/gosu/sample.rb +25 -0
  174. data/lib/gosu/song.rb +57 -0
  175. data/lib/gosu/text_input.rb +83 -0
  176. data/lib/gosu/window.rb +249 -0
  177. data/lib/gosu.rb +29 -8
  178. data/lib64/SDL3.dll +0 -0
  179. data/rdoc/gosu.rb +2 -2
  180. data/src/Audio.cpp +30 -24
  181. data/src/AudioFile.hpp +5 -4
  182. data/src/AudioFileAudioToolbox.cpp +8 -8
  183. data/src/AudioFileSDLSound.cpp +12 -15
  184. data/src/BinPacker.cpp +188 -0
  185. data/src/BinPacker.hpp +55 -0
  186. data/src/Bitmap.cpp +172 -143
  187. data/src/BitmapIO.cpp +60 -86
  188. data/src/Buffer.cpp +150 -0
  189. data/src/ClipRectStack.cpp +38 -0
  190. data/src/ClipRectStack.hpp +17 -83
  191. data/src/Color.cpp +75 -80
  192. data/src/Directories.cpp +47 -0
  193. data/src/DirectoriesUIKit.cpp +50 -0
  194. data/src/DrawOp.hpp +20 -18
  195. data/src/DrawOpQueue.hpp +27 -33
  196. data/src/Drawable.cpp +95 -0
  197. data/src/EmptyDrawable.hpp +38 -0
  198. data/src/FPS.cpp +31 -0
  199. data/src/Font.cpp +104 -74
  200. data/src/GosuGLView.cpp +13 -11
  201. data/src/GosuViewController.cpp +2 -10
  202. data/src/Graphics.cpp +86 -145
  203. data/src/GraphicsImpl.hpp +14 -68
  204. data/src/Image.cpp +41 -35
  205. data/src/Input.cpp +73 -78
  206. data/src/Macro.cpp +46 -29
  207. data/src/Macro.hpp +23 -17
  208. data/src/MarkupParser.cpp +5 -5
  209. data/src/Math.cpp +48 -22
  210. data/src/OffScreenTarget.cpp +47 -50
  211. data/src/OffScreenTarget.hpp +13 -11
  212. data/src/OpenGLContext.cpp +116 -0
  213. data/src/OpenGLContext.hpp +41 -0
  214. data/src/RenderState.hpp +49 -71
  215. data/src/Resolution.cpp +65 -53
  216. data/src/TexChunk.cpp +35 -80
  217. data/src/TexChunk.hpp +44 -35
  218. data/src/Text.cpp +1 -1
  219. data/src/TextBuilder.cpp +35 -21
  220. data/src/TextBuilder.hpp +6 -9
  221. data/src/TextInput.cpp +9 -9
  222. data/src/Texture.cpp +62 -80
  223. data/src/Texture.hpp +25 -23
  224. data/src/TiledDrawable.cpp +149 -0
  225. data/src/TiledDrawable.hpp +47 -0
  226. data/src/TimingApple.cpp +1 -1
  227. data/src/Transform.cpp +45 -50
  228. data/src/TransformStack.hpp +16 -16
  229. data/src/TrueTypeFont.cpp +59 -51
  230. data/src/TrueTypeFont.hpp +6 -7
  231. data/src/TrueTypeFontApple.cpp +28 -19
  232. data/src/TrueTypeFontUnix.cpp +39 -32
  233. data/src/TrueTypeFontWin.cpp +30 -30
  234. data/src/Utility.cpp +113 -37
  235. data/src/UtilityWin.cpp +49 -0
  236. data/src/Window.cpp +121 -151
  237. data/src/WindowUIKit.cpp +14 -14
  238. metadata +165 -118
  239. data/dependencies/SDL/include/SDL.h +0 -233
  240. data/dependencies/SDL/include/SDL_assert.h +0 -320
  241. data/dependencies/SDL/include/SDL_atomic.h +0 -415
  242. data/dependencies/SDL/include/SDL_audio.h +0 -1500
  243. data/dependencies/SDL/include/SDL_clipboard.h +0 -141
  244. data/dependencies/SDL/include/SDL_config.h +0 -331
  245. data/dependencies/SDL/include/SDL_cpuinfo.h +0 -594
  246. data/dependencies/SDL/include/SDL_endian.h +0 -348
  247. data/dependencies/SDL/include/SDL_error.h +0 -163
  248. data/dependencies/SDL/include/SDL_events.h +0 -1166
  249. data/dependencies/SDL/include/SDL_filesystem.h +0 -149
  250. data/dependencies/SDL/include/SDL_gamecontroller.h +0 -1074
  251. data/dependencies/SDL/include/SDL_gesture.h +0 -117
  252. data/dependencies/SDL/include/SDL_guid.h +0 -100
  253. data/dependencies/SDL/include/SDL_haptic.h +0 -1341
  254. data/dependencies/SDL/include/SDL_hidapi.h +0 -451
  255. data/dependencies/SDL/include/SDL_hints.h +0 -2569
  256. data/dependencies/SDL/include/SDL_joystick.h +0 -1066
  257. data/dependencies/SDL/include/SDL_keyboard.h +0 -353
  258. data/dependencies/SDL/include/SDL_keycode.h +0 -358
  259. data/dependencies/SDL/include/SDL_loadso.h +0 -115
  260. data/dependencies/SDL/include/SDL_log.h +0 -404
  261. data/dependencies/SDL/include/SDL_main.h +0 -275
  262. data/dependencies/SDL/include/SDL_mouse.h +0 -465
  263. data/dependencies/SDL/include/SDL_mutex.h +0 -471
  264. data/dependencies/SDL/include/SDL_name.h +0 -33
  265. data/dependencies/SDL/include/SDL_pixels.h +0 -644
  266. data/dependencies/SDL/include/SDL_platform.h +0 -261
  267. data/dependencies/SDL/include/SDL_quit.h +0 -58
  268. data/dependencies/SDL/include/SDL_rect.h +0 -376
  269. data/dependencies/SDL/include/SDL_render.h +0 -1919
  270. data/dependencies/SDL/include/SDL_revision.h +0 -7
  271. data/dependencies/SDL/include/SDL_rwops.h +0 -841
  272. data/dependencies/SDL/include/SDL_sensor.h +0 -322
  273. data/dependencies/SDL/include/SDL_shape.h +0 -155
  274. data/dependencies/SDL/include/SDL_stdinc.h +0 -830
  275. data/dependencies/SDL/include/SDL_surface.h +0 -997
  276. data/dependencies/SDL/include/SDL_system.h +0 -623
  277. data/dependencies/SDL/include/SDL_syswm.h +0 -386
  278. data/dependencies/SDL/include/SDL_test_images.h +0 -78
  279. data/dependencies/SDL/include/SDL_test_random.h +0 -115
  280. data/dependencies/SDL/include/SDL_thread.h +0 -464
  281. data/dependencies/SDL/include/SDL_timer.h +0 -222
  282. data/dependencies/SDL/include/SDL_touch.h +0 -150
  283. data/dependencies/SDL/include/SDL_version.h +0 -204
  284. data/dependencies/SDL/include/SDL_video.h +0 -2150
  285. data/dependencies/SDL/include/SDL_vulkan.h +0 -215
  286. data/dependencies/SDL/include/begin_code.h +0 -187
  287. data/dependencies/SDL/lib/x64/libSDL2.dll.a +0 -0
  288. data/dependencies/SDL/lib/x86/libSDL2.dll.a +0 -0
  289. data/dependencies/SDL_sound/SDL_sound.h +0 -725
  290. data/ext/gosu/extconf.rb +0 -119
  291. data/include/Gosu/IO.hpp +0 -254
  292. data/include/Gosu/ImageData.hpp +0 -53
  293. data/include/Gosu/Inspection.hpp +0 -7
  294. data/lib/SDL2.dll +0 -0
  295. data/lib/gosu/patches.rb +0 -66
  296. data/lib/gosu/run.rb +0 -20
  297. data/lib/gosu/swig_patches.rb +0 -110
  298. data/lib64/SDL2.dll +0 -0
  299. data/src/BlockAllocator.cpp +0 -131
  300. data/src/BlockAllocator.hpp +0 -32
  301. data/src/DirectoriesApple.cpp +0 -69
  302. data/src/DirectoriesUnix.cpp +0 -46
  303. data/src/DirectoriesWin.cpp +0 -65
  304. data/src/EmptyImageData.hpp +0 -52
  305. data/src/FileUnix.cpp +0 -99
  306. data/src/FileWin.cpp +0 -88
  307. data/src/IO.cpp +0 -60
  308. data/src/Iconv.hpp +0 -51
  309. data/src/Inspection.cpp +0 -27
  310. data/src/LargeImageData.cpp +0 -215
  311. data/src/LargeImageData.hpp +0 -39
  312. data/src/Log.hpp +0 -19
  313. data/src/RubyGosu.cxx +0 -13100
  314. data/src/RubyGosu.h +0 -49
  315. data/src/WinUtility.cpp +0 -61
  316. data/src/WinUtility.hpp +0 -27
  317. /data/dependencies/SDL/include/{SDL_opengles2_gl2.h → SDL3/SDL_opengles2_gl2.h} +0 -0
  318. /data/dependencies/SDL/include/{SDL_opengles2_gl2ext.h → SDL3/SDL_opengles2_gl2ext.h} +0 -0
  319. /data/dependencies/SDL/include/{SDL_opengles2_gl2platform.h → SDL3/SDL_opengles2_gl2platform.h} +0 -0
  320. /data/dependencies/SDL/include/{SDL_opengles2_khrplatform.h → SDL3/SDL_opengles2_khrplatform.h} +0 -0
@@ -0,0 +1,1657 @@
1
+ /*
2
+ Simple DirectMedia Layer
3
+ Copyright (C) 1997-2026 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
+ * # CategoryGamepad
24
+ *
25
+ * SDL provides a low-level joystick API, which just treats joysticks as an
26
+ * arbitrary pile of buttons, axes, and hat switches. If you're planning to
27
+ * write your own control configuration screen, this can give you a lot of
28
+ * flexibility, but that's a lot of work, and most things that we consider
29
+ * "joysticks" now are actually console-style gamepads. So SDL provides the
30
+ * gamepad API on top of the lower-level joystick functionality.
31
+ *
32
+ * The difference between a joystick and a gamepad is that a gamepad tells you
33
+ * _where_ a button or axis is on the device. You don't speak to gamepads in
34
+ * terms of arbitrary numbers like "button 3" or "axis 2" but in standard
35
+ * locations: the d-pad, the shoulder buttons, triggers, A/B/X/Y (or
36
+ * X/O/Square/Triangle, if you will).
37
+ *
38
+ * One turns a joystick into a gamepad by providing a magic configuration
39
+ * string, which tells SDL the details of a specific device: when you see this
40
+ * specific hardware, if button 2 gets pressed, this is actually D-Pad Up,
41
+ * etc.
42
+ *
43
+ * SDL has many popular controllers configured out of the box, and users can
44
+ * add their own controller details through an environment variable if it's
45
+ * otherwise unknown to SDL.
46
+ *
47
+ * In order to use these functions, SDL_Init() must have been called with the
48
+ * SDL_INIT_GAMEPAD flag. This causes SDL to scan the system for gamepads, and
49
+ * load appropriate drivers.
50
+ *
51
+ * If you're using SDL gamepad support in a Steam game, you must call
52
+ * SteamAPI_InitEx() before calling SDL_Init().
53
+ *
54
+ * If you would like to receive gamepad updates while the application is in
55
+ * the background, you should set the following hint before calling
56
+ * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS
57
+ *
58
+ * Gamepads support various optional features such as rumble, color LEDs,
59
+ * touchpad, gyro, etc. The support for these features varies depending on the
60
+ * controller and OS support available. You can check for LED and rumble
61
+ * capabilities at runtime by calling SDL_GetGamepadProperties() and checking
62
+ * the various capability properties. You can check for touchpad by calling
63
+ * SDL_GetNumGamepadTouchpads() and check for gyro and accelerometer by
64
+ * calling SDL_GamepadHasSensor().
65
+ *
66
+ * By default SDL will try to use the most capable driver available, but you
67
+ * can tune which OS drivers to use with the various joystick hints in
68
+ * SDL_hints.h.
69
+ *
70
+ * Your application should always support gamepad hotplugging. On some
71
+ * platforms like Xbox, Steam Deck, etc., this is a requirement for
72
+ * certification. On other platforms, like macOS and Windows when using
73
+ * Windows.Gaming.Input, controllers may not be available at startup and will
74
+ * come in at some point after you've started processing events.
75
+ */
76
+
77
+ #ifndef SDL_gamepad_h_
78
+ #define SDL_gamepad_h_
79
+
80
+ #include <SDL3/SDL_stdinc.h>
81
+ #include <SDL3/SDL_error.h>
82
+ #include <SDL3/SDL_guid.h>
83
+ #include <SDL3/SDL_iostream.h>
84
+ #include <SDL3/SDL_joystick.h>
85
+ #include <SDL3/SDL_power.h>
86
+ #include <SDL3/SDL_properties.h>
87
+ #include <SDL3/SDL_sensor.h>
88
+
89
+ #include <SDL3/SDL_begin_code.h>
90
+ /* Set up for C function definitions, even when using C++ */
91
+ #ifdef __cplusplus
92
+ extern "C" {
93
+ #endif
94
+
95
+ /**
96
+ * The structure used to identify an SDL gamepad
97
+ *
98
+ * \since This struct is available since SDL 3.2.0.
99
+ */
100
+ typedef struct SDL_Gamepad SDL_Gamepad;
101
+
102
+ /**
103
+ * Standard gamepad types.
104
+ *
105
+ * This type does not necessarily map to first-party controllers from
106
+ * Microsoft/Sony/Nintendo; in many cases, third-party controllers can report
107
+ * as these, either because they were designed for a specific console, or they
108
+ * simply most closely match that console's controllers (does it have A/B/X/Y
109
+ * buttons or X/O/Square/Triangle? Does it have a touchpad? etc).
110
+ */
111
+ typedef enum SDL_GamepadType
112
+ {
113
+ SDL_GAMEPAD_TYPE_UNKNOWN = 0,
114
+ SDL_GAMEPAD_TYPE_STANDARD,
115
+ SDL_GAMEPAD_TYPE_XBOX360,
116
+ SDL_GAMEPAD_TYPE_XBOXONE,
117
+ SDL_GAMEPAD_TYPE_PS3,
118
+ SDL_GAMEPAD_TYPE_PS4,
119
+ SDL_GAMEPAD_TYPE_PS5,
120
+ SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO,
121
+ SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT,
122
+ SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT,
123
+ SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR,
124
+ SDL_GAMEPAD_TYPE_GAMECUBE,
125
+ SDL_GAMEPAD_TYPE_STEAM,
126
+ SDL_GAMEPAD_TYPE_COUNT
127
+ } SDL_GamepadType;
128
+
129
+ /**
130
+ * The list of buttons available on a gamepad
131
+ *
132
+ * For controllers that use a diamond pattern for the face buttons, the
133
+ * south/east/west/north buttons below correspond to the locations in the
134
+ * diamond pattern. For Xbox controllers, this would be A/B/X/Y, for Nintendo
135
+ * Switch controllers, this would be B/A/Y/X, for GameCube controllers this
136
+ * would be A/X/B/Y, for PlayStation controllers this would be
137
+ * Cross/Circle/Square/Triangle.
138
+ *
139
+ * For controllers that don't use a diamond pattern for the face buttons, the
140
+ * south/east/west/north buttons indicate the buttons labeled A, B, C, D, or
141
+ * 1, 2, 3, 4, or for controllers that aren't labeled, they are the primary,
142
+ * secondary, etc. buttons.
143
+ *
144
+ * The activate action is often the south button and the cancel action is
145
+ * often the east button, but in some regions this is reversed, so your game
146
+ * should allow remapping actions based on user preferences.
147
+ *
148
+ * You can query the labels for the face buttons using
149
+ * SDL_GetGamepadButtonLabel()
150
+ *
151
+ * \since This enum is available since SDL 3.2.0.
152
+ */
153
+ typedef enum SDL_GamepadButton
154
+ {
155
+ SDL_GAMEPAD_BUTTON_INVALID = -1,
156
+ SDL_GAMEPAD_BUTTON_SOUTH, /**< Bottom face button (e.g. Xbox A button) */
157
+ SDL_GAMEPAD_BUTTON_EAST, /**< Right face button (e.g. Xbox B button) */
158
+ SDL_GAMEPAD_BUTTON_WEST, /**< Left face button (e.g. Xbox X button) */
159
+ SDL_GAMEPAD_BUTTON_NORTH, /**< Top face button (e.g. Xbox Y button) */
160
+ SDL_GAMEPAD_BUTTON_BACK,
161
+ SDL_GAMEPAD_BUTTON_GUIDE,
162
+ SDL_GAMEPAD_BUTTON_START,
163
+ SDL_GAMEPAD_BUTTON_LEFT_STICK,
164
+ SDL_GAMEPAD_BUTTON_RIGHT_STICK,
165
+ SDL_GAMEPAD_BUTTON_LEFT_SHOULDER,
166
+ SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER,
167
+ SDL_GAMEPAD_BUTTON_DPAD_UP,
168
+ SDL_GAMEPAD_BUTTON_DPAD_DOWN,
169
+ SDL_GAMEPAD_BUTTON_DPAD_LEFT,
170
+ SDL_GAMEPAD_BUTTON_DPAD_RIGHT,
171
+ SDL_GAMEPAD_BUTTON_MISC1, /**< Additional button (e.g. Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Steam Controller QAM button, Amazon Luna microphone button, Google Stadia capture button) */
172
+ SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1, /**< Upper or primary paddle, under your right hand (e.g. Xbox Elite paddle P1, DualSense Edge RB button, Right Joy-Con SR button, Steam Controller R4 button) */
173
+ SDL_GAMEPAD_BUTTON_LEFT_PADDLE1, /**< Upper or primary paddle, under your left hand (e.g. Xbox Elite paddle P3, DualSense Edge LB button, Left Joy-Con SL button, Steam Controller L4 button) */
174
+ SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2, /**< Lower or secondary paddle, under your right hand (e.g. Xbox Elite paddle P2, DualSense Edge right Fn button, Right Joy-Con SL button, Steam Controller R5 button) */
175
+ SDL_GAMEPAD_BUTTON_LEFT_PADDLE2, /**< Lower or secondary paddle, under your left hand (e.g. Xbox Elite paddle P4, DualSense Edge left Fn button, Left Joy-Con SR button, Steam Controller L5 button) */
176
+ SDL_GAMEPAD_BUTTON_TOUCHPAD, /**< PS4/PS5 touchpad button */
177
+ SDL_GAMEPAD_BUTTON_MISC2, /**< Additional button */
178
+ SDL_GAMEPAD_BUTTON_MISC3, /**< Additional button (e.g. Nintendo GameCube left trigger click) */
179
+ SDL_GAMEPAD_BUTTON_MISC4, /**< Additional button (e.g. Nintendo GameCube right trigger click) */
180
+ SDL_GAMEPAD_BUTTON_MISC5, /**< Additional button */
181
+ SDL_GAMEPAD_BUTTON_MISC6, /**< Additional button */
182
+ SDL_GAMEPAD_BUTTON_COUNT
183
+ } SDL_GamepadButton;
184
+
185
+ /**
186
+ * The set of gamepad button labels
187
+ *
188
+ * This isn't a complete set, just the face buttons to make it easy to show
189
+ * button prompts.
190
+ *
191
+ * For a complete set, you should look at the button and gamepad type and have
192
+ * a set of symbols that work well with your art style.
193
+ *
194
+ * \since This enum is available since SDL 3.2.0.
195
+ */
196
+ typedef enum SDL_GamepadButtonLabel
197
+ {
198
+ SDL_GAMEPAD_BUTTON_LABEL_UNKNOWN,
199
+ SDL_GAMEPAD_BUTTON_LABEL_A,
200
+ SDL_GAMEPAD_BUTTON_LABEL_B,
201
+ SDL_GAMEPAD_BUTTON_LABEL_X,
202
+ SDL_GAMEPAD_BUTTON_LABEL_Y,
203
+ SDL_GAMEPAD_BUTTON_LABEL_CROSS,
204
+ SDL_GAMEPAD_BUTTON_LABEL_CIRCLE,
205
+ SDL_GAMEPAD_BUTTON_LABEL_SQUARE,
206
+ SDL_GAMEPAD_BUTTON_LABEL_TRIANGLE
207
+ } SDL_GamepadButtonLabel;
208
+
209
+ /**
210
+ * The list of axes available on a gamepad
211
+ *
212
+ * Thumbstick axis values range from SDL_JOYSTICK_AXIS_MIN to
213
+ * SDL_JOYSTICK_AXIS_MAX, and are centered within ~8000 of zero, though
214
+ * advanced UI will allow users to set or autodetect the dead zone, which
215
+ * varies between gamepads.
216
+ *
217
+ * Trigger axis values range from 0 (released) to SDL_JOYSTICK_AXIS_MAX (fully
218
+ * pressed) when reported by SDL_GetGamepadAxis(). Note that this is not the
219
+ * same range that will be reported by the lower-level SDL_GetJoystickAxis().
220
+ *
221
+ * \since This enum is available since SDL 3.2.0.
222
+ */
223
+ typedef enum SDL_GamepadAxis
224
+ {
225
+ SDL_GAMEPAD_AXIS_INVALID = -1,
226
+ SDL_GAMEPAD_AXIS_LEFTX,
227
+ SDL_GAMEPAD_AXIS_LEFTY,
228
+ SDL_GAMEPAD_AXIS_RIGHTX,
229
+ SDL_GAMEPAD_AXIS_RIGHTY,
230
+ SDL_GAMEPAD_AXIS_LEFT_TRIGGER,
231
+ SDL_GAMEPAD_AXIS_RIGHT_TRIGGER,
232
+ SDL_GAMEPAD_AXIS_COUNT
233
+ } SDL_GamepadAxis;
234
+
235
+ /**
236
+ * Types of gamepad control bindings.
237
+ *
238
+ * A gamepad is a collection of bindings that map arbitrary joystick buttons,
239
+ * axes and hat switches to specific positions on a generic console-style
240
+ * gamepad. This enum is used as part of SDL_GamepadBinding to specify those
241
+ * mappings.
242
+ *
243
+ * \since This enum is available since SDL 3.2.0.
244
+ */
245
+ typedef enum SDL_GamepadBindingType
246
+ {
247
+ SDL_GAMEPAD_BINDTYPE_NONE = 0,
248
+ SDL_GAMEPAD_BINDTYPE_BUTTON,
249
+ SDL_GAMEPAD_BINDTYPE_AXIS,
250
+ SDL_GAMEPAD_BINDTYPE_HAT
251
+ } SDL_GamepadBindingType;
252
+
253
+ /**
254
+ * A mapping between one joystick input to a gamepad control.
255
+ *
256
+ * A gamepad has a collection of several bindings, to say, for example, when
257
+ * joystick button number 5 is pressed, that should be treated like the
258
+ * gamepad's "start" button.
259
+ *
260
+ * SDL has these bindings built-in for many popular controllers, and can add
261
+ * more with a simple text string. Those strings are parsed into a collection
262
+ * of these structs to make it easier to operate on the data.
263
+ *
264
+ * \since This struct is available since SDL 3.2.0.
265
+ *
266
+ * \sa SDL_GetGamepadBindings
267
+ */
268
+ typedef struct SDL_GamepadBinding
269
+ {
270
+ SDL_GamepadBindingType input_type;
271
+ union
272
+ {
273
+ int button;
274
+
275
+ struct
276
+ {
277
+ int axis;
278
+ int axis_min;
279
+ int axis_max;
280
+ } axis;
281
+
282
+ struct
283
+ {
284
+ int hat;
285
+ int hat_mask;
286
+ } hat;
287
+
288
+ } input;
289
+
290
+ SDL_GamepadBindingType output_type;
291
+ union
292
+ {
293
+ SDL_GamepadButton button;
294
+
295
+ struct
296
+ {
297
+ SDL_GamepadAxis axis;
298
+ int axis_min;
299
+ int axis_max;
300
+ } axis;
301
+
302
+ } output;
303
+ } SDL_GamepadBinding;
304
+
305
+
306
+ /**
307
+ * Add support for gamepads that SDL is unaware of or change the binding of an
308
+ * existing gamepad.
309
+ *
310
+ * The mapping string has the format "GUID,name,mapping", where GUID is the
311
+ * string value from SDL_GUIDToString(), name is the human readable string for
312
+ * the device and mappings are gamepad mappings to joystick ones. Under
313
+ * Windows there is a reserved GUID of "xinput" that covers all XInput
314
+ * devices. The mapping format for joystick is:
315
+ *
316
+ * - `bX`: a joystick button, index X
317
+ * - `hX.Y`: hat X with value Y
318
+ * - `aX`: axis X of the joystick
319
+ *
320
+ * Buttons can be used as a gamepad axes and vice versa.
321
+ *
322
+ * If a device with this GUID is already plugged in, SDL will generate an
323
+ * SDL_EVENT_GAMEPAD_ADDED event.
324
+ *
325
+ * This string shows an example of a valid mapping for a gamepad:
326
+ *
327
+ * ```c
328
+ * "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"
329
+ * ```
330
+ *
331
+ * \param mapping the mapping string.
332
+ * \returns 1 if a new mapping is added, 0 if an existing mapping is updated,
333
+ * -1 on failure; call SDL_GetError() for more information.
334
+ *
335
+ * \threadsafety It is safe to call this function from any thread.
336
+ *
337
+ * \since This function is available since SDL 3.2.0.
338
+ *
339
+ * \sa SDL_AddGamepadMappingsFromFile
340
+ * \sa SDL_AddGamepadMappingsFromIO
341
+ * \sa SDL_GetGamepadMapping
342
+ * \sa SDL_GetGamepadMappingForGUID
343
+ * \sa SDL_HINT_GAMECONTROLLERCONFIG
344
+ * \sa SDL_HINT_GAMECONTROLLERCONFIG_FILE
345
+ * \sa SDL_EVENT_GAMEPAD_ADDED
346
+ */
347
+ extern SDL_DECLSPEC int SDLCALL SDL_AddGamepadMapping(const char *mapping);
348
+
349
+ /**
350
+ * Load a set of gamepad mappings from an SDL_IOStream.
351
+ *
352
+ * You can call this function several times, if needed, to load different
353
+ * database files.
354
+ *
355
+ * If a new mapping is loaded for an already known gamepad GUID, the later
356
+ * version will overwrite the one currently loaded.
357
+ *
358
+ * Any new mappings for already plugged in controllers will generate
359
+ * SDL_EVENT_GAMEPAD_ADDED events.
360
+ *
361
+ * Mappings not belonging to the current platform or with no platform field
362
+ * specified will be ignored (i.e. mappings for Linux will be ignored in
363
+ * Windows, etc).
364
+ *
365
+ * This function will load the text database entirely in memory before
366
+ * processing it, so take this into consideration if you are in a memory
367
+ * constrained environment.
368
+ *
369
+ * \param src the data stream for the mappings to be added.
370
+ * \param closeio if true, calls SDL_CloseIO() on `src` before returning, even
371
+ * in the case of an error.
372
+ * \returns the number of mappings added or -1 on failure; call SDL_GetError()
373
+ * for more information.
374
+ *
375
+ * \threadsafety It is safe to call this function from any thread.
376
+ *
377
+ * \since This function is available since SDL 3.2.0.
378
+ *
379
+ * \sa SDL_AddGamepadMapping
380
+ * \sa SDL_AddGamepadMappingsFromFile
381
+ * \sa SDL_GetGamepadMapping
382
+ * \sa SDL_GetGamepadMappingForGUID
383
+ * \sa SDL_HINT_GAMECONTROLLERCONFIG
384
+ * \sa SDL_HINT_GAMECONTROLLERCONFIG_FILE
385
+ * \sa SDL_EVENT_GAMEPAD_ADDED
386
+ */
387
+ extern SDL_DECLSPEC int SDLCALL SDL_AddGamepadMappingsFromIO(SDL_IOStream *src, bool closeio);
388
+
389
+ /**
390
+ * Load a set of gamepad mappings from a file.
391
+ *
392
+ * You can call this function several times, if needed, to load different
393
+ * database files.
394
+ *
395
+ * If a new mapping is loaded for an already known gamepad GUID, the later
396
+ * version will overwrite the one currently loaded.
397
+ *
398
+ * Any new mappings for already plugged in controllers will generate
399
+ * SDL_EVENT_GAMEPAD_ADDED events.
400
+ *
401
+ * Mappings not belonging to the current platform or with no platform field
402
+ * specified will be ignored (i.e. mappings for Linux will be ignored in
403
+ * Windows, etc).
404
+ *
405
+ * \param file the mappings file to load.
406
+ * \returns the number of mappings added or -1 on failure; call SDL_GetError()
407
+ * for more information.
408
+ *
409
+ * \threadsafety It is safe to call this function from any thread.
410
+ *
411
+ * \since This function is available since SDL 3.2.0.
412
+ *
413
+ * \sa SDL_AddGamepadMapping
414
+ * \sa SDL_AddGamepadMappingsFromIO
415
+ * \sa SDL_GetGamepadMapping
416
+ * \sa SDL_GetGamepadMappingForGUID
417
+ * \sa SDL_HINT_GAMECONTROLLERCONFIG
418
+ * \sa SDL_HINT_GAMECONTROLLERCONFIG_FILE
419
+ * \sa SDL_EVENT_GAMEPAD_ADDED
420
+ */
421
+ extern SDL_DECLSPEC int SDLCALL SDL_AddGamepadMappingsFromFile(const char *file);
422
+
423
+ /**
424
+ * Reinitialize the SDL mapping database to its initial state.
425
+ *
426
+ * This will generate gamepad events as needed if device mappings change.
427
+ *
428
+ * \returns true on success or false on failure; call SDL_GetError() for more
429
+ * information.
430
+ *
431
+ * \threadsafety It is safe to call this function from any thread.
432
+ *
433
+ * \since This function is available since SDL 3.2.0.
434
+ */
435
+ extern SDL_DECLSPEC bool SDLCALL SDL_ReloadGamepadMappings(void);
436
+
437
+ /**
438
+ * Get the current gamepad mappings.
439
+ *
440
+ * \param count a pointer filled in with the number of mappings returned, can
441
+ * be NULL.
442
+ * \returns an array of the mapping strings, NULL-terminated, or NULL on
443
+ * failure; call SDL_GetError() for more information. This is a
444
+ * single allocation that should be freed with SDL_free() when it is
445
+ * no longer needed.
446
+ *
447
+ * \threadsafety It is safe to call this function from any thread.
448
+ *
449
+ * \since This function is available since SDL 3.2.0.
450
+ */
451
+ extern SDL_DECLSPEC char ** SDLCALL SDL_GetGamepadMappings(int *count);
452
+
453
+ /**
454
+ * Get the gamepad mapping string for a given GUID.
455
+ *
456
+ * \param guid a structure containing the GUID for which a mapping is desired.
457
+ * \returns a mapping string or NULL on failure; call SDL_GetError() for more
458
+ * information. This should be freed with SDL_free() when it is no
459
+ * longer needed.
460
+ *
461
+ * \threadsafety It is safe to call this function from any thread.
462
+ *
463
+ * \since This function is available since SDL 3.2.0.
464
+ *
465
+ * \sa SDL_GetJoystickGUIDForID
466
+ * \sa SDL_GetJoystickGUID
467
+ */
468
+ extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMappingForGUID(SDL_GUID guid);
469
+
470
+ /**
471
+ * Get the current mapping of a gamepad.
472
+ *
473
+ * Details about mappings are discussed with SDL_AddGamepadMapping().
474
+ *
475
+ * \param gamepad the gamepad you want to get the current mapping for.
476
+ * \returns a string that has the gamepad's mapping or NULL if no mapping is
477
+ * available; call SDL_GetError() for more information. This should
478
+ * be freed with SDL_free() when it is no longer needed.
479
+ *
480
+ * \threadsafety It is safe to call this function from any thread.
481
+ *
482
+ * \since This function is available since SDL 3.2.0.
483
+ *
484
+ * \sa SDL_AddGamepadMapping
485
+ * \sa SDL_GetGamepadMappingForID
486
+ * \sa SDL_GetGamepadMappingForGUID
487
+ * \sa SDL_SetGamepadMapping
488
+ */
489
+ extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMapping(SDL_Gamepad *gamepad);
490
+
491
+ /**
492
+ * Set the current mapping of a joystick or gamepad.
493
+ *
494
+ * Details about mappings are discussed with SDL_AddGamepadMapping().
495
+ *
496
+ * \param instance_id the joystick instance ID.
497
+ * \param mapping the mapping to use for this device, or NULL to clear the
498
+ * mapping.
499
+ * \returns true on success or false on failure; call SDL_GetError() for more
500
+ * information.
501
+ *
502
+ * \threadsafety It is safe to call this function from any thread.
503
+ *
504
+ * \since This function is available since SDL 3.2.0.
505
+ *
506
+ * \sa SDL_AddGamepadMapping
507
+ * \sa SDL_GetGamepadMapping
508
+ */
509
+ extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadMapping(SDL_JoystickID instance_id, const char *mapping);
510
+
511
+ /**
512
+ * Return whether a gamepad is currently connected.
513
+ *
514
+ * \returns true if a gamepad is connected, false otherwise.
515
+ *
516
+ * \threadsafety It is safe to call this function from any thread.
517
+ *
518
+ * \since This function is available since SDL 3.2.0.
519
+ *
520
+ * \sa SDL_GetGamepads
521
+ */
522
+ extern SDL_DECLSPEC bool SDLCALL SDL_HasGamepad(void);
523
+
524
+ /**
525
+ * Get a list of currently connected gamepads.
526
+ *
527
+ * \param count a pointer filled in with the number of gamepads returned, may
528
+ * be NULL.
529
+ * \returns a 0 terminated array of joystick instance IDs or NULL on failure;
530
+ * call SDL_GetError() for more information. This should be freed
531
+ * with SDL_free() when it is no longer needed.
532
+ *
533
+ * \threadsafety It is safe to call this function from any thread.
534
+ *
535
+ * \since This function is available since SDL 3.2.0.
536
+ *
537
+ * \sa SDL_HasGamepad
538
+ * \sa SDL_OpenGamepad
539
+ */
540
+ extern SDL_DECLSPEC SDL_JoystickID * SDLCALL SDL_GetGamepads(int *count);
541
+
542
+ /**
543
+ * Check if the given joystick is supported by the gamepad interface.
544
+ *
545
+ * \param instance_id the joystick instance ID.
546
+ * \returns true if the given joystick is supported by the gamepad interface,
547
+ * false if it isn't or it's an invalid index.
548
+ *
549
+ * \threadsafety It is safe to call this function from any thread.
550
+ *
551
+ * \since This function is available since SDL 3.2.0.
552
+ *
553
+ * \sa SDL_GetJoysticks
554
+ * \sa SDL_OpenGamepad
555
+ */
556
+ extern SDL_DECLSPEC bool SDLCALL SDL_IsGamepad(SDL_JoystickID instance_id);
557
+
558
+ /**
559
+ * Get the implementation dependent name of a gamepad.
560
+ *
561
+ * This can be called before any gamepads are opened.
562
+ *
563
+ * \param instance_id the joystick instance ID.
564
+ * \returns the name of the selected gamepad. If no name can be found, this
565
+ * function returns NULL; call SDL_GetError() for more information.
566
+ *
567
+ * \threadsafety It is safe to call this function from any thread.
568
+ *
569
+ * \since This function is available since SDL 3.2.0.
570
+ *
571
+ * \sa SDL_GetGamepadName
572
+ * \sa SDL_GetGamepads
573
+ */
574
+ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadNameForID(SDL_JoystickID instance_id);
575
+
576
+ /**
577
+ * Get the implementation dependent path of a gamepad.
578
+ *
579
+ * This can be called before any gamepads are opened.
580
+ *
581
+ * \param instance_id the joystick instance ID.
582
+ * \returns the path of the selected gamepad. If no path can be found, this
583
+ * function returns NULL; call SDL_GetError() for more information.
584
+ *
585
+ * \threadsafety It is safe to call this function from any thread.
586
+ *
587
+ * \since This function is available since SDL 3.2.0.
588
+ *
589
+ * \sa SDL_GetGamepadPath
590
+ * \sa SDL_GetGamepads
591
+ */
592
+ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadPathForID(SDL_JoystickID instance_id);
593
+
594
+ /**
595
+ * Get the player index of a gamepad.
596
+ *
597
+ * This can be called before any gamepads are opened.
598
+ *
599
+ * \param instance_id the joystick instance ID.
600
+ * \returns the player index of a gamepad, or -1 if it's not available.
601
+ *
602
+ * \threadsafety It is safe to call this function from any thread.
603
+ *
604
+ * \since This function is available since SDL 3.2.0.
605
+ *
606
+ * \sa SDL_GetGamepadPlayerIndex
607
+ * \sa SDL_GetGamepads
608
+ */
609
+ extern SDL_DECLSPEC int SDLCALL SDL_GetGamepadPlayerIndexForID(SDL_JoystickID instance_id);
610
+
611
+ /**
612
+ * Get the implementation-dependent GUID of a gamepad.
613
+ *
614
+ * This can be called before any gamepads are opened.
615
+ *
616
+ * \param instance_id the joystick instance ID.
617
+ * \returns the GUID of the selected gamepad. If called on an invalid index,
618
+ * this function returns a zero GUID.
619
+ *
620
+ * \threadsafety It is safe to call this function from any thread.
621
+ *
622
+ * \since This function is available since SDL 3.2.0.
623
+ *
624
+ * \sa SDL_GUIDToString
625
+ * \sa SDL_GetGamepads
626
+ */
627
+ extern SDL_DECLSPEC SDL_GUID SDLCALL SDL_GetGamepadGUIDForID(SDL_JoystickID instance_id);
628
+
629
+ /**
630
+ * Get the USB vendor ID of a gamepad, if available.
631
+ *
632
+ * This can be called before any gamepads are opened. If the vendor ID isn't
633
+ * available this function returns 0.
634
+ *
635
+ * \param instance_id the joystick instance ID.
636
+ * \returns the USB vendor ID of the selected gamepad. If called on an invalid
637
+ * index, this function returns zero.
638
+ *
639
+ * \threadsafety It is safe to call this function from any thread.
640
+ *
641
+ * \since This function is available since SDL 3.2.0.
642
+ *
643
+ * \sa SDL_GetGamepadVendor
644
+ * \sa SDL_GetGamepads
645
+ */
646
+ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadVendorForID(SDL_JoystickID instance_id);
647
+
648
+ /**
649
+ * Get the USB product ID of a gamepad, if available.
650
+ *
651
+ * This can be called before any gamepads are opened. If the product ID isn't
652
+ * available this function returns 0.
653
+ *
654
+ * \param instance_id the joystick instance ID.
655
+ * \returns the USB product ID of the selected gamepad. If called on an
656
+ * invalid index, this function returns zero.
657
+ *
658
+ * \threadsafety It is safe to call this function from any thread.
659
+ *
660
+ * \since This function is available since SDL 3.2.0.
661
+ *
662
+ * \sa SDL_GetGamepadProduct
663
+ * \sa SDL_GetGamepads
664
+ */
665
+ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductForID(SDL_JoystickID instance_id);
666
+
667
+ /**
668
+ * Get the product version of a gamepad, if available.
669
+ *
670
+ * This can be called before any gamepads are opened. If the product version
671
+ * isn't available this function returns 0.
672
+ *
673
+ * \param instance_id the joystick instance ID.
674
+ * \returns the product version of the selected gamepad. If called on an
675
+ * invalid index, this function returns zero.
676
+ *
677
+ * \threadsafety It is safe to call this function from any thread.
678
+ *
679
+ * \since This function is available since SDL 3.2.0.
680
+ *
681
+ * \sa SDL_GetGamepadProductVersion
682
+ * \sa SDL_GetGamepads
683
+ */
684
+ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductVersionForID(SDL_JoystickID instance_id);
685
+
686
+ /**
687
+ * Get the type of a gamepad.
688
+ *
689
+ * This can be called before any gamepads are opened.
690
+ *
691
+ * \param instance_id the joystick instance ID.
692
+ * \returns the gamepad type.
693
+ *
694
+ * \threadsafety It is safe to call this function from any thread.
695
+ *
696
+ * \since This function is available since SDL 3.2.0.
697
+ *
698
+ * \sa SDL_GetGamepadType
699
+ * \sa SDL_GetGamepads
700
+ * \sa SDL_GetRealGamepadTypeForID
701
+ */
702
+ extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadTypeForID(SDL_JoystickID instance_id);
703
+
704
+ /**
705
+ * Get the type of a gamepad, ignoring any mapping override.
706
+ *
707
+ * This can be called before any gamepads are opened.
708
+ *
709
+ * \param instance_id the joystick instance ID.
710
+ * \returns the gamepad type.
711
+ *
712
+ * \threadsafety It is safe to call this function from any thread.
713
+ *
714
+ * \since This function is available since SDL 3.2.0.
715
+ *
716
+ * \sa SDL_GetGamepadTypeForID
717
+ * \sa SDL_GetGamepads
718
+ * \sa SDL_GetRealGamepadType
719
+ */
720
+ extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetRealGamepadTypeForID(SDL_JoystickID instance_id);
721
+
722
+ /**
723
+ * Get the mapping of a gamepad.
724
+ *
725
+ * This can be called before any gamepads are opened.
726
+ *
727
+ * \param instance_id the joystick instance ID.
728
+ * \returns the mapping string. Returns NULL if no mapping is available. This
729
+ * should be freed with SDL_free() when it is no longer needed.
730
+ *
731
+ * \threadsafety It is safe to call this function from any thread.
732
+ *
733
+ * \since This function is available since SDL 3.2.0.
734
+ *
735
+ * \sa SDL_GetGamepads
736
+ * \sa SDL_GetGamepadMapping
737
+ */
738
+ extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMappingForID(SDL_JoystickID instance_id);
739
+
740
+ /**
741
+ * Open a gamepad for use.
742
+ *
743
+ * \param instance_id the joystick instance ID.
744
+ * \returns a gamepad identifier or NULL if an error occurred; call
745
+ * SDL_GetError() for more information.
746
+ *
747
+ * \threadsafety It is safe to call this function from any thread.
748
+ *
749
+ * \since This function is available since SDL 3.2.0.
750
+ *
751
+ * \sa SDL_CloseGamepad
752
+ * \sa SDL_IsGamepad
753
+ */
754
+ extern SDL_DECLSPEC SDL_Gamepad * SDLCALL SDL_OpenGamepad(SDL_JoystickID instance_id);
755
+
756
+ /**
757
+ * Get the SDL_Gamepad associated with a joystick instance ID, if it has been
758
+ * opened.
759
+ *
760
+ * \param instance_id the joystick instance ID of the gamepad.
761
+ * \returns an SDL_Gamepad on success or NULL on failure or if it hasn't been
762
+ * opened yet; call SDL_GetError() for more information.
763
+ *
764
+ * \threadsafety It is safe to call this function from any thread.
765
+ *
766
+ * \since This function is available since SDL 3.2.0.
767
+ */
768
+ extern SDL_DECLSPEC SDL_Gamepad * SDLCALL SDL_GetGamepadFromID(SDL_JoystickID instance_id);
769
+
770
+ /**
771
+ * Get the SDL_Gamepad associated with a player index.
772
+ *
773
+ * \param player_index the player index, which different from the instance ID.
774
+ * \returns the SDL_Gamepad associated with a player index.
775
+ *
776
+ * \threadsafety It is safe to call this function from any thread.
777
+ *
778
+ * \since This function is available since SDL 3.2.0.
779
+ *
780
+ * \sa SDL_GetGamepadPlayerIndex
781
+ * \sa SDL_SetGamepadPlayerIndex
782
+ */
783
+ extern SDL_DECLSPEC SDL_Gamepad * SDLCALL SDL_GetGamepadFromPlayerIndex(int player_index);
784
+
785
+ /**
786
+ * Get the properties associated with an opened gamepad.
787
+ *
788
+ * These properties are shared with the underlying joystick object.
789
+ *
790
+ * The following read-only properties are provided by SDL:
791
+ *
792
+ * - `SDL_PROP_GAMEPAD_CAP_MONO_LED_BOOLEAN`: true if this gamepad has an LED
793
+ * that has adjustable brightness
794
+ * - `SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN`: true if this gamepad has an LED
795
+ * that has adjustable color
796
+ * - `SDL_PROP_GAMEPAD_CAP_PLAYER_LED_BOOLEAN`: true if this gamepad has a
797
+ * player LED
798
+ * - `SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN`: true if this gamepad has
799
+ * left/right rumble
800
+ * - `SDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN`: true if this gamepad has
801
+ * simple trigger rumble
802
+ *
803
+ * \param gamepad a gamepad identifier previously returned by
804
+ * SDL_OpenGamepad().
805
+ * \returns a valid property ID on success or 0 on failure; call
806
+ * SDL_GetError() for more information.
807
+ *
808
+ * \threadsafety It is safe to call this function from any thread.
809
+ *
810
+ * \since This function is available since SDL 3.2.0.
811
+ */
812
+ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetGamepadProperties(SDL_Gamepad *gamepad);
813
+
814
+ #define SDL_PROP_GAMEPAD_CAP_MONO_LED_BOOLEAN SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN
815
+ #define SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN
816
+ #define SDL_PROP_GAMEPAD_CAP_PLAYER_LED_BOOLEAN SDL_PROP_JOYSTICK_CAP_PLAYER_LED_BOOLEAN
817
+ #define SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN
818
+ #define SDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN
819
+
820
+ /**
821
+ * Get the instance ID of an opened gamepad.
822
+ *
823
+ * \param gamepad a gamepad identifier previously returned by
824
+ * SDL_OpenGamepad().
825
+ * \returns the instance ID of the specified gamepad on success or 0 on
826
+ * failure; call SDL_GetError() for more information.
827
+ *
828
+ * \threadsafety It is safe to call this function from any thread.
829
+ *
830
+ * \since This function is available since SDL 3.2.0.
831
+ */
832
+ extern SDL_DECLSPEC SDL_JoystickID SDLCALL SDL_GetGamepadID(SDL_Gamepad *gamepad);
833
+
834
+ /**
835
+ * Get the implementation-dependent name for an opened gamepad.
836
+ *
837
+ * \param gamepad a gamepad identifier previously returned by
838
+ * SDL_OpenGamepad().
839
+ * \returns the implementation dependent name for the gamepad, or NULL if
840
+ * there is no name or the identifier passed is invalid.
841
+ *
842
+ * \threadsafety It is safe to call this function from any thread.
843
+ *
844
+ * \since This function is available since SDL 3.2.0.
845
+ *
846
+ * \sa SDL_GetGamepadNameForID
847
+ */
848
+ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadName(SDL_Gamepad *gamepad);
849
+
850
+ /**
851
+ * Get the implementation-dependent path for an opened gamepad.
852
+ *
853
+ * \param gamepad a gamepad identifier previously returned by
854
+ * SDL_OpenGamepad().
855
+ * \returns the implementation dependent path for the gamepad, or NULL if
856
+ * there is no path or the identifier passed is invalid.
857
+ *
858
+ * \threadsafety It is safe to call this function from any thread.
859
+ *
860
+ * \since This function is available since SDL 3.2.0.
861
+ *
862
+ * \sa SDL_GetGamepadPathForID
863
+ */
864
+ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadPath(SDL_Gamepad *gamepad);
865
+
866
+ /**
867
+ * Get the type of an opened gamepad.
868
+ *
869
+ * \param gamepad the gamepad object to query.
870
+ * \returns the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not
871
+ * available.
872
+ *
873
+ * \threadsafety It is safe to call this function from any thread.
874
+ *
875
+ * \since This function is available since SDL 3.2.0.
876
+ *
877
+ * \sa SDL_GetGamepadTypeForID
878
+ */
879
+ extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadType(SDL_Gamepad *gamepad);
880
+
881
+ /**
882
+ * Get the type of an opened gamepad, ignoring any mapping override.
883
+ *
884
+ * \param gamepad the gamepad object to query.
885
+ * \returns the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not
886
+ * available.
887
+ *
888
+ * \threadsafety It is safe to call this function from any thread.
889
+ *
890
+ * \since This function is available since SDL 3.2.0.
891
+ *
892
+ * \sa SDL_GetRealGamepadTypeForID
893
+ */
894
+ extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetRealGamepadType(SDL_Gamepad *gamepad);
895
+
896
+ /**
897
+ * Get the player index of an opened gamepad.
898
+ *
899
+ * For XInput gamepads this returns the XInput user index.
900
+ *
901
+ * \param gamepad the gamepad object to query.
902
+ * \returns the player index for gamepad, or -1 if it's not available.
903
+ *
904
+ * \threadsafety It is safe to call this function from any thread.
905
+ *
906
+ * \since This function is available since SDL 3.2.0.
907
+ *
908
+ * \sa SDL_SetGamepadPlayerIndex
909
+ */
910
+ extern SDL_DECLSPEC int SDLCALL SDL_GetGamepadPlayerIndex(SDL_Gamepad *gamepad);
911
+
912
+ /**
913
+ * Set the player index of an opened gamepad.
914
+ *
915
+ * \param gamepad the gamepad object to adjust.
916
+ * \param player_index player index to assign to this gamepad, or -1 to clear
917
+ * the player index and turn off player LEDs.
918
+ * \returns true on success or false on failure; call SDL_GetError() for more
919
+ * information.
920
+ *
921
+ * \threadsafety It is safe to call this function from any thread.
922
+ *
923
+ * \since This function is available since SDL 3.2.0.
924
+ *
925
+ * \sa SDL_GetGamepadPlayerIndex
926
+ */
927
+ extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadPlayerIndex(SDL_Gamepad *gamepad, int player_index);
928
+
929
+ /**
930
+ * Get the USB vendor ID of an opened gamepad, if available.
931
+ *
932
+ * If the vendor ID isn't available this function returns 0.
933
+ *
934
+ * \param gamepad the gamepad object to query.
935
+ * \returns the USB vendor ID, or zero if unavailable.
936
+ *
937
+ * \threadsafety It is safe to call this function from any thread.
938
+ *
939
+ * \since This function is available since SDL 3.2.0.
940
+ *
941
+ * \sa SDL_GetGamepadVendorForID
942
+ */
943
+ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadVendor(SDL_Gamepad *gamepad);
944
+
945
+ /**
946
+ * Get the USB product ID of an opened gamepad, if available.
947
+ *
948
+ * If the product ID isn't available this function returns 0.
949
+ *
950
+ * \param gamepad the gamepad object to query.
951
+ * \returns the USB product ID, or zero if unavailable.
952
+ *
953
+ * \threadsafety It is safe to call this function from any thread.
954
+ *
955
+ * \since This function is available since SDL 3.2.0.
956
+ *
957
+ * \sa SDL_GetGamepadProductForID
958
+ */
959
+ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProduct(SDL_Gamepad *gamepad);
960
+
961
+ /**
962
+ * Get the product version of an opened gamepad, if available.
963
+ *
964
+ * If the product version isn't available this function returns 0.
965
+ *
966
+ * \param gamepad the gamepad object to query.
967
+ * \returns the USB product version, or zero if unavailable.
968
+ *
969
+ * \threadsafety It is safe to call this function from any thread.
970
+ *
971
+ * \since This function is available since SDL 3.2.0.
972
+ *
973
+ * \sa SDL_GetGamepadProductVersionForID
974
+ */
975
+ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductVersion(SDL_Gamepad *gamepad);
976
+
977
+ /**
978
+ * Get the firmware version of an opened gamepad, if available.
979
+ *
980
+ * If the firmware version isn't available this function returns 0.
981
+ *
982
+ * \param gamepad the gamepad object to query.
983
+ * \returns the gamepad firmware version, or zero if unavailable.
984
+ *
985
+ * \threadsafety It is safe to call this function from any thread.
986
+ *
987
+ * \since This function is available since SDL 3.2.0.
988
+ */
989
+ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadFirmwareVersion(SDL_Gamepad *gamepad);
990
+
991
+ /**
992
+ * Get the serial number of an opened gamepad, if available.
993
+ *
994
+ * Returns the serial number of the gamepad, or NULL if it is not available.
995
+ *
996
+ * \param gamepad the gamepad object to query.
997
+ * \returns the serial number, or NULL if unavailable.
998
+ *
999
+ * \threadsafety It is safe to call this function from any thread.
1000
+ *
1001
+ * \since This function is available since SDL 3.2.0.
1002
+ */
1003
+ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadSerial(SDL_Gamepad *gamepad);
1004
+
1005
+ /**
1006
+ * Get the Steam Input handle of an opened gamepad, if available.
1007
+ *
1008
+ * Returns an InputHandle_t for the gamepad that can be used with Steam Input
1009
+ * API: https://partner.steamgames.com/doc/api/ISteamInput
1010
+ *
1011
+ * \param gamepad the gamepad object to query.
1012
+ * \returns the gamepad handle, or 0 if unavailable.
1013
+ *
1014
+ * \threadsafety It is safe to call this function from any thread.
1015
+ *
1016
+ * \since This function is available since SDL 3.2.0.
1017
+ */
1018
+ extern SDL_DECLSPEC Uint64 SDLCALL SDL_GetGamepadSteamHandle(SDL_Gamepad *gamepad);
1019
+
1020
+ /**
1021
+ * Get the connection state of a gamepad.
1022
+ *
1023
+ * \param gamepad the gamepad object to query.
1024
+ * \returns the connection state on success or
1025
+ * `SDL_JOYSTICK_CONNECTION_INVALID` on failure; call SDL_GetError()
1026
+ * for more information.
1027
+ *
1028
+ * \threadsafety It is safe to call this function from any thread.
1029
+ *
1030
+ * \since This function is available since SDL 3.2.0.
1031
+ */
1032
+ extern SDL_DECLSPEC SDL_JoystickConnectionState SDLCALL SDL_GetGamepadConnectionState(SDL_Gamepad *gamepad);
1033
+
1034
+ /**
1035
+ * Get the battery state of a gamepad.
1036
+ *
1037
+ * You should never take a battery status as absolute truth. Batteries
1038
+ * (especially failing batteries) are delicate hardware, and the values
1039
+ * reported here are best estimates based on what that hardware reports. It's
1040
+ * not uncommon for older batteries to lose stored power much faster than it
1041
+ * reports, or completely drain when reporting it has 20 percent left, etc.
1042
+ *
1043
+ * \param gamepad the gamepad object to query.
1044
+ * \param percent a pointer filled in with the percentage of battery life
1045
+ * left, between 0 and 100, or NULL to ignore. This will be
1046
+ * filled in with -1 we can't determine a value or there is no
1047
+ * battery.
1048
+ * \returns the current battery state.
1049
+ *
1050
+ * \threadsafety It is safe to call this function from any thread.
1051
+ *
1052
+ * \since This function is available since SDL 3.2.0.
1053
+ */
1054
+ extern SDL_DECLSPEC SDL_PowerState SDLCALL SDL_GetGamepadPowerInfo(SDL_Gamepad *gamepad, int *percent);
1055
+
1056
+ /**
1057
+ * Check if a gamepad has been opened and is currently connected.
1058
+ *
1059
+ * \param gamepad a gamepad identifier previously returned by
1060
+ * SDL_OpenGamepad().
1061
+ * \returns true if the gamepad has been opened and is currently connected, or
1062
+ * false if not.
1063
+ *
1064
+ * \threadsafety It is safe to call this function from any thread.
1065
+ *
1066
+ * \since This function is available since SDL 3.2.0.
1067
+ */
1068
+ extern SDL_DECLSPEC bool SDLCALL SDL_GamepadConnected(SDL_Gamepad *gamepad);
1069
+
1070
+ /**
1071
+ * Get the underlying joystick from a gamepad.
1072
+ *
1073
+ * This function will give you a SDL_Joystick object, which allows you to use
1074
+ * the SDL_Joystick functions with a SDL_Gamepad object. This would be useful
1075
+ * for getting a joystick's position at any given time, even if it hasn't
1076
+ * moved (moving it would produce an event, which would have the axis' value).
1077
+ *
1078
+ * The pointer returned is owned by the SDL_Gamepad. You should not call
1079
+ * SDL_CloseJoystick() on it, for example, since doing so will likely cause
1080
+ * SDL to crash.
1081
+ *
1082
+ * \param gamepad the gamepad object that you want to get a joystick from.
1083
+ * \returns an SDL_Joystick object, or NULL on failure; call SDL_GetError()
1084
+ * for more information.
1085
+ *
1086
+ * \threadsafety It is safe to call this function from any thread.
1087
+ *
1088
+ * \since This function is available since SDL 3.2.0.
1089
+ */
1090
+ extern SDL_DECLSPEC SDL_Joystick * SDLCALL SDL_GetGamepadJoystick(SDL_Gamepad *gamepad);
1091
+
1092
+ /**
1093
+ * Set the state of gamepad event processing.
1094
+ *
1095
+ * If gamepad events are disabled, you must call SDL_UpdateGamepads() yourself
1096
+ * and check the state of the gamepad when you want gamepad information.
1097
+ *
1098
+ * \param enabled whether to process gamepad events or not.
1099
+ *
1100
+ * \threadsafety It is safe to call this function from any thread.
1101
+ *
1102
+ * \since This function is available since SDL 3.2.0.
1103
+ *
1104
+ * \sa SDL_GamepadEventsEnabled
1105
+ * \sa SDL_UpdateGamepads
1106
+ */
1107
+ extern SDL_DECLSPEC void SDLCALL SDL_SetGamepadEventsEnabled(bool enabled);
1108
+
1109
+ /**
1110
+ * Query the state of gamepad event processing.
1111
+ *
1112
+ * If gamepad events are disabled, you must call SDL_UpdateGamepads() yourself
1113
+ * and check the state of the gamepad when you want gamepad information.
1114
+ *
1115
+ * \returns true if gamepad events are being processed, false otherwise.
1116
+ *
1117
+ * \threadsafety It is safe to call this function from any thread.
1118
+ *
1119
+ * \since This function is available since SDL 3.2.0.
1120
+ *
1121
+ * \sa SDL_SetGamepadEventsEnabled
1122
+ */
1123
+ extern SDL_DECLSPEC bool SDLCALL SDL_GamepadEventsEnabled(void);
1124
+
1125
+ /**
1126
+ * Get the SDL joystick layer bindings for a gamepad.
1127
+ *
1128
+ * \param gamepad a gamepad.
1129
+ * \param count a pointer filled in with the number of bindings returned.
1130
+ * \returns a NULL terminated array of pointers to bindings or NULL on
1131
+ * failure; call SDL_GetError() for more information. This is a
1132
+ * single allocation that should be freed with SDL_free() when it is
1133
+ * no longer needed.
1134
+ *
1135
+ * \threadsafety It is safe to call this function from any thread.
1136
+ *
1137
+ * \since This function is available since SDL 3.2.0.
1138
+ */
1139
+ extern SDL_DECLSPEC SDL_GamepadBinding ** SDLCALL SDL_GetGamepadBindings(SDL_Gamepad *gamepad, int *count);
1140
+
1141
+ /**
1142
+ * Manually pump gamepad updates if not using the loop.
1143
+ *
1144
+ * This function is called automatically by the event loop if events are
1145
+ * enabled. Under such circumstances, it will not be necessary to call this
1146
+ * function.
1147
+ *
1148
+ * \threadsafety It is safe to call this function from any thread.
1149
+ *
1150
+ * \since This function is available since SDL 3.2.0.
1151
+ */
1152
+ extern SDL_DECLSPEC void SDLCALL SDL_UpdateGamepads(void);
1153
+
1154
+ /**
1155
+ * Convert a string into SDL_GamepadType enum.
1156
+ *
1157
+ * This function is called internally to translate SDL_Gamepad mapping strings
1158
+ * for the underlying joystick device into the consistent SDL_Gamepad mapping.
1159
+ * You do not normally need to call this function unless you are parsing
1160
+ * SDL_Gamepad mappings in your own code.
1161
+ *
1162
+ * \param str string representing a SDL_GamepadType type.
1163
+ * \returns the SDL_GamepadType enum corresponding to the input string, or
1164
+ * `SDL_GAMEPAD_TYPE_UNKNOWN` if no match was found.
1165
+ *
1166
+ * \threadsafety It is safe to call this function from any thread.
1167
+ *
1168
+ * \since This function is available since SDL 3.2.0.
1169
+ *
1170
+ * \sa SDL_GetGamepadStringForType
1171
+ */
1172
+ extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadTypeFromString(const char *str);
1173
+
1174
+ /**
1175
+ * Convert from an SDL_GamepadType enum to a string.
1176
+ *
1177
+ * \param type an enum value for a given SDL_GamepadType.
1178
+ * \returns a string for the given type, or NULL if an invalid type is
1179
+ * specified. The string returned is of the format used by
1180
+ * SDL_Gamepad mapping strings.
1181
+ *
1182
+ * \threadsafety It is safe to call this function from any thread.
1183
+ *
1184
+ * \since This function is available since SDL 3.2.0.
1185
+ *
1186
+ * \sa SDL_GetGamepadTypeFromString
1187
+ */
1188
+ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForType(SDL_GamepadType type);
1189
+
1190
+ /**
1191
+ * Convert a string into SDL_GamepadAxis enum.
1192
+ *
1193
+ * This function is called internally to translate SDL_Gamepad mapping strings
1194
+ * for the underlying joystick device into the consistent SDL_Gamepad mapping.
1195
+ * You do not normally need to call this function unless you are parsing
1196
+ * SDL_Gamepad mappings in your own code.
1197
+ *
1198
+ * Note specially that "righttrigger" and "lefttrigger" map to
1199
+ * `SDL_GAMEPAD_AXIS_RIGHT_TRIGGER` and `SDL_GAMEPAD_AXIS_LEFT_TRIGGER`,
1200
+ * respectively.
1201
+ *
1202
+ * \param str string representing a SDL_Gamepad axis.
1203
+ * \returns the SDL_GamepadAxis enum corresponding to the input string, or
1204
+ * `SDL_GAMEPAD_AXIS_INVALID` if no match was found.
1205
+ *
1206
+ * \threadsafety It is safe to call this function from any thread.
1207
+ *
1208
+ * \since This function is available since SDL 3.2.0.
1209
+ *
1210
+ * \sa SDL_GetGamepadStringForAxis
1211
+ */
1212
+ extern SDL_DECLSPEC SDL_GamepadAxis SDLCALL SDL_GetGamepadAxisFromString(const char *str);
1213
+
1214
+ /**
1215
+ * Convert from an SDL_GamepadAxis enum to a string.
1216
+ *
1217
+ * \param axis an enum value for a given SDL_GamepadAxis.
1218
+ * \returns a string for the given axis, or NULL if an invalid axis is
1219
+ * specified. The string returned is of the format used by
1220
+ * SDL_Gamepad mapping strings.
1221
+ *
1222
+ * \threadsafety It is safe to call this function from any thread.
1223
+ *
1224
+ * \since This function is available since SDL 3.2.0.
1225
+ *
1226
+ * \sa SDL_GetGamepadAxisFromString
1227
+ */
1228
+ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForAxis(SDL_GamepadAxis axis);
1229
+
1230
+ /**
1231
+ * Query whether a gamepad has a given axis.
1232
+ *
1233
+ * This merely reports whether the gamepad's mapping defined this axis, as
1234
+ * that is all the information SDL has about the physical device.
1235
+ *
1236
+ * \param gamepad a gamepad.
1237
+ * \param axis an axis enum value (an SDL_GamepadAxis value).
1238
+ * \returns true if the gamepad has this axis, false otherwise.
1239
+ *
1240
+ * \threadsafety It is safe to call this function from any thread.
1241
+ *
1242
+ * \since This function is available since SDL 3.2.0.
1243
+ *
1244
+ * \sa SDL_GamepadHasButton
1245
+ * \sa SDL_GetGamepadAxis
1246
+ */
1247
+ extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis);
1248
+
1249
+ /**
1250
+ * Get the current state of an axis control on a gamepad.
1251
+ *
1252
+ * The axis indices start at index 0.
1253
+ *
1254
+ * For thumbsticks, the state is a value ranging from -32768 (up/left) to
1255
+ * 32767 (down/right).
1256
+ *
1257
+ * Triggers range from 0 when released to 32767 when fully pressed, and never
1258
+ * return a negative value. Note that this differs from the value reported by
1259
+ * the lower-level SDL_GetJoystickAxis(), which normally uses the full range.
1260
+ *
1261
+ * Note that for invalid gamepads or axes, this will return 0. Zero is also a
1262
+ * valid value in normal operation; usually it means a centered axis.
1263
+ *
1264
+ * \param gamepad a gamepad.
1265
+ * \param axis an axis index (one of the SDL_GamepadAxis values).
1266
+ * \returns axis state.
1267
+ *
1268
+ * \threadsafety It is safe to call this function from any thread.
1269
+ *
1270
+ * \since This function is available since SDL 3.2.0.
1271
+ *
1272
+ * \sa SDL_GamepadHasAxis
1273
+ * \sa SDL_GetGamepadButton
1274
+ */
1275
+ extern SDL_DECLSPEC Sint16 SDLCALL SDL_GetGamepadAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis);
1276
+
1277
+ /**
1278
+ * Convert a string into an SDL_GamepadButton enum.
1279
+ *
1280
+ * This function is called internally to translate SDL_Gamepad mapping strings
1281
+ * for the underlying joystick device into the consistent SDL_Gamepad mapping.
1282
+ * You do not normally need to call this function unless you are parsing
1283
+ * SDL_Gamepad mappings in your own code.
1284
+ *
1285
+ * \param str string representing a SDL_Gamepad button.
1286
+ * \returns the SDL_GamepadButton enum corresponding to the input string, or
1287
+ * `SDL_GAMEPAD_BUTTON_INVALID` if no match was found.
1288
+ *
1289
+ * \threadsafety It is safe to call this function from any thread.
1290
+ *
1291
+ * \since This function is available since SDL 3.2.0.
1292
+ *
1293
+ * \sa SDL_GetGamepadStringForButton
1294
+ */
1295
+ extern SDL_DECLSPEC SDL_GamepadButton SDLCALL SDL_GetGamepadButtonFromString(const char *str);
1296
+
1297
+ /**
1298
+ * Convert from an SDL_GamepadButton enum to a string.
1299
+ *
1300
+ * \param button an enum value for a given SDL_GamepadButton.
1301
+ * \returns a string for the given button, or NULL if an invalid button is
1302
+ * specified. The string returned is of the format used by
1303
+ * SDL_Gamepad mapping strings.
1304
+ *
1305
+ * \threadsafety It is safe to call this function from any thread.
1306
+ *
1307
+ * \since This function is available since SDL 3.2.0.
1308
+ *
1309
+ * \sa SDL_GetGamepadButtonFromString
1310
+ */
1311
+ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForButton(SDL_GamepadButton button);
1312
+
1313
+ /**
1314
+ * Query whether a gamepad has a given button.
1315
+ *
1316
+ * This merely reports whether the gamepad's mapping defined this button, as
1317
+ * that is all the information SDL has about the physical device.
1318
+ *
1319
+ * \param gamepad a gamepad.
1320
+ * \param button a button enum value (an SDL_GamepadButton value).
1321
+ * \returns true if the gamepad has this button, false otherwise.
1322
+ *
1323
+ * \threadsafety It is safe to call this function from any thread.
1324
+ *
1325
+ * \since This function is available since SDL 3.2.0.
1326
+ *
1327
+ * \sa SDL_GamepadHasAxis
1328
+ */
1329
+ extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasButton(SDL_Gamepad *gamepad, SDL_GamepadButton button);
1330
+
1331
+ /**
1332
+ * Get the current state of a button on a gamepad.
1333
+ *
1334
+ * \param gamepad a gamepad.
1335
+ * \param button a button index (one of the SDL_GamepadButton values).
1336
+ * \returns true if the button is pressed, false otherwise.
1337
+ *
1338
+ * \threadsafety It is safe to call this function from any thread.
1339
+ *
1340
+ * \since This function is available since SDL 3.2.0.
1341
+ *
1342
+ * \sa SDL_GamepadHasButton
1343
+ * \sa SDL_GetGamepadAxis
1344
+ */
1345
+ extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadButton(SDL_Gamepad *gamepad, SDL_GamepadButton button);
1346
+
1347
+ /**
1348
+ * Get the label of a button on a gamepad.
1349
+ *
1350
+ * \param type the type of gamepad to check.
1351
+ * \param button a button index (one of the SDL_GamepadButton values).
1352
+ * \returns the SDL_GamepadButtonLabel enum corresponding to the button label.
1353
+ *
1354
+ * \threadsafety It is safe to call this function from any thread.
1355
+ *
1356
+ * \since This function is available since SDL 3.2.0.
1357
+ *
1358
+ * \sa SDL_GetGamepadButtonLabel
1359
+ */
1360
+ extern SDL_DECLSPEC SDL_GamepadButtonLabel SDLCALL SDL_GetGamepadButtonLabelForType(SDL_GamepadType type, SDL_GamepadButton button);
1361
+
1362
+ /**
1363
+ * Get the label of a button on a gamepad.
1364
+ *
1365
+ * \param gamepad a gamepad.
1366
+ * \param button a button index (one of the SDL_GamepadButton values).
1367
+ * \returns the SDL_GamepadButtonLabel enum corresponding to the button label.
1368
+ *
1369
+ * \threadsafety It is safe to call this function from any thread.
1370
+ *
1371
+ * \since This function is available since SDL 3.2.0.
1372
+ *
1373
+ * \sa SDL_GetGamepadButtonLabelForType
1374
+ */
1375
+ extern SDL_DECLSPEC SDL_GamepadButtonLabel SDLCALL SDL_GetGamepadButtonLabel(SDL_Gamepad *gamepad, SDL_GamepadButton button);
1376
+
1377
+ /**
1378
+ * Get the number of touchpads on a gamepad.
1379
+ *
1380
+ * \param gamepad a gamepad.
1381
+ * \returns number of touchpads.
1382
+ *
1383
+ * \threadsafety It is safe to call this function from any thread.
1384
+ *
1385
+ * \since This function is available since SDL 3.2.0.
1386
+ *
1387
+ * \sa SDL_GetNumGamepadTouchpadFingers
1388
+ */
1389
+ extern SDL_DECLSPEC int SDLCALL SDL_GetNumGamepadTouchpads(SDL_Gamepad *gamepad);
1390
+
1391
+ /**
1392
+ * Get the number of supported simultaneous fingers on a touchpad on a game
1393
+ * gamepad.
1394
+ *
1395
+ * \param gamepad a gamepad.
1396
+ * \param touchpad a touchpad.
1397
+ * \returns number of supported simultaneous fingers.
1398
+ *
1399
+ * \threadsafety It is safe to call this function from any thread.
1400
+ *
1401
+ * \since This function is available since SDL 3.2.0.
1402
+ *
1403
+ * \sa SDL_GetGamepadTouchpadFinger
1404
+ * \sa SDL_GetNumGamepadTouchpads
1405
+ */
1406
+ extern SDL_DECLSPEC int SDLCALL SDL_GetNumGamepadTouchpadFingers(SDL_Gamepad *gamepad, int touchpad);
1407
+
1408
+ /**
1409
+ * Get the current state of a finger on a touchpad on a gamepad.
1410
+ *
1411
+ * \param gamepad a gamepad.
1412
+ * \param touchpad a touchpad.
1413
+ * \param finger a finger.
1414
+ * \param down a pointer filled with true if the finger is down, false
1415
+ * otherwise, may be NULL.
1416
+ * \param x a pointer filled with the x position, normalized 0 to 1, with the
1417
+ * origin in the upper left, may be NULL.
1418
+ * \param y a pointer filled with the y position, normalized 0 to 1, with the
1419
+ * origin in the upper left, may be NULL.
1420
+ * \param pressure a pointer filled with pressure value, may be NULL.
1421
+ * \returns true on success or false on failure; call SDL_GetError() for more
1422
+ * information.
1423
+ *
1424
+ * \threadsafety It is safe to call this function from any thread.
1425
+ *
1426
+ * \since This function is available since SDL 3.2.0.
1427
+ *
1428
+ * \sa SDL_GetNumGamepadTouchpadFingers
1429
+ */
1430
+ extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadTouchpadFinger(SDL_Gamepad *gamepad, int touchpad, int finger, bool *down, float *x, float *y, float *pressure);
1431
+
1432
+ /**
1433
+ * Return whether a gamepad has a particular sensor.
1434
+ *
1435
+ * \param gamepad the gamepad to query.
1436
+ * \param type the type of sensor to query.
1437
+ * \returns true if the sensor exists, false otherwise.
1438
+ *
1439
+ * \threadsafety It is safe to call this function from any thread.
1440
+ *
1441
+ * \since This function is available since SDL 3.2.0.
1442
+ *
1443
+ * \sa SDL_GetGamepadSensorData
1444
+ * \sa SDL_GetGamepadSensorDataRate
1445
+ * \sa SDL_SetGamepadSensorEnabled
1446
+ */
1447
+ extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasSensor(SDL_Gamepad *gamepad, SDL_SensorType type);
1448
+
1449
+ /**
1450
+ * Set whether data reporting for a gamepad sensor is enabled.
1451
+ *
1452
+ * \param gamepad the gamepad to update.
1453
+ * \param type the type of sensor to enable/disable.
1454
+ * \param enabled whether data reporting should be enabled.
1455
+ * \returns true on success or false on failure; call SDL_GetError() for more
1456
+ * information.
1457
+ *
1458
+ * \threadsafety It is safe to call this function from any thread.
1459
+ *
1460
+ * \since This function is available since SDL 3.2.0.
1461
+ *
1462
+ * \sa SDL_GamepadHasSensor
1463
+ * \sa SDL_GamepadSensorEnabled
1464
+ */
1465
+ extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadSensorEnabled(SDL_Gamepad *gamepad, SDL_SensorType type, bool enabled);
1466
+
1467
+ /**
1468
+ * Query whether sensor data reporting is enabled for a gamepad.
1469
+ *
1470
+ * \param gamepad the gamepad to query.
1471
+ * \param type the type of sensor to query.
1472
+ * \returns true if the sensor is enabled, false otherwise.
1473
+ *
1474
+ * \threadsafety It is safe to call this function from any thread.
1475
+ *
1476
+ * \since This function is available since SDL 3.2.0.
1477
+ *
1478
+ * \sa SDL_SetGamepadSensorEnabled
1479
+ */
1480
+ extern SDL_DECLSPEC bool SDLCALL SDL_GamepadSensorEnabled(SDL_Gamepad *gamepad, SDL_SensorType type);
1481
+
1482
+ /**
1483
+ * Get the data rate (number of events per second) of a gamepad sensor.
1484
+ *
1485
+ * \param gamepad the gamepad to query.
1486
+ * \param type the type of sensor to query.
1487
+ * \returns the data rate, or 0.0f if the data rate is not available.
1488
+ *
1489
+ * \threadsafety It is safe to call this function from any thread.
1490
+ *
1491
+ * \since This function is available since SDL 3.2.0.
1492
+ */
1493
+ extern SDL_DECLSPEC float SDLCALL SDL_GetGamepadSensorDataRate(SDL_Gamepad *gamepad, SDL_SensorType type);
1494
+
1495
+ /**
1496
+ * Get the current state of a gamepad sensor.
1497
+ *
1498
+ * The number of values and interpretation of the data is sensor dependent.
1499
+ * See the remarks in SDL_SensorType for details for each type of sensor.
1500
+ *
1501
+ * \param gamepad the gamepad to query.
1502
+ * \param type the type of sensor to query.
1503
+ * \param data a pointer filled with the current sensor state.
1504
+ * \param num_values the number of values to write to data.
1505
+ * \returns true on success or false on failure; call SDL_GetError() for more
1506
+ * information.
1507
+ *
1508
+ * \threadsafety It is safe to call this function from any thread.
1509
+ *
1510
+ * \since This function is available since SDL 3.2.0.
1511
+ */
1512
+ extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadSensorData(SDL_Gamepad *gamepad, SDL_SensorType type, float *data, int num_values);
1513
+
1514
+ /**
1515
+ * Start a rumble effect on a gamepad.
1516
+ *
1517
+ * Each call to this function cancels any previous rumble effect, and calling
1518
+ * it with 0 intensity stops any rumbling.
1519
+ *
1520
+ * This function requires you to process SDL events or call
1521
+ * SDL_UpdateJoysticks() to update rumble state.
1522
+ *
1523
+ * \param gamepad the gamepad to vibrate.
1524
+ * \param low_frequency_rumble the intensity of the low frequency (left)
1525
+ * rumble motor, from 0 to 0xFFFF.
1526
+ * \param high_frequency_rumble the intensity of the high frequency (right)
1527
+ * rumble motor, from 0 to 0xFFFF.
1528
+ * \param duration_ms the duration of the rumble effect, in milliseconds.
1529
+ * \returns true on success or false on failure; call SDL_GetError() for more
1530
+ * information.
1531
+ *
1532
+ * \threadsafety It is safe to call this function from any thread.
1533
+ *
1534
+ * \since This function is available since SDL 3.2.0.
1535
+ */
1536
+ extern SDL_DECLSPEC bool SDLCALL SDL_RumbleGamepad(SDL_Gamepad *gamepad, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
1537
+
1538
+ /**
1539
+ * Start a rumble effect in the gamepad's triggers.
1540
+ *
1541
+ * Each call to this function cancels any previous trigger rumble effect, and
1542
+ * calling it with 0 intensity stops any rumbling.
1543
+ *
1544
+ * Note that this is rumbling of the _triggers_ and not the gamepad as a
1545
+ * whole. This is currently only supported on Xbox One gamepads. If you want
1546
+ * the (more common) whole-gamepad rumble, use SDL_RumbleGamepad() instead.
1547
+ *
1548
+ * This function requires you to process SDL events or call
1549
+ * SDL_UpdateJoysticks() to update rumble state.
1550
+ *
1551
+ * \param gamepad the gamepad to vibrate.
1552
+ * \param left_rumble the intensity of the left trigger rumble motor, from 0
1553
+ * to 0xFFFF.
1554
+ * \param right_rumble the intensity of the right trigger rumble motor, from 0
1555
+ * to 0xFFFF.
1556
+ * \param duration_ms the duration of the rumble effect, in milliseconds.
1557
+ * \returns true on success or false on failure; call SDL_GetError() for more
1558
+ * information.
1559
+ *
1560
+ * \threadsafety It is safe to call this function from any thread.
1561
+ *
1562
+ * \since This function is available since SDL 3.2.0.
1563
+ *
1564
+ * \sa SDL_RumbleGamepad
1565
+ */
1566
+ extern SDL_DECLSPEC bool SDLCALL SDL_RumbleGamepadTriggers(SDL_Gamepad *gamepad, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
1567
+
1568
+ /**
1569
+ * Update a gamepad's LED color.
1570
+ *
1571
+ * An example of a joystick LED is the light on the back of a PlayStation 4's
1572
+ * DualShock 4 controller.
1573
+ *
1574
+ * For gamepads with a single color LED, the maximum of the RGB values will be
1575
+ * used as the LED brightness.
1576
+ *
1577
+ * \param gamepad the gamepad to update.
1578
+ * \param red the intensity of the red LED.
1579
+ * \param green the intensity of the green LED.
1580
+ * \param blue the intensity of the blue LED.
1581
+ * \returns true on success or false on failure; call SDL_GetError() for more
1582
+ * information.
1583
+ *
1584
+ * \threadsafety It is safe to call this function from any thread.
1585
+ *
1586
+ * \since This function is available since SDL 3.2.0.
1587
+ */
1588
+ extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadLED(SDL_Gamepad *gamepad, Uint8 red, Uint8 green, Uint8 blue);
1589
+
1590
+ /**
1591
+ * Send a gamepad specific effect packet.
1592
+ *
1593
+ * \param gamepad the gamepad to affect.
1594
+ * \param data the data to send to the gamepad.
1595
+ * \param size the size of the data to send to the gamepad.
1596
+ * \returns true on success or false on failure; call SDL_GetError() for more
1597
+ * information.
1598
+ *
1599
+ * \threadsafety It is safe to call this function from any thread.
1600
+ *
1601
+ * \since This function is available since SDL 3.2.0.
1602
+ */
1603
+ extern SDL_DECLSPEC bool SDLCALL SDL_SendGamepadEffect(SDL_Gamepad *gamepad, const void *data, int size);
1604
+
1605
+ /**
1606
+ * Close a gamepad previously opened with SDL_OpenGamepad().
1607
+ *
1608
+ * \param gamepad a gamepad identifier previously returned by
1609
+ * SDL_OpenGamepad().
1610
+ *
1611
+ * \threadsafety It is safe to call this function from any thread.
1612
+ *
1613
+ * \since This function is available since SDL 3.2.0.
1614
+ *
1615
+ * \sa SDL_OpenGamepad
1616
+ */
1617
+ extern SDL_DECLSPEC void SDLCALL SDL_CloseGamepad(SDL_Gamepad *gamepad);
1618
+
1619
+ /**
1620
+ * Return the sfSymbolsName for a given button on a gamepad on Apple
1621
+ * platforms.
1622
+ *
1623
+ * \param gamepad the gamepad to query.
1624
+ * \param button a button on the gamepad.
1625
+ * \returns the sfSymbolsName or NULL if the name can't be found.
1626
+ *
1627
+ * \threadsafety It is safe to call this function from any thread.
1628
+ *
1629
+ * \since This function is available since SDL 3.2.0.
1630
+ *
1631
+ * \sa SDL_GetGamepadAppleSFSymbolsNameForAxis
1632
+ */
1633
+ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadAppleSFSymbolsNameForButton(SDL_Gamepad *gamepad, SDL_GamepadButton button);
1634
+
1635
+ /**
1636
+ * Return the sfSymbolsName for a given axis on a gamepad on Apple platforms.
1637
+ *
1638
+ * \param gamepad the gamepad to query.
1639
+ * \param axis an axis on the gamepad.
1640
+ * \returns the sfSymbolsName or NULL if the name can't be found.
1641
+ *
1642
+ * \threadsafety It is safe to call this function from any thread.
1643
+ *
1644
+ * \since This function is available since SDL 3.2.0.
1645
+ *
1646
+ * \sa SDL_GetGamepadAppleSFSymbolsNameForButton
1647
+ */
1648
+ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadAppleSFSymbolsNameForAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis);
1649
+
1650
+
1651
+ /* Ends C function definitions when using C++ */
1652
+ #ifdef __cplusplus
1653
+ }
1654
+ #endif
1655
+ #include <SDL3/SDL_close_code.h>
1656
+
1657
+ #endif /* SDL_gamepad_h_ */