actual version
[sdl-headers.git] / sdlevents.inc
1 //from "sdl_events.h"
2
3   {**
4    *  The types of events that can be delivered.
5    *}
6
7 const
8
9   SDL_FIRSTEVENT       = 0;     // Unused (do not remove) (needed in pascal?)
10
11   SDL_COMMONEVENT      = 1;     //added for pascal-compatibility
12
13   { Application events }
14   SDL_QUITEV           = $100;  // User-requested quit (originally SDL_QUIT, but changed, cause theres a method called SDL_QUIT)
15
16
17   {* These application events have special meaning on iOS, see README.iOS for details *}
18   SDL_APP_TERMINATING  = $101;   {**< The application is being terminated by the OS
19                                       Called on iOS in applicationWillTerminate()
20                                       Called on Android in onDestroy()
21                                   *}
22   SDL_APP_LOWMEMORY    = $102;   {**< The application is low on memory, free memory if possible.
23                                       Called on iOS in applicationDidReceiveMemoryWarning()
24                                       Called on Android in onLowMemory()
25                                   *}
26   SDL_APP_WILLENTERBACKGROUND = $103; {**< The application is about to enter the background
27                                            Called on iOS in applicationWillResignActive()
28                                            Called on Android in onPause()
29                                        *}
30   SDL_APP_DIDENTERBACKGROUND = $104;  {**< The application did enter the background and may not get CPU for some time
31                                            Called on iOS in applicationDidEnterBackground()
32                                            Called on Android in onPause()
33                                        *}
34   SDL_APP_WILLENTERFOREGROUND = $105; {**< The application is about to enter the foreground
35                                            Called on iOS in applicationWillEnterForeground()
36                                            Called on Android in onResume()
37                                        *}
38   SDL_APP_DIDENTERFOREGROUND = $106;  {**< The application is now interactive
39                                            Called on iOS in applicationDidBecomeActive()
40                                            Called on Android in onResume()
41                                        *}
42
43   { Window events }
44   SDL_WINDOWEVENT      = $200;  // Window state change
45   SDL_SYSWMEVENT       = $201;  // System specific event
46
47   { Keyboard events }
48   SDL_KEYDOWN          = $300;  // Key pressed
49   SDL_KEYUP            = $301;  // Key released
50   SDL_TEXTEDITING      = $302;  // Keyboard text editing (composition)
51   SDL_TEXTINPUT        = $303;  // Keyboard text input
52
53   { Mouse events }
54   SDL_MOUSEMOTION      = $400;  // Mouse moved
55   SDL_MOUSEBUTTONDOWN  = $401;  // Mouse button pressed
56   SDL_MOUSEBUTTONUP    = $402;  // Mouse button released
57   SDL_MOUSEWHEEL       = $403;  // Mouse wheel motion
58
59   { Joystick events }
60   SDL_JOYAXISMOTION    = $600;  // Joystick axis motion
61   SDL_JOYBALLMOTION    = $601;  // Joystick trackball motion
62   SDL_JOYHATMOTION     = $602;  // Joystick hat position change
63   SDL_JOYBUTTONDOWN    = $603;  // Joystick button pressed
64   SDL_JOYBUTTONUP      = $604;  // Joystick button released
65   SDL_JOYDEVICEADDED   = $605;  // A new joystick has been inserted into the system 
66   SDL_JOYDEVICEREMOVED = $606;  // An opened joystick has been removed 
67
68   { Game controller events }
69   SDL_CONTROLLERAXISMOTION     = $650;  // Game controller axis motion
70   SDL_CONTROLLERBUTTONDOWN     = $651;  // Game controller button pressed 
71   SDL_CONTROLLERBUTTONUP       = $652;  // Game controller button released
72   SDL_CONTROLLERDEVICEADDED    = $653;  // A new Game controller has been inserted into the system 
73   SDL_CONTROLLERDEVICEREMOVED  = $654;  // An opened Game controller has been removed 
74   SDL_CONTROLLERDEVICEREMAPPED = $655;  // The controller mapping was updated 
75
76   { Touch events }
77   SDL_FINGERDOWN      = $700;
78   SDL_FINGERUP        = $701;
79   SDL_FINGERMOTION    = $702;
80
81   { Gesture events }
82   SDL_DOLLARGESTURE   = $800;
83   SDL_DOLLARRECORD    = $801;
84   SDL_MULTIGESTURE    = $802;
85
86   { Clipboard events }
87   SDL_CLIPBOARDUPDATE = $900; // The clipboard changed
88
89   { Drag and drop events }
90   SDL_DROPFILE        = $1000; // The system requests a file open
91
92   {** Events SDL_USEREVENT through SDL_LASTEVENT are for your use,
93    *  and should be allocated with SDL_RegisterEvents()
94    *}
95   SDL_USEREVENT    = $8000;
96
97   {**
98    *  This last event is only for bounding internal arrays (needed in pascal ??)
99    *}
100   SDL_LASTEVENT    = $FFFF;
101
102 type
103
104   TSDL_EventType = Word;
105
106   {**
107    *  Fields shared by every event
108    *}
109
110   TSDL_CommonEvent = record
111     type_: UInt32;
112     timestamp: UInt32;
113   end;
114
115   {**
116    *  Window state change event data (event.window.*)
117    *}
118
119   TSDL_WindowEvent = record
120     type_: UInt32;       // SDL_WINDOWEVENT
121     timestamp: UInt32;
122     windowID: UInt32;    // The associated window
123     event: UInt8;        // SDL_WindowEventID
124     padding1: UInt8;
125     padding2: UInt8;
126     padding3: UInt8;
127     data1: SInt32;       // event dependent data
128     data2: SInt32;       // event dependent data 
129   end;
130
131   {**
132    *  Keyboard button event structure (event.key.*)
133    *}
134   TSDL_KeyboardEvent = record
135     type_: UInt32;        // SDL_KEYDOWN or SDL_KEYUP
136     timestamp: UInt32;
137     windowID: UInt32;     // The window with keyboard focus, if any
138     state: UInt8;         // SDL_PRESSED or SDL_RELEASED 
139     _repeat: UInt8;       // Non-zero if this is a key repeat
140     padding2: UInt8;
141     padding3: UInt8;
142     keysym: TSDL_KeySym;  // The key that was pressed or released
143   end;
144
145 const
146   SDL_TEXTEDITINGEVENT_TEXT_SIZE = 32;
147
148 type
149  
150   {**
151    *  Keyboard text editing event structure (event.edit.*)
152    *}
153
154   TSDL_TextEditingEvent = record
155     type_: UInt32;                               // SDL_TEXTEDITING 
156     timestamp: UInt32;
157     windowID: UInt32;                            // The window with keyboard focus, if any
158     text: array[0..SDL_TEXTEDITINGEVENT_TEXT_SIZE] of Char;  // The editing text 
159     start: SInt32;                               // The start cursor of selected editing text
160     length: SInt32;                              // The length of selected editing text
161   end;
162
163 const
164   SDL_TEXTINPUTEVENT_TEXT_SIZE = 32;
165
166 type
167
168   {**
169    *  Keyboard text input event structure (event.text.*)
170    *}
171
172   TSDL_TextInputEvent = record
173     type_: UInt32;                                          // SDL_TEXTINPUT 
174     timestamp: UInt32;
175     windowID: UInt32;                                       // The window with keyboard focus, if any
176     text: array[0..SDL_TEXTINPUTEVENT_TEXT_SIZE] of Char;   // The input text 
177   end;
178
179   {**
180    *  Mouse motion event structure (event.motion.*)
181    *}
182  
183   TSDL_MouseMotionEvent = record
184     type_: UInt32;       // SDL_MOUSEMOTION
185     timestamp: UInt32;
186     windowID: UInt32;    // The window with mouse focus, if any
187     which: UInt32;       // The mouse instance id, or SDL_TOUCH_MOUSEID
188     state: UInt8;        // The current button state 
189     padding1: UInt8;
190     padding2: UInt8;
191     padding3: UInt8;
192     x: SInt32;           // X coordinate, relative to window
193     y: SInt32;           // Y coordinate, relative to window
194     xrel: SInt32;        // The relative motion in the X direction 
195     yrel: SInt32;        // The relative motion in the Y direction
196   end;
197
198   {**
199    *  Mouse button event structure (event.button.*)
200    *}
201
202   TSDL_MouseButtonEvent = record
203     type_: UInt32;       // SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP 
204     timestamp: UInt32;
205     windowID: UInt32;    // The window with mouse focus, if any
206     which: UInt32;       // The mouse instance id, or SDL_TOUCH_MOUSEID 
207     button: UInt8;       // The mouse button index
208     state: UInt8;        // SDL_PRESSED or SDL_RELEASED
209     padding1: UInt8;
210     padding2: UInt8;
211     x: SInt32;           // X coordinate, relative to window
212     y: SInt32;           // Y coordinate, relative to window 
213   end;
214
215   {**
216    *  Mouse wheel event structure (event.wheel.*)
217    *}
218  
219   TSDL_MouseWheelEvent = record
220     type_: UInt32;        // SDL_MOUSEWHEEL
221     timestamp: UInt32;
222     windowID: UInt32;    // The window with mouse focus, if any
223     which: UInt32;       // The mouse instance id, or SDL_TOUCH_MOUSEID
224     x: SInt32;           // The amount scrolled horizontally 
225     y: SInt32;           // The amount scrolled vertically
226   end;
227
228   {**
229    *  Joystick axis motion event structure (event.jaxis.*)
230    *}
231
232   TSDL_JoyAxisEvent = record
233     type_: UInt32;         // SDL_JOYAXISMOTION 
234     timestamp: UInt32;
235     which: TSDL_JoystickID; // The joystick instance id
236     axis: UInt8;           // The joystick axis index 
237     padding1: UInt8;
238     padding2: UInt8;
239     padding3: UInt8;
240     value: SInt16;         // The axis value (range: -32768 to 32767)
241     padding4: UInt16;
242   end;
243
244   {**
245    *  Joystick trackball motion event structure (event.jball.*)
246    *}
247
248   TSDL_JoyBallEvent = record
249     type_: UInt32;         // SDL_JOYBALLMOTION
250     timestamp: UInt32;
251     which: TSDL_JoystickID; // The joystick instance id
252     ball: UInt8;           // The joystick trackball index
253     padding1: UInt8;
254     padding2: UInt8;
255     padding3: UInt8;
256     xrel: SInt16;          // The relative motion in the X direction
257     yrel: SInt16;          // The relative motion in the Y direction
258   end;
259
260   {**
261    *  Joystick hat position change event structure (event.jhat.*)
262    *}
263
264   TSDL_JoyHatEvent = record
265     type_: UInt32;         // SDL_JOYHATMOTION
266     timestamp: UInt32;
267     which: TSDL_JoystickID; // The joystick instance id
268     hat: UInt8;            // The joystick hat index
269     value: UInt8;         {*  The hat position value.
270                            *  SDL_HAT_LEFTUP   SDL_HAT_UP       SDL_HAT_RIGHTUP
271                            *  SDL_HAT_LEFT     SDL_HAT_CENTERED SDL_HAT_RIGHT
272                            *  SDL_HAT_LEFTDOWN SDL_HAT_DOWN     SDL_HAT_RIGHTDOWN
273                            *
274                            *  Note that zero means the POV is centered.
275                            *}
276     padding1: UInt8;
277     padding2: UInt8;
278   end;
279
280   {**
281    *  Joystick button event structure (event.jbutton.*)
282    *}
283
284   TSDL_JoyButtonEvent = record
285     type_: UInt32;        // SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP
286     timestamp: UInt32;
287     which: TSDL_JoystickID; // The joystick instance id 
288     button: UInt8;         // The joystick button index
289     state: UInt8;          // SDL_PRESSED or SDL_RELEASED
290     padding1: UInt8;
291     padding2: UInt8;
292   end;
293
294   {**
295    *  Joystick device event structure (event.jdevice.*)
296    *}
297
298   TSDL_JoyDeviceEvent = record
299     type_: UInt32;      // SDL_JOYDEVICEADDED or SDL_JOYDEVICEREMOVED
300     timestamp: UInt32;
301     which: SInt32;      // The joystick device index for the ADDED event, instance id for the REMOVED event
302   end;
303
304   {**
305    *  Game controller axis motion event structure (event.caxis.*)
306    *}
307
308   TSDL_ControllerAxisEvent = record
309     type_: UInt32;         // SDL_CONTROLLERAXISMOTION
310     timestamp: UInt32;
311     which: TSDL_JoystickID; // The joystick instance id
312     axis: UInt8;           // The controller axis (SDL_GameControllerAxis)
313     padding1: UInt8;
314     padding2: UInt8;
315     padding3: UInt8;
316     value: SInt16;         // The axis value (range: -32768 to 32767)
317     padding4: UInt16;
318   end;
319
320   {**
321    *  Game controller button event structure (event.cbutton.*)
322    *}
323
324   TSDL_ControllerButtonEvent = record
325     type_: UInt32;         // SDL_CONTROLLERBUTTONDOWN or SDL_CONTROLLERBUTTONUP
326     timestamp: UInt32;
327     which: TSDL_JoystickID; // The joystick instance id
328     button: UInt8;         // The controller button (SDL_GameControllerButton)
329     state: UInt8;          // SDL_PRESSED or SDL_RELEASED
330     padding1: UInt8;
331     padding2: UInt8;
332   end;
333
334
335   {**
336    *  Controller device event structure (event.cdevice.*)
337    *}
338
339   TSDL_ControllerDeviceEvent = record
340     type_: UInt32;       // SDL_CONTROLLERDEVICEADDED, SDL_CONTROLLERDEVICEREMOVED, or SDL_CONTROLLERDEVICEREMAPPED
341     timestamp: UInt32;
342     which: SInt32;       // The joystick device index for the ADDED event, instance id for the REMOVED or REMAPPED event
343   end;
344
345   {**
346    *  Touch finger event structure (event.tfinger.*)
347    *}
348
349   TSDL_TouchFingerEvent = record
350     type_: UInt32;         // SDL_FINGERMOTION or SDL_FINGERDOWN or SDL_FINGERUP
351     timestamp: UInt32;
352     touchId: TSDL_TouchID;  // The touch device id
353     fingerId: TSDL_FingerID;
354     x: Float;              // Normalized in the range 0...1
355     y: Float;              // Normalized in the range 0...1
356     dx: Float;             // Normalized in the range 0...1
357     dy: Float;             // Normalized in the range 0...1
358     pressure: Float;       // Normalized in the range 0...1
359   end;
360
361   {**
362    *  Multiple Finger Gesture Event (event.mgesture.*)
363    *}
364   TSDL_MultiGestureEvent = record
365     type_: UInt32;        // SDL_MULTIGESTURE
366     timestamp: UInt32;
367     touchId: TSDL_TouchID; // The touch device index
368     dTheta: Float;
369     dDist: Float;
370     x: Float;
371     y: Float;
372     numFingers: UInt16;
373     padding: UInt16;
374   end;
375
376
377   {* (event.dgesture.*) *}
378   TSDL_DollarGestureEvent = record
379     type_: UInt32;         // SDL_DOLLARGESTURE
380     timestamp: UInt32;
381     touchId: TSDL_TouchID;  // The touch device id
382     gestureId: TSDL_GestureID;
383     numFingers: UInt32;
384     error: Float;
385     x: Float;              // Normalized center of gesture
386     y: Float;              // Normalized center of gesture
387   end;
388
389
390   {**
391    *  An event used to request a file open by the system (event.drop.*)
392    *  This event is disabled by default, you can enable it with SDL_EventState()
393    *  If you enable this event, you must free the filename in the event.
394    *}
395
396   TSDL_DropEvent = record
397     type_: UInt32;      // SDL_DROPFILE
398     timestamp: UInt32;
399     _file: PAnsiChar;   // The file name, which should be freed with SDL_free()
400   end;
401
402   {**
403    *  The "quit requested" event
404    *}
405
406   TSDL_QuitEvent = record
407     type_: UInt32;        // SDL_QUIT
408     timestamp: UInt32;
409   end;
410
411   {**
412    *  A user-defined event type (event.user.*)
413    *}
414
415   TSDL_UserEvent = record
416     type_: UInt32;       // SDL_USEREVENT through SDL_NUMEVENTS-1
417     timestamp: UInt32;
418     windowID: UInt32;    // The associated window if any
419     code: SInt32;        // User defined event code
420     data1: Pointer;      // User defined data pointer
421     data2: Pointer;      // User defined data pointer
422   end;
423
424   {$IFDEF Unix}
425     //These are the various supported subsystems under UNIX
426     TSDL_SysWm = ( SDL_SYSWM_X11 ) ;
427   {$ENDIF}
428
429   // The windows custom event structure
430   {$IFDEF Windows}
431     PSDL_SysWMmsg = ^TSDL_SysWMmsg;
432     TSDL_SysWMmsg = record
433       version: TSDL_Version;
434       h_wnd: HWND; // The window for the message
435       msg: UInt32; // The type of message
436       w_Param: WPARAM; // WORD message parameter
437       lParam: LPARAM; // LONG message parameter
438     end;
439   {$ELSE}
440
441     {$IFDEF Unix}
442       { The Linux custom event structure }
443       PSDL_SysWMmsg = ^TSDL_SysWMmsg;
444       TSDL_SysWMmsg = record
445         version : TSDL_Version;
446         subsystem : TSDL_SysWm;
447         {$IFDEF FPC}
448           {$IFNDEF DARWIN}
449           event : TXEvent;
450           {$ENDIF}
451         {$ELSE}
452           event : XEvent;
453         {$ENDIF}
454       end;
455     {$ELSE}
456       { The generic custom event structure }
457       PSDL_SysWMmsg = ^TSDL_SysWMmsg;
458       TSDL_SysWMmsg = record
459         version: TSDL_Version;
460         data: Integer;
461       end;
462     {$ENDIF}
463
464   {$ENDIF}
465
466   // The Windows custom window manager information structure
467   {$IFDEF Windows}
468     PSDL_SysWMinfo = ^TSDL_SysWMinfo;
469     TSDL_SysWMinfo = record
470       version : TSDL_Version;
471       window : HWnd;    // The display window
472     end;
473   {$ELSE}
474     // The Linux custom window manager information structure
475     {$IFDEF Unix}
476       {$IFNDEF DARWIN}
477       TX11 = record
478         display : PDisplay;     // The X11 display
479         window : TWindow;               // The X11 display window */
480         {* These locking functions should be called around
481            any X11 functions using the display variable.
482            They lock the event thread, so should not be
483            called around event functions or from event filters.
484          *}
485         lock_func : Pointer;
486         unlock_func : Pointer;
487
488         // Introduced in SDL 1.0.2
489         fswindow : TWindow;     // The X11 fullscreen window */
490         wmwindow : TWindow;     // The X11 managed input window */
491       end;
492       {$ENDIF}
493
494       PSDL_SysWMinfo = ^TSDL_SysWMinfo;
495       TSDL_SysWMinfo = record
496          version : TSDL_Version;
497          subsystem : TSDL_SysWm;
498          {$IFNDEF DARWIN}
499          X11 : TX11;
500          {$ENDIF}
501       end;
502     {$ELSE}
503       // The generic custom window manager information structure
504       PSDL_SysWMinfo = ^TSDL_SysWMinfo;
505       TSDL_SysWMinfo = record
506         version : TSDL_Version;
507         data : integer;
508       end;
509     {$ENDIF}
510
511   {$ENDIF}
512
513   {**
514    *  A video driver dependent system event (event.syswm.*)
515    *  This event is disabled by default, you can enable it with SDL_EventState()
516    *
517    *  If you want to use this event, you should include SDL_syswm.h.
518    *}
519
520   PSDL_SysWMEvent = ^TSDL_SysWMEvent;
521   TSDL_SysWMEvent = record
522     type_: UInt32;       // SDL_SYSWMEVENT
523     timestamp: UInt32;
524     msg: PSDL_SysWMmsg;  // driver dependent data (defined in SDL_syswm.h)
525   end;
526
527   {**
528    *  General event structure
529    *}
530
531   PSDL_Event = ^TSDL_Event;
532   TSDL_Event = record
533     case Integer of
534       0:  (type_: UInt32);
535
536       SDL_COMMONEVENT:  (common: TSDL_CommonEvent);
537       SDL_WINDOWEVENT:  (window: TSDL_WindowEvent);
538
539       SDL_KEYUP,
540       SDL_KEYDOWN:  (key: TSDL_KeyboardEvent);
541       SDL_TEXTEDITING:  (edit: TSDL_TextEditingEvent);
542       SDL_TEXTINPUT:  (text: TSDL_TextInputEvent);
543
544       SDL_MOUSEMOTION:  (motion: TSDL_MouseMotionEvent);
545       SDL_MOUSEBUTTONUP,
546       SDL_MOUSEBUTTONDOWN:  (button: TSDL_MouseButtonEvent);
547       SDL_MOUSEWHEEL:  (wheel: TSDL_MouseWheelEvent);
548           
549       SDL_JOYAXISMOTION:  (jaxis: TSDL_JoyAxisEvent);
550       SDL_JOYBALLMOTION: (jball: TSDL_JoyBallEvent);
551       SDL_JOYHATMOTION: (jhat: TSDL_JoyHatEvent);
552       SDL_JOYBUTTONDOWN,
553       SDL_JOYBUTTONUP: (jbutton: TSDL_JoyButtonEvent);
554       SDL_JOYDEVICEADDED,
555       SDL_JOYDEVICEREMOVED: (jdevice: TSDL_JoyDeviceEvent);
556
557       SDL_CONTROLLERAXISMOTION: (caxis: TSDL_ControllerAxisEvent);
558       SDL_CONTROLLERBUTTONUP,
559       SDL_CONTROLLERBUTTONDOWN: (cbutton: TSDL_ControllerButtonEvent);
560       SDL_CONTROLLERDEVICEADDED,
561       SDL_CONTROLLERDEVICEREMOVED,
562       SDL_CONTROLLERDEVICEREMAPPED: (cdevice: TSDL_ControllerDeviceEvent);
563
564       SDL_QUITEV: (quit: TSDL_QuitEvent);
565
566       SDL_USEREVENT: (user: TSDL_UserEvent);
567       SDL_SYSWMEVENT: (syswm: TSDL_SysWMEvent);
568
569       SDL_FINGERDOWN,
570       SDL_FINGERUP,
571       SDL_FINGERMOTION: (tfinger: TSDL_TouchFingerEvent);
572       SDL_MULTIGESTURE: (mgesture: TSDL_MultiGestureEvent);
573       SDL_DOLLARGESTURE,SDL_DOLLARRECORD: (dgesture: TSDL_DollarGestureEvent);
574
575       SDL_DROPFILE: (drop: TSDL_DropEvent);
576   end;
577
578
579   {* Function prototypes *}
580
581   {**
582    *  Pumps the event loop, gathering events from the input devices.
583    *  
584    *  This function updates the event queue and internal input device state.
585    *  
586    *  This should only be run in the thread that sets the video mode.
587    *}
588   procedure SDL_PumpEvents cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_PumpEvents' {$ENDIF} {$ENDIF};
589
590 const
591   SDL_ADDEVENT = 0;
592   SDL_PEEKEVENT = 1;
593   SDL_GETEVENT = 2;
594
595 type
596   TSDL_EventAction = Word;
597
598   {**
599    *  Checks the event queue for messages and optionally returns them.
600    *
601    *  If action is SDL_ADDEVENT, up to numevents events will be added to
602    *  the back of the event queue.
603    *
604    *  If action is SDL_PEEKEVENT, up to numevents events at the front
605    *  of the event queue, within the specified minimum and maximum type,
606    *  will be returned and will not be removed from the queue.
607    *
608    *  If action is SDL_GETEVENT, up to numevents events at the front
609    *  of the event queue, within the specified minimum and maximum type,
610    *  will be returned and will be removed from the queue.
611    *
612    *  Result: The number of events actually stored, or -1 if there was an error.
613    *
614    *  This function is thread-safe.
615    *}
616
617   function SDL_PeepEvents(events: PSDL_Event; numevents: SInt32; action: TSDL_EventAction; minType: UInt32; maxType: UInt32): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_PeepEvents' {$ENDIF} {$ENDIF};
618
619   {**
620    *  Checks to see if certain event types are in the event queue.
621    *}
622
623   function SDL_HasEvent(type_: UInt32): TSDL_Bool  cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HasEvent' {$ENDIF} {$ENDIF};
624   function SDL_HasEvents(minType: UInt32; maxType: UInt32): TSDL_Bool cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HasEvents' {$ENDIF} {$ENDIF};
625
626   {**
627    *  This function clears events from the event queue
628    *}
629
630   procedure SDL_FlushEvent(type_: UInt32) cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_FlushEvent' {$ENDIF} {$ENDIF};
631   procedure SDL_FlushEvents(minType: UInt32; maxType: UInt32) cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_FlushEvents' {$ENDIF} {$ENDIF};
632
633   {**
634    *  Polls for currently pending events.
635    *
636    *  1 if there are any pending events, or 0 if there are none available.
637    *
638    *  event - If not nil, the next event is removed from the queue and
639    *               stored in that area.
640    *}
641
642   function SDL_PollEvent(event: PSDL_Event): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_PollEvent' {$ENDIF} {$ENDIF};
643
644   {**
645    *  Waits indefinitely for the next available event.
646    *  
647    *  1, or 0 if there was an error while waiting for events.
648    *   
649    *  event - If not nil, the next event is removed from the queue and 
650    *  stored in that area.
651    *}
652
653   function SDL_WaitEvent(event: PSDL_Event): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_WaitEvent' {$ENDIF} {$ENDIF};
654
655   {**
656    *  Waits until the specified timeout (in milliseconds) for the next
657    *  available event.
658    *  
659    *  1, or 0 if there was an error while waiting for events.
660    *  
661    *  event - If not nil, the next event is removed from the queue and
662    *  stored in that area.
663    *}
664  
665   function SDL_WaitEventTimeout(event: PSDL_Event; timeout: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_WaitEventTimeout' {$ENDIF} {$ENDIF};
666
667   {**
668    *  Add an event to the event queue.
669    *  
670    *  1 on success, 0 if the event was filtered, or -1 if the event queue
671    *  was full or there was some other error.
672    *}
673
674   function SDL_PushEvent(event: PSDL_Event): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_PumpEvents' {$ENDIF} {$ENDIF};
675
676 type
677   PSDL_EventFilter = ^TSDL_EventFilter;
678   {$IFNDEF GPC}
679     TSDL_EventFilter = function( event: PSDL_Event ): Integer; cdecl;
680   {$ELSE}
681     TSDL_EventFilter = function( event: PSDL_Event ): Integer;
682   {$ENDIF}
683
684   {**
685    *  Sets up a filter to process all events before they change internal state and
686    *  are posted to the internal event queue.
687    *
688    *  If the filter returns 1, then the event will be added to the internal queue.
689    *  If it returns 0, then the event will be dropped from the queue, but the 
690    *  internal state will still be updated.  This allows selective filtering of
691    *  dynamically arriving events.
692    *
693    *  Be very careful of what you do in the event filter function, as 
694    *  it may run in a different thread!
695    *  
696    *  There is one caveat when dealing with the SDL_QUITEVENT event type.  The
697    *  event filter is only called when the window manager desires to close the
698    *  application window.  If the event filter returns 1, then the window will
699    *  be closed, otherwise the window will remain open if possible.
700    *
701    *  If the quit event is generated by an interrupt signal, it will bypass the
702    *  internal queue and be delivered to the application at the next event poll.
703    *}
704  
705   procedure SDL_SetEventFilter(filter: TSDL_EventFilter; userdata: Pointer) cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetEventFilter' {$ENDIF} {$ENDIF};
706
707   {**
708    *  Return the current event filter - can be used to "chain" filters.
709    *  If there is no event filter set, this function returns SDL_FALSE.
710    *}
711
712   function SDL_GetEventFilter(filter: PSDL_EventFilter; userdata: Pointer): TSDL_Bool cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetEventFilter' {$ENDIF} {$ENDIF};
713
714   {**
715    *  Add a function which is called when an event is added to the queue.
716    *}
717  
718   procedure SDL_AddEventWatch(filter: TSDL_EventFilter; userdata: Pointer) cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_AddEventWatch' {$ENDIF} {$ENDIF};
719
720   {**
721    *  Remove an event watch function added with SDL_AddEventWatch()
722    *}
723  
724   procedure SDL_DelEventWatch(filter: TSDL_EventFilter; userdata: Pointer) cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_DelEventWatch' {$ENDIF} {$ENDIF};
725
726   {**
727    *  Run the filter function on the current event queue, removing any
728    *  events for which the filter returns 0.
729    *}
730
731   procedure SDL_FilterEvents(filter: TSDL_EventFilter; userdata: Pointer) cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_FilterEvents' {$ENDIF} {$ENDIF};
732
733 const
734
735   SDL_QUERY   = -1;
736   SDL_IGNORE  =  0;
737   SDL_DISABLE =  0;
738   SDL_ENABLE  =  1;
739
740   {**
741    *  This function allows you to set the state of processing certain events.
742    *   - If state is set to SDL_IGNORE, that event will be automatically
743    *     dropped from the event queue and will not event be filtered.
744    *   - If state is set to SDL_ENABLE, that event will be processed
745    *     normally.
746    *   - If state is set to SDL_QUERY, SDL_EventState() will return the
747    *     current processing state of the specified event.
748    *}
749
750   function SDL_EventState(type_: UInt32; state: SInt32): UInt8 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_EventState' {$ENDIF} {$ENDIF};
751
752   function SDL_GetEventState(type_: UInt32): UInt8;
753
754   {**
755    *  This function allocates a set of user-defined events, and returns
756    *  the beginning event number for that set of events.
757    *
758    *  If there aren't enough user-defined events left, this function
759    *  returns (Uint32)-1
760    *}
761
762   function SDL_RegisterEvents(numevents: SInt32): UInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RegisterEvents' {$ENDIF} {$ENDIF};