sdl3-bindings 1.0.0.beta.1
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.
- checksums.yaml +7 -0
- data/ChangeLog +159 -0
- data/LICENSE.txt +21 -0
- data/README.md +132 -0
- data/lib/sdl3.rb +150 -0
- data/lib/sdl3_assert.rb +61 -0
- data/lib/sdl3_asyncio.rb +68 -0
- data/lib/sdl3_atomic.rb +64 -0
- data/lib/sdl3_audio.rb +120 -0
- data/lib/sdl3_bits.rb +38 -0
- data/lib/sdl3_blendmode.rb +63 -0
- data/lib/sdl3_camera.rb +67 -0
- data/lib/sdl3_clipboard.rb +49 -0
- data/lib/sdl3_cpuinfo.rb +55 -0
- data/lib/sdl3_dialog.rb +60 -0
- data/lib/sdl3_endian.rb +39 -0
- data/lib/sdl3_error.rb +41 -0
- data/lib/sdl3_events.rb +680 -0
- data/lib/sdl3_filesystem.rb +82 -0
- data/lib/sdl3_gamepad.rb +216 -0
- data/lib/sdl3_gpu.rb +836 -0
- data/lib/sdl3_guid.rb +44 -0
- data/lib/sdl3_haptic.rb +209 -0
- data/lib/sdl3_hidapi.rb +84 -0
- data/lib/sdl3_hints.rb +285 -0
- data/lib/sdl3_image.rb +108 -0
- data/lib/sdl3_init.rb +71 -0
- data/lib/sdl3_iostream.rb +115 -0
- data/lib/sdl3_joystick.rb +174 -0
- data/lib/sdl3_keyboard.rb +81 -0
- data/lib/sdl3_keycode.rb +310 -0
- data/lib/sdl3_loadso.rb +39 -0
- data/lib/sdl3_locale.rb +44 -0
- data/lib/sdl3_log.rb +85 -0
- data/lib/sdl3_messagebox.rb +88 -0
- data/lib/sdl3_misc.rb +37 -0
- data/lib/sdl3_mixer.rb +179 -0
- data/lib/sdl3_mouse.rb +90 -0
- data/lib/sdl3_mutex.rb +77 -0
- data/lib/sdl3_pen.rb +56 -0
- data/lib/sdl3_pixels.rb +296 -0
- data/lib/sdl3_platform.rb +37 -0
- data/lib/sdl3_power.rb +44 -0
- data/lib/sdl3_process.rb +65 -0
- data/lib/sdl3_properties.rb +67 -0
- data/lib/sdl3_rect.rb +98 -0
- data/lib/sdl3_render.rb +240 -0
- data/lib/sdl3_revision.rb +37 -0
- data/lib/sdl3_scancode.rb +286 -0
- data/lib/sdl3_sensor.rb +61 -0
- data/lib/sdl3_sound.rb +98 -0
- data/lib/sdl3_stdinc.rb +229 -0
- data/lib/sdl3_storage.rb +70 -0
- data/lib/sdl3_surface.rb +122 -0
- data/lib/sdl3_thread.rb +65 -0
- data/lib/sdl3_time.rb +66 -0
- data/lib/sdl3_timer.rb +54 -0
- data/lib/sdl3_touch.rb +56 -0
- data/lib/sdl3_tray.rb +66 -0
- data/lib/sdl3_ttf.rb +216 -0
- data/lib/sdl3_version.rb +41 -0
- data/lib/sdl3_video.rb +341 -0
- data/lib/sdl3_vulkan.rb +46 -0
- metadata +118 -0
data/lib/sdl3_events.rb
ADDED
|
@@ -0,0 +1,680 @@
|
|
|
1
|
+
# Ruby-SDL3 : SDL3 wrapper for Ruby
|
|
2
|
+
#
|
|
3
|
+
# * https://github.com/vaiorabbit/sdl3-bindings
|
|
4
|
+
#
|
|
5
|
+
# [NOTICE] Autogenerated. Do not edit.
|
|
6
|
+
|
|
7
|
+
require 'ffi'
|
|
8
|
+
|
|
9
|
+
module SDL
|
|
10
|
+
extend FFI::Library
|
|
11
|
+
# Define/Macro
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# Enum
|
|
15
|
+
|
|
16
|
+
EVENT_FIRST = 0
|
|
17
|
+
EVENT_QUIT = 256
|
|
18
|
+
EVENT_TERMINATING = 257
|
|
19
|
+
EVENT_LOW_MEMORY = 258
|
|
20
|
+
EVENT_WILL_ENTER_BACKGROUND = 259
|
|
21
|
+
EVENT_DID_ENTER_BACKGROUND = 260
|
|
22
|
+
EVENT_WILL_ENTER_FOREGROUND = 261
|
|
23
|
+
EVENT_DID_ENTER_FOREGROUND = 262
|
|
24
|
+
EVENT_LOCALE_CHANGED = 263
|
|
25
|
+
EVENT_SYSTEM_THEME_CHANGED = 264
|
|
26
|
+
EVENT_DISPLAY_ORIENTATION = 337
|
|
27
|
+
EVENT_DISPLAY_ADDED = 338
|
|
28
|
+
EVENT_DISPLAY_REMOVED = 339
|
|
29
|
+
EVENT_DISPLAY_MOVED = 340
|
|
30
|
+
EVENT_DISPLAY_DESKTOP_MODE_CHANGED = 341
|
|
31
|
+
EVENT_DISPLAY_CURRENT_MODE_CHANGED = 342
|
|
32
|
+
EVENT_DISPLAY_CONTENT_SCALE_CHANGED = 343
|
|
33
|
+
EVENT_DISPLAY_FIRST = 337
|
|
34
|
+
EVENT_DISPLAY_LAST = 343
|
|
35
|
+
EVENT_WINDOW_SHOWN = 514
|
|
36
|
+
EVENT_WINDOW_HIDDEN = 515
|
|
37
|
+
EVENT_WINDOW_EXPOSED = 516
|
|
38
|
+
EVENT_WINDOW_MOVED = 517
|
|
39
|
+
EVENT_WINDOW_RESIZED = 518
|
|
40
|
+
EVENT_WINDOW_PIXEL_SIZE_CHANGED = 519
|
|
41
|
+
EVENT_WINDOW_METAL_VIEW_RESIZED = 520
|
|
42
|
+
EVENT_WINDOW_MINIMIZED = 521
|
|
43
|
+
EVENT_WINDOW_MAXIMIZED = 522
|
|
44
|
+
EVENT_WINDOW_RESTORED = 523
|
|
45
|
+
EVENT_WINDOW_MOUSE_ENTER = 524
|
|
46
|
+
EVENT_WINDOW_MOUSE_LEAVE = 525
|
|
47
|
+
EVENT_WINDOW_FOCUS_GAINED = 526
|
|
48
|
+
EVENT_WINDOW_FOCUS_LOST = 527
|
|
49
|
+
EVENT_WINDOW_CLOSE_REQUESTED = 528
|
|
50
|
+
EVENT_WINDOW_HIT_TEST = 529
|
|
51
|
+
EVENT_WINDOW_ICCPROF_CHANGED = 530
|
|
52
|
+
EVENT_WINDOW_DISPLAY_CHANGED = 531
|
|
53
|
+
EVENT_WINDOW_DISPLAY_SCALE_CHANGED = 532
|
|
54
|
+
EVENT_WINDOW_SAFE_AREA_CHANGED = 533
|
|
55
|
+
EVENT_WINDOW_OCCLUDED = 534
|
|
56
|
+
EVENT_WINDOW_ENTER_FULLSCREEN = 535
|
|
57
|
+
EVENT_WINDOW_LEAVE_FULLSCREEN = 536
|
|
58
|
+
EVENT_WINDOW_DESTROYED = 537
|
|
59
|
+
EVENT_WINDOW_HDR_STATE_CHANGED = 538
|
|
60
|
+
EVENT_WINDOW_FIRST = 514
|
|
61
|
+
EVENT_WINDOW_LAST = 538
|
|
62
|
+
EVENT_KEY_DOWN = 768
|
|
63
|
+
EVENT_KEY_UP = 769
|
|
64
|
+
EVENT_TEXT_EDITING = 770
|
|
65
|
+
EVENT_TEXT_INPUT = 771
|
|
66
|
+
EVENT_KEYMAP_CHANGED = 772
|
|
67
|
+
EVENT_KEYBOARD_ADDED = 773
|
|
68
|
+
EVENT_KEYBOARD_REMOVED = 774
|
|
69
|
+
EVENT_TEXT_EDITING_CANDIDATES = 775
|
|
70
|
+
EVENT_MOUSE_MOTION = 1024
|
|
71
|
+
EVENT_MOUSE_BUTTON_DOWN = 1025
|
|
72
|
+
EVENT_MOUSE_BUTTON_UP = 1026
|
|
73
|
+
EVENT_MOUSE_WHEEL = 1027
|
|
74
|
+
EVENT_MOUSE_ADDED = 1028
|
|
75
|
+
EVENT_MOUSE_REMOVED = 1029
|
|
76
|
+
EVENT_JOYSTICK_AXIS_MOTION = 1536
|
|
77
|
+
EVENT_JOYSTICK_BALL_MOTION = 1537
|
|
78
|
+
EVENT_JOYSTICK_HAT_MOTION = 1538
|
|
79
|
+
EVENT_JOYSTICK_BUTTON_DOWN = 1539
|
|
80
|
+
EVENT_JOYSTICK_BUTTON_UP = 1540
|
|
81
|
+
EVENT_JOYSTICK_ADDED = 1541
|
|
82
|
+
EVENT_JOYSTICK_REMOVED = 1542
|
|
83
|
+
EVENT_JOYSTICK_BATTERY_UPDATED = 1543
|
|
84
|
+
EVENT_JOYSTICK_UPDATE_COMPLETE = 1544
|
|
85
|
+
EVENT_GAMEPAD_AXIS_MOTION = 1616
|
|
86
|
+
EVENT_GAMEPAD_BUTTON_DOWN = 1617
|
|
87
|
+
EVENT_GAMEPAD_BUTTON_UP = 1618
|
|
88
|
+
EVENT_GAMEPAD_ADDED = 1619
|
|
89
|
+
EVENT_GAMEPAD_REMOVED = 1620
|
|
90
|
+
EVENT_GAMEPAD_REMAPPED = 1621
|
|
91
|
+
EVENT_GAMEPAD_TOUCHPAD_DOWN = 1622
|
|
92
|
+
EVENT_GAMEPAD_TOUCHPAD_MOTION = 1623
|
|
93
|
+
EVENT_GAMEPAD_TOUCHPAD_UP = 1624
|
|
94
|
+
EVENT_GAMEPAD_SENSOR_UPDATE = 1625
|
|
95
|
+
EVENT_GAMEPAD_UPDATE_COMPLETE = 1626
|
|
96
|
+
EVENT_GAMEPAD_STEAM_HANDLE_UPDATED = 1627
|
|
97
|
+
EVENT_FINGER_DOWN = 1792
|
|
98
|
+
EVENT_FINGER_UP = 1793
|
|
99
|
+
EVENT_FINGER_MOTION = 1794
|
|
100
|
+
EVENT_FINGER_CANCELED = 1795
|
|
101
|
+
EVENT_CLIPBOARD_UPDATE = 2304
|
|
102
|
+
EVENT_DROP_FILE = 4096
|
|
103
|
+
EVENT_DROP_TEXT = 4097
|
|
104
|
+
EVENT_DROP_BEGIN = 4098
|
|
105
|
+
EVENT_DROP_COMPLETE = 4099
|
|
106
|
+
EVENT_DROP_POSITION = 4100
|
|
107
|
+
EVENT_AUDIO_DEVICE_ADDED = 4352
|
|
108
|
+
EVENT_AUDIO_DEVICE_REMOVED = 4353
|
|
109
|
+
EVENT_AUDIO_DEVICE_FORMAT_CHANGED = 4354
|
|
110
|
+
EVENT_SENSOR_UPDATE = 4608
|
|
111
|
+
EVENT_PEN_PROXIMITY_IN = 4864
|
|
112
|
+
EVENT_PEN_PROXIMITY_OUT = 4865
|
|
113
|
+
EVENT_PEN_DOWN = 4866
|
|
114
|
+
EVENT_PEN_UP = 4867
|
|
115
|
+
EVENT_PEN_BUTTON_DOWN = 4868
|
|
116
|
+
EVENT_PEN_BUTTON_UP = 4869
|
|
117
|
+
EVENT_PEN_MOTION = 4870
|
|
118
|
+
EVENT_PEN_AXIS = 4871
|
|
119
|
+
EVENT_CAMERA_DEVICE_ADDED = 5120
|
|
120
|
+
EVENT_CAMERA_DEVICE_REMOVED = 5121
|
|
121
|
+
EVENT_CAMERA_DEVICE_APPROVED = 5122
|
|
122
|
+
EVENT_CAMERA_DEVICE_DENIED = 5123
|
|
123
|
+
EVENT_RENDER_TARGETS_RESET = 8192
|
|
124
|
+
EVENT_RENDER_DEVICE_RESET = 8193
|
|
125
|
+
EVENT_RENDER_DEVICE_LOST = 8194
|
|
126
|
+
EVENT_PRIVATE0 = 16384
|
|
127
|
+
EVENT_PRIVATE1 = 16385
|
|
128
|
+
EVENT_PRIVATE2 = 16386
|
|
129
|
+
EVENT_PRIVATE3 = 16387
|
|
130
|
+
EVENT_POLL_SENTINEL = 32512
|
|
131
|
+
EVENT_USER = 32768
|
|
132
|
+
EVENT_LAST = 65535
|
|
133
|
+
EVENT_ENUM_PADDING = 2147483647
|
|
134
|
+
ADDEVENT = 0
|
|
135
|
+
PEEKEVENT = 1
|
|
136
|
+
GETEVENT = 2
|
|
137
|
+
|
|
138
|
+
# Typedef
|
|
139
|
+
|
|
140
|
+
typedef :int, :SDL_EventType
|
|
141
|
+
typedef :int, :SDL_EventAction
|
|
142
|
+
callback :SDL_EventFilter, [:pointer, :pointer], :bool
|
|
143
|
+
|
|
144
|
+
# Struct
|
|
145
|
+
|
|
146
|
+
class CommonEvent < FFI::Struct
|
|
147
|
+
layout(
|
|
148
|
+
:type, :uint,
|
|
149
|
+
:reserved, :uint,
|
|
150
|
+
:timestamp, :ulong_long,
|
|
151
|
+
)
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
class DisplayEvent < FFI::Struct
|
|
155
|
+
layout(
|
|
156
|
+
:type, :int,
|
|
157
|
+
:reserved, :uint,
|
|
158
|
+
:timestamp, :ulong_long,
|
|
159
|
+
:displayID, :uint,
|
|
160
|
+
:data1, :int,
|
|
161
|
+
:data2, :int,
|
|
162
|
+
)
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
class WindowEvent < FFI::Struct
|
|
166
|
+
layout(
|
|
167
|
+
:type, :int,
|
|
168
|
+
:reserved, :uint,
|
|
169
|
+
:timestamp, :ulong_long,
|
|
170
|
+
:windowID, :uint,
|
|
171
|
+
:data1, :int,
|
|
172
|
+
:data2, :int,
|
|
173
|
+
)
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
class KeyboardDeviceEvent < FFI::Struct
|
|
177
|
+
layout(
|
|
178
|
+
:type, :int,
|
|
179
|
+
:reserved, :uint,
|
|
180
|
+
:timestamp, :ulong_long,
|
|
181
|
+
:which, :uint,
|
|
182
|
+
)
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
class KeyboardEvent < FFI::Struct
|
|
186
|
+
layout(
|
|
187
|
+
:type, :int,
|
|
188
|
+
:reserved, :uint,
|
|
189
|
+
:timestamp, :ulong_long,
|
|
190
|
+
:windowID, :uint,
|
|
191
|
+
:which, :uint,
|
|
192
|
+
:scancode, :int,
|
|
193
|
+
:key, :uint,
|
|
194
|
+
:mod, :ushort,
|
|
195
|
+
:raw, :ushort,
|
|
196
|
+
:down, :bool,
|
|
197
|
+
:repeat, :bool,
|
|
198
|
+
)
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
class TextEditingEvent < FFI::Struct
|
|
202
|
+
layout(
|
|
203
|
+
:type, :int,
|
|
204
|
+
:reserved, :uint,
|
|
205
|
+
:timestamp, :ulong_long,
|
|
206
|
+
:windowID, :uint,
|
|
207
|
+
:text, :pointer,
|
|
208
|
+
:start, :int,
|
|
209
|
+
:length, :int,
|
|
210
|
+
)
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
class TextEditingCandidatesEvent < FFI::Struct
|
|
214
|
+
layout(
|
|
215
|
+
:type, :int,
|
|
216
|
+
:reserved, :uint,
|
|
217
|
+
:timestamp, :ulong_long,
|
|
218
|
+
:windowID, :uint,
|
|
219
|
+
:candidates, :pointer,
|
|
220
|
+
:num_candidates, :int,
|
|
221
|
+
:selected_candidate, :int,
|
|
222
|
+
:horizontal, :bool,
|
|
223
|
+
:padding1, :uchar,
|
|
224
|
+
:padding2, :uchar,
|
|
225
|
+
:padding3, :uchar,
|
|
226
|
+
)
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
class TextInputEvent < FFI::Struct
|
|
230
|
+
layout(
|
|
231
|
+
:type, :int,
|
|
232
|
+
:reserved, :uint,
|
|
233
|
+
:timestamp, :ulong_long,
|
|
234
|
+
:windowID, :uint,
|
|
235
|
+
:text, :pointer,
|
|
236
|
+
)
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
class MouseDeviceEvent < FFI::Struct
|
|
240
|
+
layout(
|
|
241
|
+
:type, :int,
|
|
242
|
+
:reserved, :uint,
|
|
243
|
+
:timestamp, :ulong_long,
|
|
244
|
+
:which, :uint,
|
|
245
|
+
)
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
class MouseMotionEvent < FFI::Struct
|
|
249
|
+
layout(
|
|
250
|
+
:type, :int,
|
|
251
|
+
:reserved, :uint,
|
|
252
|
+
:timestamp, :ulong_long,
|
|
253
|
+
:windowID, :uint,
|
|
254
|
+
:which, :uint,
|
|
255
|
+
:state, :uint,
|
|
256
|
+
:x, :float,
|
|
257
|
+
:y, :float,
|
|
258
|
+
:xrel, :float,
|
|
259
|
+
:yrel, :float,
|
|
260
|
+
)
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
class MouseButtonEvent < FFI::Struct
|
|
264
|
+
layout(
|
|
265
|
+
:type, :int,
|
|
266
|
+
:reserved, :uint,
|
|
267
|
+
:timestamp, :ulong_long,
|
|
268
|
+
:windowID, :uint,
|
|
269
|
+
:which, :uint,
|
|
270
|
+
:button, :uchar,
|
|
271
|
+
:down, :bool,
|
|
272
|
+
:clicks, :uchar,
|
|
273
|
+
:padding, :uchar,
|
|
274
|
+
:x, :float,
|
|
275
|
+
:y, :float,
|
|
276
|
+
)
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
class MouseWheelEvent < FFI::Struct
|
|
280
|
+
layout(
|
|
281
|
+
:type, :int,
|
|
282
|
+
:reserved, :uint,
|
|
283
|
+
:timestamp, :ulong_long,
|
|
284
|
+
:windowID, :uint,
|
|
285
|
+
:which, :uint,
|
|
286
|
+
:x, :float,
|
|
287
|
+
:y, :float,
|
|
288
|
+
:direction, :int,
|
|
289
|
+
:mouse_x, :float,
|
|
290
|
+
:mouse_y, :float,
|
|
291
|
+
)
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
class JoyAxisEvent < FFI::Struct
|
|
295
|
+
layout(
|
|
296
|
+
:type, :int,
|
|
297
|
+
:reserved, :uint,
|
|
298
|
+
:timestamp, :ulong_long,
|
|
299
|
+
:which, :uint,
|
|
300
|
+
:axis, :uchar,
|
|
301
|
+
:padding1, :uchar,
|
|
302
|
+
:padding2, :uchar,
|
|
303
|
+
:padding3, :uchar,
|
|
304
|
+
:value, :short,
|
|
305
|
+
:padding4, :ushort,
|
|
306
|
+
)
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
class JoyBallEvent < FFI::Struct
|
|
310
|
+
layout(
|
|
311
|
+
:type, :int,
|
|
312
|
+
:reserved, :uint,
|
|
313
|
+
:timestamp, :ulong_long,
|
|
314
|
+
:which, :uint,
|
|
315
|
+
:ball, :uchar,
|
|
316
|
+
:padding1, :uchar,
|
|
317
|
+
:padding2, :uchar,
|
|
318
|
+
:padding3, :uchar,
|
|
319
|
+
:xrel, :short,
|
|
320
|
+
:yrel, :short,
|
|
321
|
+
)
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
class JoyHatEvent < FFI::Struct
|
|
325
|
+
layout(
|
|
326
|
+
:type, :int,
|
|
327
|
+
:reserved, :uint,
|
|
328
|
+
:timestamp, :ulong_long,
|
|
329
|
+
:which, :uint,
|
|
330
|
+
:hat, :uchar,
|
|
331
|
+
:value, :uchar,
|
|
332
|
+
:padding1, :uchar,
|
|
333
|
+
:padding2, :uchar,
|
|
334
|
+
)
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
class JoyButtonEvent < FFI::Struct
|
|
338
|
+
layout(
|
|
339
|
+
:type, :int,
|
|
340
|
+
:reserved, :uint,
|
|
341
|
+
:timestamp, :ulong_long,
|
|
342
|
+
:which, :uint,
|
|
343
|
+
:button, :uchar,
|
|
344
|
+
:down, :bool,
|
|
345
|
+
:padding1, :uchar,
|
|
346
|
+
:padding2, :uchar,
|
|
347
|
+
)
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
class JoyDeviceEvent < FFI::Struct
|
|
351
|
+
layout(
|
|
352
|
+
:type, :int,
|
|
353
|
+
:reserved, :uint,
|
|
354
|
+
:timestamp, :ulong_long,
|
|
355
|
+
:which, :uint,
|
|
356
|
+
)
|
|
357
|
+
end
|
|
358
|
+
|
|
359
|
+
class JoyBatteryEvent < FFI::Struct
|
|
360
|
+
layout(
|
|
361
|
+
:type, :int,
|
|
362
|
+
:reserved, :uint,
|
|
363
|
+
:timestamp, :ulong_long,
|
|
364
|
+
:which, :uint,
|
|
365
|
+
:state, :int,
|
|
366
|
+
:percent, :int,
|
|
367
|
+
)
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
class GamepadAxisEvent < FFI::Struct
|
|
371
|
+
layout(
|
|
372
|
+
:type, :int,
|
|
373
|
+
:reserved, :uint,
|
|
374
|
+
:timestamp, :ulong_long,
|
|
375
|
+
:which, :uint,
|
|
376
|
+
:axis, :uchar,
|
|
377
|
+
:padding1, :uchar,
|
|
378
|
+
:padding2, :uchar,
|
|
379
|
+
:padding3, :uchar,
|
|
380
|
+
:value, :short,
|
|
381
|
+
:padding4, :ushort,
|
|
382
|
+
)
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
class GamepadButtonEvent < FFI::Struct
|
|
386
|
+
layout(
|
|
387
|
+
:type, :int,
|
|
388
|
+
:reserved, :uint,
|
|
389
|
+
:timestamp, :ulong_long,
|
|
390
|
+
:which, :uint,
|
|
391
|
+
:button, :uchar,
|
|
392
|
+
:down, :bool,
|
|
393
|
+
:padding1, :uchar,
|
|
394
|
+
:padding2, :uchar,
|
|
395
|
+
)
|
|
396
|
+
end
|
|
397
|
+
|
|
398
|
+
class GamepadDeviceEvent < FFI::Struct
|
|
399
|
+
layout(
|
|
400
|
+
:type, :int,
|
|
401
|
+
:reserved, :uint,
|
|
402
|
+
:timestamp, :ulong_long,
|
|
403
|
+
:which, :uint,
|
|
404
|
+
)
|
|
405
|
+
end
|
|
406
|
+
|
|
407
|
+
class GamepadTouchpadEvent < FFI::Struct
|
|
408
|
+
layout(
|
|
409
|
+
:type, :int,
|
|
410
|
+
:reserved, :uint,
|
|
411
|
+
:timestamp, :ulong_long,
|
|
412
|
+
:which, :uint,
|
|
413
|
+
:touchpad, :int,
|
|
414
|
+
:finger, :int,
|
|
415
|
+
:x, :float,
|
|
416
|
+
:y, :float,
|
|
417
|
+
:pressure, :float,
|
|
418
|
+
)
|
|
419
|
+
end
|
|
420
|
+
|
|
421
|
+
class GamepadSensorEvent < FFI::Struct
|
|
422
|
+
layout(
|
|
423
|
+
:type, :int,
|
|
424
|
+
:reserved, :uint,
|
|
425
|
+
:timestamp, :ulong_long,
|
|
426
|
+
:which, :uint,
|
|
427
|
+
:sensor, :int,
|
|
428
|
+
:data, [:float, 3],
|
|
429
|
+
:sensor_timestamp, :ulong_long,
|
|
430
|
+
)
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
class AudioDeviceEvent < FFI::Struct
|
|
434
|
+
layout(
|
|
435
|
+
:type, :int,
|
|
436
|
+
:reserved, :uint,
|
|
437
|
+
:timestamp, :ulong_long,
|
|
438
|
+
:which, :uint,
|
|
439
|
+
:recording, :bool,
|
|
440
|
+
:padding1, :uchar,
|
|
441
|
+
:padding2, :uchar,
|
|
442
|
+
:padding3, :uchar,
|
|
443
|
+
)
|
|
444
|
+
end
|
|
445
|
+
|
|
446
|
+
class CameraDeviceEvent < FFI::Struct
|
|
447
|
+
layout(
|
|
448
|
+
:type, :int,
|
|
449
|
+
:reserved, :uint,
|
|
450
|
+
:timestamp, :ulong_long,
|
|
451
|
+
:which, :uint,
|
|
452
|
+
)
|
|
453
|
+
end
|
|
454
|
+
|
|
455
|
+
class RenderEvent < FFI::Struct
|
|
456
|
+
layout(
|
|
457
|
+
:type, :int,
|
|
458
|
+
:reserved, :uint,
|
|
459
|
+
:timestamp, :ulong_long,
|
|
460
|
+
:windowID, :uint,
|
|
461
|
+
)
|
|
462
|
+
end
|
|
463
|
+
|
|
464
|
+
class TouchFingerEvent < FFI::Struct
|
|
465
|
+
layout(
|
|
466
|
+
:type, :int,
|
|
467
|
+
:reserved, :uint,
|
|
468
|
+
:timestamp, :ulong_long,
|
|
469
|
+
:touchID, :ulong_long,
|
|
470
|
+
:fingerID, :ulong_long,
|
|
471
|
+
:x, :float,
|
|
472
|
+
:y, :float,
|
|
473
|
+
:dx, :float,
|
|
474
|
+
:dy, :float,
|
|
475
|
+
:pressure, :float,
|
|
476
|
+
:windowID, :uint,
|
|
477
|
+
)
|
|
478
|
+
end
|
|
479
|
+
|
|
480
|
+
class PenProximityEvent < FFI::Struct
|
|
481
|
+
layout(
|
|
482
|
+
:type, :int,
|
|
483
|
+
:reserved, :uint,
|
|
484
|
+
:timestamp, :ulong_long,
|
|
485
|
+
:windowID, :uint,
|
|
486
|
+
:which, :uint,
|
|
487
|
+
)
|
|
488
|
+
end
|
|
489
|
+
|
|
490
|
+
class PenMotionEvent < FFI::Struct
|
|
491
|
+
layout(
|
|
492
|
+
:type, :int,
|
|
493
|
+
:reserved, :uint,
|
|
494
|
+
:timestamp, :ulong_long,
|
|
495
|
+
:windowID, :uint,
|
|
496
|
+
:which, :uint,
|
|
497
|
+
:pen_state, :uint,
|
|
498
|
+
:x, :float,
|
|
499
|
+
:y, :float,
|
|
500
|
+
)
|
|
501
|
+
end
|
|
502
|
+
|
|
503
|
+
class PenTouchEvent < FFI::Struct
|
|
504
|
+
layout(
|
|
505
|
+
:type, :int,
|
|
506
|
+
:reserved, :uint,
|
|
507
|
+
:timestamp, :ulong_long,
|
|
508
|
+
:windowID, :uint,
|
|
509
|
+
:which, :uint,
|
|
510
|
+
:pen_state, :uint,
|
|
511
|
+
:x, :float,
|
|
512
|
+
:y, :float,
|
|
513
|
+
:eraser, :bool,
|
|
514
|
+
:down, :bool,
|
|
515
|
+
)
|
|
516
|
+
end
|
|
517
|
+
|
|
518
|
+
class PenButtonEvent < FFI::Struct
|
|
519
|
+
layout(
|
|
520
|
+
:type, :int,
|
|
521
|
+
:reserved, :uint,
|
|
522
|
+
:timestamp, :ulong_long,
|
|
523
|
+
:windowID, :uint,
|
|
524
|
+
:which, :uint,
|
|
525
|
+
:pen_state, :uint,
|
|
526
|
+
:x, :float,
|
|
527
|
+
:y, :float,
|
|
528
|
+
:button, :uchar,
|
|
529
|
+
:down, :bool,
|
|
530
|
+
)
|
|
531
|
+
end
|
|
532
|
+
|
|
533
|
+
class PenAxisEvent < FFI::Struct
|
|
534
|
+
layout(
|
|
535
|
+
:type, :int,
|
|
536
|
+
:reserved, :uint,
|
|
537
|
+
:timestamp, :ulong_long,
|
|
538
|
+
:windowID, :uint,
|
|
539
|
+
:which, :uint,
|
|
540
|
+
:pen_state, :uint,
|
|
541
|
+
:x, :float,
|
|
542
|
+
:y, :float,
|
|
543
|
+
:axis, :int,
|
|
544
|
+
:value, :float,
|
|
545
|
+
)
|
|
546
|
+
end
|
|
547
|
+
|
|
548
|
+
class DropEvent < FFI::Struct
|
|
549
|
+
layout(
|
|
550
|
+
:type, :int,
|
|
551
|
+
:reserved, :uint,
|
|
552
|
+
:timestamp, :ulong_long,
|
|
553
|
+
:windowID, :uint,
|
|
554
|
+
:x, :float,
|
|
555
|
+
:y, :float,
|
|
556
|
+
:source, :pointer,
|
|
557
|
+
:data, :pointer,
|
|
558
|
+
)
|
|
559
|
+
end
|
|
560
|
+
|
|
561
|
+
class ClipboardEvent < FFI::Struct
|
|
562
|
+
layout(
|
|
563
|
+
:type, :int,
|
|
564
|
+
:reserved, :uint,
|
|
565
|
+
:timestamp, :ulong_long,
|
|
566
|
+
:owner, :bool,
|
|
567
|
+
:num_mime_types, :int,
|
|
568
|
+
:mime_types, :pointer,
|
|
569
|
+
)
|
|
570
|
+
end
|
|
571
|
+
|
|
572
|
+
class SensorEvent < FFI::Struct
|
|
573
|
+
layout(
|
|
574
|
+
:type, :int,
|
|
575
|
+
:reserved, :uint,
|
|
576
|
+
:timestamp, :ulong_long,
|
|
577
|
+
:which, :uint,
|
|
578
|
+
:data, [:float, 6],
|
|
579
|
+
:sensor_timestamp, :ulong_long,
|
|
580
|
+
)
|
|
581
|
+
end
|
|
582
|
+
|
|
583
|
+
class QuitEvent < FFI::Struct
|
|
584
|
+
layout(
|
|
585
|
+
:type, :int,
|
|
586
|
+
:reserved, :uint,
|
|
587
|
+
:timestamp, :ulong_long,
|
|
588
|
+
)
|
|
589
|
+
end
|
|
590
|
+
|
|
591
|
+
class UserEvent < FFI::Struct
|
|
592
|
+
layout(
|
|
593
|
+
:type, :uint,
|
|
594
|
+
:reserved, :uint,
|
|
595
|
+
:timestamp, :ulong_long,
|
|
596
|
+
:windowID, :uint,
|
|
597
|
+
:code, :int,
|
|
598
|
+
:data1, :pointer,
|
|
599
|
+
:data2, :pointer,
|
|
600
|
+
)
|
|
601
|
+
end
|
|
602
|
+
|
|
603
|
+
class Event < FFI::Union
|
|
604
|
+
layout(
|
|
605
|
+
:type, :uint,
|
|
606
|
+
:common, CommonEvent,
|
|
607
|
+
:display, DisplayEvent,
|
|
608
|
+
:window, WindowEvent,
|
|
609
|
+
:kdevice, KeyboardDeviceEvent,
|
|
610
|
+
:key, KeyboardEvent,
|
|
611
|
+
:edit, TextEditingEvent,
|
|
612
|
+
:edit_candidates, TextEditingCandidatesEvent,
|
|
613
|
+
:text, TextInputEvent,
|
|
614
|
+
:mdevice, MouseDeviceEvent,
|
|
615
|
+
:motion, MouseMotionEvent,
|
|
616
|
+
:button, MouseButtonEvent,
|
|
617
|
+
:wheel, MouseWheelEvent,
|
|
618
|
+
:jdevice, JoyDeviceEvent,
|
|
619
|
+
:jaxis, JoyAxisEvent,
|
|
620
|
+
:jball, JoyBallEvent,
|
|
621
|
+
:jhat, JoyHatEvent,
|
|
622
|
+
:jbutton, JoyButtonEvent,
|
|
623
|
+
:jbattery, JoyBatteryEvent,
|
|
624
|
+
:gdevice, GamepadDeviceEvent,
|
|
625
|
+
:gaxis, GamepadAxisEvent,
|
|
626
|
+
:gbutton, GamepadButtonEvent,
|
|
627
|
+
:gtouchpad, GamepadTouchpadEvent,
|
|
628
|
+
:gsensor, GamepadSensorEvent,
|
|
629
|
+
:adevice, AudioDeviceEvent,
|
|
630
|
+
:cdevice, CameraDeviceEvent,
|
|
631
|
+
:sensor, SensorEvent,
|
|
632
|
+
:quit, QuitEvent,
|
|
633
|
+
:user, UserEvent,
|
|
634
|
+
:tfinger, TouchFingerEvent,
|
|
635
|
+
:pproximity, PenProximityEvent,
|
|
636
|
+
:ptouch, PenTouchEvent,
|
|
637
|
+
:pmotion, PenMotionEvent,
|
|
638
|
+
:pbutton, PenButtonEvent,
|
|
639
|
+
:paxis, PenAxisEvent,
|
|
640
|
+
:render, RenderEvent,
|
|
641
|
+
:drop, DropEvent,
|
|
642
|
+
:clipboard, ClipboardEvent,
|
|
643
|
+
:padding, [:uchar, 128],
|
|
644
|
+
)
|
|
645
|
+
end
|
|
646
|
+
|
|
647
|
+
|
|
648
|
+
# Function
|
|
649
|
+
|
|
650
|
+
def self.setup_events_symbols(output_error = false)
|
|
651
|
+
entries = [
|
|
652
|
+
[:PumpEvents, :SDL_PumpEvents, [], :void],
|
|
653
|
+
[:PeepEvents, :SDL_PeepEvents, [:pointer, :int, :int, :uint, :uint], :int],
|
|
654
|
+
[:HasEvent, :SDL_HasEvent, [:uint], :bool],
|
|
655
|
+
[:HasEvents, :SDL_HasEvents, [:uint, :uint], :bool],
|
|
656
|
+
[:FlushEvent, :SDL_FlushEvent, [:uint], :void],
|
|
657
|
+
[:FlushEvents, :SDL_FlushEvents, [:uint, :uint], :void],
|
|
658
|
+
[:PollEvent, :SDL_PollEvent, [:pointer], :bool],
|
|
659
|
+
[:WaitEvent, :SDL_WaitEvent, [:pointer], :bool],
|
|
660
|
+
[:WaitEventTimeout, :SDL_WaitEventTimeout, [:pointer, :int], :bool],
|
|
661
|
+
[:PushEvent, :SDL_PushEvent, [:pointer], :bool],
|
|
662
|
+
[:SetEventFilter, :SDL_SetEventFilter, [:SDL_EventFilter, :pointer], :void],
|
|
663
|
+
[:GetEventFilter, :SDL_GetEventFilter, [:pointer, :pointer], :bool],
|
|
664
|
+
[:AddEventWatch, :SDL_AddEventWatch, [:SDL_EventFilter, :pointer], :bool],
|
|
665
|
+
[:RemoveEventWatch, :SDL_RemoveEventWatch, [:SDL_EventFilter, :pointer], :void],
|
|
666
|
+
[:FilterEvents, :SDL_FilterEvents, [:SDL_EventFilter, :pointer], :void],
|
|
667
|
+
[:SetEventEnabled, :SDL_SetEventEnabled, [:uint, :bool], :void],
|
|
668
|
+
[:EventEnabled, :SDL_EventEnabled, [:uint], :bool],
|
|
669
|
+
[:RegisterEvents, :SDL_RegisterEvents, [:int], :uint],
|
|
670
|
+
[:GetWindowFromEvent, :SDL_GetWindowFromEvent, [:pointer], :pointer],
|
|
671
|
+
]
|
|
672
|
+
entries.each do |entry|
|
|
673
|
+
attach_function entry[0], entry[1], entry[2], entry[3]
|
|
674
|
+
rescue FFI::NotFoundError => e
|
|
675
|
+
warn "[Warning] Failed to import #{entry[0]} (#{e})." if output_error
|
|
676
|
+
end
|
|
677
|
+
end
|
|
678
|
+
|
|
679
|
+
end
|
|
680
|
+
|