summaryrefslogtreecommitdiff
path: root/sdl3/bindings/events.scm
blob: c27be6802345f6105cc3fe3084a94b2709ffaaa4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
90
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
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
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
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
;;; guile-sdl3 -- Scheme bindings for SDL3
;;; Copyright © 2024 David Thompson <dthompson2@worcester.edu>
;;;
;;; Licensed under the Apache License, Version 2.0 (the "License");
;;; you may not use this file except in compliance with the License.
;;; You may obtain a copy of the License at
;;;
;;;    http://www.apache.org/licenses/LICENSE-2.0
;;;
;;; Unless required by applicable law or agreed to in writing, software
;;; distributed under the License is distributed on an "AS IS" BASIS,
;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;;; See the License for the specific language governing permissions and
;;; limitations under the License.

;;; Commentary:
;;
;; Low-level FFI binding utilities.
;;
;;; Code:

(define-module (sdl3 bindings events)
  #:use-module (bstruct)
  #:use-module (sdl3 bindings utils)
  #:use-module (system foreign)
  #:export (SDL_EventType
            symbol->event-type
            event-type->symbol
            SDL_EVENT_FIRST
            SDL_EVENT_QUIT
            SDL_EVENT_TERMINATING
            SDL_EVENT_LOW_MEMORY
            SDL_EVENT_WILL_ENTER_BACKGROUND
            SDL_EVENT_DID_ENTER_BACKGROUND
            SDL_EVENT_WILL_ENTER_FOREGROUND
            SDL_EVENT_DID_ENTER_FOREGROUND
            SDL_EVENT_LOCALE_CHANGED
            SDL_EVENT_SYSTEM_THEME_CHANGED
            SDL_EVENT_DISPLAY_ORIENTATION
            SDL_EVENT_DISPLAY_ADDED
            SDL_EVENT_DISPLAY_REMOVED
            SDL_EVENT_DISPLAY_MOVED
            SDL_EVENT_DISPLAY_DESKTOP_MODE_CHANGED
            SDL_EVENT_DISPLAY_CURRENT_MODE_CHANGED
            SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED
            SDL_EVENT_WINDOW_SHOWN
            SDL_EVENT_WINDOW_HIDDEN
            SDL_EVENT_WINDOW_EXPOSED
            SDL_EVENT_WINDOW_MOVED
            SDL_EVENT_WINDOW_RESIZED
            SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED
            SDL_EVENT_WINDOW_METAL_VIEW_RESIZED
            SDL_EVENT_WINDOW_MINIMIZED
            SDL_EVENT_WINDOW_MAXIMIZED
            SDL_EVENT_WINDOW_RESTORED
            SDL_EVENT_WINDOW_MOUSE_ENTER
            SDL_EVENT_WINDOW_MOUSE_LEAVE
            SDL_EVENT_WINDOW_FOCUS_GAINED
            SDL_EVENT_WINDOW_FOCUS_LOST
            SDL_EVENT_WINDOW_CLOSE_REQUESTED
            SDL_EVENT_WINDOW_HIT_TEST
            SDL_EVENT_WINDOW_ICCPROF_CHANGED
            SDL_EVENT_WINDOW_DISPLAY_CHANGED
            SDL_EVENT_WINDOW_DISPLAY_SCALE_CHANGED
            SDL_EVENT_WINDOW_SAFE_AREA_CHANGED
            SDL_EVENT_WINDOW_OCCLUDED
            SDL_EVENT_WINDOW_ENTER_FULLSCREEN
            SDL_EVENT_WINDOW_LEAVE_FULLSCREEN
            SDL_EVENT_WINDOW_DESTROYED
            SDL_EVENT_WINDOW_HDR_STATE_CHANGED
            SDL_EVENT_KEY_DOWN
            SDL_EVENT_KEY_UP
            SDL_EVENT_TEXT_EDITING
            SDL_EVENT_TEXT_INPUT
            SDL_EVENT_KEYMAP_CHANGED
            SDL_EVENT_KEYBOARD_ADDED
            SDL_EVENT_KEYBOARD_REMOVED
            SDL_EVENT_TEXT_EDITING_CANDIDATES
            SDL_EVENT_MOUSE_MOTION
            SDL_EVENT_MOUSE_BUTTON_DOWN
            SDL_EVENT_MOUSE_BUTTON_UP
            SDL_EVENT_MOUSE_WHEEL
            SDL_EVENT_MOUSE_ADDED
            SDL_EVENT_MOUSE_REMOVED
            SDL_EVENT_JOYSTICK_AXIS_MOTION
            SDL_EVENT_JOYSTICK_BALL_MOTION
            SDL_EVENT_JOYSTICK_HAT_MOTION
            SDL_EVENT_JOYSTICK_BUTTON_DOWN
            SDL_EVENT_JOYSTICK_BUTTON_UP
            SDL_EVENT_JOYSTICK_ADDED
            SDL_EVENT_JOYSTICK_REMOVED
            SDL_EVENT_JOYSTICK_BATTERY_UPDATED
            SDL_EVENT_JOYSTICK_UPDATE_COMPLETE
            SDL_EVENT_GAMEPAD_AXIS_MOTION
            SDL_EVENT_GAMEPAD_BUTTON_DOWN
            SDL_EVENT_GAMEPAD_BUTTON_UP
            SDL_EVENT_GAMEPAD_ADDED
            SDL_EVENT_GAMEPAD_REMOVED
            SDL_EVENT_GAMEPAD_REMAPPED
            SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN
            SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION
            SDL_EVENT_GAMEPAD_TOUCHPAD_UP
            SDL_EVENT_GAMEPAD_SENSOR_UPDATE
            SDL_EVENT_GAMEPAD_UPDATE_COMPLETE
            SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED
            SDL_EVENT_FINGER_DOWN
            SDL_EVENT_FINGER_UP
            SDL_EVENT_FINGER_MOTION
            SDL_EVENT_CLIPBOARD_UPDATE
            SDL_EVENT_DROP_FILE
            SDL_EVENT_DROP_TEXT
            SDL_EVENT_DROP_BEGIN
            SDL_EVENT_DROP_COMPLETE
            SDL_EVENT_DROP_POSITION
            SDL_EVENT_AUDIO_DEVICE_ADDED
            SDL_EVENT_AUDIO_DEVICE_REMOVED
            SDL_EVENT_AUDIO_DEVICE_FORMAT_CHANGED
            SDL_EVENT_SENSOR_UPDATE
            SDL_EVENT_PEN_PROXIMITY_IN
            SDL_EVENT_PEN_PROXIMITY_OUT
            SDL_EVENT_PEN_DOWN
            SDL_EVENT_PEN_UP
            SDL_EVENT_PEN_BUTTON_DOWN
            SDL_EVENT_PEN_BUTTON_UP
            SDL_EVENT_PEN_MOTION
            SDL_EVENT_PEN_AXIS
            SDL_EVENT_CAMERA_DEVICE_ADDED
            SDL_EVENT_CAMERA_DEVICE_REMOVED
            SDL_EVENT_CAMERA_DEVICE_APPROVED
            SDL_EVENT_CAMERA_DEVICE_DENIED
            SDL_EVENT_RENDER_TARGETS_RESET
            SDL_EVENT_RENDER_DEVICE_RESET
            SDL_EVENT_POLL_SENTINEL
            SDL_EVENT_DISPLAY_FIRST
            SDL_EVENT_DISPLAY_LAST
            SDL_EVENT_WINDOW_FIRST
            SDL_EVENT_WINDOW_LAST
            SDL_EVENT_USER
            SDL_EVENT_LAST
            SDL_EVENT_ENUM_PADDING

            SDL_CommonEvent
            SDL_DisplayEvent
            SDL_WindowEvent
            SDL_KeyboardDeviceEvent
            SDL_KeyboardEvent
            SDL_TextEditingEvent
            SDL_TextEditingCandidatesEvent
            SDL_TextInputEvent
            SDL_MouseDeviceEvent
            SDL_MouseMotionEvent
            SDL_MouseButtonEvent
            SDL_MouseWheelEvent
            SDL_JoyAxisEvent
            SDL_JoyBallEvent
            SDL_JoyHatEvent
            SDL_JoyButtonEvent
            SDL_JoyDeviceEvent
            SDL_JoyBatteryEvent
            SDL_GamepadAxisEvent
            SDL_GamepadButtonEvent
            SDL_GamepadDeviceEvent
            SDL_GamepadTouchpadEvent
            SDL_GamepadSensorEvent
            SDL_AudioDeviceEvent
            SDL_CameraDeviceEvent
            SDL_TouchFingerEvent
            SDL_PenProximityEvent
            SDL_PenMotionEvent
            SDL_PenTouchEvent
            SDL_PenButtonEvent
            SDL_PenAxisEvent
            SDL_DropEvent
            SDL_ClipboardEvent
            SDL_SensorEvent
            SDL_QuitEvent
            SDL_UserEvent
            SDL_Event

            SDL_PumpEvents
            SDL_HasEvent
            SDL_HasEvents
            SDL_FlushEvent
            SDL_FlushEvents
            SDL_PollEvent
            SDL_WaitEvent
            SDL_WaitEventTimeout
            SDL_PushEvent))

