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