sdl2-bindings 0.0.4 → 0.0.5

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 (47) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +79 -69
  3. data/LICENSE.txt +0 -0
  4. data/README.md +49 -47
  5. data/lib/sdl2.rb +170 -170
  6. data/lib/sdl2_audio.rb +201 -200
  7. data/lib/sdl2_blendmode.rb +69 -69
  8. data/lib/sdl2_clipboard.rb +51 -51
  9. data/lib/sdl2_cpuinfo.rb +106 -103
  10. data/lib/sdl2_error.rb +64 -61
  11. data/lib/sdl2_events.rb +530 -500
  12. data/lib/sdl2_filesystem.rb +48 -48
  13. data/lib/sdl2_framerate.rb +67 -67
  14. data/lib/sdl2_gamecontroller.rb +254 -207
  15. data/lib/sdl2_gesture.rb +55 -55
  16. data/lib/sdl2_gfxPrimitives.rb +222 -222
  17. data/lib/sdl2_haptic.rb +269 -268
  18. data/lib/sdl2_hints.rb +174 -159
  19. data/lib/sdl2_image.rb +185 -185
  20. data/lib/sdl2_imageFilter.rb +132 -132
  21. data/lib/sdl2_joystick.rb +230 -199
  22. data/lib/sdl2_keyboard.rb +99 -99
  23. data/lib/sdl2_keycode.rb +304 -300
  24. data/lib/sdl2_log.rb +115 -115
  25. data/lib/sdl2_main.rb +67 -67
  26. data/lib/sdl2_messagebox.rb +98 -98
  27. data/lib/sdl2_mixer.rb +307 -307
  28. data/lib/sdl2_mouse.rb +117 -117
  29. data/lib/sdl2_pixels.rb +224 -218
  30. data/lib/sdl2_platform.rb +45 -45
  31. data/lib/sdl2_power.rb +51 -51
  32. data/lib/sdl2_rect.rb +102 -102
  33. data/lib/sdl2_render.rb +290 -290
  34. data/lib/sdl2_rotozoom.rb +66 -66
  35. data/lib/sdl2_rwops.rb +208 -208
  36. data/lib/sdl2_scancode.rb +287 -287
  37. data/lib/sdl2_shape.rb +77 -77
  38. data/lib/sdl2_stdinc.rb +393 -370
  39. data/lib/sdl2_surface.rb +182 -179
  40. data/lib/sdl2_syswm.rb +154 -154
  41. data/lib/sdl2_timer.rb +62 -62
  42. data/lib/sdl2_touch.rb +73 -73
  43. data/lib/sdl2_ttf.rb +190 -190
  44. data/lib/sdl2_version.rb +62 -62
  45. data/lib/sdl2_video.rb +411 -407
  46. data/lib/sdl2_vulkan.rb +64 -64
  47. metadata +5 -5