(define-enum SDL_EventType
  symbol->event-type
  event-type->symbol
  (first SDL_EVENT_FIRST)
  (quit SDL_EVENT_QUIT #x100)
  (terminating SDL_EVENT_TERMINATING)
  (low-memory SDL_EVENT_LOW_MEMORY)
  (will-enter-background SDL_EVENT_WILL_ENTER_BACKGROUND)
  (did-enter-background SDL_EVENT_DID_ENTER_BACKGROUND)
  (will-enter-foreground SDL_EVENT_WILL_ENTER_FOREGROUND)
  (did-enter-foreground SDL_EVENT_DID_ENTER_FOREGROUND)
  (locale-changed SDL_EVENT_LOCALE_CHANGED)
  (system-theme-changed SDL_EVENT_SYSTEM_THEME_CHANGED)
  (display-orientation SDL_EVENT_DISPLAY_ORIENTATION #x151)
  (display-added SDL_EVENT_DISPLAY_ADDED)
  (display-removed SDL_EVENT_DISPLAY_REMOVED)
  (display-moved SDL_EVENT_DISPLAY_MOVED)
  (display-desktop-mode-changed SDL_EVENT_DISPLAY_DESKTOP_MODE_CHANGED)
  (display-current-mode-changed SDL_EVENT_DISPLAY_CURRENT_MODE_CHANGED)
  (display-content-scale-changed SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED)
  (window-shown SDL_EVENT_WINDOW_SHOWN #x202)
  (window-hidden SDL_EVENT_WINDOW_HIDDEN)
  (window-exposed SDL_EVENT_WINDOW_EXPOSED)
  (window-moved SDL_EVENT_WINDOW_MOVED)
  (window-resized SDL_EVENT_WINDOW_RESIZED)
  (window-pixel-size-changed SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED)
  (window-metal-view-resized SDL_EVENT_WINDOW_METAL_VIEW_RESIZED)
  (window-minimized SDL_EVENT_WINDOW_MINIMIZED)
  (window-maximized SDL_EVENT_WINDOW_MAXIMIZED)
  (window-restored SDL_EVENT_WINDOW_RESTORED)
  (window-mouse-enter SDL_EVENT_WINDOW_MOUSE_ENTER)
  (window-mouse-leave SDL_EVENT_WINDOW_MOUSE_LEAVE)
  (window-focus-gained SDL_EVENT_WINDOW_FOCUS_GAINED)
  (window-focus-lost SDL_EVENT_WINDOW_FOCUS_LOST)
  (window-close-requested SDL_EVENT_WINDOW_CLOSE_REQUESTED)
  (window-hit-test SDL_EVENT_WINDOW_HIT_TEST)
  (window-iccprof-changed SDL_EVENT_WINDOW_ICCPROF_CHANGED)
  (window-display-changed SDL_EVENT_WINDOW_DISPLAY_CHANGED)
  (window-display-scale-changed SDL_EVENT_WINDOW_DISPLAY_SCALE_CHANGED)
  (window-safe-area-changed SDL_EVENT_WINDOW_SAFE_AREA_CHANGED)
  (window-occluded SDL_EVENT_WINDOW_OCCLUDED)
  (window-enter-fullscreen SDL_EVENT_WINDOW_ENTER_FULLSCREEN)
  (window-leave-fullscreen SDL_EVENT_WINDOW_LEAVE_FULLSCREEN)
  (window-destroyed SDL_EVENT_WINDOW_DESTROYED)
  (window-hdr-state-changed SDL_EVENT_WINDOW_HDR_STATE_CHANGED)
  (key-down SDL_EVENT_KEY_DOWN #x300)
  (key-up SDL_EVENT_KEY_UP)
  (text-editing SDL_EVENT_TEXT_EDITING)
  (text-input SDL_EVENT_TEXT_INPUT)
  (keymap-changed SDL_EVENT_KEYMAP_CHANGED)
  (keyboard-added SDL_EVENT_KEYBOARD_ADDED)
  (keyboard-removed SDL_EVENT_KEYBOARD_REMOVED)
  (text-editing-candidates SDL_EVENT_TEXT_EDITING_CANDIDATES)
  (mouse-motion SDL_EVENT_MOUSE_MOTION #x400)
  (mouse-button-down SDL_EVENT_MOUSE_BUTTON_DOWN)
  (mouse-button-up SDL_EVENT_MOUSE_BUTTON_UP)
  (mouse-wheel SDL_EVENT_MOUSE_WHEEL)
  (mouse-added SDL_EVENT_MOUSE_ADDED)
  (mouse-removed SDL_EVENT_MOUSE_REMOVED)
  (joystick-axis-motion SDL_EVENT_JOYSTICK_AXIS_MOTION #x600)
  (joystick-ball-motion SDL_EVENT_JOYSTICK_BALL_MOTION)
  (joystick-hat-motion SDL_EVENT_JOYSTICK_HAT_MOTION)
  (joystick-button-down SDL_EVENT_JOYSTICK_BUTTON_DOWN)
  (joystick-button-up SDL_EVENT_JOYSTICK_BUTTON_UP)
  (joystick-added SDL_EVENT_JOYSTICK_ADDED)
  (joystick-removed SDL_EVENT_JOYSTICK_REMOVED)
  (joystick-battery-updated SDL_EVENT_JOYSTICK_BATTERY_UPDATED)
  (joystick-update-complete SDL_EVENT_JOYSTICK_UPDATE_COMPLETE)
  (gamepad-axis-motion SDL_EVENT_GAMEPAD_AXIS_MOTION #x650)
  (gamepad-button-down SDL_EVENT_GAMEPAD_BUTTON_DOWN)
  (gamepad-button-up SDL_EVENT_GAMEPAD_BUTTON_UP)
  (gamepad-added SDL_EVENT_GAMEPAD_ADDED)
  (gamepad-removed SDL_EVENT_GAMEPAD_REMOVED)
  (gamepad-remapped SDL_EVENT_GAMEPAD_REMAPPED)
  (gamepad-touchpad-down SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN)
  (gamepad-touchpad-motion SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION)
  (gamepad-touchpad-up SDL_EVENT_GAMEPAD_TOUCHPAD_UP)
  (gamepad-sensor-update SDL_EVENT_GAMEPAD_SENSOR_UPDATE)
  (gamepad-update-complete SDL_EVENT_GAMEPAD_UPDATE_COMPLETE)
  (gamepad-steam-handle-updated SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED)
  (finger-down SDL_EVENT_FINGER_DOWN #x700)
  (finger-up SDL_EVENT_FINGER_UP)
  (finger-motion SDL_EVENT_FINGER_MOTION)
  (clipboard-update SDL_EVENT_CLIPBOARD_UPDATE #x900)
  (drop-file SDL_EVENT_DROP_FILE #x1000)
  (drop-text SDL_EVENT_DROP_TEXT)
  (drop-begin SDL_EVENT_DROP_BEGIN)
  (drop-complete SDL_EVENT_DROP_COMPLETE)
  (drop-position SDL_EVENT_DROP_POSITION)
  (audio-device-added SDL_EVENT_AUDIO_DEVICE_ADDED #x1100)
  (audio-device-removed SDL_EVENT_AUDIO_DEVICE_REMOVED)
  (audio-device-format-changed SDL_EVENT_AUDIO_DEVICE_FORMAT_CHANGED)
  (sensor-update SDL_EVENT_SENSOR_UPDATE #x1200)
  (pen-proximity-in SDL_EVENT_PEN_PROXIMITY_IN #x1300)
  (pen-proximity-out SDL_EVENT_PEN_PROXIMITY_OUT)
  (pen-down SDL_EVENT_PEN_DOWN)
  (pen-up SDL_EVENT_PEN_UP)
  (pen-button-down SDL_EVENT_PEN_BUTTON_DOWN)
  (pen-button-up SDL_EVENT_PEN_BUTTON_UP)
  (pen-motion SDL_EVENT_PEN_MOTION)
  (pen-axis SDL_EVENT_PEN_AXIS)
  (camera-device-added SDL_EVENT_CAMERA_DEVICE_ADDED #x1400)
  (camera-device-removed SDL_EVENT_CAMERA_DEVICE_REMOVED)
  (camera-device-approved SDL_EVENT_CAMERA_DEVICE_APPROVED)
  (camera-device-denied SDL_EVENT_CAMERA_DEVICE_DENIED)
  (render-targets-reset SDL_EVENT_RENDER_TARGETS_RESET #x2000)
  (render-device-reset SDL_EVENT_RENDER_DEVICE_RESET)
  (poll-sentinel SDL_EVENT_POLL_SENTINEL #x7F00))

(define SDL_EVENT_DISPLAY_FIRST SDL_EVENT_DISPLAY_ORIENTATION)
(define SDL_EVENT_DISPLAY_LAST  SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED)
(define SDL_EVENT_WINDOW_FIRST  SDL_EVENT_WINDOW_SHOWN)
(define SDL_EVENT_WINDOW_LAST   SDL_EVENT_WINDOW_HDR_STATE_CHANGED)
(define SDL_EVENT_USER          #x8000)
(define SDL_EVENT_LAST          #xFFFF)
(define SDL_EVENT_ENUM_PADDING  #x7FFFFFFF)

(define-bstruct SDL_CommonEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)))

(define-bstruct SDL_DisplayEvent
  (struct
   (type int) ; SDL_EventType
   (reserved uint32)
   (timestamp uint64)
   (displayID uint32) ; SDL_DisplayID
   (data1 int32)
   (data2 int32)))

(define-bstruct SDL_WindowEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)
   (windowID uint32) ; SDL_WindowID
   (data1 int32)
   (data2 int32)))

(define-bstruct SDL_KeyboardDeviceEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)
   (which uint32) ; SDL_KeyboardID
   ))

(define-bstruct SDL_KeyboardEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)
   (windowID uint32) ; SDL_WindowID
   (which uint32) ; SDL_KeyboardID
   (scancode int) ; SDL_Scancode
   (key int) ; SDL_Keycode
   (mod uint16) ; SDL_Keymod
   (raw uint16)
   (down uint8) ; bool
   (repeat uint8) ; bool
   ))

(define-bstruct SDL_TextEditingEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)
   (windowID uint32) ; SDL_WindowID
   (text (* uint8)) ; char*
   (start int32)
   (length int32)))

(define-bstruct SDL_TextEditingCandidatesEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)
   (windowID uint32) ; SDL_WindowID
   (candidates (* uint8))
   (num_candidates int32)
   (selected_candidate int32)
   (horizontal uint8) ; bool
   (_ uint8)
   (_ uint8)
   (_ uint8)))

(define-bstruct SDL_TextInputEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)
   (windowID uint32) ; SDL_WindowID
   (text (* uint8))))

(define-bstruct SDL_MouseDeviceEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)
   (which uint32) ; SDL_MouseID
   ))

(define-bstruct SDL_MouseMotionEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)
   (windowID uint32) ; SDL_WindowID
   (which uint32) ; SDL_MouseID
   (state uint32) ; SDL_MouseButtonFlags
   (x float)
   (y float)
   (xrel float)
   (yrel float)))

(define-bstruct SDL_MouseButtonEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)
   (windowID uint32) ; SDL_WindowID
   (which uint32) ; SDL_MouseID
   (button uint8)
   (down uint8) ; bool
   (clicks uint8)
   (_ uint8)
   (x float)
   (y float)))

