sdl2-bindings 0.0.8 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +124 -92
- data/LICENSE.txt +1 -1
- data/README.md +77 -53
- data/lib/sdl2.rb +131 -172
- data/lib/sdl2_audio.rb +261 -222
- data/lib/sdl2_blendmode.rb +72 -69
- data/lib/sdl2_clipboard.rb +56 -51
- data/lib/sdl2_cpuinfo.rb +129 -106
- data/lib/sdl2_error.rb +71 -64
- data/lib/sdl2_events.rb +564 -533
- data/lib/sdl2_filesystem.rb +52 -48
- data/lib/sdl2_framerate.rb +74 -67
- data/lib/sdl2_gamecontroller.rb +329 -274
- data/lib/sdl2_gesture.rb +61 -55
- data/lib/sdl2_gfxPrimitives.rb +283 -222
- data/lib/sdl2_haptic.rb +301 -269
- data/lib/sdl2_hidapi.rb +139 -118
- data/lib/sdl2_hints.rb +221 -197
- data/lib/sdl2_image.rb +232 -185
- data/lib/sdl2_imageFilter.rb +164 -132
- data/lib/sdl2_joystick.rb +294 -239
- data/lib/sdl2_keyboard.rb +125 -99
- data/lib/sdl2_keycode.rb +307 -305
- data/lib/sdl2_log.rb +131 -115
- data/lib/sdl2_main.rb +74 -67
- data/lib/sdl2_messagebox.rb +102 -98
- data/lib/sdl2_misc.rb +48 -45
- data/lib/sdl2_mixer.rb +392 -317
- data/lib/sdl2_mouse.rb +136 -117
- data/lib/sdl2_pixels.rb +240 -224
- data/lib/sdl2_platform.rb +48 -45
- data/lib/sdl2_power.rb +54 -51
- data/lib/sdl2_rect.rb +145 -102
- data/lib/sdl2_render.rb +408 -322
- data/lib/sdl2_rotozoom.rb +76 -66
- data/lib/sdl2_rwops.rb +238 -208
- data/lib/sdl2_scancode.rb +289 -287
- data/lib/sdl2_sensor.rb +115 -97
- data/lib/sdl2_shape.rb +83 -77
- data/lib/sdl2_sound.rb +154 -0
- data/lib/sdl2_stdinc.rb +556 -439
- data/lib/sdl2_surface.rb +229 -188
- data/lib/sdl2_syswm.rb +160 -156
- data/lib/sdl2_timer.rb +74 -65
- data/lib/sdl2_touch.rb +86 -75
- data/lib/sdl2_ttf.rb +358 -202
- data/lib/sdl2_version.rb +67 -62
- data/lib/sdl2_video.rb +540 -446
- data/lib/sdl2_vulkan.rb +72 -64
- metadata +19 -4
data/lib/sdl2_events.rb
CHANGED
@@ -1,533 +1,564 @@
|
|
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
|
11
|
-
extend FFI::Library
|
12
|
-
# Define/Macro
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
# Enum
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
typedef :int, :
|
90
|
-
typedef :int, :SDL_eventaction
|
91
|
-
callback :SDL_EventFilter, [:pointer, :pointer], :int
|
92
|
-
|
93
|
-
# Struct
|
94
|
-
|
95
|
-
class
|
96
|
-
layout(
|
97
|
-
:type, :uint,
|
98
|
-
:timestamp, :uint,
|
99
|
-
)
|
100
|
-
end
|
101
|
-
|
102
|
-
class
|
103
|
-
layout(
|
104
|
-
:type, :uint,
|
105
|
-
:timestamp, :uint,
|
106
|
-
:display, :uint,
|
107
|
-
:event, :uchar,
|
108
|
-
:padding1, :uchar,
|
109
|
-
:padding2, :uchar,
|
110
|
-
:padding3, :uchar,
|
111
|
-
:data1, :int,
|
112
|
-
)
|
113
|
-
end
|
114
|
-
|
115
|
-
class
|
116
|
-
layout(
|
117
|
-
:type, :uint,
|
118
|
-
:timestamp, :uint,
|
119
|
-
:windowID, :uint,
|
120
|
-
:event, :uchar,
|
121
|
-
:padding1, :uchar,
|
122
|
-
:padding2, :uchar,
|
123
|
-
:padding3, :uchar,
|
124
|
-
:data1, :int,
|
125
|
-
:data2, :int,
|
126
|
-
)
|
127
|
-
end
|
128
|
-
|
129
|
-
class
|
130
|
-
layout(
|
131
|
-
:type, :uint,
|
132
|
-
:timestamp, :uint,
|
133
|
-
:windowID, :uint,
|
134
|
-
:state, :uchar,
|
135
|
-
:repeat, :uchar,
|
136
|
-
:padding2, :uchar,
|
137
|
-
:padding3, :uchar,
|
138
|
-
:keysym,
|
139
|
-
)
|
140
|
-
end
|
141
|
-
|
142
|
-
class
|
143
|
-
layout(
|
144
|
-
:type, :uint,
|
145
|
-
:timestamp, :uint,
|
146
|
-
:windowID, :uint,
|
147
|
-
:text, [:char, 32],
|
148
|
-
:start, :int,
|
149
|
-
:length, :int,
|
150
|
-
)
|
151
|
-
end
|
152
|
-
|
153
|
-
class
|
154
|
-
layout(
|
155
|
-
:type, :uint,
|
156
|
-
:timestamp, :uint,
|
157
|
-
:windowID, :uint,
|
158
|
-
:text,
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
:
|
167
|
-
:
|
168
|
-
:
|
169
|
-
:
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
:
|
179
|
-
:
|
180
|
-
:
|
181
|
-
:
|
182
|
-
:
|
183
|
-
:
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
:
|
194
|
-
:
|
195
|
-
:
|
196
|
-
:
|
197
|
-
:x, :int,
|
198
|
-
:y, :int,
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
:
|
208
|
-
:
|
209
|
-
:
|
210
|
-
:
|
211
|
-
:
|
212
|
-
:
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
:
|
222
|
-
:
|
223
|
-
:
|
224
|
-
:
|
225
|
-
:
|
226
|
-
:
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
:
|
236
|
-
:
|
237
|
-
:
|
238
|
-
:
|
239
|
-
:
|
240
|
-
:
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
:
|
248
|
-
:
|
249
|
-
:
|
250
|
-
:
|
251
|
-
:
|
252
|
-
:
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
:
|
260
|
-
:
|
261
|
-
:
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
:
|
271
|
-
:
|
272
|
-
:
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
:
|
282
|
-
:
|
283
|
-
:
|
284
|
-
:
|
285
|
-
:
|
286
|
-
:
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
:
|
294
|
-
:
|
295
|
-
:
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
:
|
305
|
-
:
|
306
|
-
:
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
:
|
315
|
-
:
|
316
|
-
:
|
317
|
-
:
|
318
|
-
:
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
:
|
326
|
-
:
|
327
|
-
:
|
328
|
-
:
|
329
|
-
:
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
:
|
337
|
-
:
|
338
|
-
:
|
339
|
-
:
|
340
|
-
:
|
341
|
-
:
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
:
|
352
|
-
:
|
353
|
-
:
|
354
|
-
:
|
355
|
-
:
|
356
|
-
:
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
:
|
366
|
-
:
|
367
|
-
:
|
368
|
-
:
|
369
|
-
:numFingers, :
|
370
|
-
:
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
:
|
379
|
-
:
|
380
|
-
:
|
381
|
-
:
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
:
|
390
|
-
:
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
:
|
415
|
-
:
|
416
|
-
)
|
417
|
-
end
|
418
|
-
|
419
|
-
class
|
420
|
-
layout(
|
421
|
-
:type, :uint,
|
422
|
-
:timestamp, :uint,
|
423
|
-
:
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
:
|
433
|
-
:
|
434
|
-
:
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
:
|
441
|
-
:
|
442
|
-
:
|
443
|
-
:
|
444
|
-
:
|
445
|
-
:
|
446
|
-
:
|
447
|
-
:
|
448
|
-
:
|
449
|
-
:
|
450
|
-
:
|
451
|
-
:
|
452
|
-
:
|
453
|
-
:
|
454
|
-
:
|
455
|
-
:
|
456
|
-
:
|
457
|
-
:
|
458
|
-
:
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
:
|
468
|
-
:
|
469
|
-
:
|
470
|
-
:
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
:
|
480
|
-
:
|
481
|
-
:
|
482
|
-
:
|
483
|
-
:
|
484
|
-
|
485
|
-
|
486
|
-
:
|
487
|
-
:
|
488
|
-
:
|
489
|
-
:
|
490
|
-
:
|
491
|
-
:
|
492
|
-
:
|
493
|
-
:
|
494
|
-
:
|
495
|
-
:
|
496
|
-
|
497
|
-
|
498
|
-
:
|
499
|
-
:
|
500
|
-
:
|
501
|
-
:
|
502
|
-
:
|
503
|
-
|
504
|
-
|
505
|
-
:
|
506
|
-
:
|
507
|
-
:
|
508
|
-
:
|
509
|
-
:
|
510
|
-
:
|
511
|
-
:
|
512
|
-
:
|
513
|
-
:
|
514
|
-
:
|
515
|
-
|
516
|
-
|
517
|
-
:
|
518
|
-
:
|
519
|
-
:
|
520
|
-
:
|
521
|
-
:
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
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 SDL
|
11
|
+
extend FFI::Library
|
12
|
+
# Define/Macro
|
13
|
+
|
14
|
+
RELEASED = 0
|
15
|
+
PRESSED = 1
|
16
|
+
TEXTEDITINGEVENT_TEXT_SIZE = 32
|
17
|
+
TEXTINPUTEVENT_TEXT_SIZE = 32
|
18
|
+
QUERY = -1
|
19
|
+
IGNORE = 0
|
20
|
+
DISABLE = 0
|
21
|
+
ENABLE = 1
|
22
|
+
|
23
|
+
# Enum
|
24
|
+
|
25
|
+
FIRSTEVENT = 0
|
26
|
+
QUIT = 256
|
27
|
+
APP_TERMINATING = 257
|
28
|
+
APP_LOWMEMORY = 258
|
29
|
+
APP_WILLENTERBACKGROUND = 259
|
30
|
+
APP_DIDENTERBACKGROUND = 260
|
31
|
+
APP_WILLENTERFOREGROUND = 261
|
32
|
+
APP_DIDENTERFOREGROUND = 262
|
33
|
+
LOCALECHANGED = 263
|
34
|
+
DISPLAYEVENT = 336
|
35
|
+
WINDOWEVENT = 512
|
36
|
+
SYSWMEVENT = 513
|
37
|
+
KEYDOWN = 768
|
38
|
+
KEYUP = 769
|
39
|
+
TEXTEDITING = 770
|
40
|
+
TEXTINPUT = 771
|
41
|
+
KEYMAPCHANGED = 772
|
42
|
+
TEXTEDITING_EXT = 773
|
43
|
+
MOUSEMOTION = 1024
|
44
|
+
MOUSEBUTTONDOWN = 1025
|
45
|
+
MOUSEBUTTONUP = 1026
|
46
|
+
MOUSEWHEEL = 1027
|
47
|
+
JOYAXISMOTION = 1536
|
48
|
+
JOYBALLMOTION = 1537
|
49
|
+
JOYHATMOTION = 1538
|
50
|
+
JOYBUTTONDOWN = 1539
|
51
|
+
JOYBUTTONUP = 1540
|
52
|
+
JOYDEVICEADDED = 1541
|
53
|
+
JOYDEVICEREMOVED = 1542
|
54
|
+
CONTROLLERAXISMOTION = 1616
|
55
|
+
CONTROLLERBUTTONDOWN = 1617
|
56
|
+
CONTROLLERBUTTONUP = 1618
|
57
|
+
CONTROLLERDEVICEADDED = 1619
|
58
|
+
CONTROLLERDEVICEREMOVED = 1620
|
59
|
+
CONTROLLERDEVICEREMAPPED = 1621
|
60
|
+
CONTROLLERTOUCHPADDOWN = 1622
|
61
|
+
CONTROLLERTOUCHPADMOTION = 1623
|
62
|
+
CONTROLLERTOUCHPADUP = 1624
|
63
|
+
CONTROLLERSENSORUPDATE = 1625
|
64
|
+
FINGERDOWN = 1792
|
65
|
+
FINGERUP = 1793
|
66
|
+
FINGERMOTION = 1794
|
67
|
+
DOLLARGESTURE = 2048
|
68
|
+
DOLLARRECORD = 2049
|
69
|
+
MULTIGESTURE = 2050
|
70
|
+
CLIPBOARDUPDATE = 2304
|
71
|
+
DROPFILE = 4096
|
72
|
+
DROPTEXT = 4097
|
73
|
+
DROPBEGIN = 4098
|
74
|
+
DROPCOMPLETE = 4099
|
75
|
+
AUDIODEVICEADDED = 4352
|
76
|
+
AUDIODEVICEREMOVED = 4353
|
77
|
+
SENSORUPDATE = 4608
|
78
|
+
RENDER_TARGETS_RESET = 8192
|
79
|
+
RENDER_DEVICE_RESET = 8193
|
80
|
+
POLLSENTINEL = 32512
|
81
|
+
USEREVENT = 32768
|
82
|
+
LASTEVENT = 65535
|
83
|
+
ADDEVENT = 0
|
84
|
+
PEEKEVENT = 1
|
85
|
+
GETEVENT = 2
|
86
|
+
|
87
|
+
# Typedef
|
88
|
+
|
89
|
+
typedef :int, :SDL_EventType
|
90
|
+
typedef :int, :SDL_eventaction
|
91
|
+
callback :SDL_EventFilter, [:pointer, :pointer], :int
|
92
|
+
|
93
|
+
# Struct
|
94
|
+
|
95
|
+
class CommonEvent < FFI::Struct
|
96
|
+
layout(
|
97
|
+
:type, :uint,
|
98
|
+
:timestamp, :uint,
|
99
|
+
)
|
100
|
+
end
|
101
|
+
|
102
|
+
class DisplayEvent < FFI::Struct
|
103
|
+
layout(
|
104
|
+
:type, :uint,
|
105
|
+
:timestamp, :uint,
|
106
|
+
:display, :uint,
|
107
|
+
:event, :uchar,
|
108
|
+
:padding1, :uchar,
|
109
|
+
:padding2, :uchar,
|
110
|
+
:padding3, :uchar,
|
111
|
+
:data1, :int,
|
112
|
+
)
|
113
|
+
end
|
114
|
+
|
115
|
+
class WindowEvent < FFI::Struct
|
116
|
+
layout(
|
117
|
+
:type, :uint,
|
118
|
+
:timestamp, :uint,
|
119
|
+
:windowID, :uint,
|
120
|
+
:event, :uchar,
|
121
|
+
:padding1, :uchar,
|
122
|
+
:padding2, :uchar,
|
123
|
+
:padding3, :uchar,
|
124
|
+
:data1, :int,
|
125
|
+
:data2, :int,
|
126
|
+
)
|
127
|
+
end
|
128
|
+
|
129
|
+
class KeyboardEvent < FFI::Struct
|
130
|
+
layout(
|
131
|
+
:type, :uint,
|
132
|
+
:timestamp, :uint,
|
133
|
+
:windowID, :uint,
|
134
|
+
:state, :uchar,
|
135
|
+
:repeat, :uchar,
|
136
|
+
:padding2, :uchar,
|
137
|
+
:padding3, :uchar,
|
138
|
+
:keysym, Keysym,
|
139
|
+
)
|
140
|
+
end
|
141
|
+
|
142
|
+
class TextEditingEvent < FFI::Struct
|
143
|
+
layout(
|
144
|
+
:type, :uint,
|
145
|
+
:timestamp, :uint,
|
146
|
+
:windowID, :uint,
|
147
|
+
:text, [:char, 32],
|
148
|
+
:start, :int,
|
149
|
+
:length, :int,
|
150
|
+
)
|
151
|
+
end
|
152
|
+
|
153
|
+
class TextEditingExtEvent < FFI::Struct
|
154
|
+
layout(
|
155
|
+
:type, :uint,
|
156
|
+
:timestamp, :uint,
|
157
|
+
:windowID, :uint,
|
158
|
+
:text, :pointer,
|
159
|
+
:start, :int,
|
160
|
+
:length, :int,
|
161
|
+
)
|
162
|
+
end
|
163
|
+
|
164
|
+
class TextInputEvent < FFI::Struct
|
165
|
+
layout(
|
166
|
+
:type, :uint,
|
167
|
+
:timestamp, :uint,
|
168
|
+
:windowID, :uint,
|
169
|
+
:text, [:char, 32],
|
170
|
+
)
|
171
|
+
end
|
172
|
+
|
173
|
+
class MouseMotionEvent < FFI::Struct
|
174
|
+
layout(
|
175
|
+
:type, :uint,
|
176
|
+
:timestamp, :uint,
|
177
|
+
:windowID, :uint,
|
178
|
+
:which, :uint,
|
179
|
+
:state, :uint,
|
180
|
+
:x, :int,
|
181
|
+
:y, :int,
|
182
|
+
:xrel, :int,
|
183
|
+
:yrel, :int,
|
184
|
+
)
|
185
|
+
end
|
186
|
+
|
187
|
+
class MouseButtonEvent < FFI::Struct
|
188
|
+
layout(
|
189
|
+
:type, :uint,
|
190
|
+
:timestamp, :uint,
|
191
|
+
:windowID, :uint,
|
192
|
+
:which, :uint,
|
193
|
+
:button, :uchar,
|
194
|
+
:state, :uchar,
|
195
|
+
:clicks, :uchar,
|
196
|
+
:padding1, :uchar,
|
197
|
+
:x, :int,
|
198
|
+
:y, :int,
|
199
|
+
)
|
200
|
+
end
|
201
|
+
|
202
|
+
class MouseWheelEvent < FFI::Struct
|
203
|
+
layout(
|
204
|
+
:type, :uint,
|
205
|
+
:timestamp, :uint,
|
206
|
+
:windowID, :uint,
|
207
|
+
:which, :uint,
|
208
|
+
:x, :int,
|
209
|
+
:y, :int,
|
210
|
+
:direction, :uint,
|
211
|
+
:preciseX, :float,
|
212
|
+
:preciseY, :float,
|
213
|
+
)
|
214
|
+
end
|
215
|
+
|
216
|
+
class JoyAxisEvent < FFI::Struct
|
217
|
+
layout(
|
218
|
+
:type, :uint,
|
219
|
+
:timestamp, :uint,
|
220
|
+
:which, :int,
|
221
|
+
:axis, :uchar,
|
222
|
+
:padding1, :uchar,
|
223
|
+
:padding2, :uchar,
|
224
|
+
:padding3, :uchar,
|
225
|
+
:value, :short,
|
226
|
+
:padding4, :ushort,
|
227
|
+
)
|
228
|
+
end
|
229
|
+
|
230
|
+
class JoyBallEvent < FFI::Struct
|
231
|
+
layout(
|
232
|
+
:type, :uint,
|
233
|
+
:timestamp, :uint,
|
234
|
+
:which, :int,
|
235
|
+
:ball, :uchar,
|
236
|
+
:padding1, :uchar,
|
237
|
+
:padding2, :uchar,
|
238
|
+
:padding3, :uchar,
|
239
|
+
:xrel, :short,
|
240
|
+
:yrel, :short,
|
241
|
+
)
|
242
|
+
end
|
243
|
+
|
244
|
+
class JoyHatEvent < FFI::Struct
|
245
|
+
layout(
|
246
|
+
:type, :uint,
|
247
|
+
:timestamp, :uint,
|
248
|
+
:which, :int,
|
249
|
+
:hat, :uchar,
|
250
|
+
:value, :uchar,
|
251
|
+
:padding1, :uchar,
|
252
|
+
:padding2, :uchar,
|
253
|
+
)
|
254
|
+
end
|
255
|
+
|
256
|
+
class JoyButtonEvent < FFI::Struct
|
257
|
+
layout(
|
258
|
+
:type, :uint,
|
259
|
+
:timestamp, :uint,
|
260
|
+
:which, :int,
|
261
|
+
:button, :uchar,
|
262
|
+
:state, :uchar,
|
263
|
+
:padding1, :uchar,
|
264
|
+
:padding2, :uchar,
|
265
|
+
)
|
266
|
+
end
|
267
|
+
|
268
|
+
class JoyDeviceEvent < FFI::Struct
|
269
|
+
layout(
|
270
|
+
:type, :uint,
|
271
|
+
:timestamp, :uint,
|
272
|
+
:which, :int,
|
273
|
+
)
|
274
|
+
end
|
275
|
+
|
276
|
+
class ControllerAxisEvent < FFI::Struct
|
277
|
+
layout(
|
278
|
+
:type, :uint,
|
279
|
+
:timestamp, :uint,
|
280
|
+
:which, :int,
|
281
|
+
:axis, :uchar,
|
282
|
+
:padding1, :uchar,
|
283
|
+
:padding2, :uchar,
|
284
|
+
:padding3, :uchar,
|
285
|
+
:value, :short,
|
286
|
+
:padding4, :ushort,
|
287
|
+
)
|
288
|
+
end
|
289
|
+
|
290
|
+
class ControllerButtonEvent < FFI::Struct
|
291
|
+
layout(
|
292
|
+
:type, :uint,
|
293
|
+
:timestamp, :uint,
|
294
|
+
:which, :int,
|
295
|
+
:button, :uchar,
|
296
|
+
:state, :uchar,
|
297
|
+
:padding1, :uchar,
|
298
|
+
:padding2, :uchar,
|
299
|
+
)
|
300
|
+
end
|
301
|
+
|
302
|
+
class ControllerDeviceEvent < FFI::Struct
|
303
|
+
layout(
|
304
|
+
:type, :uint,
|
305
|
+
:timestamp, :uint,
|
306
|
+
:which, :int,
|
307
|
+
)
|
308
|
+
end
|
309
|
+
|
310
|
+
class ControllerTouchpadEvent < FFI::Struct
|
311
|
+
layout(
|
312
|
+
:type, :uint,
|
313
|
+
:timestamp, :uint,
|
314
|
+
:which, :int,
|
315
|
+
:touchpad, :int,
|
316
|
+
:finger, :int,
|
317
|
+
:x, :float,
|
318
|
+
:y, :float,
|
319
|
+
:pressure, :float,
|
320
|
+
)
|
321
|
+
end
|
322
|
+
|
323
|
+
class ControllerSensorEvent < FFI::Struct
|
324
|
+
layout(
|
325
|
+
:type, :uint,
|
326
|
+
:timestamp, :uint,
|
327
|
+
:which, :int,
|
328
|
+
:sensor, :int,
|
329
|
+
:data, [:float, 3],
|
330
|
+
)
|
331
|
+
end
|
332
|
+
|
333
|
+
class AudioDeviceEvent < FFI::Struct
|
334
|
+
layout(
|
335
|
+
:type, :uint,
|
336
|
+
:timestamp, :uint,
|
337
|
+
:which, :uint,
|
338
|
+
:iscapture, :uchar,
|
339
|
+
:padding1, :uchar,
|
340
|
+
:padding2, :uchar,
|
341
|
+
:padding3, :uchar,
|
342
|
+
)
|
343
|
+
end
|
344
|
+
|
345
|
+
class TouchFingerEvent < FFI::Struct
|
346
|
+
layout(
|
347
|
+
:type, :uint,
|
348
|
+
:timestamp, :uint,
|
349
|
+
:touchId, :long_long,
|
350
|
+
:fingerId, :long_long,
|
351
|
+
:x, :float,
|
352
|
+
:y, :float,
|
353
|
+
:dx, :float,
|
354
|
+
:dy, :float,
|
355
|
+
:pressure, :float,
|
356
|
+
:windowID, :uint,
|
357
|
+
)
|
358
|
+
end
|
359
|
+
|
360
|
+
class MultiGestureEvent < FFI::Struct
|
361
|
+
layout(
|
362
|
+
:type, :uint,
|
363
|
+
:timestamp, :uint,
|
364
|
+
:touchId, :long_long,
|
365
|
+
:dTheta, :float,
|
366
|
+
:dDist, :float,
|
367
|
+
:x, :float,
|
368
|
+
:y, :float,
|
369
|
+
:numFingers, :ushort,
|
370
|
+
:padding, :ushort,
|
371
|
+
)
|
372
|
+
end
|
373
|
+
|
374
|
+
class DollarGestureEvent < FFI::Struct
|
375
|
+
layout(
|
376
|
+
:type, :uint,
|
377
|
+
:timestamp, :uint,
|
378
|
+
:touchId, :long_long,
|
379
|
+
:gestureId, :long_long,
|
380
|
+
:numFingers, :uint,
|
381
|
+
:error, :float,
|
382
|
+
:x, :float,
|
383
|
+
:y, :float,
|
384
|
+
)
|
385
|
+
end
|
386
|
+
|
387
|
+
class DropEvent < FFI::Struct
|
388
|
+
layout(
|
389
|
+
:type, :uint,
|
390
|
+
:timestamp, :uint,
|
391
|
+
:file, :pointer,
|
392
|
+
:windowID, :uint,
|
393
|
+
)
|
394
|
+
end
|
395
|
+
|
396
|
+
class SensorEvent < FFI::Struct
|
397
|
+
layout(
|
398
|
+
:type, :uint,
|
399
|
+
:timestamp, :uint,
|
400
|
+
:which, :int,
|
401
|
+
:data, [:float, 6],
|
402
|
+
)
|
403
|
+
end
|
404
|
+
|
405
|
+
class QuitEvent < FFI::Struct
|
406
|
+
layout(
|
407
|
+
:type, :uint,
|
408
|
+
:timestamp, :uint,
|
409
|
+
)
|
410
|
+
end
|
411
|
+
|
412
|
+
class OSEvent < FFI::Struct
|
413
|
+
layout(
|
414
|
+
:type, :uint,
|
415
|
+
:timestamp, :uint,
|
416
|
+
)
|
417
|
+
end
|
418
|
+
|
419
|
+
class UserEvent < FFI::Struct
|
420
|
+
layout(
|
421
|
+
:type, :uint,
|
422
|
+
:timestamp, :uint,
|
423
|
+
:windowID, :uint,
|
424
|
+
:code, :int,
|
425
|
+
:data1, :pointer,
|
426
|
+
:data2, :pointer,
|
427
|
+
)
|
428
|
+
end
|
429
|
+
|
430
|
+
class SysWMEvent < FFI::Struct
|
431
|
+
layout(
|
432
|
+
:type, :uint,
|
433
|
+
:timestamp, :uint,
|
434
|
+
:msg, :pointer,
|
435
|
+
)
|
436
|
+
end
|
437
|
+
|
438
|
+
class Event < FFI::Union
|
439
|
+
layout(
|
440
|
+
:type, :uint,
|
441
|
+
:common, CommonEvent,
|
442
|
+
:display, DisplayEvent,
|
443
|
+
:window, WindowEvent,
|
444
|
+
:key, KeyboardEvent,
|
445
|
+
:edit, TextEditingEvent,
|
446
|
+
:editExt, TextEditingExtEvent,
|
447
|
+
:text, TextInputEvent,
|
448
|
+
:motion, MouseMotionEvent,
|
449
|
+
:button, MouseButtonEvent,
|
450
|
+
:wheel, MouseWheelEvent,
|
451
|
+
:jaxis, JoyAxisEvent,
|
452
|
+
:jball, JoyBallEvent,
|
453
|
+
:jhat, JoyHatEvent,
|
454
|
+
:jbutton, JoyButtonEvent,
|
455
|
+
:jdevice, JoyDeviceEvent,
|
456
|
+
:caxis, ControllerAxisEvent,
|
457
|
+
:cbutton, ControllerButtonEvent,
|
458
|
+
:cdevice, ControllerDeviceEvent,
|
459
|
+
:ctouchpad, ControllerTouchpadEvent,
|
460
|
+
:csensor, ControllerSensorEvent,
|
461
|
+
:adevice, AudioDeviceEvent,
|
462
|
+
:sensor, SensorEvent,
|
463
|
+
:quit, QuitEvent,
|
464
|
+
:user, UserEvent,
|
465
|
+
:syswm, SysWMEvent,
|
466
|
+
:tfinger, TouchFingerEvent,
|
467
|
+
:mgesture, MultiGestureEvent,
|
468
|
+
:dgesture, DollarGestureEvent,
|
469
|
+
:drop, DropEvent,
|
470
|
+
:padding, [:uchar, 56],
|
471
|
+
)
|
472
|
+
end
|
473
|
+
|
474
|
+
|
475
|
+
# Function
|
476
|
+
|
477
|
+
def self.setup_events_symbols(output_error = false)
|
478
|
+
symbols = [
|
479
|
+
:SDL_PumpEvents,
|
480
|
+
:SDL_PeepEvents,
|
481
|
+
:SDL_HasEvent,
|
482
|
+
:SDL_HasEvents,
|
483
|
+
:SDL_FlushEvent,
|
484
|
+
:SDL_FlushEvents,
|
485
|
+
:SDL_PollEvent,
|
486
|
+
:SDL_WaitEvent,
|
487
|
+
:SDL_WaitEventTimeout,
|
488
|
+
:SDL_PushEvent,
|
489
|
+
:SDL_SetEventFilter,
|
490
|
+
:SDL_GetEventFilter,
|
491
|
+
:SDL_AddEventWatch,
|
492
|
+
:SDL_DelEventWatch,
|
493
|
+
:SDL_FilterEvents,
|
494
|
+
:SDL_EventState,
|
495
|
+
:SDL_RegisterEvents,
|
496
|
+
]
|
497
|
+
apis = {
|
498
|
+
:SDL_PumpEvents => :PumpEvents,
|
499
|
+
:SDL_PeepEvents => :PeepEvents,
|
500
|
+
:SDL_HasEvent => :HasEvent,
|
501
|
+
:SDL_HasEvents => :HasEvents,
|
502
|
+
:SDL_FlushEvent => :FlushEvent,
|
503
|
+
:SDL_FlushEvents => :FlushEvents,
|
504
|
+
:SDL_PollEvent => :PollEvent,
|
505
|
+
:SDL_WaitEvent => :WaitEvent,
|
506
|
+
:SDL_WaitEventTimeout => :WaitEventTimeout,
|
507
|
+
:SDL_PushEvent => :PushEvent,
|
508
|
+
:SDL_SetEventFilter => :SetEventFilter,
|
509
|
+
:SDL_GetEventFilter => :GetEventFilter,
|
510
|
+
:SDL_AddEventWatch => :AddEventWatch,
|
511
|
+
:SDL_DelEventWatch => :DelEventWatch,
|
512
|
+
:SDL_FilterEvents => :FilterEvents,
|
513
|
+
:SDL_EventState => :EventState,
|
514
|
+
:SDL_RegisterEvents => :RegisterEvents,
|
515
|
+
}
|
516
|
+
args = {
|
517
|
+
:SDL_PumpEvents => [],
|
518
|
+
:SDL_PeepEvents => [:pointer, :int, :int, :uint, :uint],
|
519
|
+
:SDL_HasEvent => [:uint],
|
520
|
+
:SDL_HasEvents => [:uint, :uint],
|
521
|
+
:SDL_FlushEvent => [:uint],
|
522
|
+
:SDL_FlushEvents => [:uint, :uint],
|
523
|
+
:SDL_PollEvent => [:pointer],
|
524
|
+
:SDL_WaitEvent => [:pointer],
|
525
|
+
:SDL_WaitEventTimeout => [:pointer, :int],
|
526
|
+
:SDL_PushEvent => [:pointer],
|
527
|
+
:SDL_SetEventFilter => [:SDL_EventFilter, :pointer],
|
528
|
+
:SDL_GetEventFilter => [:pointer, :pointer],
|
529
|
+
:SDL_AddEventWatch => [:SDL_EventFilter, :pointer],
|
530
|
+
:SDL_DelEventWatch => [:SDL_EventFilter, :pointer],
|
531
|
+
:SDL_FilterEvents => [:SDL_EventFilter, :pointer],
|
532
|
+
:SDL_EventState => [:uint, :int],
|
533
|
+
:SDL_RegisterEvents => [:int],
|
534
|
+
}
|
535
|
+
retvals = {
|
536
|
+
:SDL_PumpEvents => :void,
|
537
|
+
:SDL_PeepEvents => :int,
|
538
|
+
:SDL_HasEvent => :int,
|
539
|
+
:SDL_HasEvents => :int,
|
540
|
+
:SDL_FlushEvent => :void,
|
541
|
+
:SDL_FlushEvents => :void,
|
542
|
+
:SDL_PollEvent => :int,
|
543
|
+
:SDL_WaitEvent => :int,
|
544
|
+
:SDL_WaitEventTimeout => :int,
|
545
|
+
:SDL_PushEvent => :int,
|
546
|
+
:SDL_SetEventFilter => :void,
|
547
|
+
:SDL_GetEventFilter => :int,
|
548
|
+
:SDL_AddEventWatch => :void,
|
549
|
+
:SDL_DelEventWatch => :void,
|
550
|
+
:SDL_FilterEvents => :void,
|
551
|
+
:SDL_EventState => :uchar,
|
552
|
+
:SDL_RegisterEvents => :uint,
|
553
|
+
}
|
554
|
+
symbols.each do |sym|
|
555
|
+
begin
|
556
|
+
attach_function apis[sym], sym, args[sym], retvals[sym]
|
557
|
+
rescue FFI::NotFoundError => error
|
558
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
|
559
|
+
end
|
560
|
+
end
|
561
|
+
end
|
562
|
+
|
563
|
+
end
|
564
|
+
|