1 
2 //          Copyright 2018 - 2021 Michael D. Parker
3 // Distributed under the Boost Software License, Version 1.0.
4 //    (See accompanying file LICENSE_1_0.txt or copy at
5 //          http://www.boost.org/LICENSE_1_0.txt)
6 
7 module bindbc.sdl.bind.sdlevents;
8 
9 import bindbc.sdl.config;
10 
11 import bindbc.sdl.bind.sdlgesture,
12        bindbc.sdl.bind.sdljoystick,
13        bindbc.sdl.bind.sdlkeyboard,
14        bindbc.sdl.bind.sdlkeycode,
15        bindbc.sdl.bind.sdlstdinc,
16        bindbc.sdl.bind.sdlsyswm,
17        bindbc.sdl.bind.sdltouch,
18        bindbc.sdl.bind.sdlvideo;
19 
20 enum {
21     SDL_RELEASED = 0,
22     SDL_PRESSED = 1,
23 }
24 
25 static if(sdlSupport >= SDLSupport.sdl209) {
26     enum SDL_EventType {
27         SDL_FIRSTEVENT = 0,
28         SDL_QUIT = 0x100,
29         SDL_APP_TERMINATING,
30         SDL_APP_LOWMEMORY,
31         SDL_APP_WILLENTERBACKGROUND,
32         SDL_APP_DIDENTERBACKGROUND,
33         SDL_APP_WILLENTERFOREGROUND,
34         SDL_APP_DIDENTERFOREGROUND,
35         SDL_LOCALECHANGED,
36         SDL_DISPLAYEVENT = 0x150,
37         SDL_WINDOWEVENT = 0x200,
38         SDL_SYSWMEVENT,
39         SDL_KEYDOWN = 0x300,
40         SDL_KEYUP,
41         SDL_TEXTEDITING,
42         SDL_TEXTINPUT,
43         SDL_KEYMAPCHANGED,
44         SDL_MOUSEMOTION = 0x400,
45         SDL_MOUSEBUTTONDOWN,
46         SDL_MOUSEBUTTONUP,
47         SDL_MOUSEWHEEL,
48         SDL_JOYAXISMOTION = 0x600,
49         SDL_JOYBALLMOTION,
50         SDL_JOYHATMOTION,
51         SDL_JOYBUTTONDOWN,
52         SDL_JOYBUTTONUP,
53         SDL_JOYDEVICEADDED,
54         SDL_JOYDEVICEREMOVED,
55         SDL_CONTROLLERAXISMOTION = 0x650,
56         SDL_CONTROLLERBUTTONDOWN,
57         SDL_CONTROLLERBUTTONUP,
58         SDL_CONTROLLERDEVICEADDED,
59         SDL_CONTROLLERDEVICEREMOVED,
60         SDL_CONTROLLERDEVICEREMAPPED,
61         SDL_CONTROLLERTOUCHPADDOWN,
62         SDL_CONTROLLERTOUCHPADMOTION,
63         SDL_CONTROLLERTOUCHPADUP,
64         SDL_CONTROLLERSENSORUPDATE,
65         SDL_FINGERDOWN = 0x700,
66         SDL_FINGERUP,
67         SDL_FINGERMOTION,
68         SDL_DOLLARGESTURE = 0x800,
69         SDL_DOLLARRECORD,
70         SDL_MULTIGESTURE,
71         SDL_CLIPBOARDUPDATE = 0x900,
72         SDL_DROPFILE = 0x1000,
73         SDL_DROPTEXT,
74         SDL_DROPBEGIN,
75         SDL_DROPCOMPLETE,
76         SDL_AUDIODEVICEADDED = 0x1100,
77         SDL_AUDIODEVICEREMOVED,
78         SDL_SENSORUPDATE = 0x1200,
79         SDL_RENDER_TARGETS_RESET = 0x2000,
80         SDL_RENDER_DEVICE_RESET,
81         SDL_USEREVENT = 0x8000,
82         SDL_LASTEVENT = 0xFFFF
83     }
84 }
85 else static if(sdlSupport >= SDLSupport.sdl209) {
86     enum SDL_EventType {
87         SDL_FIRSTEVENT = 0,
88         SDL_QUIT = 0x100,
89         SDL_APP_TERMINATING,
90         SDL_APP_LOWMEMORY,
91         SDL_APP_WILLENTERBACKGROUND,
92         SDL_APP_DIDENTERBACKGROUND,
93         SDL_APP_WILLENTERFOREGROUND,
94         SDL_APP_DIDENTERFOREGROUND,
95         SDL_DISPLAYEVENT = 0x150,
96         SDL_WINDOWEVENT = 0x200,
97         SDL_SYSWMEVENT,
98         SDL_KEYDOWN = 0x300,
99         SDL_KEYUP,
100         SDL_TEXTEDITING,
101         SDL_TEXTINPUT,
102         SDL_KEYMAPCHANGED,
103         SDL_MOUSEMOTION = 0x400,
104         SDL_MOUSEBUTTONDOWN,
105         SDL_MOUSEBUTTONUP,
106         SDL_MOUSEWHEEL,
107         SDL_JOYAXISMOTION = 0x600,
108         SDL_JOYBALLMOTION,
109         SDL_JOYHATMOTION,
110         SDL_JOYBUTTONDOWN,
111         SDL_JOYBUTTONUP,
112         SDL_JOYDEVICEADDED,
113         SDL_JOYDEVICEREMOVED,
114         SDL_CONTROLLERAXISMOTION = 0x650,
115         SDL_CONTROLLERBUTTONDOWN,
116         SDL_CONTROLLERBUTTONUP,
117         SDL_CONTROLLERDEVICEADDED,
118         SDL_CONTROLLERDEVICEREMOVED,
119         SDL_CONTROLLERDEVICEREMAPPED,
120         SDL_FINGERDOWN = 0x700,
121         SDL_FINGERUP,
122         SDL_FINGERMOTION,
123         SDL_DOLLARGESTURE = 0x800,
124         SDL_DOLLARRECORD,
125         SDL_MULTIGESTURE,
126         SDL_CLIPBOARDUPDATE = 0x900,
127         SDL_DROPFILE = 0x1000,
128         SDL_DROPTEXT,
129         SDL_DROPBEGIN,
130         SDL_DROPCOMPLETE,
131         SDL_AUDIODEVICEADDED = 0x1100,
132         SDL_AUDIODEVICEREMOVED,
133         SDL_SENSORUPDATE = 0x1200,
134         SDL_RENDER_TARGETS_RESET = 0x2000,
135         SDL_RENDER_DEVICE_RESET,
136         SDL_USEREVENT = 0x8000,
137         SDL_LASTEVENT = 0xFFFF
138     }
139 }
140 else static if(sdlSupport >= SDLSupport.sdl205) {
141     enum SDL_EventType {
142         SDL_FIRSTEVENT = 0,
143         SDL_QUIT = 0x100,
144         SDL_APP_TERMINATING,
145         SDL_APP_LOWMEMORY,
146         SDL_APP_WILLENTERBACKGROUND,
147         SDL_APP_DIDENTERBACKGROUND,
148         SDL_APP_WILLENTERFOREGROUND,
149         SDL_APP_DIDENTERFOREGROUND,
150         SDL_WINDOWEVENT = 0x200,
151         SDL_SYSWMEVENT,
152         SDL_KEYDOWN = 0x300,
153         SDL_KEYUP,
154         SDL_TEXTEDITING,
155         SDL_TEXTINPUT,
156         SDL_KEYMAPCHANGED,
157         SDL_MOUSEMOTION = 0x400,
158         SDL_MOUSEBUTTONDOWN,
159         SDL_MOUSEBUTTONUP,
160         SDL_MOUSEWHEEL,
161         SDL_JOYAXISMOTION = 0x600,
162         SDL_JOYBALLMOTION,
163         SDL_JOYHATMOTION,
164         SDL_JOYBUTTONDOWN,
165         SDL_JOYBUTTONUP,
166         SDL_JOYDEVICEADDED,
167         SDL_JOYDEVICEREMOVED,
168         SDL_CONTROLLERAXISMOTION = 0x650,
169         SDL_CONTROLLERBUTTONDOWN,
170         SDL_CONTROLLERBUTTONUP,
171         SDL_CONTROLLERDEVICEADDED,
172         SDL_CONTROLLERDEVICEREMOVED,
173         SDL_CONTROLLERDEVICEREMAPPED,
174         SDL_FINGERDOWN = 0x700,
175         SDL_FINGERUP,
176         SDL_FINGERMOTION,
177         SDL_DOLLARGESTURE = 0x800,
178         SDL_DOLLARRECORD,
179         SDL_MULTIGESTURE,
180         SDL_CLIPBOARDUPDATE = 0x900,
181         SDL_DROPFILE = 0x1000,
182         SDL_DROPTEXT,
183         SDL_DROPBEGIN,
184         SDL_DROPCOMPLETE,
185         SDL_AUDIODEVICEADDED = 0x1100,
186         SDL_AUDIODEVICEREMOVED,
187         SDL_RENDER_TARGETS_RESET = 0x2000,
188         SDL_RENDER_DEVICE_RESET,
189         SDL_USEREVENT = 0x8000,
190         SDL_LASTEVENT = 0xFFFF
191     }
192 }
193 else static if(sdlSupport >= SDLSupport.sdl204) {
194     enum SDL_EventType {
195         SDL_FIRSTEVENT = 0,
196         SDL_QUIT = 0x100,
197         SDL_APP_TERMINATING,
198         SDL_APP_LOWMEMORY,
199         SDL_APP_WILLENTERBACKGROUND,
200         SDL_APP_DIDENTERBACKGROUND,
201         SDL_APP_WILLENTERFOREGROUND,
202         SDL_APP_DIDENTERFOREGROUND,
203         SDL_WINDOWEVENT = 0x200,
204         SDL_SYSWMEVENT,
205         SDL_KEYDOWN = 0x300,
206         SDL_KEYUP,
207         SDL_TEXTEDITING,
208         SDL_TEXTINPUT,
209         SDL_KEYMAPCHANGED,
210         SDL_MOUSEMOTION = 0x400,
211         SDL_MOUSEBUTTONDOWN,
212         SDL_MOUSEBUTTONUP,
213         SDL_MOUSEWHEEL,
214         SDL_JOYAXISMOTION = 0x600,
215         SDL_JOYBALLMOTION,
216         SDL_JOYHATMOTION,
217         SDL_JOYBUTTONDOWN,
218         SDL_JOYBUTTONUP,
219         SDL_JOYDEVICEADDED,
220         SDL_JOYDEVICEREMOVED,
221         SDL_CONTROLLERAXISMOTION = 0x650,
222         SDL_CONTROLLERBUTTONDOWN,
223         SDL_CONTROLLERBUTTONUP,
224         SDL_CONTROLLERDEVICEADDED,
225         SDL_CONTROLLERDEVICEREMOVED,
226         SDL_CONTROLLERDEVICEREMAPPED,
227         SDL_FINGERDOWN = 0x700,
228         SDL_FINGERUP,
229         SDL_FINGERMOTION,
230         SDL_DOLLARGESTURE = 0x800,
231         SDL_DOLLARRECORD,
232         SDL_MULTIGESTURE,
233         SDL_CLIPBOARDUPDATE = 0x900,
234         SDL_DROPFILE = 0x1000,
235         SDL_AUDIODEVICEADDED = 0x1100,
236         SDL_AUDIODEVICEREMOVED,
237         SDL_RENDER_TARGETS_RESET = 0x2000,
238         SDL_RENDER_DEVICE_RESET,
239         SDL_USEREVENT = 0x8000,
240         SDL_LASTEVENT = 0xFFFF
241     }
242 }
243 else static if(sdlSupport >= SDLSupport.sdl201) {
244     enum SDL_EventType {
245         SDL_FIRSTEVENT = 0,
246         SDL_QUIT = 0x100,
247         SDL_APP_TERMINATING,
248         SDL_APP_LOWMEMORY,
249         SDL_APP_WILLENTERBACKGROUND,
250         SDL_APP_DIDENTERBACKGROUND,
251         SDL_APP_WILLENTERFOREGROUND,
252         SDL_APP_DIDENTERFOREGROUND,
253         SDL_WINDOWEVENT = 0x200,
254         SDL_SYSWMEVENT,
255         SDL_KEYDOWN = 0x300,
256         SDL_KEYUP,
257         SDL_TEXTEDITING,
258         SDL_TEXTINPUT,
259         SDL_MOUSEMOTION = 0x400,
260         SDL_MOUSEBUTTONDOWN,
261         SDL_MOUSEBUTTONUP,
262         SDL_MOUSEWHEEL,
263         SDL_JOYAXISMOTION = 0x600,
264         SDL_JOYBALLMOTION,
265         SDL_JOYHATMOTION,
266         SDL_JOYBUTTONDOWN,
267         SDL_JOYBUTTONUP,
268         SDL_JOYDEVICEADDED,
269         SDL_JOYDEVICEREMOVED,
270         SDL_CONTROLLERAXISMOTION = 0x650,
271         SDL_CONTROLLERBUTTONDOWN,
272         SDL_CONTROLLERBUTTONUP,
273         SDL_CONTROLLERDEVICEADDED,
274         SDL_CONTROLLERDEVICEREMOVED,
275         SDL_CONTROLLERDEVICEREMAPPED,
276         SDL_FINGERDOWN = 0x700,
277         SDL_FINGERUP,
278         SDL_FINGERMOTION,
279         SDL_DOLLARGESTURE = 0x800,
280         SDL_DOLLARRECORD,
281         SDL_MULTIGESTURE,
282         SDL_CLIPBOARDUPDATE = 0x900,
283         SDL_DROPFILE = 0x1000,
284         SDL_RENDER_TARGETS_RESET = 0x2000,
285         SDL_USEREVENT = 0x8000,
286         SDL_LASTEVENT = 0xFFFF
287     }
288 }
289 else {
290     enum SDL_EventType {
291         SDL_FIRSTEVENT = 0,
292         SDL_QUIT = 0x100,
293         SDL_APP_TERMINATING,
294         SDL_APP_LOWMEMORY,
295         SDL_APP_WILLENTERBACKGROUND,
296         SDL_APP_DIDENTERBACKGROUND,
297         SDL_APP_WILLENTERFOREGROUND,
298         SDL_APP_DIDENTERFOREGROUND,
299         SDL_WINDOWEVENT = 0x200,
300         SDL_SYSWMEVENT,
301         SDL_KEYDOWN = 0x300,
302         SDL_KEYUP,
303         SDL_TEXTEDITING,
304         SDL_TEXTINPUT,
305         SDL_MOUSEMOTION = 0x400,
306         SDL_MOUSEBUTTONDOWN,
307         SDL_MOUSEBUTTONUP,
308         SDL_MOUSEWHEEL,
309         SDL_JOYAXISMOTION = 0x600,
310         SDL_JOYBALLMOTION,
311         SDL_JOYHATMOTION,
312         SDL_JOYBUTTONDOWN,
313         SDL_JOYBUTTONUP,
314         SDL_JOYDEVICEADDED,
315         SDL_JOYDEVICEREMOVED,
316         SDL_CONTROLLERAXISMOTION = 0x650,
317         SDL_CONTROLLERBUTTONDOWN,
318         SDL_CONTROLLERBUTTONUP,
319         SDL_CONTROLLERDEVICEADDED,
320         SDL_CONTROLLERDEVICEREMOVED,
321         SDL_CONTROLLERDEVICEREMAPPED,
322         SDL_FINGERDOWN = 0x700,
323         SDL_FINGERUP,
324         SDL_FINGERMOTION,
325         SDL_DOLLARGESTURE = 0x800,
326         SDL_DOLLARRECORD,
327         SDL_MULTIGESTURE,
328         SDL_CLIPBOARDUPDATE = 0x900,
329         SDL_DROPFILE = 0x1000,
330         SDL_USEREVENT = 0x8000,
331         SDL_LASTEVENT = 0xFFFF
332     }
333 }
334 mixin(expandEnum!SDL_EventType);
335 
336 struct SDL_CommonEvent {
337     SDL_EventType type;
338     uint timestamp;
339 }
340 
341 static if(sdlSupport >= SDLSupport.sdl209) {
342     struct SDL_DisplayEvent {
343         SDL_EventType type;
344         uint timestamp;
345         uint display;
346         ubyte event;
347         ubyte padding1;
348         ubyte padding2;
349         ubyte padding3;
350         int data1;
351     }
352 }
353 
354 struct SDL_WindowEvent {
355     SDL_EventType type;
356     uint timestamp;
357     uint windowID;
358     SDL_WindowEventID event;
359     ubyte padding1;
360     ubyte padding2;
361     ubyte padding3;
362     int data1;
363     int data2;
364 }
365 
366 struct SDL_KeyboardEvent {
367     SDL_EventType type;
368     uint timestamp;
369     uint windowID;
370     ubyte state;
371     ubyte repeat;
372     ubyte padding2;
373     ubyte padding3;
374     SDL_Keysym keysym;
375 }
376 
377 enum SDL_TEXTEDITINGEVENT_TEXT_SIZE = 32;
378 struct SDL_TextEditingEvent {
379     SDL_EventType type;
380     uint timestamp;
381     uint windowID;
382     char[SDL_TEXTEDITINGEVENT_TEXT_SIZE] text;
383     int start;
384     int length;
385 }
386 
387 enum SDL_TEXTINPUTEVENT_TEXT_SIZE = 32;
388 struct SDL_TextInputEvent {
389     SDL_EventType type;
390     uint timestamp;
391     uint windowID;
392     char[SDL_TEXTINPUTEVENT_TEXT_SIZE] text;
393 }
394 
395 struct SDL_MouseMotionEvent {
396     SDL_EventType type;
397     uint timestamp;
398     uint windowID;
399     uint which;
400     uint state;
401     int x;
402     int y;
403     int xrel;
404     int yrel;
405 }
406 
407 struct SDL_MouseButtonEvent {
408     SDL_EventType type;
409     uint timestamp;
410     uint windowID;
411     uint which;
412     ubyte button;
413     ubyte state;
414     static if(sdlSupport == SDLSupport.sdl200) {
415         ubyte padding1;
416         ubyte padding2;
417     }
418     else {
419         ubyte clicks;
420         ubyte padding1;
421     }
422     int x;
423     int y;
424 }
425 
426 struct SDL_MouseWheelEvent {
427     SDL_EventType type;
428     uint timestamp;
429     uint windowID;
430     uint which;
431     int x;
432     int y;
433     static if(sdlSupport >= SDLSupport.sdl204) {
434         uint direction;
435     }
436 }
437 
438 struct SDL_JoyAxisEvent {
439     SDL_EventType type;
440     uint timestamp;
441     SDL_JoystickID which;
442     ubyte axis;
443     ubyte padding1;
444     ubyte padding2;
445     ubyte padding3;
446     short value;
447     ushort padding4;
448 }
449 
450 struct SDL_JoyBallEvent {
451     SDL_EventType type;
452     uint timestamp;
453     SDL_JoystickID which;
454     ubyte ball;
455     ubyte padding1;
456     ubyte padding2;
457     ubyte padding3;
458     short xrel;
459     short yrel;
460 }
461 
462 struct SDL_JoyHatEvent {
463     SDL_EventType type;
464     uint timestamp;
465     SDL_JoystickID which;
466     ubyte hat;
467     ubyte value;
468     ubyte padding1;
469     ubyte padding2;
470 }
471 
472 struct SDL_JoyButtonEvent {
473     SDL_EventType type;
474     uint timestamp;
475     SDL_JoystickID which;
476     ubyte button;
477     ubyte state;
478     ubyte padding1;
479     ubyte padding2;
480 }
481 
482 struct SDL_JoyDeviceEvent {
483     SDL_EventType type;
484     uint timestamp;
485     int which;
486 }
487 
488 struct SDL_ControllerAxisEvent {
489     SDL_EventType type;
490     uint timestamp;
491     SDL_JoystickID which;
492     ubyte axis;
493     ubyte padding1;
494     ubyte padding2;
495     ubyte padding3;
496     short value;
497     ushort padding4;
498 }
499 
500 struct SDL_ControllerButtonEvent {
501     SDL_EventType type;
502     uint timestamp;
503     SDL_JoystickID which;
504     ubyte button;
505     ubyte state;
506     ubyte padding1;
507     ubyte padding2;
508 }
509 
510 struct SDL_ControllerDeviceEvent {
511     SDL_EventType type;
512     uint timestamp;
513     int which;
514 }
515 
516 static if(sdlSupport >= SDLSupport.sdl2014) {
517     struct SDL_ControllerTouchpadEvent {
518         uint type;
519         uint timestamp;
520         SDL_JoystickID which;
521         int touchpad;
522         int finger;
523         float x;
524         float y;
525         float pressure;
526     }
527 
528     struct SDL_ControllerSensorEvent {
529         uint type;
530         uint timestamp;
531         SDL_JoystickID which;
532         int sensor;
533         float[3] data;
534     }
535 }
536 
537 static if(sdlSupport >= SDLSupport.sdl204) {
538     struct SDL_AudioDeviceEvent {
539         uint type;
540         uint timestamp;
541         uint which;
542         ubyte iscapture;
543         ubyte padding1;
544         ubyte padding2;
545         ubyte padding3;
546     }
547 }
548 
549 struct SDL_TouchFingerEvent {
550     SDL_EventType type;
551     uint timestamp;
552     SDL_TouchID touchId;
553     SDL_FingerID fingerId;
554     float x;
555     float y;
556     float dx;
557     float dy;
558     float pressure;
559 
560     static if(sdlSupport >= SDLSupport.sdl2012) {
561         uint windowID;
562     }
563 }
564 
565 struct SDL_MultiGestureEvent {
566     SDL_EventType type;
567     uint timestamp;
568     SDL_TouchID touchId;
569     float dTheta;
570     float dDist;
571     float x;
572     float y;
573     ushort numFingers;
574     ushort padding;
575 }
576 
577 struct SDL_DollarGestureEvent {
578     SDL_EventType type;
579     uint timestamp;
580     SDL_TouchID touchId;
581     SDL_GestureID gestureId;
582     uint numFingers;
583     float error;
584     float x;
585     float y;
586 }
587 
588 struct SDL_DropEvent {
589     SDL_EventType type;
590     uint timestamp;
591     char* file;
592     static if(sdlSupport >= SDLSupport.sdl205) {
593         uint windowID;
594     }
595 }
596 
597 struct SDL_SensorEvent {
598     SDL_EventType type;
599     uint timestamp;
600     int which;
601     float[6] data;
602 }
603 
604 struct SDL_QuitEvent {
605     SDL_EventType type;
606     uint timestamp;
607 }
608 
609 struct SDL_OSEvent {
610     SDL_EventType type;
611     uint timestamp;
612 }
613 
614 struct SDL_UserEvent {
615     SDL_EventType type;
616     uint timestamp;
617     uint windowID;
618     int code;
619     void* data1;
620     void* data2;
621 }
622 
623 struct SDL_SysWMEvent {
624     SDL_EventType type;
625     uint timestamp;
626     SDL_SysWMmsg* msg;
627 }
628 
629 union SDL_Event {
630     SDL_EventType type;
631     SDL_CommonEvent common;
632     static if(sdlSupport >= SDLSupport.sdl209) {
633         SDL_DisplayEvent display;
634     }
635     SDL_WindowEvent window;
636     SDL_KeyboardEvent key;
637     SDL_TextEditingEvent edit;
638     SDL_TextInputEvent text;
639     SDL_MouseMotionEvent motion;
640     SDL_MouseButtonEvent button;
641     SDL_MouseWheelEvent wheel;
642     SDL_JoyAxisEvent jaxis;
643     SDL_JoyBallEvent jball;
644     SDL_JoyHatEvent jhat;
645     SDL_JoyButtonEvent jbutton;
646     SDL_JoyDeviceEvent jdevice;
647     SDL_ControllerAxisEvent caxis;
648     SDL_ControllerButtonEvent cbutton;
649     SDL_ControllerDeviceEvent cdevice;
650     static if(sdlSupport >= SDLSupport.sdl2014) {
651         SDL_ControllerTouchpadEvent ctouchpad;
652         SDL_ControllerSensorEvent csensor;
653     }
654     static if(sdlSupport >= SDLSupport.sdl204) {
655         SDL_AudioDeviceEvent adevice;
656     }
657     static if(sdlSupport >= SDLSupport.sdl209) {
658         SDL_SensorEvent sensor;
659     }
660     SDL_QuitEvent quit;
661     SDL_UserEvent user;
662     SDL_SysWMEvent syswm;
663     SDL_TouchFingerEvent tfinger;
664     SDL_MultiGestureEvent mgesture;
665     SDL_DollarGestureEvent dgesture;
666     SDL_DropEvent drop;
667 
668     ubyte[56] padding;
669 }
670 
671 enum SDL_eventaction {
672     SDL_ADDEVENT,
673     SDL_PEEKEVENT,
674     SDL_GETEVENT
675 }
676 alias SDL_EventAction = SDL_eventaction;
677 mixin(expandEnum!SDL_EventAction);
678 
679 extern(C) nothrow alias SDL_EventFilter = int function(void* userdata, SDL_Event* event);
680 
681 enum {
682     SDL_QUERY = -1,
683     SDL_IGNORE = 0,
684     SDL_DISABLE = 0,
685     SDL_ENABLE = 1,
686 }
687 
688 @nogc nothrow {
689     int SDL_GetEventState(SDL_EventType type) {
690         pragma(inline, true);
691         return SDL_EventState(type, SDL_QUERY);
692     }
693 
694     // This is implemented in SDL_quit.h, but works better here.
695     bool SDL_QuitRequested() {
696         pragma(inline, true);
697         SDL_PumpEvents();
698         return SDL_PeepEvents(null,0,SDL_PEEKEVENT,SDL_QUIT,SDL_QUIT) > 0;
699     }
700 }
701 
702 static if(staticBinding) {
703     extern(C) @nogc nothrow {
704         void SDL_PumpEvents();
705         int SDL_PeepEvents(SDL_Event* events, int numevents, SDL_eventaction action, uint minType, uint maxType);
706         SDL_bool SDL_HasEvent(uint type);
707         SDL_bool SDL_HasEvents(uint minType, uint maxType);
708         void SDL_FlushEvent(uint type);
709         void SDL_FlushEvents(uint minType, uint maxType);
710         int SDL_PollEvent(SDL_Event* event);
711         int SDL_WaitEvent(SDL_Event* event);
712         int SDL_WaitEventTimeout(SDL_Event* event, int timeout);
713         int SDL_PushEvent(SDL_Event* event);
714         void SDL_SetEventFilter(SDL_EventFilter filter, void* userdata);
715         SDL_bool SDL_GetEventFilter(SDL_EventFilter* filter, void** userdata);
716         void SDL_AddEventWatch(SDL_EventFilter filter, void* userdata);
717         void SDL_DelEventWatch(SDL_EventFilter filter, void* userdata);
718         void SDL_FilterEvents(SDL_EventFilter filter, void* userdata);
719         ubyte SDL_EventState(uint type, int state);
720         uint SDL_RegisterEvents(int numevents);
721     }
722 }
723 else {
724     extern(C) @nogc nothrow {
725         alias pSDL_PumpEvents = void function();
726         alias pSDL_PeepEvents = int function(SDL_Event* events, int numevents, SDL_eventaction action, uint minType, uint maxType);
727         alias pSDL_HasEvent = SDL_bool function(uint type);
728         alias pSDL_HasEvents = SDL_bool function(uint minType, uint maxType);
729         alias pSDL_FlushEvent = void function(uint type);
730         alias pSDL_FlushEvents = void function(uint minType, uint maxType);
731         alias pSDL_PollEvent = int function(SDL_Event* event);
732         alias pSDL_WaitEvent = int function(SDL_Event* event);
733         alias pSDL_WaitEventTimeout = int function(SDL_Event* event, int timeout);
734         alias pSDL_PushEvent = int function(SDL_Event* event);
735         alias pSDL_SetEventFilter = void function(SDL_EventFilter filter, void* userdata);
736         alias pSDL_GetEventFilter = SDL_bool function(SDL_EventFilter* filter, void** userdata);
737         alias pSDL_AddEventWatch = void function(SDL_EventFilter filter, void* userdata);
738         alias pSDL_DelEventWatch = void function(SDL_EventFilter filter, void* userdata);
739         alias pSDL_FilterEvents = void function(SDL_EventFilter filter, void* userdata);
740         alias pSDL_EventState = ubyte function(uint type, int state);
741         alias pSDL_RegisterEvents = uint function(int numevents);
742     }
743 
744     __gshared {
745         pSDL_PumpEvents SDL_PumpEvents;
746         pSDL_PeepEvents SDL_PeepEvents;
747         pSDL_HasEvent SDL_HasEvent;
748         pSDL_HasEvents SDL_HasEvents;
749         pSDL_FlushEvent SDL_FlushEvent;
750         pSDL_FlushEvents SDL_FlushEvents;
751         pSDL_PollEvent SDL_PollEvent;
752         pSDL_WaitEvent SDL_WaitEvent;
753         pSDL_WaitEventTimeout SDL_WaitEventTimeout;
754         pSDL_PushEvent SDL_PushEvent;
755         pSDL_SetEventFilter SDL_SetEventFilter;
756         pSDL_GetEventFilter SDL_GetEventFilter;
757         pSDL_AddEventWatch SDL_AddEventWatch;
758         pSDL_DelEventWatch SDL_DelEventWatch;
759         pSDL_FilterEvents SDL_FilterEvents;
760         pSDL_EventState SDL_EventState;
761         pSDL_RegisterEvents SDL_RegisterEvents;
762     }
763 }