(define-bstruct SDL_MouseWheelEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)
   (windowID uint32) ; SDL_WindowID
   (which uint32) ; SDL_MouseID
   (x float)
   (y float)
   (direction int) ; SDL_MouseWheelDirection
   (mouse_x float)
   (mouse_y float)))

(define-bstruct SDL_JoyAxisEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)
   (which uint32) ; SDL_JoystickID
   (axis uint8)
   (_ uint8)
   (_ uint8)
   (_ uint8)
   (value int16)
   (_ uint16)))

(define-bstruct SDL_JoyBallEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)
   (which uint32) ; SDL_JoystickID
   (ball uint8)
   (_ uint8)
   (_ uint8)
   (_ uint8)
   (xrel int32)
   (yrel int32)))

(define-bstruct SDL_JoyHatEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)
   (which uint32) ; SDL_JoystickID
   (hat uint8)
   (value uint8)
   (_ uint8)
   (_ uint8)))

(define-bstruct SDL_JoyButtonEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)
   (which uint32) ; SDL_JoystickID
   (button uint8)
   (down uint8) ; bool
   (_ uint8)
   (_ uint8)
   ))

(define-bstruct SDL_JoyDeviceEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)
   (which uint32) ; SDL_JoystickID
   ))

(define-bstruct SDL_JoyBatteryEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)
   (which uint32) ; SDL_JoystickID
   (state int) ; SDL_PowerState
   (percent int)))