@@ -1,51 +1,51 @@
1
- # Ruby-SDL2 : Yet another SDL2 wrapper for Ruby
2
- #
3
- # * https://github.com/vaiorabbit/sdl2-bindings
4
- #
5
- # [NOTICE] This is an automatically generated file.
6
-
7
- require 'ffi'
8
-
9
- module SDL2
10
- extend FFI::Library
11
- # Define/Macro
12
-
13
-
14
- # Enum
15
-
16
-
17
- # Typedef
18
-
19
-
20
- # Struct
21
-
22
-
23
- # Function
24
-
25
- def self.setup_clipboard_symbols()
26
- symbols = [
27
- :SDL_SetClipboardText,
28
- :SDL_GetClipboardText,
29
- :SDL_HasClipboardText,
30
- ]
31
- args = {
32
- :SDL_SetClipboardText => [:pointer],
33
- :SDL_GetClipboardText => [],
34
- :SDL_HasClipboardText => [],
35
- }
36
- retvals = {
37
- :SDL_SetClipboardText => :int,
38
- :SDL_GetClipboardText => :pointer,
39
- :SDL_HasClipboardText => :int,
40
- }
41
- symbols.each do |sym|
42
- begin
43
- attach_function sym, args[sym], retvals[sym]
44
- rescue FFI::NotFoundError => error
45
- $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
46
- end
47
- end
48
- end
49
-
50
- end
51
-
1
+ # Ruby-SDL2 : Yet another SDL2 wrapper for Ruby
2
+ #
3
+ # * https://github.com/vaiorabbit/sdl2-bindings
4
+ #
5
+ # [NOTICE] This is an automatically generated file.
6
+
7
+ require 'ffi'
8
+
9
+ module SDL2
10
+ extend FFI::Library
11
+ # Define/Macro
12
+
13
+
14
+ # Enum
15
+
16
+
17
+ # Typedef
18
+
19
+
20
+ # Struct
21
+
22
+
23
+ # Function
24
+
25
+ def self.setup_clipboard_symbols()
26
+ symbols = [
27
+ :SDL_SetClipboardText,
28
+ :SDL_GetClipboardText,
29
+ :SDL_HasClipboardText,
30
+ ]
31
+ args = {
32
+ :SDL_SetClipboardText => [:pointer],
33
+ :SDL_GetClipboardText => [],
34
+ :SDL_HasClipboardText => [],
35
+ }
36
+ retvals = {
37
+ :SDL_SetClipboardText => :int,
38
+ :SDL_GetClipboardText => :pointer,
39
+ :SDL_HasClipboardText => :int,
40
+ }
41
+ symbols.each do |sym|
42
+ begin
43
+ attach_function sym, args[sym], retvals[sym]
44
+ rescue FFI::NotFoundError => error
45
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
46
+ end
47
+ end
48
+ end
49
+
50
+ end
51
+
@@ -1,103 +1,106 @@
1
- # Ruby-SDL2 : Yet another SDL2 wrapper for Ruby
2
- #
3
- # * https://github.com/vaiorabbit/sdl2-bindings
4
- #
5
- # [NOTICE] This is an automatically generated file.
6
-
7
- require 'ffi'
8
-
9
- module SDL2
10
- extend FFI::Library
11
- # Define/Macro
12
-
13
- SDL_CACHELINE_SIZE = 128
14
-
15
- # Enum
16
-
17
-
18
- # Typedef
19
-
20
-
21
- # Struct
22
-
23
-
24
- # Function
25
-
26
- def self.setup_cpuinfo_symbols()
27
- symbols = [
28
- :SDL_GetCPUCount,
29
- :SDL_GetCPUCacheLineSize,
30
- :SDL_HasRDTSC,
31
- :SDL_HasAltiVec,
32
- :SDL_HasMMX,
33
- :SDL_Has3DNow,
34
- :SDL_HasSSE,
35
- :SDL_HasSSE2,
36
- :SDL_HasSSE3,
37
- :SDL_HasSSE41,
38
- :SDL_HasSSE42,
39
- :SDL_HasAVX,
40
- :SDL_HasAVX2,
41
- :SDL_HasAVX512F,
42
- :SDL_HasARMSIMD,
43
- :SDL_HasNEON,
44
- :SDL_GetSystemRAM,
45
- :SDL_SIMDGetAlignment,
46
- :SDL_SIMDAlloc,
47
- :SDL_SIMDFree,
48
- ]
49
- args = {
50
- :SDL_GetCPUCount => [],
51
- :SDL_GetCPUCacheLineSize => [],
52
- :SDL_HasRDTSC => [],
53
- :SDL_HasAltiVec => [],
54
- :SDL_HasMMX => [],
55
- :SDL_Has3DNow => [],
56
- :SDL_HasSSE => [],
57
- :SDL_HasSSE2 => [],
58
- :SDL_HasSSE3 => [],
59
- :SDL_HasSSE41 => [],
60
- :SDL_HasSSE42 => [],
61
- :SDL_HasAVX => [],
62
- :SDL_HasAVX2 => [],
63
- :SDL_HasAVX512F => [],
64
- :SDL_HasARMSIMD => [],
65
- :SDL_HasNEON => [],
66
- :SDL_GetSystemRAM => [],
67
- :SDL_SIMDGetAlignment => [],
68
- :SDL_SIMDAlloc => [:ulong],
69
- :SDL_SIMDFree => [:pointer],
70
- }
71
- retvals = {
72
- :SDL_GetCPUCount => :int,
73
- :SDL_GetCPUCacheLineSize => :int,
74
- :SDL_HasRDTSC => :int,
75
- :SDL_HasAltiVec => :int,
76
- :SDL_HasMMX => :int,
77
- :SDL_Has3DNow => :int,
78
- :SDL_HasSSE => :int,
79
- :SDL_HasSSE2 => :int,
80
- :SDL_HasSSE3 => :int,
81
- :SDL_HasSSE41 => :int,
82
- :SDL_HasSSE42 => :int,
83
- :SDL_HasAVX => :int,
84
- :SDL_HasAVX2 => :int,
85
- :SDL_HasAVX512F => :int,
86
- :SDL_HasARMSIMD => :int,
87
- :SDL_HasNEON => :int,
88
- :SDL_GetSystemRAM => :int,
89
- :SDL_SIMDGetAlignment => :size_t,
90
- :SDL_SIMDAlloc => :pointer,
91
- :SDL_SIMDFree => :void,
92
- }
93
- symbols.each do |sym|
94
- begin
95
- attach_function sym, args[sym], retvals[sym]
96
- rescue FFI::NotFoundError => error
97
- $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
98
- end
99
- end
100
- end
101
-
102
- end
103
-
1
+ # Ruby-SDL2 : Yet another SDL2 wrapper for Ruby
2
+ #
3
+ # * https://github.com/vaiorabbit/sdl2-bindings
4
+ #
5
+ # [NOTICE] This is an automatically generated file.
6
+
7
+ require 'ffi'
8
+
9
+ module SDL2
10
+ extend FFI::Library
11
+ # Define/Macro
12
+
13
+ SDL_CACHELINE_SIZE = 128
14
+
15
+ # Enum
16
+
17
+
18
+ # Typedef
19
+
20
+
21
+ # Struct
22
+
23
+
24
+ # Function
25
+
26
+ def self.setup_cpuinfo_symbols()
27
+ symbols = [
28
+ :SDL_GetCPUCount,
29
+ :SDL_GetCPUCacheLineSize,
30
+ :SDL_HasRDTSC,
31
+ :SDL_HasAltiVec,
32
+ :SDL_HasMMX,
33
+ :SDL_Has3DNow,
34
+ :SDL_HasSSE,
35
+ :SDL_HasSSE2,
36
+ :SDL_HasSSE3,
37
+ :SDL_HasSSE41,
38
+ :SDL_HasSSE42,
39
+ :SDL_HasAVX,
40
+ :SDL_HasAVX2,
41
+ :SDL_HasAVX512F,
42
+ :SDL_HasARMSIMD,
43
+ :SDL_HasNEON,
44
+ :SDL_GetSystemRAM,
45
+ :SDL_SIMDGetAlignment,
46
+ :SDL_SIMDAlloc,
47
+ :SDL_SIMDRealloc,
48
+ :SDL_SIMDFree,
49
+ ]
50
+ args = {
51
+ :SDL_GetCPUCount => [],
52
+ :SDL_GetCPUCacheLineSize => [],
53
+ :SDL_HasRDTSC => [],
54
+ :SDL_HasAltiVec => [],
55
+ :SDL_HasMMX => [],
56
+ :SDL_Has3DNow => [],
57
+ :SDL_HasSSE => [],
58
+ :SDL_HasSSE2 => [],
59
+ :SDL_HasSSE3 => [],
60
+ :SDL_HasSSE41 => [],
61
+ :SDL_HasSSE42 => [],
62
+ :SDL_HasAVX => [],
63
+ :SDL_HasAVX2 => [],
64
+ :SDL_HasAVX512F => [],
65
+ :SDL_HasARMSIMD => [],
66
+ :SDL_HasNEON => [],
67
+ :SDL_GetSystemRAM => [],
68
+ :SDL_SIMDGetAlignment => [],
69
+ :SDL_SIMDAlloc => [:ulong],
70
+ :SDL_SIMDRealloc => [:pointer, :ulong],
71
+ :SDL_SIMDFree => [:pointer],
72
+ }
73
+ retvals = {
74
+ :SDL_GetCPUCount => :int,
75
+ :SDL_GetCPUCacheLineSize => :int,
76
+ :SDL_HasRDTSC => :int,
77
+ :SDL_HasAltiVec => :int,
78
+ :SDL_HasMMX => :int,
79
+ :SDL_Has3DNow => :int,
80
+ :SDL_HasSSE => :int,
81
+ :SDL_HasSSE2 => :int,
82
+ :SDL_HasSSE3 => :int,
83
+ :SDL_HasSSE41 => :int,
84
+ :SDL_HasSSE42 => :int,
85
+ :SDL_HasAVX => :int,
86
+ :SDL_HasAVX2 => :int,
87
+ :SDL_HasAVX512F => :int,
88
+ :SDL_HasARMSIMD => :int,
89
+ :SDL_HasNEON => :int,
90
+ :SDL_GetSystemRAM => :int,
91
+ :SDL_SIMDGetAlignment => :size_t,
92
+ :SDL_SIMDAlloc => :pointer,
93
+ :SDL_SIMDRealloc => :pointer,
94
+ :SDL_SIMDFree => :void,
95
+ }
96
+ symbols.each do |sym|
97
+ begin
98
+ attach_function sym, args[sym], retvals[sym]
99
+ rescue FFI::NotFoundError => error
100
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
101
+ end
102
+ end
103
+ end
104
+
105
+ end
106
+
@@ -1,61 +1,64 @@
1
- # Ruby-SDL2 : Yet another SDL2 wrapper for Ruby
2
- #
3
- # * https://github.com/vaiorabbit/sdl2-bindings
4
- #
5
- # [NOTICE] This is an automatically generated file.
6
-
7
- require 'ffi'
8
-
9
- module SDL2
10
- extend FFI::Library
11
- # Define/Macro
12
-
13
-
14
- # Enum
15
-
16
- SDL_ENOMEM = 0
17
- SDL_EFREAD = 1
18
- SDL_EFWRITE = 2
19
- SDL_EFSEEK = 3
20
- SDL_UNSUPPORTED = 4
21
- SDL_LASTERROR = 5
22
-
23
- # Typedef
24
-
25
- typedef :int, :SDL_errorcode
26
-
27
- # Struct
28
-
29
-
30
- # Function
31
-
32
- def self.setup_error_symbols()
33
- symbols = [
34
- :SDL_SetError,
35
- :SDL_GetError,
36
- :SDL_ClearError,
37
- :SDL_Error,
38
- ]
39
- args = {
40
- :SDL_SetError => [:pointer],
41
- :SDL_GetError => [],
42
- :SDL_ClearError => [],
43
- :SDL_Error => [:int],
44
- }
45
- retvals = {
46
- :SDL_SetError => :int,
47
- :SDL_GetError => :pointer,
48
- :SDL_ClearError => :void,
49
- :SDL_Error => :int,
50
- }
51
- symbols.each do |sym|
52
- begin
53
- attach_function sym, args[sym], retvals[sym]
54
- rescue FFI::NotFoundError => error
55
- $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
56
- end
57
- end
58
- end
59
-
60
- end
61
-
1
+ # Ruby-SDL2 : Yet another SDL2 wrapper for Ruby
2
+ #
3
+ # * https://github.com/vaiorabbit/sdl2-bindings
4
+ #
5
+ # [NOTICE] This is an automatically generated file.
6
+
7
+ require 'ffi'
8
+
9
+ module SDL2
10
+ extend FFI::Library
11
+ # Define/Macro
12
+
13
+
14
+ # Enum
15
+
16
+ SDL_ENOMEM = 0
17
+ SDL_EFREAD = 1
18
+ SDL_EFWRITE = 2
19
+ SDL_EFSEEK = 3
20
+ SDL_UNSUPPORTED = 4
21
+ SDL_LASTERROR = 5
22
+
23
+ # Typedef
24
+
25
+ typedef :int, :SDL_errorcode
26
+
27
+ # Struct
28
+
29
+
30
+ # Function
31
+
32
+ def self.setup_error_symbols()
33
+ symbols = [
34
+ :SDL_SetError,
35
+ :SDL_GetError,
36
+ :SDL_GetErrorMsg,
37
+ :SDL_ClearError,
38
+ :SDL_Error,
39
+ ]
40
+ args = {
41
+ :SDL_SetError => [:pointer],
42
+ :SDL_GetError => [],
43
+ :SDL_GetErrorMsg => [:pointer, :int],
44
+ :SDL_ClearError => [],
45
+ :SDL_Error => [:int],
46
+ }
47
+ retvals = {
48
+ :SDL_SetError => :int,
49
+ :SDL_GetError => :pointer,
50
+ :SDL_GetErrorMsg => :pointer,
51
+ :SDL_ClearError => :void,
52
+ :SDL_Error => :int,
53
+ }
54
+ symbols.each do |sym|
55
+ begin
56
+ attach_function sym, args[sym], retvals[sym]
57
+ rescue FFI::NotFoundError => error
58
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
59
+ end
60
+ end
61
+ end
62
+
63
+ end
64
+
@@ -1,500 +1,530 @@
1
- # Ruby-SDL2 : Yet another SDL2 wrapper for Ruby
2
- #
3
- # * https://github.com/vaiorabbit/sdl2-bindings
4
- #
5
- # [NOTICE] This is an automatically generated file.
6
-
7
- require 'ffi'
8
- require_relative 'sdl2_keyboard'
9
-
10
- module SDL2
11
- extend FFI::Library
12
- # Define/Macro
13
-
14
- SDL_RELEASED = 0
15
- SDL_PRESSED = 1
16
- SDL_TEXTEDITINGEVENT_TEXT_SIZE = 32
17
- SDL_TEXTINPUTEVENT_TEXT_SIZE = 2
18
- SDL_QUERY = -1
19
- SDL_IGNORE = 0
20
- SDL_DISABLE = 0
21
- SDL_ENABLE = 1
22
-
23
- # Enum
24
-
25
- SDL_FIRSTEVENT = 0
26
- SDL_QUIT = 256
27
- SDL_APP_TERMINATING = 257
28
- SDL_APP_LOWMEMORY = 258
29
- SDL_APP_WILLENTERBACKGROUND = 259
30
- SDL_APP_DIDENTERBACKGROUND = 260
31
- SDL_APP_WILLENTERFOREGROUND = 261
32
- SDL_APP_DIDENTERFOREGROUND = 262
33
- SDL_DISPLAYEVENT = 336
34
- SDL_WINDOWEVENT = 512
35
- SDL_SYSWMEVENT = 513
36
- SDL_KEYDOWN = 768
37
- SDL_KEYUP = 769
38
- SDL_TEXTEDITING = 770
39
- SDL_TEXTINPUT = 771
40
- SDL_KEYMAPCHANGED = 772
41
- SDL_MOUSEMOTION = 1024
42
- SDL_MOUSEBUTTONDOWN = 1025
43
- SDL_MOUSEBUTTONUP = 1026
44
- SDL_MOUSEWHEEL = 1027
45
- SDL_JOYAXISMOTION = 1536
46
- SDL_JOYBALLMOTION = 1537
47
- SDL_JOYHATMOTION = 1538
48
- SDL_JOYBUTTONDOWN = 1539
49
- SDL_JOYBUTTONUP = 1540
50
- SDL_JOYDEVICEADDED = 1541
51
- SDL_JOYDEVICEREMOVED = 1542
52
- SDL_CONTROLLERAXISMOTION = 1616
53
- SDL_CONTROLLERBUTTONDOWN = 1617
54
- SDL_CONTROLLERBUTTONUP = 1618
55
- SDL_CONTROLLERDEVICEADDED = 1619
56
- SDL_CONTROLLERDEVICEREMOVED = 1620
57
- SDL_CONTROLLERDEVICEREMAPPED = 1621
58
- SDL_FINGERDOWN = 1792
59
- SDL_FINGERUP = 1793
60
- SDL_FINGERMOTION = 1794
61
- SDL_DOLLARGESTURE = 2048
62
- SDL_DOLLARRECORD = 2049
63
- SDL_MULTIGESTURE = 2050
64
- SDL_CLIPBOARDUPDATE = 2304
65
- SDL_DROPFILE = 4096
66
- SDL_DROPTEXT = 4097
67
- SDL_DROPBEGIN = 4098
68
- SDL_DROPCOMPLETE = 4099
69
- SDL_AUDIODEVICEADDED = 4352
70
- SDL_AUDIODEVICEREMOVED = 4353
71
- SDL_SENSORUPDATE = 4608
72
- SDL_RENDER_TARGETS_RESET = 8192
73
- SDL_RENDER_DEVICE_RESET = 8193
74
- SDL_USEREVENT = 32768
75
- SDL_LASTEVENT = 65535
76
- SDL_ADDEVENT = 0
77
- SDL_PEEKEVENT = 1
78
- SDL_GETEVENT = 2
79
-
80
- # Typedef
81
-
82
- typedef :int, :SDL_EventType
83
- typedef :int, :SDL_compile_time_assert_SDL_Event
84
- typedef :int, :SDL_eventaction
85
- callback :SDL_EventFilter, [:pointer, :pointer], :int
86
-
87
- # Struct
88
-
89
- class SDL_CommonEvent < FFI::Struct
90
- layout(
91
- :type, :uint,
92
- :timestamp, :uint,
93
- )
94
- end
95
-
96
- class SDL_DisplayEvent < FFI::Struct
97
- layout(
98
- :type, :uint,
99
- :timestamp, :uint,
100
- :display, :uint,
101
- :event, :uchar,
102
- :padding1, :uchar,
103
- :padding2, :uchar,
104
- :padding3, :uchar,
105
- :data1, :int,
106
- )
107
- end
108
-
109
- class SDL_WindowEvent < FFI::Struct
110
- layout(
111
- :type, :uint,
112
- :timestamp, :uint,
113
- :windowID, :uint,
114
- :event, :uchar,
115
- :padding1, :uchar,
116
- :padding2, :uchar,
117
- :padding3, :uchar,
118
- :data1, :int,
119
- :data2, :int,
120
- )
121
- end
122
-
123
- class SDL_KeyboardEvent < FFI::Struct
124
- layout(
125
- :type, :uint,
126
- :timestamp, :uint,
127
- :windowID, :uint,
128
- :state, :uchar,
129
- :repeat, :uchar,
130
- :padding2, :uchar,
131
- :padding3, :uchar,
132
- :keysym, SDL_Keysym,
133
- )
134
- end
135
-
136
- class SDL_TextEditingEvent < FFI::Struct
137
- layout(
138
- :type, :uint,
139
- :timestamp, :uint,
140
- :windowID, :uint,
141
- :text, [:char, 32],
142
- :start, :int,
143
- :length, :int,
144
- )
145
- end
146
-
147
- class SDL_TextInputEvent < FFI::Struct
148
- layout(
149
- :type, :uint,
150
- :timestamp, :uint,
151
- :windowID, :uint,
152
- :text, [:char, 32],
153
- )
154
- end
155
-
156
- class SDL_MouseMotionEvent < FFI::Struct
157
- layout(
158
- :type, :uint,
159
- :timestamp, :uint,
160
- :windowID, :uint,
161
- :which, :uint,
162
- :state, :uint,
163
- :x, :int,
164
- :y, :int,
165
- :xrel, :int,
166
- :yrel, :int,
167
- )
168
- end
169
-
170
- class SDL_MouseButtonEvent < FFI::Struct
171
- layout(
172
- :type, :uint,
173
- :timestamp, :uint,
174
- :windowID, :uint,
175
- :which, :uint,
176
- :button, :uchar,
177
- :state, :uchar,
178
- :clicks, :uchar,
179
- :padding1, :uchar,
180
- :x, :int,
181
- :y, :int,
182
- )
183
- end
184
-
185
- class SDL_MouseWheelEvent < FFI::Struct
186
- layout(
187
- :type, :uint,
188
- :timestamp, :uint,
189
- :windowID, :uint,
190
- :which, :uint,
191
- :x, :int,
192
- :y, :int,
193
- :direction, :uint,
194
- )
195
- end
196
-
197
- class SDL_JoyAxisEvent < FFI::Struct
198
- layout(
199
- :type, :uint,
200
- :timestamp, :uint,
201
- :which, :int,
202
- :axis, :uchar,
203
- :padding1, :uchar,
204
- :padding2, :uchar,
205
- :padding3, :uchar,
206
- :value, :short,
207
- :padding4, :ushort,
208
- )
209
- end
210
-
211
- class SDL_JoyBallEvent < FFI::Struct
212
- layout(
213
- :type, :uint,
214
- :timestamp, :uint,
215
- :which, :int,
216
- :ball, :uchar,
217
- :padding1, :uchar,
218
- :padding2, :uchar,
219
- :padding3, :uchar,
220
- :xrel, :short,
221
- :yrel, :short,
222
- )
223
- end
224
-
225
- class SDL_JoyHatEvent < FFI::Struct
226
- layout(
227
- :type, :uint,
228
- :timestamp, :uint,
229
- :which, :int,
230
- :hat, :uchar,
231
- :value, :uchar,
232
- :padding1, :uchar,
233
- :padding2, :uchar,
234
- )
235
- end
236
-
237
- class SDL_JoyButtonEvent < FFI::Struct
238
- layout(
239
- :type, :uint,
240
- :timestamp, :uint,
241
- :which, :int,
242
- :button, :uchar,
243
- :state, :uchar,
244
- :padding1, :uchar,
245
- :padding2, :uchar,
246
- )
247
- end
248
-
249
- class SDL_JoyDeviceEvent < FFI::Struct
250
- layout(
251
- :type, :uint,
252
- :timestamp, :uint,
253
- :which, :int,
254
- )
255
- end
256
-
257
- class SDL_ControllerAxisEvent < FFI::Struct
258
- layout(
259
- :type, :uint,
260
- :timestamp, :uint,
261
- :which, :int,
262
- :axis, :uchar,
263
- :padding1, :uchar,
264
- :padding2, :uchar,
265
- :padding3, :uchar,
266
- :value, :short,
267
- :padding4, :ushort,
268
- )
269
- end
270
-
271
- class SDL_ControllerButtonEvent < FFI::Struct
272
- layout(
273
- :type, :uint,
274
- :timestamp, :uint,
275
- :which, :int,
276
- :button, :uchar,
277
- :state, :uchar,
278
- :padding1, :uchar,
279
- :padding2, :uchar,
280
- )
281
- end
282
-
283
- class SDL_ControllerDeviceEvent < FFI::Struct
284
- layout(
285
- :type, :uint,
286
- :timestamp, :uint,
287
- :which, :int,
288
- )
289
- end
290
-
291
- class SDL_AudioDeviceEvent < FFI::Struct
292
- layout(
293
- :type, :uint,
294
- :timestamp, :uint,
295
- :which, :uint,
296
- :iscapture, :uchar,
297
- :padding1, :uchar,
298
- :padding2, :uchar,
299
- :padding3, :uchar,
300
- )
301
- end
302
-
303
- class SDL_TouchFingerEvent < FFI::Struct
304
- layout(
305
- :type, :uint,
306
- :timestamp, :uint,
307
- :touchId, :long_long,
308
- :fingerId, :long_long,
309
- :x, :float,
310
- :y, :float,
311
- :dx, :float,
312
- :dy, :float,
313
- :pressure, :float,
314
- :windowID, :uint,
315
- )
316
- end
317
-
318
- class SDL_MultiGestureEvent < FFI::Struct
319
- layout(
320
- :type, :uint,
321
- :timestamp, :uint,
322
- :touchId, :long_long,
323
- :dTheta, :float,
324
- :dDist, :float,
325
- :x, :float,
326
- :y, :float,
327
- :numFingers, :ushort,
328
- :padding, :ushort,
329
- )
330
- end
331
-
332
- class SDL_DollarGestureEvent < FFI::Struct
333
- layout(
334
- :type, :uint,
335
- :timestamp, :uint,
336
- :touchId, :long_long,
337
- :gestureId, :long_long,
338
- :numFingers, :uint,
339
- :error, :float,
340
- :x, :float,
341
- :y, :float,
342
- )
343
- end
344
-
345
- class SDL_DropEvent < FFI::Struct
346
- layout(
347
- :type, :uint,
348
- :timestamp, :uint,
349
- :file, :pointer,
350
- :windowID, :uint,
351
- )
352
- end
353
-
354
- class SDL_SensorEvent < FFI::Struct
355
- layout(
356
- :type, :uint,
357
- :timestamp, :uint,
358
- :which, :int,
359
- :data, [:float, 6],
360
- )
361
- end
362
-
363
- class SDL_QuitEvent < FFI::Struct
364
- layout(
365
- :type, :uint,
366
- :timestamp, :uint,
367
- )
368
- end
369
-
370
- class SDL_OSEvent < FFI::Struct
371
- layout(
372
- :type, :uint,
373
- :timestamp, :uint,
374
- )
375
- end
376
-
377
- class SDL_UserEvent < FFI::Struct
378
- layout(
379
- :type, :uint,
380
- :timestamp, :uint,
381
- :windowID, :uint,
382
- :code, :int,
383
- :data1, :pointer,
384
- :data2, :pointer,
385
- )
386
- end
387
-
388
- class SDL_SysWMEvent < FFI::Struct
389
- layout(
390
- :type, :uint,
391
- :timestamp, :uint,
392
- :msg, :pointer,
393
- )
394
- end
395
-
396
- class SDL_Event < FFI::Union
397
- layout(
398
- :type, :uint,
399
- :common, SDL_CommonEvent,
400
- :display, SDL_DisplayEvent,
401
- :window, SDL_WindowEvent,
402
- :key, SDL_KeyboardEvent,
403
- :edit, SDL_TextEditingEvent,
404
- :text, SDL_TextInputEvent,
405
- :motion, SDL_MouseMotionEvent,
406
- :button, SDL_MouseButtonEvent,
407
- :wheel, SDL_MouseWheelEvent,
408
- :jaxis, SDL_JoyAxisEvent,
409
- :jball, SDL_JoyBallEvent,
410
- :jhat, SDL_JoyHatEvent,
411
- :jbutton, SDL_JoyButtonEvent,
412
- :jdevice, SDL_JoyDeviceEvent,
413
- :caxis, SDL_ControllerAxisEvent,
414
- :cbutton, SDL_ControllerButtonEvent,
415
- :cdevice, SDL_ControllerDeviceEvent,
416
- :adevice, SDL_AudioDeviceEvent,
417
- :sensor, SDL_SensorEvent,
418
- :quit, SDL_QuitEvent,
419
- :user, SDL_UserEvent,
420
- :syswm, SDL_SysWMEvent,
421
- :tfinger, SDL_TouchFingerEvent,
422
- :mgesture, SDL_MultiGestureEvent,
423
- :dgesture, SDL_DollarGestureEvent,
424
- :drop, SDL_DropEvent,
425
- :padding, [:uchar, 56],
426
- )
427
- end
428
-
429
-
430
- # Function
431
-
432
- def self.setup_events_symbols()
433
- symbols = [
434
- :SDL_PumpEvents,
435
- :SDL_PeepEvents,
436
- :SDL_HasEvent,
437
- :SDL_HasEvents,
438
- :SDL_FlushEvent,
439
- :SDL_FlushEvents,
440
- :SDL_PollEvent,
441
- :SDL_WaitEvent,
442
- :SDL_WaitEventTimeout,
443
- :SDL_PushEvent,
444
- :SDL_SetEventFilter,
445
- :SDL_GetEventFilter,
446
- :SDL_AddEventWatch,
447
- :SDL_DelEventWatch,
448
- :SDL_FilterEvents,
449
- :SDL_EventState,
450
- :SDL_RegisterEvents,
451
- ]
452
- args = {
453
- :SDL_PumpEvents => [],
454
- :SDL_PeepEvents => [:pointer, :int, :int, :uint, :uint],
455
- :SDL_HasEvent => [:uint],
456
- :SDL_HasEvents => [:uint, :uint],
457
- :SDL_FlushEvent => [:uint],
458
- :SDL_FlushEvents => [:uint, :uint],
459
- :SDL_PollEvent => [:pointer],
460
- :SDL_WaitEvent => [:pointer],
461
- :SDL_WaitEventTimeout => [:pointer, :int],
462
- :SDL_PushEvent => [:pointer],
463
- :SDL_SetEventFilter => [:SDL_EventFilter, :pointer],
464
- :SDL_GetEventFilter => [:pointer, :pointer],
465
- :SDL_AddEventWatch => [:SDL_EventFilter, :pointer],
466
- :SDL_DelEventWatch => [:SDL_EventFilter, :pointer],
467
- :SDL_FilterEvents => [:SDL_EventFilter, :pointer],
468
- :SDL_EventState => [:uint, :int],
469
- :SDL_RegisterEvents => [:int],
470
- }
471
- retvals = {
472
- :SDL_PumpEvents => :void,
473
- :SDL_PeepEvents => :int,
474
- :SDL_HasEvent => :int,
475
- :SDL_HasEvents => :int,
476
- :SDL_FlushEvent => :void,
477
- :SDL_FlushEvents => :void,
478
- :SDL_PollEvent => :int,
479
- :SDL_WaitEvent => :int,
480
- :SDL_WaitEventTimeout => :int,
481
- :SDL_PushEvent => :int,
482
- :SDL_SetEventFilter => :void,
483
- :SDL_GetEventFilter => :int,
484
- :SDL_AddEventWatch => :void,
485
- :SDL_DelEventWatch => :void,
486
- :SDL_FilterEvents => :void,
487
- :SDL_EventState => :uchar,
488
- :SDL_RegisterEvents => :uint,
489
- }
490
- symbols.each do |sym|
491
- begin
492
- attach_function sym, args[sym], retvals[sym]
493
- rescue FFI::NotFoundError => error
494
- $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
495
- end
496
- end
497
- end
498
-
499
- end
500
-
1
+ # Ruby-SDL2 : Yet another SDL2 wrapper for Ruby
2
+ #
3
+ # * https://github.com/vaiorabbit/sdl2-bindings
4
+ #
5
+ # [NOTICE] This is an automatically generated file.
6
+
7
+ require 'ffi'
8
+ require_relative 'sdl2_keyboard'
9
+
10
+ module SDL2
11
+ extend FFI::Library
12
+ # Define/Macro
13
+
14
+ SDL_RELEASED = 0
15
+ SDL_PRESSED = 1
16
+ SDL_TEXTEDITINGEVENT_TEXT_SIZE = 32
17
+ SDL_TEXTINPUTEVENT_TEXT_SIZE = 32
18
+ SDL_QUERY = -1
19
+ SDL_IGNORE = 0
20
+ SDL_DISABLE = 0
21
+ SDL_ENABLE = 1
22
+
23
+ # Enum
24
+
25
+ SDL_FIRSTEVENT = 0
26
+ SDL_QUIT = 256
27
+ SDL_APP_TERMINATING = 257
28
+ SDL_APP_LOWMEMORY = 258
29
+ SDL_APP_WILLENTERBACKGROUND = 259
30
+ SDL_APP_DIDENTERBACKGROUND = 260
31
+ SDL_APP_WILLENTERFOREGROUND = 261
32
+ SDL_APP_DIDENTERFOREGROUND = 262
33
+ SDL_LOCALECHANGED = 263
34
+ SDL_DISPLAYEVENT = 336
35
+ SDL_WINDOWEVENT = 512
36
+ SDL_SYSWMEVENT = 513
37
+ SDL_KEYDOWN = 768
38
+ SDL_KEYUP = 769
39
+ SDL_TEXTEDITING = 770
40
+ SDL_TEXTINPUT = 771
41
+ SDL_KEYMAPCHANGED = 772
42
+ SDL_MOUSEMOTION = 1024
43
+ SDL_MOUSEBUTTONDOWN = 1025
44
+ SDL_MOUSEBUTTONUP = 1026
45
+ SDL_MOUSEWHEEL = 1027
46
+ SDL_JOYAXISMOTION = 1536
47
+ SDL_JOYBALLMOTION = 1537
48
+ SDL_JOYHATMOTION = 1538
49
+ SDL_JOYBUTTONDOWN = 1539
50
+ SDL_JOYBUTTONUP = 1540
51
+ SDL_JOYDEVICEADDED = 1541
52
+ SDL_JOYDEVICEREMOVED = 1542
53
+ SDL_CONTROLLERAXISMOTION = 1616
54
+ SDL_CONTROLLERBUTTONDOWN = 1617
55
+ SDL_CONTROLLERBUTTONUP = 1618
56
+ SDL_CONTROLLERDEVICEADDED = 1619
57
+ SDL_CONTROLLERDEVICEREMOVED = 1620
58
+ SDL_CONTROLLERDEVICEREMAPPED = 1621
59
+ SDL_CONTROLLERTOUCHPADDOWN = 1622
60
+ SDL_CONTROLLERTOUCHPADMOTION = 1623
61
+ SDL_CONTROLLERTOUCHPADUP = 1624
62
+ SDL_CONTROLLERSENSORUPDATE = 1625
63
+ SDL_FINGERDOWN = 1792
64
+ SDL_FINGERUP = 1793
65
+ SDL_FINGERMOTION = 1794
66
+ SDL_DOLLARGESTURE = 2048
67
+ SDL_DOLLARRECORD = 2049
68
+ SDL_MULTIGESTURE = 2050
69
+ SDL_CLIPBOARDUPDATE = 2304
70
+ SDL_DROPFILE = 4096
71
+ SDL_DROPTEXT = 4097
72
+ SDL_DROPBEGIN = 4098
73
+ SDL_DROPCOMPLETE = 4099
74
+ SDL_AUDIODEVICEADDED = 4352
75
+ SDL_AUDIODEVICEREMOVED = 4353
76
+ SDL_SENSORUPDATE = 4608
77
+ SDL_RENDER_TARGETS_RESET = 8192
78
+ SDL_RENDER_DEVICE_RESET = 8193
79
+ SDL_USEREVENT = 32768
80
+ SDL_LASTEVENT = 65535
81
+ SDL_ADDEVENT = 0
82
+ SDL_PEEKEVENT = 1
83
+ SDL_GETEVENT = 2
84
+
85
+ # Typedef
86
+
87
+ typedef :int, :SDL_EventType
88
+ typedef :int, :SDL_compile_time_assert_SDL_Event
89
+ typedef :int, :SDL_eventaction
90
+ callback :SDL_EventFilter, [:pointer, :pointer], :int
91
+
92
+ # Struct
93
+
94
+ class SDL_CommonEvent < FFI::Struct
95
+ layout(
96
+ :type, :uint,
97
+ :timestamp, :uint,
98
+ )
99
+ end
100
+
101
+ class SDL_DisplayEvent < FFI::Struct
102
+ layout(
103
+ :type, :uint,
104
+ :timestamp, :uint,
105
+ :display, :uint,
106
+ :event, :uchar,
107
+ :padding1, :uchar,
108
+ :padding2, :uchar,
109
+ :padding3, :uchar,
110
+ :data1, :int,
111
+ )
112
+ end
113
+
114
+ class SDL_WindowEvent < FFI::Struct
115
+ layout(
116
+ :type, :uint,
117
+ :timestamp, :uint,
118
+ :windowID, :uint,
119
+ :event, :uchar,
120
+ :padding1, :uchar,
121
+ :padding2, :uchar,
122
+ :padding3, :uchar,
123
+ :data1, :int,
124
+ :data2, :int,
125
+ )
126
+ end
127
+
128
+ class SDL_KeyboardEvent < FFI::Struct
129
+ layout(
130
+ :type, :uint,
131
+ :timestamp, :uint,
132
+ :windowID, :uint,
133
+ :state, :uchar,
134
+ :repeat, :uchar,
135
+ :padding2, :uchar,
136
+ :padding3, :uchar,
137
+ :keysym, SDL_Keysym,
138
+ )
139
+ end
140
+
141
+ class SDL_TextEditingEvent < FFI::Struct
142
+ layout(
143
+ :type, :uint,
144
+ :timestamp, :uint,
145
+ :windowID, :uint,
146
+ :text, [:char, 32],
147
+ :start, :int,
148
+ :length, :int,
149
+ )
150
+ end
151
+
152
+ class SDL_TextInputEvent < FFI::Struct
153
+ layout(
154
+ :type, :uint,
155
+ :timestamp, :uint,
156
+ :windowID, :uint,
157
+ :text, [:char, 32],
158
+ )
159
+ end
160
+
161
+ class SDL_MouseMotionEvent < FFI::Struct
162
+ layout(
163
+ :type, :uint,
164
+ :timestamp, :uint,
165
+ :windowID, :uint,
166
+ :which, :uint,
167
+ :state, :uint,
168
+ :x, :int,
169
+ :y, :int,
170
+ :xrel, :int,
171
+ :yrel, :int,
172
+ )
173
+ end
174
+
175
+ class SDL_MouseButtonEvent < FFI::Struct
176
+ layout(
177
+ :type, :uint,
178
+ :timestamp, :uint,
179
+ :windowID, :uint,
180
+ :which, :uint,
181
+ :button, :uchar,
182
+ :state, :uchar,
183
+ :clicks, :uchar,
184
+ :padding1, :uchar,
185
+ :x, :int,
186
+ :y, :int,
187
+ )
188
+ end
189
+
190
+ class SDL_MouseWheelEvent < FFI::Struct
191
+ layout(
192
+ :type, :uint,
193
+ :timestamp, :uint,
194
+ :windowID, :uint,
195
+ :which, :uint,
196
+ :x, :int,
197
+ :y, :int,
198
+ :direction, :uint,
199
+ )
200
+ end
201
+
202
+ class SDL_JoyAxisEvent < FFI::Struct
203
+ layout(
204
+ :type, :uint,
205
+ :timestamp, :uint,
206
+ :which, :int,
207
+ :axis, :uchar,
208
+ :padding1, :uchar,
209
+ :padding2, :uchar,
210
+ :padding3, :uchar,
211
+ :value, :short,
212
+ :padding4, :ushort,
213
+ )
214
+ end
215
+
216
+ class SDL_JoyBallEvent < FFI::Struct
217
+ layout(
218
+ :type, :uint,
219
+ :timestamp, :uint,
220
+ :which, :int,
221
+ :ball, :uchar,
222
+ :padding1, :uchar,
223
+ :padding2, :uchar,
224
+ :padding3, :uchar,
225
+ :xrel, :short,
226
+ :yrel, :short,
227
+ )
228
+ end
229
+
230
+ class SDL_JoyHatEvent < FFI::Struct
231
+ layout(
232
+ :type, :uint,
233
+ :timestamp, :uint,
234
+ :which, :int,
235
+ :hat, :uchar,
236
+ :value, :uchar,
237
+ :padding1, :uchar,
238
+ :padding2, :uchar,
239
+ )
240
+ end
241
+
242
+ class SDL_JoyButtonEvent < FFI::Struct
243
+ layout(
244
+ :type, :uint,
245
+ :timestamp, :uint,
246
+ :which, :int,
247
+ :button, :uchar,
248
+ :state, :uchar,
249
+ :padding1, :uchar,
250
+ :padding2, :uchar,
251
+ )
252
+ end
253
+
254
+ class SDL_JoyDeviceEvent < FFI::Struct
255
+ layout(
256
+ :type, :uint,
257
+ :timestamp, :uint,
258
+ :which, :int,
259
+ )
260
+ end
261
+
262
+ class SDL_ControllerAxisEvent < FFI::Struct
263
+ layout(
264
+ :type, :uint,
265
+ :timestamp, :uint,
266
+ :which, :int,
267
+ :axis, :uchar,
268
+ :padding1, :uchar,
269
+ :padding2, :uchar,
270
+ :padding3, :uchar,
271
+ :value, :short,
272
+ :padding4, :ushort,
273
+ )
274
+ end
275
+
276
+ class SDL_ControllerButtonEvent < FFI::Struct
277
+ layout(
278
+ :type, :uint,
279
+ :timestamp, :uint,
280
+ :which, :int,
281
+ :button, :uchar,
282
+ :state, :uchar,
283
+ :padding1, :uchar,
284
+ :padding2, :uchar,
285
+ )
286
+ end
287
+
288
+ class SDL_ControllerDeviceEvent < FFI::Struct
289
+ layout(
290
+ :type, :uint,
291
+ :timestamp, :uint,
292
+ :which, :int,
293
+ )
294
+ end
295
+
296
+ class SDL_ControllerTouchpadEvent < FFI::Struct
297
+ layout(
298
+ :type, :uint,
299
+ :timestamp, :uint,
300
+ :which, :int,
301
+ :touchpad, :int,
302
+ :finger, :int,
303
+ :x, :float,
304
+ :y, :float,
305
+ :pressure, :float,
306
+ )
307
+ end
308
+
309
+ class SDL_ControllerSensorEvent < FFI::Struct
310
+ layout(
311
+ :type, :uint,
312
+ :timestamp, :uint,
313
+ :which, :int,
314
+ :sensor, :int,
315
+ :data, [:float, 3],
316
+ )
317
+ end
318
+
319
+ class SDL_AudioDeviceEvent < FFI::Struct
320
+ layout(
321
+ :type, :uint,
322
+ :timestamp, :uint,
323
+ :which, :uint,
324
+ :iscapture, :uchar,
325
+ :padding1, :uchar,
326
+ :padding2, :uchar,
327
+ :padding3, :uchar,
328
+ )
329
+ end
330
+
331
+ class SDL_TouchFingerEvent < FFI::Struct
332
+ layout(
333
+ :type, :uint,
334
+ :timestamp, :uint,
335
+ :touchId, :long_long,
336
+ :fingerId, :long_long,
337
+ :x, :float,
338
+ :y, :float,
339
+ :dx, :float,
340
+ :dy, :float,
341
+ :pressure, :float,
342
+ :windowID, :uint,
343
+ )
344
+ end
345
+
346
+ class SDL_MultiGestureEvent < FFI::Struct
347
+ layout(
348
+ :type, :uint,
349
+ :timestamp, :uint,
350
+ :touchId, :long_long,
351
+ :dTheta, :float,
352
+ :dDist, :float,
353
+ :x, :float,
354
+ :y, :float,
355
+ :numFingers, :ushort,
356
+ :padding, :ushort,
357
+ )
358
+ end
359
+
360
+ class SDL_DollarGestureEvent < FFI::Struct
361
+ layout(
362
+ :type, :uint,
363
+ :timestamp, :uint,
364
+ :touchId, :long_long,
365
+ :gestureId, :long_long,
366
+ :numFingers, :uint,
367
+ :error, :float,
368
+ :x, :float,
369
+ :y, :float,
370
+ )
371
+ end
372
+
373
+ class SDL_DropEvent < FFI::Struct
374
+ layout(
375
+ :type, :uint,
376
+ :timestamp, :uint,
377
+ :file, :pointer,
378
+ :windowID, :uint,
379
+ )
380
+ end
381
+
382
+ class SDL_SensorEvent < FFI::Struct
383
+ layout(
384
+ :type, :uint,
385
+ :timestamp, :uint,
386
+ :which, :int,
387
+ :data, [:float, 6],
388
+ )
389
+ end
390
+
391
+ class SDL_QuitEvent < FFI::Struct
392
+ layout(
393
+ :type, :uint,
394
+ :timestamp, :uint,
395
+ )
396
+ end
397
+
398
+ class SDL_OSEvent < FFI::Struct
399
+ layout(
400
+ :type, :uint,
401
+ :timestamp, :uint,
402
+ )
403
+ end
404
+
405
+ class SDL_UserEvent < FFI::Struct
406
+ layout(
407
+ :type, :uint,
408
+ :timestamp, :uint,
409
+ :windowID, :uint,
410
+ :code, :int,
411
+ :data1, :pointer,
412
+ :data2, :pointer,
413
+ )
414
+ end
415
+
416
+ class SDL_SysWMEvent < FFI::Struct
417
+ layout(
418
+ :type, :uint,
419
+ :timestamp, :uint,
420
+ :msg, :pointer,
421
+ )
422
+ end
423
+
424
+ class SDL_Event < FFI::Union
425
+ layout(
426
+ :type, :uint,
427
+ :common, SDL_CommonEvent,
428
+ :display, SDL_DisplayEvent,
429
+ :window, SDL_WindowEvent,
430
+ :key, SDL_KeyboardEvent,
431
+ :edit, SDL_TextEditingEvent,
432
+ :text, SDL_TextInputEvent,
433
+ :motion, SDL_MouseMotionEvent,
434
+ :button, SDL_MouseButtonEvent,
435
+ :wheel, SDL_MouseWheelEvent,
436
+ :jaxis, SDL_JoyAxisEvent,
437
+ :jball, SDL_JoyBallEvent,
438
+ :jhat, SDL_JoyHatEvent,
439
+ :jbutton, SDL_JoyButtonEvent,
440
+ :jdevice, SDL_JoyDeviceEvent,
441
+ :caxis, SDL_ControllerAxisEvent,
442
+ :cbutton, SDL_ControllerButtonEvent,
443
+ :cdevice, SDL_ControllerDeviceEvent,
444
+ :ctouchpad, SDL_ControllerTouchpadEvent,
445
+ :csensor, SDL_ControllerSensorEvent,
446
+ :adevice, SDL_AudioDeviceEvent,
447
+ :sensor, SDL_SensorEvent,
448
+ :quit, SDL_QuitEvent,
449
+ :user, SDL_UserEvent,
450
+ :syswm, SDL_SysWMEvent,
451
+ :tfinger, SDL_TouchFingerEvent,
452
+ :mgesture, SDL_MultiGestureEvent,
453
+ :dgesture, SDL_DollarGestureEvent,
454
+ :drop, SDL_DropEvent,
455
+ :padding, [:uchar, 56],
456
+ )
457
+ end
458
+
459
+
460
+ # Function
461
+
462
+ def self.setup_events_symbols()
463
+ symbols = [
464
+ :SDL_PumpEvents,
465
+ :SDL_PeepEvents,
466
+ :SDL_HasEvent,
467
+ :SDL_HasEvents,
468
+ :SDL_FlushEvent,
469
+ :SDL_FlushEvents,
470
+ :SDL_PollEvent,
471
+ :SDL_WaitEvent,
472
+ :SDL_WaitEventTimeout,
473
+ :SDL_PushEvent,
474
+ :SDL_SetEventFilter,
475
+ :SDL_GetEventFilter,
476
+ :SDL_AddEventWatch,
477
+ :SDL_DelEventWatch,
478
+ :SDL_FilterEvents,
479
+ :SDL_EventState,
480
+ :SDL_RegisterEvents,
481
+ ]
482
+ args = {
483
+ :SDL_PumpEvents => [],
484
+ :SDL_PeepEvents => [:pointer, :int, :int, :uint, :uint],
485
+ :SDL_HasEvent => [:uint],
486
+ :SDL_HasEvents => [:uint, :uint],
487
+ :SDL_FlushEvent => [:uint],
488
+ :SDL_FlushEvents => [:uint, :uint],
489
+ :SDL_PollEvent => [:pointer],
490
+ :SDL_WaitEvent => [:pointer],
491
+ :SDL_WaitEventTimeout => [:pointer, :int],
492
+ :SDL_PushEvent => [:pointer],
493
+ :SDL_SetEventFilter => [:SDL_EventFilter, :pointer],
494
+ :SDL_GetEventFilter => [:pointer, :pointer],
495
+ :SDL_AddEventWatch => [:SDL_EventFilter, :pointer],
496
+ :SDL_DelEventWatch => [:SDL_EventFilter, :pointer],
497
+ :SDL_FilterEvents => [:SDL_EventFilter, :pointer],
498
+ :SDL_EventState => [:uint, :int],
499
+ :SDL_RegisterEvents => [:int],
500
+ }
501
+ retvals = {
502
+ :SDL_PumpEvents => :void,
503
+ :SDL_PeepEvents => :int,
504
+ :SDL_HasEvent => :int,
505
+ :SDL_HasEvents => :int,
506
+ :SDL_FlushEvent => :void,
507
+ :SDL_FlushEvents => :void,
508
+ :SDL_PollEvent => :int,
509
+ :SDL_WaitEvent => :int,
510
+ :SDL_WaitEventTimeout => :int,
511
+ :SDL_PushEvent => :int,
512
+ :SDL_SetEventFilter => :void,
513
+ :SDL_GetEventFilter => :int,
514
+ :SDL_AddEventWatch => :void,
515
+ :SDL_DelEventWatch => :void,
516
+ :SDL_FilterEvents => :void,
517
+ :SDL_EventState => :uchar,
518
+ :SDL_RegisterEvents => :uint,
519
+ }
520
+ symbols.each do |sym|
521
+ begin
522
+ attach_function sym, args[sym], retvals[sym]
523
+ rescue FFI::NotFoundError => error
524
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
525
+ end
526
+ end
527
+ end
528
+
529
+ end
530
+