gosu 0.15.1 → 1.1.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (227) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/COPYING +1 -1
  4. data/dependencies/SDL/include/SDL.h +138 -0
  5. data/dependencies/SDL/include/SDL_assert.h +293 -0
  6. data/dependencies/SDL/include/SDL_atomic.h +295 -0
  7. data/dependencies/SDL/include/SDL_audio.h +859 -0
  8. data/dependencies/SDL/include/SDL_bits.h +121 -0
  9. data/dependencies/SDL/include/SDL_blendmode.h +123 -0
  10. data/dependencies/SDL/include/SDL_clipboard.h +71 -0
  11. data/dependencies/SDL/include/SDL_config.h +55 -0
  12. data/dependencies/SDL/include/SDL_config_android.h +182 -0
  13. data/dependencies/SDL/include/SDL_config_iphoneos.h +207 -0
  14. data/dependencies/SDL/include/SDL_config_macosx.h +266 -0
  15. data/dependencies/SDL/include/SDL_config_minimal.h +85 -0
  16. data/dependencies/SDL/include/SDL_config_os2.h +188 -0
  17. data/dependencies/SDL/include/SDL_config_pandora.h +135 -0
  18. data/dependencies/SDL/include/SDL_config_psp.h +165 -0
  19. data/dependencies/SDL/include/SDL_config_windows.h +288 -0
  20. data/dependencies/SDL/include/SDL_config_winrt.h +243 -0
  21. data/dependencies/SDL/include/SDL_config_wiz.h +149 -0
  22. data/dependencies/SDL/include/SDL_copying.h +20 -0
  23. data/dependencies/SDL/include/SDL_cpuinfo.h +299 -0
  24. data/dependencies/SDL/include/SDL_egl.h +1676 -0
  25. data/dependencies/SDL/include/SDL_endian.h +263 -0
  26. data/dependencies/SDL/include/SDL_error.h +112 -0
  27. data/dependencies/SDL/include/SDL_events.h +827 -0
  28. data/dependencies/SDL/include/SDL_filesystem.h +136 -0
  29. data/dependencies/SDL/include/SDL_gamecontroller.h +541 -0
  30. data/dependencies/SDL/include/SDL_gesture.h +87 -0
  31. data/dependencies/SDL/include/SDL_haptic.h +1247 -0
  32. data/dependencies/SDL/include/SDL_hints.h +1578 -0
  33. data/dependencies/SDL/include/SDL_joystick.h +499 -0
  34. data/dependencies/SDL/include/SDL_keyboard.h +217 -0
  35. data/dependencies/SDL/include/SDL_keycode.h +351 -0
  36. data/dependencies/SDL/include/SDL_loadso.h +81 -0
  37. data/dependencies/SDL/include/SDL_locale.h +101 -0
  38. data/dependencies/SDL/include/SDL_log.h +211 -0
  39. data/dependencies/SDL/include/SDL_main.h +180 -0
  40. data/dependencies/SDL/include/SDL_messagebox.h +146 -0
  41. data/dependencies/SDL/include/SDL_metal.h +117 -0
  42. data/dependencies/SDL/include/SDL_misc.h +75 -0
  43. data/dependencies/SDL/include/SDL_mouse.h +302 -0
  44. data/dependencies/SDL/include/SDL_mutex.h +251 -0
  45. data/dependencies/SDL/include/SDL_name.h +33 -0
  46. data/dependencies/SDL/include/SDL_opengl.h +2183 -0
  47. data/dependencies/SDL/include/SDL_opengl_glext.h +11180 -0
  48. data/dependencies/SDL/include/SDL_opengles.h +39 -0
  49. data/dependencies/SDL/include/SDL_opengles2.h +52 -0
  50. data/dependencies/SDL/include/SDL_opengles2_gl2.h +621 -0
  51. data/dependencies/SDL/include/SDL_opengles2_gl2ext.h +2050 -0
  52. data/dependencies/SDL/include/SDL_opengles2_gl2platform.h +30 -0
  53. data/dependencies/SDL/include/SDL_opengles2_khrplatform.h +282 -0
  54. data/dependencies/SDL/include/SDL_pixels.h +479 -0
  55. data/dependencies/SDL/include/SDL_platform.h +198 -0
  56. data/dependencies/SDL/include/SDL_power.h +75 -0
  57. data/dependencies/SDL/include/SDL_quit.h +58 -0
  58. data/dependencies/SDL/include/SDL_rect.h +174 -0
  59. data/dependencies/SDL/include/SDL_render.h +1158 -0
  60. data/dependencies/SDL/include/SDL_revision.h +2 -0
  61. data/dependencies/SDL/include/SDL_rwops.h +283 -0
  62. data/dependencies/SDL/include/SDL_scancode.h +413 -0
  63. data/dependencies/SDL/include/SDL_sensor.h +267 -0
  64. data/dependencies/SDL/include/SDL_shape.h +144 -0
  65. data/dependencies/SDL/include/SDL_stdinc.h +647 -0
  66. data/dependencies/SDL/include/SDL_surface.h +563 -0
  67. data/dependencies/SDL/include/SDL_system.h +325 -0
  68. data/dependencies/SDL/include/SDL_syswm.h +354 -0
  69. data/dependencies/SDL/include/SDL_test.h +69 -0
  70. data/dependencies/SDL/include/SDL_test_assert.h +105 -0
  71. data/dependencies/SDL/include/SDL_test_common.h +218 -0
  72. data/dependencies/SDL/include/SDL_test_compare.h +69 -0
  73. data/dependencies/SDL/include/SDL_test_crc32.h +124 -0
  74. data/dependencies/SDL/include/SDL_test_font.h +81 -0
  75. data/dependencies/SDL/include/SDL_test_fuzzer.h +384 -0
  76. data/dependencies/SDL/include/SDL_test_harness.h +134 -0
  77. data/dependencies/SDL/include/SDL_test_images.h +78 -0
  78. data/dependencies/SDL/include/SDL_test_log.h +67 -0
  79. data/dependencies/SDL/include/SDL_test_md5.h +129 -0
  80. data/dependencies/SDL/include/SDL_test_memory.h +63 -0
  81. data/dependencies/SDL/include/SDL_test_random.h +115 -0
  82. data/dependencies/SDL/include/SDL_thread.h +366 -0
  83. data/dependencies/SDL/include/SDL_timer.h +115 -0
  84. data/dependencies/SDL/include/SDL_touch.h +102 -0
  85. data/dependencies/SDL/include/SDL_types.h +29 -0
  86. data/dependencies/SDL/include/SDL_version.h +162 -0
  87. data/dependencies/SDL/include/SDL_video.h +1282 -0
  88. data/dependencies/SDL/include/SDL_vulkan.h +276 -0
  89. data/dependencies/SDL/include/begin_code.h +166 -0
  90. data/dependencies/SDL/include/close_code.h +40 -0
  91. data/dependencies/SDL/lib/x64/libSDL2.dll.a +0 -0
  92. data/dependencies/SDL/lib/x86/libSDL2.dll.a +0 -0
  93. data/dependencies/SDL_sound/SDL_sound.c +795 -0
  94. data/dependencies/SDL_sound/SDL_sound.h +725 -0
  95. data/dependencies/SDL_sound/SDL_sound_aiff.c +537 -0
  96. data/dependencies/SDL_sound/SDL_sound_au.c +352 -0
  97. data/dependencies/SDL_sound/SDL_sound_coreaudio.c +747 -0
  98. data/dependencies/SDL_sound/SDL_sound_flac.c +182 -0
  99. data/dependencies/SDL_sound/SDL_sound_internal.h +304 -0
  100. data/dependencies/SDL_sound/SDL_sound_modplug.c +228 -0
  101. data/dependencies/SDL_sound/SDL_sound_mp3.c +184 -0
  102. data/dependencies/SDL_sound/SDL_sound_raw.c +164 -0
  103. data/dependencies/SDL_sound/SDL_sound_shn.c +1309 -0
  104. data/dependencies/SDL_sound/SDL_sound_voc.c +550 -0
  105. data/dependencies/SDL_sound/SDL_sound_vorbis.c +223 -0
  106. data/dependencies/SDL_sound/SDL_sound_wav.c +783 -0
  107. data/dependencies/SDL_sound/dr_flac.h +5906 -0
  108. data/dependencies/SDL_sound/dr_mp3.h +2832 -0
  109. data/dependencies/SDL_sound/libmodplug/fastmix.c +1748 -0
  110. data/dependencies/SDL_sound/libmodplug/libmodplug.h +1001 -0
  111. data/dependencies/SDL_sound/libmodplug/load_669.c +188 -0
  112. data/dependencies/SDL_sound/libmodplug/load_abc.c +4725 -0
  113. data/dependencies/SDL_sound/libmodplug/load_amf.c +403 -0
  114. data/dependencies/SDL_sound/libmodplug/load_ams.c +587 -0
  115. data/dependencies/SDL_sound/libmodplug/load_dbm.c +357 -0
  116. data/dependencies/SDL_sound/libmodplug/load_dmf.c +531 -0
  117. data/dependencies/SDL_sound/libmodplug/load_dsm.c +232 -0
  118. data/dependencies/SDL_sound/libmodplug/load_far.c +253 -0
  119. data/dependencies/SDL_sound/libmodplug/load_it.c +796 -0
  120. data/dependencies/SDL_sound/libmodplug/load_mdl.c +488 -0
  121. data/dependencies/SDL_sound/libmodplug/load_med.c +757 -0
  122. data/dependencies/SDL_sound/libmodplug/load_mid.c +1405 -0
  123. data/dependencies/SDL_sound/libmodplug/load_mod.c +269 -0
  124. data/dependencies/SDL_sound/libmodplug/load_mt2.c +546 -0
  125. data/dependencies/SDL_sound/libmodplug/load_mtm.c +142 -0
  126. data/dependencies/SDL_sound/libmodplug/load_okt.c +192 -0
  127. data/dependencies/SDL_sound/libmodplug/load_pat.c +1143 -0
  128. data/dependencies/SDL_sound/libmodplug/load_pat.h +25 -0
  129. data/dependencies/SDL_sound/libmodplug/load_psm.c +350 -0
  130. data/dependencies/SDL_sound/libmodplug/load_ptm.c +204 -0
  131. data/dependencies/SDL_sound/libmodplug/load_s3m.c +325 -0
  132. data/dependencies/SDL_sound/libmodplug/load_stm.c +180 -0
  133. data/dependencies/SDL_sound/libmodplug/load_ult.c +206 -0
  134. data/dependencies/SDL_sound/libmodplug/load_umx.c +51 -0
  135. data/dependencies/SDL_sound/libmodplug/load_xm.c +554 -0
  136. data/dependencies/SDL_sound/libmodplug/mmcmp.c +382 -0
  137. data/dependencies/SDL_sound/libmodplug/modplug.c +170 -0
  138. data/dependencies/SDL_sound/libmodplug/modplug.h +90 -0
  139. data/dependencies/SDL_sound/libmodplug/snd_dsp.c +301 -0
  140. data/dependencies/SDL_sound/libmodplug/snd_flt.c +63 -0
  141. data/dependencies/SDL_sound/libmodplug/snd_fx.c +2350 -0
  142. data/dependencies/SDL_sound/libmodplug/sndfile.c +1169 -0
  143. data/dependencies/SDL_sound/libmodplug/sndmix.c +1034 -0
  144. data/dependencies/SDL_sound/libmodplug/tables.h +371 -0
  145. data/{src/stb_vorbis.c → dependencies/SDL_sound/stb_vorbis.h} +143 -78
  146. data/dependencies/al_soft/AL/al.h +655 -0
  147. data/dependencies/al_soft/AL/alc.h +270 -0
  148. data/dependencies/al_soft/AL/alext.h +585 -0
  149. data/dependencies/al_soft/AL/efx-creative.h +3 -0
  150. data/dependencies/al_soft/AL/efx-presets.h +402 -0
  151. data/dependencies/al_soft/AL/efx.h +762 -0
  152. data/dependencies/al_soft/x64/libOpenAL32.dll.a +0 -0
  153. data/dependencies/al_soft/x86/libOpenAL32.dll.a +0 -0
  154. data/{src → dependencies/stb}/stb_image.h +330 -127
  155. data/{src → dependencies/stb}/stb_image_write.h +156 -85
  156. data/{src → dependencies/stb}/stb_truetype.h +192 -69
  157. data/{src → dependencies/utf8proc}/utf8proc.c +0 -0
  158. data/{src → dependencies/utf8proc}/utf8proc.h +0 -0
  159. data/{src → dependencies/utf8proc}/utf8proc_data.h +0 -0
  160. data/ext/gosu/extconf.rb +53 -39
  161. data/{Gosu → include/Gosu}/Audio.hpp +6 -8
  162. data/include/Gosu/Bitmap.hpp +100 -0
  163. data/{Gosu → include/Gosu}/Buttons.hpp +104 -44
  164. data/{Gosu → include/Gosu}/Color.hpp +0 -0
  165. data/{Gosu → include/Gosu}/Directories.hpp +0 -0
  166. data/{Gosu → include/Gosu}/Font.hpp +1 -1
  167. data/{Gosu → include/Gosu}/Fwd.hpp +0 -5
  168. data/{Gosu → include/Gosu}/Gosu.hpp +0 -0
  169. data/{Gosu → include/Gosu}/Graphics.hpp +0 -0
  170. data/{Gosu → include/Gosu}/GraphicsBase.hpp +0 -0
  171. data/{Gosu → include/Gosu}/IO.hpp +0 -0
  172. data/{Gosu → include/Gosu}/Image.hpp +7 -6
  173. data/{Gosu → include/Gosu}/ImageData.hpp +0 -0
  174. data/{Gosu → include/Gosu}/Input.hpp +39 -51
  175. data/{Gosu → include/Gosu}/Inspection.hpp +0 -0
  176. data/{Gosu → include/Gosu}/Math.hpp +0 -0
  177. data/{Gosu → include/Gosu}/Platform.hpp +0 -0
  178. data/{Gosu → include/Gosu}/Text.hpp +0 -0
  179. data/{Gosu → include/Gosu}/TextInput.hpp +0 -0
  180. data/{Gosu → include/Gosu}/Timing.hpp +0 -0
  181. data/{Gosu → include/Gosu}/Utility.hpp +15 -4
  182. data/{Gosu → include/Gosu}/Version.hpp +3 -3
  183. data/{Gosu → include/Gosu}/Window.hpp +46 -34
  184. data/lib/OpenAL32.dll +0 -0
  185. data/lib/SDL2.dll +0 -0
  186. data/lib/gosu.rb +0 -3
  187. data/lib/gosu/patches.rb +0 -23
  188. data/lib/gosu/preview.rb +1 -3
  189. data/lib/gosu/swig_patches.rb +6 -8
  190. data/lib64/OpenAL32.dll +0 -0
  191. data/lib64/SDL2.dll +0 -0
  192. data/rdoc/gosu.rb +112 -23
  193. data/src/Audio.cpp +50 -224
  194. data/src/AudioFile.hpp +20 -37
  195. data/src/AudioFileAudioToolbox.cpp +237 -0
  196. data/src/AudioFileSDLSound.cpp +147 -0
  197. data/src/AudioImpl.cpp +3 -12
  198. data/src/AudioImpl.hpp +3 -1
  199. data/src/Bitmap.cpp +85 -83
  200. data/src/BitmapIO.cpp +52 -58
  201. data/src/Font.cpp +4 -1
  202. data/src/Graphics.cpp +7 -4
  203. data/src/Image.cpp +13 -16
  204. data/src/Input.cpp +412 -164
  205. data/src/LargeImageData.cpp +2 -1
  206. data/src/MarkupParser.cpp +2 -1
  207. data/src/Resolution.cpp +8 -8
  208. data/src/RubyGosu.cxx +1184 -352
  209. data/src/RubyGosu.h +3 -2
  210. data/src/TexChunk.cpp +1 -1
  211. data/src/Text.cpp +1 -0
  212. data/src/TextBuilder.cpp +3 -1
  213. data/src/Texture.cpp +1 -1
  214. data/src/TrueTypeFont.cpp +2 -1
  215. data/src/TrueTypeFontWin.cpp +3 -3
  216. data/src/Utility.cpp +11 -7
  217. data/src/Window.cpp +90 -62
  218. data/src/WindowUIKit.cpp +21 -9
  219. metadata +195 -46
  220. data/Gosu/AutoLink.hpp +0 -14
  221. data/Gosu/Bitmap.hpp +0 -113
  222. data/lib/gosu/zen.rb +0 -89
  223. data/src/AudioToolboxFile.hpp +0 -210
  224. data/src/MPEGFile.hpp +0 -90
  225. data/src/OggFile.hpp +0 -92
  226. data/src/SndFile.hpp +0 -174
  227. data/src/WinMain.cpp +0 -64