(define-bstruct SDL_GamepadAxisEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)
   (which uint32) ; SDL_JoystickID
   (axis uint8)
   (_ uint8)
   (_ uint8)
   (_ uint8)
   (value int16)
   (_ uint16)))

(define-bstruct SDL_GamepadButtonEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)
   (which uint32) ; SDL_JoystickID
   (button uint8)
   (down uint8) ; bool
   (_ uint8)
   (_ uint8)))

(define-bstruct SDL_GamepadDeviceEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)
   (which uint32) ; SDL_JoystickID
   ))

(define-bstruct SDL_GamepadTouchpadEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)
   (which uint32) ; SDL_JoystickID
   (touchpad int32)
   (finger int32)
   (x float)
   (y float)
   (pressure float)))

(define-bstruct SDL_GamepadSensorEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)
   (which uint32) ; SDL_JoystickID
   (sensor int32)
   (data (array 3 float))
   (sensor_timestamp uint64)))

(define-bstruct SDL_AudioDeviceEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)
   (which uint32) ; SDL_AudioDeviceID
   (recording uint8) ; bool
   (_ uint8)
   (_ uint8)
   (_ uint8)))

(define-bstruct SDL_CameraDeviceEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)
   (which uint32) ; SDL_CameraID
   ))

(define-bstruct SDL_TouchFingerEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)
   (touchID uint32) ; SDL_TouchID
   (fingerID uint32) ; SDL_FingerID
   (x float)
   (y float)
   (dx float)
   (dy float)
   (pressure float)
   (windowID uint32) ; SDL_WindowID
   ))

