4 * The types of events that can be delivered.
9 SDL_FIRSTEVENT = 0; // Unused (do not remove) (needed in pascal?)
11 SDL_COMMONEVENT = 1; //added for pascal-compatibility
13 { Application events }
14 SDL_QUITEV = $100; // User-requested quit (originally SDL_QUIT, but changed, cause theres a method called SDL_QUIT)
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()
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()
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()
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()
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()
38 SDL_APP_DIDENTERFOREGROUND = $106; {**< The application is now interactive
39 Called on iOS in applicationDidBecomeActive()
40 Called on Android in onResume()
44 SDL_WINDOWEVENT = $200; // Window state change
45 SDL_SYSWMEVENT = $201; // System specific event
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 SDL_KEYMAPCHANGED = $304; // Keymap changed due to a system event such as an
53 // input language or keyboard layout change.
56 SDL_MOUSEMOTION = $400; // Mouse moved
57 SDL_MOUSEBUTTONDOWN = $401; // Mouse button pressed
58 SDL_MOUSEBUTTONUP = $402; // Mouse button released
59 SDL_MOUSEWHEEL = $403; // Mouse wheel motion
62 SDL_JOYAXISMOTION = $600; // Joystick axis motion
63 SDL_JOYBALLMOTION = $601; // Joystick trackball motion
64 SDL_JOYHATMOTION = $602; // Joystick hat position change
65 SDL_JOYBUTTONDOWN = $603; // Joystick button pressed
66 SDL_JOYBUTTONUP = $604; // Joystick button released
67 SDL_JOYDEVICEADDED = $605; // A new joystick has been inserted into the system
68 SDL_JOYDEVICEREMOVED = $606; // An opened joystick has been removed
70 { Game controller events }
71 SDL_CONTROLLERAXISMOTION = $650; // Game controller axis motion
72 SDL_CONTROLLERBUTTONDOWN = $651; // Game controller button pressed
73 SDL_CONTROLLERBUTTONUP = $652; // Game controller button released
74 SDL_CONTROLLERDEVICEADDED = $653; // A new Game controller has been inserted into the system
75 SDL_CONTROLLERDEVICEREMOVED = $654; // An opened Game controller has been removed
76 SDL_CONTROLLERDEVICEREMAPPED = $655; // The controller mapping was updated
79 SDL_FINGERDOWN = $700;
81 SDL_FINGERMOTION = $702;
84 SDL_DOLLARGESTURE = $800;
85 SDL_DOLLARRECORD = $801;
86 SDL_MULTIGESTURE = $802;
89 SDL_CLIPBOARDUPDATE = $900; // The clipboard changed
91 { Drag and drop events }
92 SDL_DROPFILE = $1000; // The system requests a file open
94 { Audio hotplug events }
95 SDL_AUDIODEVICEADDED = $1100; // A new audio device is available
96 SDL_AUDIODEVICEREMOVED = $1101; // An audio device has been removed.
99 SDL_RENDER_TARGETS_RESET = $2000; // The render targets have been reset
100 SDL_RENDER_DEVICE_RESET = $2001; // The device has been reset and all textures need to be recreated
102 {** Events SDL_USEREVENT through SDL_LASTEVENT are for your use,
103 * and should be allocated with SDL_RegisterEvents()
105 SDL_USEREVENT = $8000;
108 * This last event is only for bounding internal arrays (needed in pascal ??)
110 SDL_LASTEVENT = $FFFF;
114 TSDL_EventType = Word;
117 * Fields shared by every event
120 TSDL_CommonEvent = record
126 * Window state change event data (event.window.*)
129 TSDL_WindowEvent = record
130 type_: UInt32; // SDL_WINDOWEVENT
132 windowID: UInt32; // The associated window
133 event: UInt8; // SDL_WindowEventID
137 data1: SInt32; // event dependent data
138 data2: SInt32; // event dependent data
142 * Keyboard button event structure (event.key.*)
144 TSDL_KeyboardEvent = record
145 type_: UInt32; // SDL_KEYDOWN or SDL_KEYUP
147 windowID: UInt32; // The window with keyboard focus, if any
148 state: UInt8; // SDL_PRESSED or SDL_RELEASED
149 _repeat: UInt8; // Non-zero if this is a key repeat
152 keysym: TSDL_KeySym; // The key that was pressed or released
156 SDL_TEXTEDITINGEVENT_TEXT_SIZE = 32;
161 * Keyboard text editing event structure (event.edit.*)
164 TSDL_TextEditingEvent = record
165 type_: UInt32; // SDL_TEXTEDITING
167 windowID: UInt32; // The window with keyboard focus, if any
168 text: array[0..SDL_TEXTEDITINGEVENT_TEXT_SIZE] of Char; // The editing text
169 start: SInt32; // The start cursor of selected editing text
170 length: SInt32; // The length of selected editing text
174 SDL_TEXTINPUTEVENT_TEXT_SIZE = 32;
179 * Keyboard text input event structure (event.text.*)
182 TSDL_TextInputEvent = record
183 type_: UInt32; // SDL_TEXTINPUT
185 windowID: UInt32; // The window with keyboard focus, if any
186 text: array[0..SDL_TEXTINPUTEVENT_TEXT_SIZE] of Char; // The input text
190 * Mouse motion event structure (event.motion.*)
193 TSDL_MouseMotionEvent = record
194 type_: UInt32; // SDL_MOUSEMOTION
196 windowID: UInt32; // The window with mouse focus, if any
197 which: UInt32; // The mouse instance id, or SDL_TOUCH_MOUSEID
198 state: UInt8; // The current button state
202 x: SInt32; // X coordinate, relative to window
203 y: SInt32; // Y coordinate, relative to window
204 xrel: SInt32; // The relative motion in the X direction
205 yrel: SInt32; // The relative motion in the Y direction
209 * Mouse button event structure (event.button.*)
212 TSDL_MouseButtonEvent = record
213 type_: UInt32; // SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP
215 windowID: UInt32; // The window with mouse focus, if any
216 which: UInt32; // The mouse instance id, or SDL_TOUCH_MOUSEID
217 button: UInt8; // The mouse button index
218 state: UInt8; // SDL_PRESSED or SDL_RELEASED
219 clicks: UInt8; // 1 for single-click, 2 for double-click, etc.
221 x: SInt32; // X coordinate, relative to window
222 y: SInt32; // Y coordinate, relative to window
226 * Mouse wheel event structure (event.wheel.*)
229 TSDL_MouseWheelEvent = record
230 type_: UInt32; // SDL_MOUSEWHEEL
232 windowID: UInt32; // The window with mouse focus, if any
233 which: UInt32; // The mouse instance id, or SDL_TOUCH_MOUSEID
234 x: SInt32; // The amount scrolled horizontally
235 y: SInt32; // The amount scrolled vertically
236 direction: UInt32; // Set to one of the SDL_MOUSEWHEEL_* defines. When FLIPPED the values in X and Y will be opposite. Multiply by -1 to change them back
240 * Joystick axis motion event structure (event.jaxis.*)
243 TSDL_JoyAxisEvent = record
244 type_: UInt32; // SDL_JOYAXISMOTION
246 which: TSDL_JoystickID; // The joystick instance id
247 axis: UInt8; // The joystick axis index
251 value: SInt16; // The axis value (range: -32768 to 32767)
256 * Joystick trackball motion event structure (event.jball.*)
259 TSDL_JoyBallEvent = record
260 type_: UInt32; // SDL_JOYBALLMOTION
262 which: TSDL_JoystickID; // The joystick instance id
263 ball: UInt8; // The joystick trackball index
267 xrel: SInt16; // The relative motion in the X direction
268 yrel: SInt16; // The relative motion in the Y direction
272 * Joystick hat position change event structure (event.jhat.*)
275 TSDL_JoyHatEvent = record
276 type_: UInt32; // SDL_JOYHATMOTION
278 which: TSDL_JoystickID; // The joystick instance id
279 hat: UInt8; // The joystick hat index
280 value: UInt8; {* The hat position value.
281 * SDL_HAT_LEFTUP SDL_HAT_UP SDL_HAT_RIGHTUP
282 * SDL_HAT_LEFT SDL_HAT_CENTERED SDL_HAT_RIGHT
283 * SDL_HAT_LEFTDOWN SDL_HAT_DOWN SDL_HAT_RIGHTDOWN
285 * Note that zero means the POV is centered.
292 * Joystick button event structure (event.jbutton.*)
295 TSDL_JoyButtonEvent = record
296 type_: UInt32; // SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP
298 which: TSDL_JoystickID; // The joystick instance id
299 button: UInt8; // The joystick button index
300 state: UInt8; // SDL_PRESSED or SDL_RELEASED
306 * Joystick device event structure (event.jdevice.*)
309 TSDL_JoyDeviceEvent = record
310 type_: UInt32; // SDL_JOYDEVICEADDED or SDL_JOYDEVICEREMOVED
312 which: SInt32; // The joystick device index for the ADDED event, instance id for the REMOVED event
316 * Game controller axis motion event structure (event.caxis.*)
319 TSDL_ControllerAxisEvent = record
320 type_: UInt32; // SDL_CONTROLLERAXISMOTION
322 which: TSDL_JoystickID; // The joystick instance id
323 axis: UInt8; // The controller axis (SDL_GameControllerAxis)
327 value: SInt16; // The axis value (range: -32768 to 32767)
332 * Game controller button event structure (event.cbutton.*)
335 TSDL_ControllerButtonEvent = record
336 type_: UInt32; // SDL_CONTROLLERBUTTONDOWN or SDL_CONTROLLERBUTTONUP
338 which: TSDL_JoystickID; // The joystick instance id
339 button: UInt8; // The controller button (SDL_GameControllerButton)
340 state: UInt8; // SDL_PRESSED or SDL_RELEASED
347 * Controller device event structure (event.cdevice.*)
350 TSDL_ControllerDeviceEvent = record
351 type_: UInt32; // SDL_CONTROLLERDEVICEADDED, SDL_CONTROLLERDEVICEREMOVED, or SDL_CONTROLLERDEVICEREMAPPED
353 which: SInt32; // The joystick device index for the ADDED event, instance id for the REMOVED or REMAPPED event
357 * Audio device event structure (event.adevice.*)
360 TSDL_AudioDeviceEvent = record
361 type_: UInt32; // ::SDL_AUDIODEVICEADDED, or ::SDL_AUDIODEVICEREMOVED
363 which: UInt32; // The audio device index for the ADDED event (valid until next SDL_GetNumAudioDevices() call), SDL_AudioDeviceID for the REMOVED event
364 iscapture: UInt8; // zero if an output device, non-zero if a capture device.
372 * Touch finger event structure (event.tfinger.*)
375 TSDL_TouchFingerEvent = record
376 type_: UInt32; // SDL_FINGERMOTION or SDL_FINGERDOWN or SDL_FINGERUP
378 touchId: TSDL_TouchID; // The touch device id
379 fingerId: TSDL_FingerID;
380 x: Float; // Normalized in the range 0...1
381 y: Float; // Normalized in the range 0...1
382 dx: Float; // Normalized in the range 0...1
383 dy: Float; // Normalized in the range 0...1
384 pressure: Float; // Normalized in the range 0...1
388 * Multiple Finger Gesture Event (event.mgesture.*)
390 TSDL_MultiGestureEvent = record
391 type_: UInt32; // SDL_MULTIGESTURE
393 touchId: TSDL_TouchID; // The touch device index
403 {* (event.dgesture.*) *}
404 TSDL_DollarGestureEvent = record
405 type_: UInt32; // SDL_DOLLARGESTURE
407 touchId: TSDL_TouchID; // The touch device id
408 gestureId: TSDL_GestureID;
411 x: Float; // Normalized center of gesture
412 y: Float; // Normalized center of gesture
417 * An event used to request a file open by the system (event.drop.*)
418 * This event is disabled by default, you can enable it with SDL_EventState()
419 * If you enable this event, you must free the filename in the event.
422 TSDL_DropEvent = record
423 type_: UInt32; // SDL_DROPFILE
425 _file: PAnsiChar; // The file name, which should be freed with SDL_free()
429 * The "quit requested" event
432 TSDL_QuitEvent = record
433 type_: UInt32; // SDL_QUIT
438 * A user-defined event type (event.user.*)
441 TSDL_UserEvent = record
442 type_: UInt32; // SDL_USEREVENT through SDL_NUMEVENTS-1
444 windowID: UInt32; // The associated window if any
445 code: SInt32; // User defined event code
446 data1: Pointer; // User defined data pointer
447 data2: Pointer; // User defined data pointer
451 * A video driver dependent system event (event.syswm.*)
452 * This event is disabled by default, you can enable it with SDL_EventState()
454 * If you want to use this event, you should include SDL_syswm.h.
457 PSDL_SysWMEvent = ^TSDL_SysWMEvent;
458 TSDL_SysWMEvent = record
459 type_: UInt32; // SDL_SYSWMEVENT
461 msg: PSDL_SysWMmsg; // driver dependent data (defined in SDL_syswm.h)
465 * General event structure
468 PSDL_Event = ^TSDL_Event;
473 SDL_COMMONEVENT: (common: TSDL_CommonEvent);
474 SDL_WINDOWEVENT: (window: TSDL_WindowEvent);
477 SDL_KEYDOWN: (key: TSDL_KeyboardEvent);
478 SDL_TEXTEDITING: (edit: TSDL_TextEditingEvent);
479 SDL_TEXTINPUT: (text: TSDL_TextInputEvent);
481 SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent);
483 SDL_MOUSEBUTTONDOWN: (button: TSDL_MouseButtonEvent);
484 SDL_MOUSEWHEEL: (wheel: TSDL_MouseWheelEvent);
486 SDL_JOYAXISMOTION: (jaxis: TSDL_JoyAxisEvent);
487 SDL_JOYBALLMOTION: (jball: TSDL_JoyBallEvent);
488 SDL_JOYHATMOTION: (jhat: TSDL_JoyHatEvent);
490 SDL_JOYBUTTONUP: (jbutton: TSDL_JoyButtonEvent);
492 SDL_JOYDEVICEREMOVED: (jdevice: TSDL_JoyDeviceEvent);
494 SDL_CONTROLLERAXISMOTION: (caxis: TSDL_ControllerAxisEvent);
495 SDL_CONTROLLERBUTTONUP,
496 SDL_CONTROLLERBUTTONDOWN: (cbutton: TSDL_ControllerButtonEvent);
497 SDL_CONTROLLERDEVICEADDED,
498 SDL_CONTROLLERDEVICEREMOVED,
499 SDL_CONTROLLERDEVICEREMAPPED: (cdevice: TSDL_ControllerDeviceEvent);
501 SDL_AUDIODEVICEADDED,
502 SDL_AUDIODEVICEREMOVED: (adevice: TSDL_AudioDeviceEvent);
504 SDL_QUITEV: (quit: TSDL_QuitEvent);
506 SDL_USEREVENT: (user: TSDL_UserEvent);
507 SDL_SYSWMEVENT: (syswm: TSDL_SysWMEvent);
511 SDL_FINGERMOTION: (tfinger: TSDL_TouchFingerEvent);
512 SDL_MULTIGESTURE: (mgesture: TSDL_MultiGestureEvent);
513 SDL_DOLLARGESTURE,SDL_DOLLARRECORD: (dgesture: TSDL_DollarGestureEvent);
515 SDL_DROPFILE: (drop: TSDL_DropEvent);
519 {* Function prototypes *}
522 * Pumps the event loop, gathering events from the input devices.
524 * This function updates the event queue and internal input device state.
526 * This should only be run in the thread that sets the video mode.
528 procedure SDL_PumpEvents cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_PumpEvents' {$ENDIF} {$ENDIF};
536 TSDL_EventAction = Word;
539 * Checks the event queue for messages and optionally returns them.
541 * If action is SDL_ADDEVENT, up to numevents events will be added to
542 * the back of the event queue.
544 * If action is SDL_PEEKEVENT, up to numevents events at the front
545 * of the event queue, within the specified minimum and maximum type,
546 * will be returned and will not be removed from the queue.
548 * If action is SDL_GETEVENT, up to numevents events at the front
549 * of the event queue, within the specified minimum and maximum type,
550 * will be returned and will be removed from the queue.
552 * Result: The number of events actually stored, or -1 if there was an error.
554 * This function is thread-safe.
557 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};
560 * Checks to see if certain event types are in the event queue.
563 function SDL_HasEvent(type_: UInt32): TSDL_Bool cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HasEvent' {$ENDIF} {$ENDIF};
564 function SDL_HasEvents(minType: UInt32; maxType: UInt32): TSDL_Bool cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HasEvents' {$ENDIF} {$ENDIF};
567 * This function clears events from the event queue
570 procedure SDL_FlushEvent(type_: UInt32) cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_FlushEvent' {$ENDIF} {$ENDIF};
571 procedure SDL_FlushEvents(minType: UInt32; maxType: UInt32) cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_FlushEvents' {$ENDIF} {$ENDIF};
574 * Polls for currently pending events.
576 * 1 if there are any pending events, or 0 if there are none available.
578 * event - If not nil, the next event is removed from the queue and
579 * stored in that area.
582 function SDL_PollEvent(event: PSDL_Event): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_PollEvent' {$ENDIF} {$ENDIF};
585 * Waits indefinitely for the next available event.
587 * 1, or 0 if there was an error while waiting for events.
589 * event - If not nil, the next event is removed from the queue and
590 * stored in that area.
593 function SDL_WaitEvent(event: PSDL_Event): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_WaitEvent' {$ENDIF} {$ENDIF};
596 * Waits until the specified timeout (in milliseconds) for the next
599 * 1, or 0 if there was an error while waiting for events.
601 * event - If not nil, the next event is removed from the queue and
602 * stored in that area.
605 function SDL_WaitEventTimeout(event: PSDL_Event; timeout: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_WaitEventTimeout' {$ENDIF} {$ENDIF};
608 * Add an event to the event queue.
610 * 1 on success, 0 if the event was filtered, or -1 if the event queue
611 * was full or there was some other error.
614 function SDL_PushEvent(event: PSDL_Event): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_PumpEvents' {$ENDIF} {$ENDIF};
617 PSDL_EventFilter = ^TSDL_EventFilter;
619 TSDL_EventFilter = function( userdata: Pointer; event: PSDL_Event ): Integer; cdecl;
621 TSDL_EventFilter = function( userdata: Pointer; event: PSDL_Event ): Integer;
625 * Sets up a filter to process all events before they change internal state and
626 * are posted to the internal event queue.
628 * If the filter returns 1, then the event will be added to the internal queue.
629 * If it returns 0, then the event will be dropped from the queue, but the
630 * internal state will still be updated. This allows selective filtering of
631 * dynamically arriving events.
633 * Be very careful of what you do in the event filter function, as
634 * it may run in a different thread!
636 * There is one caveat when dealing with the SDL_QUITEVENT event type. The
637 * event filter is only called when the window manager desires to close the
638 * application window. If the event filter returns 1, then the window will
639 * be closed, otherwise the window will remain open if possible.
641 * If the quit event is generated by an interrupt signal, it will bypass the
642 * internal queue and be delivered to the application at the next event poll.
645 procedure SDL_SetEventFilter(filter: TSDL_EventFilter; userdata: Pointer) cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetEventFilter' {$ENDIF} {$ENDIF};
648 * Return the current event filter - can be used to "chain" filters.
649 * If there is no event filter set, this function returns SDL_FALSE.
652 function SDL_GetEventFilter(var filter: PSDL_EventFilter; var userdata: PPointer): TSDL_Bool cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetEventFilter' {$ENDIF} {$ENDIF};
655 * Add a function which is called when an event is added to the queue.
658 procedure SDL_AddEventWatch(filter: TSDL_EventFilter; userdata: Pointer) cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_AddEventWatch' {$ENDIF} {$ENDIF};
661 * Remove an event watch function added with SDL_AddEventWatch()
664 procedure SDL_DelEventWatch(filter: TSDL_EventFilter; userdata: Pointer) cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_DelEventWatch' {$ENDIF} {$ENDIF};
667 * Run the filter function on the current event queue, removing any
668 * events for which the filter returns 0.
671 procedure SDL_FilterEvents(filter: TSDL_EventFilter; userdata: Pointer) cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_FilterEvents' {$ENDIF} {$ENDIF};
681 * This function allows you to set the state of processing certain events.
682 * - If state is set to SDL_IGNORE, that event will be automatically
683 * dropped from the event queue and will not event be filtered.
684 * - If state is set to SDL_ENABLE, that event will be processed
686 * - If state is set to SDL_QUERY, SDL_EventState() will return the
687 * current processing state of the specified event.
690 function SDL_EventState(type_: UInt32; state: SInt32): UInt8 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_EventState' {$ENDIF} {$ENDIF};
692 function SDL_GetEventState(type_: UInt32): UInt8;
695 * This function allocates a set of user-defined events, and returns
696 * the beginning event number for that set of events.
698 * If there aren't enough user-defined events left, this function
702 function SDL_RegisterEvents(numevents: SInt32): UInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RegisterEvents' {$ENDIF} {$ENDIF};