@@ -0,0 +1,263 @@
1
+ /*
2
+ Simple DirectMedia Layer
3
+ Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
4
+
5
+ This software is provided 'as-is', without any express or implied
6
+ warranty. In no event will the authors be held liable for any damages
7
+ arising from the use of this software.
8
+
9
+ Permission is granted to anyone to use this software for any purpose,
10
+ including commercial applications, and to alter it and redistribute it
11
+ freely, subject to the following restrictions:
12
+
13
+ 1. The origin of this software must not be misrepresented; you must not
14
+ claim that you wrote the original software. If you use this software
15
+ in a product, an acknowledgment in the product documentation would be
16
+ appreciated but is not required.
17
+ 2. Altered source versions must be plainly marked as such, and must not be
18
+ misrepresented as being the original software.
19
+ 3. This notice may not be removed or altered from any source distribution.
20
+ */
21
+
22
+ /**
23
+ * \file SDL_endian.h
24
+ *
25
+ * Functions for reading and writing endian-specific values
26
+ */
27
+
28
+ #ifndef SDL_endian_h_
29
+ #define SDL_endian_h_
30
+
31
+ #include "SDL_stdinc.h"
32
+
33
+ /**
34
+ * \name The two types of endianness
35
+ */
36
+ /* @{ */
37
+ #define SDL_LIL_ENDIAN 1234
38
+ #define SDL_BIG_ENDIAN 4321
39
+ /* @} */
40
+
41
+ #ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */
42
+ #ifdef __linux__
43
+ #include <endian.h>
44
+ #define SDL_BYTEORDER __BYTE_ORDER
45
+ #elif defined(__OpenBSD__)
46
+ #include <endian.h>
47
+ #define SDL_BYTEORDER BYTE_ORDER
48
+ #else
49
+ #if defined(__hppa__) || \
50
+ defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \
51
+ (defined(__MIPS__) && defined(__MIPSEB__)) || \
52
+ defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \
53
+ defined(__sparc__)
54
+ #define SDL_BYTEORDER SDL_BIG_ENDIAN
55
+ #else
56
+ #define SDL_BYTEORDER SDL_LIL_ENDIAN
57
+ #endif
58
+ #endif /* __linux__ */
59
+ #endif /* !SDL_BYTEORDER */
60
+
61
+
62
+ #include "begin_code.h"
63
+ /* Set up for C function definitions, even when using C++ */
64
+ #ifdef __cplusplus
65
+ extern "C" {
66
+ #endif
67
+
68
+ /**
69
+ * \file SDL_endian.h
70
+ */
71
+ #if defined(__GNUC__) && defined(__i386__) && \
72
+ !(__GNUC__ == 2 && __GNUC_MINOR__ == 95 /* broken gcc version */)
73
+ SDL_FORCE_INLINE Uint16
74
+ SDL_Swap16(Uint16 x)
75
+ {
76
+ __asm__("xchgb %b0,%h0": "=q"(x):"0"(x));
77
+ return x;
78
+ }
79
+ #elif defined(__GNUC__) && defined(__x86_64__)
80
+ SDL_FORCE_INLINE Uint16
81
+ SDL_Swap16(Uint16 x)
82
+ {
83
+ __asm__("xchgb %b0,%h0": "=Q"(x):"0"(x));
84
+ return x;
85
+ }
86
+ #elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))
87
+ SDL_FORCE_INLINE Uint16
88
+ SDL_Swap16(Uint16 x)
89
+ {
90
+ int result;
91
+
92
+ __asm__("rlwimi %0,%2,8,16,23": "=&r"(result):"0"(x >> 8), "r"(x));
93
+ return (Uint16)result;
94
+ }
95
+ #elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__)
96
+ SDL_FORCE_INLINE Uint16
97
+ SDL_Swap16(Uint16 x)
98
+ {
99
+ __asm__("rorw #8,%0": "=d"(x): "0"(x):"cc");
100
+ return x;
101
+ }
102
+ #elif defined(__WATCOMC__) && defined(__386__)
103
+ extern _inline Uint16 SDL_Swap16(Uint16);
104
+ #pragma aux SDL_Swap16 = \
105
+ "xchg al, ah" \
106
+ parm [ax] \
107
+ modify [ax];
108
+ #else
109
+ SDL_FORCE_INLINE Uint16
110
+ SDL_Swap16(Uint16 x)
111
+ {
112
+ return SDL_static_cast(Uint16, ((x << 8) | (x >> 8)));
113
+ }
114
+ #endif
115
+
116
+ #if defined(__GNUC__) && defined(__i386__)
117
+ SDL_FORCE_INLINE Uint32
118
+ SDL_Swap32(Uint32 x)
119
+ {
120
+ __asm__("bswap %0": "=r"(x):"0"(x));
121
+ return x;
122
+ }
123
+ #elif defined(__GNUC__) && defined(__x86_64__)
124
+ SDL_FORCE_INLINE Uint32
125
+ SDL_Swap32(Uint32 x)
126
+ {
127
+ __asm__("bswapl %0": "=r"(x):"0"(x));
128
+ return x;
129
+ }
130
+ #elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))
131
+ SDL_FORCE_INLINE Uint32
132
+ SDL_Swap32(Uint32 x)
133
+ {
134
+ Uint32 result;
135
+
136
+ __asm__("rlwimi %0,%2,24,16,23": "=&r"(result):"0"(x >> 24), "r"(x));
137
+ __asm__("rlwimi %0,%2,8,8,15": "=&r"(result):"0"(result), "r"(x));
138
+ __asm__("rlwimi %0,%2,24,0,7": "=&r"(result):"0"(result), "r"(x));
139
+ return result;
140
+ }
141
+ #elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__)
142
+ SDL_FORCE_INLINE Uint32
143
+ SDL_Swap32(Uint32 x)
144
+ {
145
+ __asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0": "=d"(x): "0"(x):"cc");
146
+ return x;
147
+ }
148
+ #elif defined(__WATCOMC__) && defined(__386__)
149
+ extern _inline Uint32 SDL_Swap32(Uint32);
150
+ #ifndef __SW_3 /* 486+ */
151
+ #pragma aux SDL_Swap32 = \
152
+ "bswap eax" \
153
+ parm [eax] \
154
+ modify [eax];
155
+ #else /* 386-only */
156
+ #pragma aux SDL_Swap32 = \
157
+ "xchg al, ah" \
158
+ "ror eax, 16" \
159
+ "xchg al, ah" \
160
+ parm [eax] \
161
+ modify [eax];
162
+ #endif
163
+ #else
164
+ SDL_FORCE_INLINE Uint32
165
+ SDL_Swap32(Uint32 x)
166
+ {
167
+ return SDL_static_cast(Uint32, ((x << 24) | ((x << 8) & 0x00FF0000) |
168
+ ((x >> 8) & 0x0000FF00) | (x >> 24)));
169
+ }
170
+ #endif
171
+
172
+ #if defined(__GNUC__) && defined(__i386__)
173
+ SDL_FORCE_INLINE Uint64
174
+ SDL_Swap64(Uint64 x)
175
+ {
176
+ union
177
+ {
178
+ struct
179
+ {
180
+ Uint32 a, b;
181
+ } s;
182
+ Uint64 u;
183
+ } v;
184
+ v.u = x;
185
+ __asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1": "=r"(v.s.a), "=r"(v.s.b):"0"(v.s.a),
186
+ "1"(v.s.
187
+ b));
188
+ return v.u;
189
+ }
190
+ #elif defined(__GNUC__) && defined(__x86_64__)
191
+ SDL_FORCE_INLINE Uint64
192
+ SDL_Swap64(Uint64 x)
193
+ {
194
+ __asm__("bswapq %0": "=r"(x):"0"(x));
195
+ return x;
196
+ }
197
+ #else
198
+ SDL_FORCE_INLINE Uint64
199
+ SDL_Swap64(Uint64 x)
200
+ {
201
+ Uint32 hi, lo;
202
+
203
+ /* Separate into high and low 32-bit values and swap them */
204
+ lo = SDL_static_cast(Uint32, x & 0xFFFFFFFF);
205
+ x >>= 32;
206
+ hi = SDL_static_cast(Uint32, x & 0xFFFFFFFF);
207
+ x = SDL_Swap32(lo);
208
+ x <<= 32;
209
+ x |= SDL_Swap32(hi);
210
+ return (x);
211
+ }
212
+ #endif
213
+
214
+
215
+ SDL_FORCE_INLINE float
216
+ SDL_SwapFloat(float x)
217
+ {
218
+ union
219
+ {
220
+ float f;
221
+ Uint32 ui32;
222
+ } swapper;
223
+ swapper.f = x;
224
+ swapper.ui32 = SDL_Swap32(swapper.ui32);
225
+ return swapper.f;
226
+ }
227
+
228
+
229
+ /**
230
+ * \name Swap to native
231
+ * Byteswap item from the specified endianness to the native endianness.
232
+ */
233
+ /* @{ */
234
+ #if SDL_BYTEORDER == SDL_LIL_ENDIAN
235
+ #define SDL_SwapLE16(X) (X)
236
+ #define SDL_SwapLE32(X) (X)
237
+ #define SDL_SwapLE64(X) (X)
238
+ #define SDL_SwapFloatLE(X) (X)
239
+ #define SDL_SwapBE16(X) SDL_Swap16(X)
240
+ #define SDL_SwapBE32(X) SDL_Swap32(X)
241
+ #define SDL_SwapBE64(X) SDL_Swap64(X)
242
+ #define SDL_SwapFloatBE(X) SDL_SwapFloat(X)
243
+ #else
244
+ #define SDL_SwapLE16(X) SDL_Swap16(X)
245
+ #define SDL_SwapLE32(X) SDL_Swap32(X)
246
+ #define SDL_SwapLE64(X) SDL_Swap64(X)
247
+ #define SDL_SwapFloatLE(X) SDL_SwapFloat(X)
248
+ #define SDL_SwapBE16(X) (X)
249
+ #define SDL_SwapBE32(X) (X)
250
+ #define SDL_SwapBE64(X) (X)
251
+ #define SDL_SwapFloatBE(X) (X)
252
+ #endif
253
+ /* @} *//* Swap to native */
254
+
255
+ /* Ends C function definitions when using C++ */
256
+ #ifdef __cplusplus
257
+ }
258
+ #endif
259
+ #include "close_code.h"
260
+
261
+ #endif /* SDL_endian_h_ */
262
+
263
+ /* vi: set ts=4 sw=4 expandtab: */
@@ -0,0 +1,112 @@
1
+ /*
2
+ Simple DirectMedia Layer
3
+ Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
4
+
5
+ This software is provided 'as-is', without any express or implied
6
+ warranty. In no event will the authors be held liable for any damages
7
+ arising from the use of this software.
8
+
9
+ Permission is granted to anyone to use this software for any purpose,
10
+ including commercial applications, and to alter it and redistribute it
11
+ freely, subject to the following restrictions:
12
+
13
+ 1. The origin of this software must not be misrepresented; you must not
14
+ claim that you wrote the original software. If you use this software
15
+ in a product, an acknowledgment in the product documentation would be
16
+ appreciated but is not required.
17
+ 2. Altered source versions must be plainly marked as such, and must not be
18
+ misrepresented as being the original software.
19
+ 3. This notice may not be removed or altered from any source distribution.
20
+ */
21
+
22
+ /**
23
+ * \file SDL_error.h
24
+ *
25
+ * Simple error message routines for SDL.
26
+ */
27
+
28
+ #ifndef SDL_error_h_
29
+ #define SDL_error_h_
30
+
31
+ #include "SDL_stdinc.h"
32
+
33
+ #include "begin_code.h"
34
+ /* Set up for C function definitions, even when using C++ */
35
+ #ifdef __cplusplus
36
+ extern "C" {
37
+ #endif
38
+
39
+ /* Public functions */
40
+
41
+
42
+ /**
43
+ * \brief Set the error message for the current thread
44
+ *
45
+ * \return -1, there is no error handling for this function
46
+ */
47
+ extern DECLSPEC int SDLCALL SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1);
48
+
49
+ /**
50
+ * \brief Get the last error message that was set
51
+ *
52
+ * SDL API functions may set error messages and then succeed, so you should
53
+ * only use the error value if a function fails.
54
+ *
55
+ * This returns a pointer to a static buffer for convenience and should not
56
+ * be called by multiple threads simultaneously.
57
+ *
58
+ * \return a pointer to the last error message that was set
59
+ */
60
+ extern DECLSPEC const char *SDLCALL SDL_GetError(void);
61
+
62
+ /**
63
+ * \brief Get the last error message that was set for the current thread
64
+ *
65
+ * SDL API functions may set error messages and then succeed, so you should
66
+ * only use the error value if a function fails.
67
+ *
68
+ * \param errstr A buffer to fill with the last error message that was set
69
+ * for the current thread
70
+ * \param maxlen The size of the buffer pointed to by the errstr parameter
71
+ *
72
+ * \return errstr
73
+ */
74
+ extern DECLSPEC char * SDLCALL SDL_GetErrorMsg(char *errstr, int maxlen);
75
+
76
+ /**
77
+ * \brief Clear the error message for the current thread
78
+ */
79
+ extern DECLSPEC void SDLCALL SDL_ClearError(void);
80
+
81
+ /**
82
+ * \name Internal error functions
83
+ *
84
+ * \internal
85
+ * Private error reporting function - used internally.
86
+ */
87
+ /* @{ */
88
+ #define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM)
89
+ #define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED)
90
+ #define SDL_InvalidParamError(param) SDL_SetError("Parameter '%s' is invalid", (param))
91
+ typedef enum
92
+ {
93
+ SDL_ENOMEM,
94
+ SDL_EFREAD,
95
+ SDL_EFWRITE,
96
+ SDL_EFSEEK,
97
+ SDL_UNSUPPORTED,
98
+ SDL_LASTERROR
99
+ } SDL_errorcode;
100
+ /* SDL_Error() unconditionally returns -1. */
101
+ extern DECLSPEC int SDLCALL SDL_Error(SDL_errorcode code);
102
+ /* @} *//* Internal error functions */
103
+
104
+ /* Ends C function definitions when using C++ */
105
+ #ifdef __cplusplus
106
+ }
107
+ #endif
108
+ #include "close_code.h"
109
+
110
+ #endif /* SDL_error_h_ */
111
+
112
+ /* vi: set ts=4 sw=4 expandtab: */
@@ -0,0 +1,827 @@
1
+ /*
2
+ Simple DirectMedia Layer
3
+ Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
4
+
5
+ This software is provided 'as-is', without any express or implied
6
+ warranty. In no event will the authors be held liable for any damages
7
+ arising from the use of this software.
8
+
9
+ Permission is granted to anyone to use this software for any purpose,
10
+ including commercial applications, and to alter it and redistribute it
11
+ freely, subject to the following restrictions:
12
+
13
+ 1. The origin of this software must not be misrepresented; you must not
14
+ claim that you wrote the original software. If you use this software
15
+ in a product, an acknowledgment in the product documentation would be
16
+ appreciated but is not required.
17
+ 2. Altered source versions must be plainly marked as such, and must not be
18
+ misrepresented as being the original software.
19
+ 3. This notice may not be removed or altered from any source distribution.
20
+ */
21
+
22
+ /**
23
+ * \file SDL_events.h
24
+ *
25
+ * Include file for SDL event handling.
26
+ */
27
+
28
+ #ifndef SDL_events_h_
29
+ #define SDL_events_h_
30
+
31
+ #include "SDL_stdinc.h"
32
+ #include "SDL_error.h"
33
+ #include "SDL_video.h"
34
+ #include "SDL_keyboard.h"
35
+ #include "SDL_mouse.h"
36
+ #include "SDL_joystick.h"
37
+ #include "SDL_gamecontroller.h"
38
+ #include "SDL_quit.h"
39
+ #include "SDL_gesture.h"
40
+ #include "SDL_touch.h"
41
+
42
+ #include "begin_code.h"
43
+ /* Set up for C function definitions, even when using C++ */
44
+ #ifdef __cplusplus
45
+ extern "C" {
46
+ #endif
47
+
48
+ /* General keyboard/mouse state definitions */
49
+ #define SDL_RELEASED 0
50
+ #define SDL_PRESSED 1
51
+
52
+ /**
53
+ * \brief The types of events that can be delivered.
54
+ */
55
+ typedef enum
56
+ {
57
+ SDL_FIRSTEVENT = 0, /**< Unused (do not remove) */
58
+
59
+ /* Application events */
60
+ SDL_QUIT = 0x100, /**< User-requested quit */
61
+
62
+ /* These application events have special meaning on iOS, see README-ios.md for details */
63
+ SDL_APP_TERMINATING, /**< The application is being terminated by the OS
64
+ Called on iOS in applicationWillTerminate()
65
+ Called on Android in onDestroy()
66
+ */
67
+ SDL_APP_LOWMEMORY, /**< The application is low on memory, free memory if possible.
68
+ Called on iOS in applicationDidReceiveMemoryWarning()
69
+ Called on Android in onLowMemory()
70
+ */
71
+ SDL_APP_WILLENTERBACKGROUND, /**< The application is about to enter the background
72
+ Called on iOS in applicationWillResignActive()
73
+ Called on Android in onPause()
74
+ */
75
+ SDL_APP_DIDENTERBACKGROUND, /**< The application did enter the background and may not get CPU for some time
76
+ Called on iOS in applicationDidEnterBackground()
77
+ Called on Android in onPause()
78
+ */
79
+ SDL_APP_WILLENTERFOREGROUND, /**< The application is about to enter the foreground
80
+ Called on iOS in applicationWillEnterForeground()
81
+ Called on Android in onResume()
82
+ */
83
+ SDL_APP_DIDENTERFOREGROUND, /**< The application is now interactive
84
+ Called on iOS in applicationDidBecomeActive()
85
+ Called on Android in onResume()
86
+ */
87
+
88
+ SDL_LOCALECHANGED, /**< The user's locale preferences have changed. */
89
+
90
+ /* Display events */
91
+ SDL_DISPLAYEVENT = 0x150, /**< Display state change */
92
+
93
+ /* Window events */
94
+ SDL_WINDOWEVENT = 0x200, /**< Window state change */
95
+ SDL_SYSWMEVENT, /**< System specific event */
96
+
97
+ /* Keyboard events */
98
+ SDL_KEYDOWN = 0x300, /**< Key pressed */
99
+ SDL_KEYUP, /**< Key released */
100
+ SDL_TEXTEDITING, /**< Keyboard text editing (composition) */
101
+ SDL_TEXTINPUT, /**< Keyboard text input */
102
+ SDL_KEYMAPCHANGED, /**< Keymap changed due to a system event such as an
103
+ input language or keyboard layout change.
104
+ */
105
+
106
+ /* Mouse events */
107
+ SDL_MOUSEMOTION = 0x400, /**< Mouse moved */
108
+ SDL_MOUSEBUTTONDOWN, /**< Mouse button pressed */
109
+ SDL_MOUSEBUTTONUP, /**< Mouse button released */
110
+ SDL_MOUSEWHEEL, /**< Mouse wheel motion */
111
+
112
+ /* Joystick events */
113
+ SDL_JOYAXISMOTION = 0x600, /**< Joystick axis motion */
114
+ SDL_JOYBALLMOTION, /**< Joystick trackball motion */
115
+ SDL_JOYHATMOTION, /**< Joystick hat position change */
116
+ SDL_JOYBUTTONDOWN, /**< Joystick button pressed */
117
+ SDL_JOYBUTTONUP, /**< Joystick button released */
118
+ SDL_JOYDEVICEADDED, /**< A new joystick has been inserted into the system */
119
+ SDL_JOYDEVICEREMOVED, /**< An opened joystick has been removed */
120
+
121
+ /* Game controller events */
122
+ SDL_CONTROLLERAXISMOTION = 0x650, /**< Game controller axis motion */
123
+ SDL_CONTROLLERBUTTONDOWN, /**< Game controller button pressed */
124
+ SDL_CONTROLLERBUTTONUP, /**< Game controller button released */
125
+ SDL_CONTROLLERDEVICEADDED, /**< A new Game controller has been inserted into the system */
126
+ SDL_CONTROLLERDEVICEREMOVED, /**< An opened Game controller has been removed */
127
+ SDL_CONTROLLERDEVICEREMAPPED, /**< The controller mapping was updated */
128
+ SDL_CONTROLLERTOUCHPADDOWN, /**< Game controller touchpad was touched */
129
+ SDL_CONTROLLERTOUCHPADMOTION, /**< Game controller touchpad finger was moved */
130
+ SDL_CONTROLLERTOUCHPADUP, /**< Game controller touchpad finger was lifted */
131
+ SDL_CONTROLLERSENSORUPDATE, /**< Game controller sensor was updated */
132
+
133
+ /* Touch events */
134
+ SDL_FINGERDOWN = 0x700,
135
+ SDL_FINGERUP,
136
+ SDL_FINGERMOTION,
137
+
138
+ /* Gesture events */
139
+ SDL_DOLLARGESTURE = 0x800,
140
+ SDL_DOLLARRECORD,
141
+ SDL_MULTIGESTURE,
142
+
143
+ /* Clipboard events */
144
+ SDL_CLIPBOARDUPDATE = 0x900, /**< The clipboard changed */
145
+
146
+ /* Drag and drop events */
147
+ SDL_DROPFILE = 0x1000, /**< The system requests a file open */
148
+ SDL_DROPTEXT, /**< text/plain drag-and-drop event */
149
+ SDL_DROPBEGIN, /**< A new set of drops is beginning (NULL filename) */
150
+ SDL_DROPCOMPLETE, /**< Current set of drops is now complete (NULL filename) */
151
+
152
+ /* Audio hotplug events */
153
+ SDL_AUDIODEVICEADDED = 0x1100, /**< A new audio device is available */
154
+ SDL_AUDIODEVICEREMOVED, /**< An audio device has been removed. */
155
+
156
+ /* Sensor events */
157
+ SDL_SENSORUPDATE = 0x1200, /**< A sensor was updated */
158
+
159
+ /* Render events */
160
+ SDL_RENDER_TARGETS_RESET = 0x2000, /**< The render targets have been reset and their contents need to be updated */
161
+ SDL_RENDER_DEVICE_RESET, /**< The device has been reset and all textures need to be recreated */
162
+
163
+ /** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use,
164
+ * and should be allocated with SDL_RegisterEvents()
165
+ */
166
+ SDL_USEREVENT = 0x8000,
167
+
168
+ /**
169
+ * This last event is only for bounding internal arrays
170
+ */
171
+ SDL_LASTEVENT = 0xFFFF
172
+ } SDL_EventType;
173
+
174
+ /**
175
+ * \brief Fields shared by every event
176
+ */
177
+ typedef struct SDL_CommonEvent
178
+ {
179
+ Uint32 type;
180
+ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
181
+ } SDL_CommonEvent;
182
+
183
+ /**
184
+ * \brief Display state change event data (event.display.*)
185
+ */
186
+ typedef struct SDL_DisplayEvent
187
+ {
188
+ Uint32 type; /**< ::SDL_DISPLAYEVENT */
189
+ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
190
+ Uint32 display; /**< The associated display index */
191
+ Uint8 event; /**< ::SDL_DisplayEventID */
192
+ Uint8 padding1;
193
+ Uint8 padding2;
194
+ Uint8 padding3;
195
+ Sint32 data1; /**< event dependent data */
196
+ } SDL_DisplayEvent;
197
+
198
+ /**
199
+ * \brief Window state change event data (event.window.*)
200
+ */
201
+ typedef struct SDL_WindowEvent
202
+ {
203
+ Uint32 type; /**< ::SDL_WINDOWEVENT */
204
+ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
205
+ Uint32 windowID; /**< The associated window */
206
+ Uint8 event; /**< ::SDL_WindowEventID */
207
+ Uint8 padding1;
208
+ Uint8 padding2;
209
+ Uint8 padding3;
210
+ Sint32 data1; /**< event dependent data */
211
+ Sint32 data2; /**< event dependent data */
212
+ } SDL_WindowEvent;
213
+
214
+ /**
215
+ * \brief Keyboard button event structure (event.key.*)
216
+ */
217
+ typedef struct SDL_KeyboardEvent
218
+ {
219
+ Uint32 type; /**< ::SDL_KEYDOWN or ::SDL_KEYUP */
220
+ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
221
+ Uint32 windowID; /**< The window with keyboard focus, if any */
222
+ Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
223
+ Uint8 repeat; /**< Non-zero if this is a key repeat */
224
+ Uint8 padding2;
225
+ Uint8 padding3;
226
+ SDL_Keysym keysym; /**< The key that was pressed or released */
227
+ } SDL_KeyboardEvent;
228
+
229
+ #define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32)
230
+ /**
231
+ * \brief Keyboard text editing event structure (event.edit.*)
232
+ */
233
+ typedef struct SDL_TextEditingEvent
234
+ {
235
+ Uint32 type; /**< ::SDL_TEXTEDITING */
236
+ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
237
+ Uint32 windowID; /**< The window with keyboard focus, if any */
238
+ char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; /**< The editing text */
239
+ Sint32 start; /**< The start cursor of selected editing text */
240
+ Sint32 length; /**< The length of selected editing text */
241
+ } SDL_TextEditingEvent;
242
+
243
+
244
+ #define SDL_TEXTINPUTEVENT_TEXT_SIZE (32)
245
+ /**
246
+ * \brief Keyboard text input event structure (event.text.*)
247
+ */
248
+ typedef struct SDL_TextInputEvent
249
+ {
250
+ Uint32 type; /**< ::SDL_TEXTINPUT */
251
+ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
252
+ Uint32 windowID; /**< The window with keyboard focus, if any */
253
+ char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; /**< The input text */
254
+ } SDL_TextInputEvent;
255
+
256
+ /**
257
+ * \brief Mouse motion event structure (event.motion.*)
258
+ */
259
+ typedef struct SDL_MouseMotionEvent
260
+ {
261
+ Uint32 type; /**< ::SDL_MOUSEMOTION */
262
+ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
263
+ Uint32 windowID; /**< The window with mouse focus, if any */
264
+ Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
265
+ Uint32 state; /**< The current button state */
266
+ Sint32 x; /**< X coordinate, relative to window */
267
+ Sint32 y; /**< Y coordinate, relative to window */
268
+ Sint32 xrel; /**< The relative motion in the X direction */
269
+ Sint32 yrel; /**< The relative motion in the Y direction */
270
+ } SDL_MouseMotionEvent;
271
+
272
+ /**
273
+ * \brief Mouse button event structure (event.button.*)
274
+ */
275
+ typedef struct SDL_MouseButtonEvent
276
+ {
277
+ Uint32 type; /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */
278
+ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
279
+ Uint32 windowID; /**< The window with mouse focus, if any */
280
+ Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
281
+ Uint8 button; /**< The mouse button index */
282
+ Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
283
+ Uint8 clicks; /**< 1 for single-click, 2 for double-click, etc. */
284
+ Uint8 padding1;
285
+ Sint32 x; /**< X coordinate, relative to window */
286
+ Sint32 y; /**< Y coordinate, relative to window */
287
+ } SDL_MouseButtonEvent;
288
+
289
+ /**
290
+ * \brief Mouse wheel event structure (event.wheel.*)
291
+ */
292
+ typedef struct SDL_MouseWheelEvent
293
+ {
294
+ Uint32 type; /**< ::SDL_MOUSEWHEEL */
295
+ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
296
+ Uint32 windowID; /**< The window with mouse focus, if any */
297
+ Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
298
+ Sint32 x; /**< The amount scrolled horizontally, positive to the right and negative to the left */
299
+ Sint32 y; /**< The amount scrolled vertically, positive away from the user and negative toward the user */
300
+ Uint32 direction; /**< Set to one of the SDL_MOUSEWHEEL_* defines. When FLIPPED the values in X and Y will be opposite. Multiply by -1 to change them back */
301
+ } SDL_MouseWheelEvent;
302
+
303
+ /**
304
+ * \brief Joystick axis motion event structure (event.jaxis.*)
305
+ */
306
+ typedef struct SDL_JoyAxisEvent
307
+ {
308
+ Uint32 type; /**< ::SDL_JOYAXISMOTION */
309
+ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
310
+ SDL_JoystickID which; /**< The joystick instance id */
311
+ Uint8 axis; /**< The joystick axis index */
312
+ Uint8 padding1;
313
+ Uint8 padding2;
314
+ Uint8 padding3;
315
+ Sint16 value; /**< The axis value (range: -32768 to 32767) */
316
+ Uint16 padding4;
317
+ } SDL_JoyAxisEvent;
318
+
319
+ /**
320
+ * \brief Joystick trackball motion event structure (event.jball.*)
321
+ */
322
+ typedef struct SDL_JoyBallEvent
323
+ {
324
+ Uint32 type; /**< ::SDL_JOYBALLMOTION */
325
+ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
326
+ SDL_JoystickID which; /**< The joystick instance id */
327
+ Uint8 ball; /**< The joystick trackball index */
328
+ Uint8 padding1;
329
+ Uint8 padding2;
330
+ Uint8 padding3;
331
+ Sint16 xrel; /**< The relative motion in the X direction */
332
+ Sint16 yrel; /**< The relative motion in the Y direction */
333
+ } SDL_JoyBallEvent;
334
+
335
+ /**
336
+ * \brief Joystick hat position change event structure (event.jhat.*)
337
+ */
338
+ typedef struct SDL_JoyHatEvent
339
+ {
340
+ Uint32 type; /**< ::SDL_JOYHATMOTION */
341
+ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
342
+ SDL_JoystickID which; /**< The joystick instance id */
343
+ Uint8 hat; /**< The joystick hat index */
344
+ Uint8 value; /**< The hat position value.
345
+ * \sa ::SDL_HAT_LEFTUP ::SDL_HAT_UP ::SDL_HAT_RIGHTUP
346
+ * \sa ::SDL_HAT_LEFT ::SDL_HAT_CENTERED ::SDL_HAT_RIGHT
347
+ * \sa ::SDL_HAT_LEFTDOWN ::SDL_HAT_DOWN ::SDL_HAT_RIGHTDOWN
348
+ *
349
+ * Note that zero means the POV is centered.
350
+ */
351
+ Uint8 padding1;
352
+ Uint8 padding2;
353
+ } SDL_JoyHatEvent;
354
+
355
+ /**
356
+ * \brief Joystick button event structure (event.jbutton.*)
357
+ */
358
+ typedef struct SDL_JoyButtonEvent
359
+ {
360
+ Uint32 type; /**< ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP */
361
+ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
362
+ SDL_JoystickID which; /**< The joystick instance id */
363
+ Uint8 button; /**< The joystick button index */
364
+ Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
365
+ Uint8 padding1;
366
+ Uint8 padding2;
367
+ } SDL_JoyButtonEvent;
368
+
369
+ /**
370
+ * \brief Joystick device event structure (event.jdevice.*)
371
+ */
372
+ typedef struct SDL_JoyDeviceEvent
373
+ {
374
+ Uint32 type; /**< ::SDL_JOYDEVICEADDED or ::SDL_JOYDEVICEREMOVED */
375
+ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
376
+ Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED event */
377
+ } SDL_JoyDeviceEvent;
378
+
379
+
380
+ /**
381
+ * \brief Game controller axis motion event structure (event.caxis.*)
382
+ */
383
+ typedef struct SDL_ControllerAxisEvent
384
+ {
385
+ Uint32 type; /**< ::SDL_CONTROLLERAXISMOTION */
386
+ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
387
+ SDL_JoystickID which; /**< The joystick instance id */
388
+ Uint8 axis; /**< The controller axis (SDL_GameControllerAxis) */
389
+ Uint8 padding1;
390
+ Uint8 padding2;
391
+ Uint8 padding3;
392
+ Sint16 value; /**< The axis value (range: -32768 to 32767) */
393
+ Uint16 padding4;
394
+ } SDL_ControllerAxisEvent;
395
+
396
+
397
+ /**
398
+ * \brief Game controller button event structure (event.cbutton.*)
399
+ */
400
+ typedef struct SDL_ControllerButtonEvent
401
+ {
402
+ Uint32 type; /**< ::SDL_CONTROLLERBUTTONDOWN or ::SDL_CONTROLLERBUTTONUP */
403
+ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
404
+ SDL_JoystickID which; /**< The joystick instance id */
405
+ Uint8 button; /**< The controller button (SDL_GameControllerButton) */
406
+ Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
407
+ Uint8 padding1;
408
+ Uint8 padding2;
409
+ } SDL_ControllerButtonEvent;
410
+
411
+
412
+ /**
413
+ * \brief Controller device event structure (event.cdevice.*)
414
+ */
415
+ typedef struct SDL_ControllerDeviceEvent
416
+ {
417
+ Uint32 type; /**< ::SDL_CONTROLLERDEVICEADDED, ::SDL_CONTROLLERDEVICEREMOVED, or ::SDL_CONTROLLERDEVICEREMAPPED */
418
+ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
419
+ Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED or REMAPPED event */
420
+ } SDL_ControllerDeviceEvent;
421
+
422
+ /**
423
+ * \brief Game controller touchpad event structure (event.ctouchpad.*)
424
+ */
425
+ typedef struct SDL_ControllerTouchpadEvent
426
+ {
427
+ Uint32 type; /**< ::SDL_CONTROLLERTOUCHPADDOWN or ::SDL_CONTROLLERTOUCHPADMOTION or ::SDL_CONTROLLERTOUCHPADUP */
428
+ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
429
+ SDL_JoystickID which; /**< The joystick instance id */
430
+ Sint32 touchpad; /**< The index of the touchpad */
431
+ Sint32 finger; /**< The index of the finger on the touchpad */
432
+ float x; /**< Normalized in the range 0...1 with 0 being on the left */
433
+ float y; /**< Normalized in the range 0...1 with 0 being at the top */
434
+ float pressure; /**< Normalized in the range 0...1 */
435
+ } SDL_ControllerTouchpadEvent;
436
+
437
+ /**
438
+ * \brief Game controller sensor event structure (event.csensor.*)
439
+ */
440
+ typedef struct SDL_ControllerSensorEvent
441
+ {
442
+ Uint32 type; /**< ::SDL_CONTROLLERSENSORUPDATE */
443
+ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
444
+ SDL_JoystickID which; /**< The joystick instance id */
445
+ Sint32 sensor; /**< The type of the sensor, one of the values of ::SDL_SensorType */
446
+ float data[3]; /**< Up to 3 values from the sensor, as defined in SDL_sensor.h */
447
+ } SDL_ControllerSensorEvent;
448
+
449
+ /**
450
+ * \brief Audio device event structure (event.adevice.*)
451
+ */
452
+ typedef struct SDL_AudioDeviceEvent
453
+ {
454
+ Uint32 type; /**< ::SDL_AUDIODEVICEADDED, or ::SDL_AUDIODEVICEREMOVED */
455
+ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
456
+ Uint32 which; /**< The audio device index for the ADDED event (valid until next SDL_GetNumAudioDevices() call), SDL_AudioDeviceID for the REMOVED event */
457
+ Uint8 iscapture; /**< zero if an output device, non-zero if a capture device. */
458
+ Uint8 padding1;
459
+ Uint8 padding2;
460
+ Uint8 padding3;
461
+ } SDL_AudioDeviceEvent;
462
+
463
+
464
+ /**
465
+ * \brief Touch finger event structure (event.tfinger.*)
466
+ */
467
+ typedef struct SDL_TouchFingerEvent
468
+ {
469
+ Uint32 type; /**< ::SDL_FINGERMOTION or ::SDL_FINGERDOWN or ::SDL_FINGERUP */
470
+ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
471
+ SDL_TouchID touchId; /**< The touch device id */
472
+ SDL_FingerID fingerId;
473
+ float x; /**< Normalized in the range 0...1 */
474
+ float y; /**< Normalized in the range 0...1 */
475
+ float dx; /**< Normalized in the range -1...1 */
476
+ float dy; /**< Normalized in the range -1...1 */
477
+ float pressure; /**< Normalized in the range 0...1 */
478
+ Uint32 windowID; /**< The window underneath the finger, if any */
479
+ } SDL_TouchFingerEvent;
480
+
481
+
482
+ /**
483
+ * \brief Multiple Finger Gesture Event (event.mgesture.*)
484
+ */
485
+ typedef struct SDL_MultiGestureEvent
486
+ {
487
+ Uint32 type; /**< ::SDL_MULTIGESTURE */
488
+ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
489
+ SDL_TouchID touchId; /**< The touch device id */
490
+ float dTheta;
491
+ float dDist;
492
+ float x;
493
+ float y;
494
+ Uint16 numFingers;
495
+ Uint16 padding;
496
+ } SDL_MultiGestureEvent;
497
+
498
+
499
+ /**
500
+ * \brief Dollar Gesture Event (event.dgesture.*)
501
+ */
502
+ typedef struct SDL_DollarGestureEvent
503
+ {
504
+ Uint32 type; /**< ::SDL_DOLLARGESTURE or ::SDL_DOLLARRECORD */
505
+ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
506
+ SDL_TouchID touchId; /**< The touch device id */
507
+ SDL_GestureID gestureId;
508
+ Uint32 numFingers;
509
+ float error;
510
+ float x; /**< Normalized center of gesture */
511
+ float y; /**< Normalized center of gesture */
512
+ } SDL_DollarGestureEvent;
513
+
514
+
515
+ /**
516
+ * \brief An event used to request a file open by the system (event.drop.*)
517
+ * This event is enabled by default, you can disable it with SDL_EventState().
518
+ * \note If this event is enabled, you must free the filename in the event.
519
+ */
520
+ typedef struct SDL_DropEvent
521
+ {
522
+ Uint32 type; /**< ::SDL_DROPBEGIN or ::SDL_DROPFILE or ::SDL_DROPTEXT or ::SDL_DROPCOMPLETE */
523
+ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
524
+ char *file; /**< The file name, which should be freed with SDL_free(), is NULL on begin/complete */
525
+ Uint32 windowID; /**< The window that was dropped on, if any */
526
+ } SDL_DropEvent;
527
+
528
+
529
+ /**
530
+ * \brief Sensor event structure (event.sensor.*)
531
+ */
532
+ typedef struct SDL_SensorEvent
533
+ {
534
+ Uint32 type; /**< ::SDL_SENSORUPDATE */
535
+ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
536
+ Sint32 which; /**< The instance ID of the sensor */
537
+ float data[6]; /**< Up to 6 values from the sensor - additional values can be queried using SDL_SensorGetData() */
538
+ } SDL_SensorEvent;
539
+
540
+ /**
541
+ * \brief The "quit requested" event
542
+ */
543
+ typedef struct SDL_QuitEvent
544
+ {
545
+ Uint32 type; /**< ::SDL_QUIT */
546
+ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
547
+ } SDL_QuitEvent;
548
+
549
+ /**
550
+ * \brief OS Specific event
551
+ */
552
+ typedef struct SDL_OSEvent
553
+ {
554
+ Uint32 type; /**< ::SDL_QUIT */
555
+ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
556
+ } SDL_OSEvent;
557
+
558
+ /**
559
+ * \brief A user-defined event type (event.user.*)
560
+ */
561
+ typedef struct SDL_UserEvent
562
+ {
563
+ Uint32 type; /**< ::SDL_USEREVENT through ::SDL_LASTEVENT-1 */
564
+ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
565
+ Uint32 windowID; /**< The associated window if any */
566
+ Sint32 code; /**< User defined event code */
567
+ void *data1; /**< User defined data pointer */
568
+ void *data2; /**< User defined data pointer */
569
+ } SDL_UserEvent;
570
+
571
+
572
+ struct SDL_SysWMmsg;
573
+ typedef struct SDL_SysWMmsg SDL_SysWMmsg;
574
+
575
+ /**
576
+ * \brief A video driver dependent system event (event.syswm.*)
577
+ * This event is disabled by default, you can enable it with SDL_EventState()
578
+ *
579
+ * \note If you want to use this event, you should include SDL_syswm.h.
580
+ */
581
+ typedef struct SDL_SysWMEvent
582
+ {
583
+ Uint32 type; /**< ::SDL_SYSWMEVENT */
584
+ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
585
+ SDL_SysWMmsg *msg; /**< driver dependent data, defined in SDL_syswm.h */
586
+ } SDL_SysWMEvent;
587
+
588
+ /**
589
+ * \brief General event structure
590
+ */
591
+ typedef union SDL_Event
592
+ {
593
+ Uint32 type; /**< Event type, shared with all events */
594
+ SDL_CommonEvent common; /**< Common event data */
595
+ SDL_DisplayEvent display; /**< Display event data */
596
+ SDL_WindowEvent window; /**< Window event data */
597
+ SDL_KeyboardEvent key; /**< Keyboard event data */
598
+ SDL_TextEditingEvent edit; /**< Text editing event data */
599
+ SDL_TextInputEvent text; /**< Text input event data */
600
+ SDL_MouseMotionEvent motion; /**< Mouse motion event data */
601
+ SDL_MouseButtonEvent button; /**< Mouse button event data */
602
+ SDL_MouseWheelEvent wheel; /**< Mouse wheel event data */
603
+ SDL_JoyAxisEvent jaxis; /**< Joystick axis event data */
604
+ SDL_JoyBallEvent jball; /**< Joystick ball event data */
605
+ SDL_JoyHatEvent jhat; /**< Joystick hat event data */
606
+ SDL_JoyButtonEvent jbutton; /**< Joystick button event data */
607
+ SDL_JoyDeviceEvent jdevice; /**< Joystick device change event data */
608
+ SDL_ControllerAxisEvent caxis; /**< Game Controller axis event data */
609
+ SDL_ControllerButtonEvent cbutton; /**< Game Controller button event data */
610
+ SDL_ControllerDeviceEvent cdevice; /**< Game Controller device event data */
611
+ SDL_ControllerTouchpadEvent ctouchpad; /**< Game Controller touchpad event data */
612
+ SDL_ControllerSensorEvent csensor; /**< Game Controller sensor event data */
613
+ SDL_AudioDeviceEvent adevice; /**< Audio device event data */
614
+ SDL_SensorEvent sensor; /**< Sensor event data */
615
+ SDL_QuitEvent quit; /**< Quit request event data */
616
+ SDL_UserEvent user; /**< Custom event data */
617
+ SDL_SysWMEvent syswm; /**< System dependent window event data */
618
+ SDL_TouchFingerEvent tfinger; /**< Touch finger event data */
619
+ SDL_MultiGestureEvent mgesture; /**< Gesture event data */
620
+ SDL_DollarGestureEvent dgesture; /**< Gesture event data */
621
+ SDL_DropEvent drop; /**< Drag and drop event data */
622
+
623
+ /* This is necessary for ABI compatibility between Visual C++ and GCC
624
+ Visual C++ will respect the push pack pragma and use 52 bytes for
625
+ this structure, and GCC will use the alignment of the largest datatype
626
+ within the union, which is 8 bytes.
627
+
628
+ So... we'll add padding to force the size to be 56 bytes for both.
629
+ */
630
+ Uint8 padding[56];
631
+ } SDL_Event;
632
+
633
+ /* Make sure we haven't broken binary compatibility */
634
+ SDL_COMPILE_TIME_ASSERT(SDL_Event, sizeof(SDL_Event) == 56);
635
+
636
+
637
+ /* Function prototypes */
638
+
639
+ /**
640
+ * Pumps the event loop, gathering events from the input devices.
641
+ *
642
+ * This function updates the event queue and internal input device state.
643
+ *
644
+ * This should only be run in the thread that sets the video mode.
645
+ */
646
+ extern DECLSPEC void SDLCALL SDL_PumpEvents(void);
647
+
648
+ /* @{ */
649
+ typedef enum
650
+ {
651
+ SDL_ADDEVENT,
652
+ SDL_PEEKEVENT,
653
+ SDL_GETEVENT
654
+ } SDL_eventaction;
655
+
656
+ /**
657
+ * Checks the event queue for messages and optionally returns them.
658
+ *
659
+ * If \c action is ::SDL_ADDEVENT, up to \c numevents events will be added to
660
+ * the back of the event queue.
661
+ *
662
+ * If \c action is ::SDL_PEEKEVENT, up to \c numevents events at the front
663
+ * of the event queue, within the specified minimum and maximum type,
664
+ * will be returned and will not be removed from the queue.
665
+ *
666
+ * If \c action is ::SDL_GETEVENT, up to \c numevents events at the front
667
+ * of the event queue, within the specified minimum and maximum type,
668
+ * will be returned and will be removed from the queue.
669
+ *
670
+ * \return The number of events actually stored, or -1 if there was an error.
671
+ *
672
+ * This function is thread-safe.
673
+ */
674
+ extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents,
675
+ SDL_eventaction action,
676
+ Uint32 minType, Uint32 maxType);
677
+ /* @} */
678
+
679
+ /**
680
+ * Checks to see if certain event types are in the event queue.
681
+ */
682
+ extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 type);
683
+ extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType);
684
+
685
+ /**
686
+ * This function clears events from the event queue
687
+ * This function only affects currently queued events. If you want to make
688
+ * sure that all pending OS events are flushed, you can call SDL_PumpEvents()
689
+ * on the main thread immediately before the flush call.
690
+ */
691
+ extern DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type);
692
+ extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType);
693
+
694
+ /**
695
+ * \brief Polls for currently pending events.
696
+ *
697
+ * \return 1 if there are any pending events, or 0 if there are none available.
698
+ *
699
+ * \param event If not NULL, the next event is removed from the queue and
700
+ * stored in that area.
701
+ */
702
+ extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event * event);
703
+
704
+ /**
705
+ * \brief Waits indefinitely for the next available event.
706
+ *
707
+ * \return 1, or 0 if there was an error while waiting for events.
708
+ *
709
+ * \param event If not NULL, the next event is removed from the queue and
710
+ * stored in that area.
711
+ */
712
+ extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event * event);
713
+
714
+ /**
715
+ * \brief Waits until the specified timeout (in milliseconds) for the next
716
+ * available event.
717
+ *
718
+ * \return 1, or 0 if there was an error while waiting for events.
719
+ *
720
+ * \param event If not NULL, the next event is removed from the queue and
721
+ * stored in that area.
722
+ * \param timeout The timeout (in milliseconds) to wait for next event.
723
+ */
724
+ extern DECLSPEC int SDLCALL SDL_WaitEventTimeout(SDL_Event * event,
725
+ int timeout);
726
+
727
+ /**
728
+ * \brief Add an event to the event queue.
729
+ *
730
+ * \return 1 on success, 0 if the event was filtered, or -1 if the event queue
731
+ * was full or there was some other error.
732
+ */
733
+ extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event * event);
734
+
735
+ typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event);
736
+
737
+ /**
738
+ * Sets up a filter to process all events before they change internal state and
739
+ * are posted to the internal event queue.
740
+ *
741
+ * The filter is prototyped as:
742
+ * \code
743
+ * int SDL_EventFilter(void *userdata, SDL_Event * event);
744
+ * \endcode
745
+ *
746
+ * If the filter returns 1, then the event will be added to the internal queue.
747
+ * If it returns 0, then the event will be dropped from the queue, but the
748
+ * internal state will still be updated. This allows selective filtering of
749
+ * dynamically arriving events.
750
+ *
751
+ * \warning Be very careful of what you do in the event filter function, as
752
+ * it may run in a different thread!
753
+ *
754
+ * There is one caveat when dealing with the ::SDL_QuitEvent event type. The
755
+ * event filter is only called when the window manager desires to close the
756
+ * application window. If the event filter returns 1, then the window will
757
+ * be closed, otherwise the window will remain open if possible.
758
+ *
759
+ * If the quit event is generated by an interrupt signal, it will bypass the
760
+ * internal queue and be delivered to the application at the next event poll.
761
+ */
762
+ extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter,
763
+ void *userdata);
764
+
765
+ /**
766
+ * Return the current event filter - can be used to "chain" filters.
767
+ * If there is no event filter set, this function returns SDL_FALSE.
768
+ */
769
+ extern DECLSPEC SDL_bool SDLCALL SDL_GetEventFilter(SDL_EventFilter * filter,
770
+ void **userdata);
771
+
772
+ /**
773
+ * Add a function which is called when an event is added to the queue.
774
+ */
775
+ extern DECLSPEC void SDLCALL SDL_AddEventWatch(SDL_EventFilter filter,
776
+ void *userdata);
777
+
778
+ /**
779
+ * Remove an event watch function added with SDL_AddEventWatch()
780
+ */
781
+ extern DECLSPEC void SDLCALL SDL_DelEventWatch(SDL_EventFilter filter,
782
+ void *userdata);
783
+
784
+ /**
785
+ * Run the filter function on the current event queue, removing any
786
+ * events for which the filter returns 0.
787
+ */
788
+ extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter,
789
+ void *userdata);
790
+
791
+ /* @{ */
792
+ #define SDL_QUERY -1
793
+ #define SDL_IGNORE 0
794
+ #define SDL_DISABLE 0
795
+ #define SDL_ENABLE 1
796
+
797
+ /**
798
+ * This function allows you to set the state of processing certain events.
799
+ * - If \c state is set to ::SDL_IGNORE, that event will be automatically
800
+ * dropped from the event queue and will not be filtered.
801
+ * - If \c state is set to ::SDL_ENABLE, that event will be processed
802
+ * normally.
803
+ * - If \c state is set to ::SDL_QUERY, SDL_EventState() will return the
804
+ * current processing state of the specified event.
805
+ */
806
+ extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state);
807
+ /* @} */
808
+ #define SDL_GetEventState(type) SDL_EventState(type, SDL_QUERY)
809
+
810
+ /**
811
+ * This function allocates a set of user-defined events, and returns
812
+ * the beginning event number for that set of events.
813
+ *
814
+ * If there aren't enough user-defined events left, this function
815
+ * returns (Uint32)-1
816
+ */
817
+ extern DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents);
818
+
819
+ /* Ends C function definitions when using C++ */
820
+ #ifdef __cplusplus
821
+ }
822
+ #endif
823
+ #include "close_code.h"
824
+
825
+ #endif /* SDL_events_h_ */
826
+
827
+ /* vi: set ts=4 sw=4 expandtab: */