(define-bstruct SDL_PenProximityEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)
   (windowID uint32) ; SDL_WindowID
   (which uint32) ; SDL_PenID
   ))

(define-bstruct SDL_PenMotionEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)
   (windowID uint32) ; SDL_WindowID
   (which uint32) ; SDL_PenID
   (pen_state uint32) ; SDL_PenInputFlags
   ))

(define-bstruct SDL_PenTouchEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)
   (windowID uint32) ; SDL_WindowID
   (which uint32) ; SDL_PenID
   (pen_state uint32) ; SDL_PenInputFlags
   (x float)
   (y float)
   (eraser uint8) ; bool
   (down uint8) ; bool
   ))

(define-bstruct SDL_PenButtonEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)
   (windowID uint32) ; SDL_WindowID
   (which uint32) ; SDL_PenID
   (pen_state uint32) ; SDL_PenInputFlags
   (x float)
   (y float)
   (button uint8)
   (down uint8) ; bool
   ))

(define-bstruct SDL_PenAxisEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)
   (windowID uint32)                       ; SDL_WindowID
   (which uint32)                          ; SDL_PenID
   (pen_state uint32)                      ; SDL_PenInputFlags
   (x float)
   (y float)
   (axis int)                           ; SDL_PenAxis
   (value float)))

(define-bstruct SDL_DropEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)
   (windowID uint32) ; SDL_WindowID
   (x float)
   (y float)
   (source (* uint8)) ; char*
   (data (* uint8)) ; char*
   ))

(define-bstruct SDL_ClipboardEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)))

(define-bstruct SDL_SensorEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)
   (which uint32) ; SDL_SensorID
   (data (array 6 float))
   (sensor_timestamp uint64)))

(define-bstruct SDL_QuitEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)))

(define-bstruct SDL_UserEvent
  (struct
   (type uint32)
   (reserved uint32)
   (timestamp uint64)
   (windowID uint32) ; SDL_WindowID
   (code int32)
   (data1 (* void))
   (data2 (* void))))

(define-bstruct SDL_Event
  (union
   (type uint32)
   (common SDL_CommonEvent)
   (display SDL_DisplayEvent)
   (window SDL_WindowEvent)
   (kdevice SDL_KeyboardDeviceEvent)
   (key SDL_KeyboardEvent)
   (edit SDL_TextEditingEvent)
   (edit_candidates SDL_TextEditingCandidatesEvent)
   (text SDL_TextInputEvent)
   (mdevice SDL_MouseDeviceEvent)
   (motion SDL_MouseMotionEvent)
   (button SDL_MouseButtonEvent)
   (wheel SDL_MouseWheelEvent)
   (jdevice SDL_JoyDeviceEvent)
   (jaxis SDL_JoyAxisEvent)
   (jball SDL_JoyBallEvent)
   (jhat SDL_JoyHatEvent)
   (jbutton SDL_JoyButtonEvent)
   (jbattery SDL_JoyBatteryEvent)
   (gdevice SDL_GamepadDeviceEvent)
   (gaxis SDL_GamepadAxisEvent)
   (gbutton SDL_GamepadButtonEvent)
   (gtouchpad SDL_GamepadTouchpadEvent)
   (gsensor SDL_GamepadSensorEvent)
   (adevice SDL_AudioDeviceEvent)
   (cdevice SDL_CameraDeviceEvent)
   (sensor SDL_SensorEvent)
   (quit SDL_QuitEvent)
   (user SDL_UserEvent)
   (tfinger SDL_TouchFingerEvent)
   (pproximity SDL_PenProximityEvent)
   (ptouch SDL_PenTouchEvent)
   (pmotion SDL_PenMotionEvent)
   (pbutton SDL_PenButtonEvent)
   (paxis SDL_PenAxisEvent)
   (drop SDL_DropEvent)
   (clipboard SDL_ClipboardEvent)
   (_ (array 128 uint8))))

(define-sdl SDL_PumpEvents)
;; SDL_PeepEvents
(define-sdl SDL_HasEvent uint32 -> bool)
(define-sdl SDL_HasEvents uint32 uint32 -> bool)
(define-sdl SDL_FlushEvent uint32)
(define-sdl SDL_FlushEvents uint32 uint32)
(define-sdl SDL_PollEvent '* -> bool)
(define-sdl SDL_WaitEvent '* -> bool)
(define-sdl SDL_WaitEventTimeout '* int32 -> bool)
(define-sdl SDL_PushEvent '* -> bool)
;; SDL_SetEventFilter
;; SDL_GetEventFilter
;; SDL_AddEventWatch
;; SDL_RemoveEventWatch
;; SDL_FilterEvents
;; SDL_SetEventEnabled
;; SDL_EventEnabled
;; SDL_RegisterEvents
;; SDL_GetWindowFromEvent