1717 * coming and going, the system changing in some way, etc.
1818 *
1919 * An app generally takes a moment, perhaps at the start of a new frame, to
20- * examine any events that have occured since the last time and process or
20+ * examine any events that have occurred since the last time and process or
2121 * ignore them. This is generally done by calling SDL_PollEvent() in a loop
2222 * until it returns false (or, if using the main callbacks, events are
2323 * provided one at a time in calls to SDL_AppEvent() before the next call to
@@ -92,15 +92,17 @@ const
9292 SDL_EVENT_DISPLAY_DESKTOP_MODE_CHANGED = TSDL_EventType(341 ); { *< Display has changed desktop mode }
9393 SDL_EVENT_DISPLAY_CURRENT_MODE_CHANGED = TSDL_EventType(342 ); { *< Display has changed current mode }
9494 SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED = TSDL_EventType(343 ); { *< Display has changed content scale }
95+ SDL_EVENT_DISPLAY_USABLE_BOUNDS_CHANGED = TSDL_EventType(344 ); { *< Display has changed usable bounds }
9596 SDL_EVENT_DISPLAY_FIRST = TSDL_EventType(SDL_EVENT_DISPLAY_ORIENTATION);
96- SDL_EVENT_DISPLAY_LAST = TSDL_EventType(SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED );
97+ SDL_EVENT_DISPLAY_LAST = TSDL_EventType(SDL_EVENT_DISPLAY_USABLE_BOUNDS_CHANGED );
9798
9899 { Window events }
99100 { 0x200 was SDL_WINDOWEVENT, reserve the number for sdl2-compat }
100101 { 0x201 was SDL_SYSWMEVENT, reserve the number for sdl2-compat }
101102 SDL_EVENT_WINDOW_SHOWN = TSDL_EventType($202 ); { *< Window has been shown }
102103 SDL_EVENT_WINDOW_HIDDEN = TSDL_EventType(515 ); { *< Window has been hidden }
103- SDL_EVENT_WINDOW_EXPOSED = TSDL_EventType(516 ); { *< Window has been exposed and should be redrawn, and can be redrawn directly from event watchers for this event }
104+ SDL_EVENT_WINDOW_EXPOSED = TSDL_EventType(516 ); { *< Window has been exposed and should be redrawn, and can be redrawn directly from event watchers for this event.
105+ data1 is 1 for live-resize expose events, 0 otherwise. }
104106 SDL_EVENT_WINDOW_MOVED = TSDL_EventType(517 ); { *< Window has been moved to data1, data2 }
105107 SDL_EVENT_WINDOW_RESIZED = TSDL_EventType(518 ); { *< Window has been resized to data1xdata2 }
106108 SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED = TSDL_EventType(519 ); { *< The pixel size of the window has changed to data1xdata2 }
@@ -139,6 +141,8 @@ const
139141 SDL_EVENT_KEYBOARD_ADDED = TSDL_EventType(773 ); { *< A new keyboard has been inserted into the system }
140142 SDL_EVENT_KEYBOARD_REMOVED = TSDL_EventType(774 ); { *< A keyboard has been removed }
141143 SDL_EVENT_TEXT_EDITING_CANDIDATES = TSDL_EventType(775 ); { *< Keyboard text editing candidates }
144+ SDL_EVENT_SCREEN_KEYBOARD_SHOWN = TSDL_EventType(776 ); { *< The on-screen keyboard has been shown }
145+ SDL_EVENT_SCREEN_KEYBOARD_HIDDEN = TSDL_EventType(777 ); { *< The on-screen keyboard has been hidden }
142146
143147 { Mouse events }
144148 SDL_EVENT_MOUSE_MOTION = TSDL_EventType($400 ); { *< Mouse moved }
@@ -179,10 +183,15 @@ const
179183 SDL_EVENT_FINGER_MOTION = TSDL_EventType(1794 );
180184 SDL_EVENT_FINGER_CANCELED = TSDL_EventType(1795 );
181185
186+ { Pinch events }
187+ SDL_EVENT_PINCH_BEGIN = TSDL_EventType($710 ); { Pinch gesture started }
188+ SDL_EVENT_PINCH_UPDATE = TSDL_EventType($711 ); { Pinch gesture updated }
189+ SDL_EVENT_PINCH_END = TSDL_EventType($712 ); { Pinch gesture ended }
190+
182191 { 0x800, 0x801, and 0x802 were the Gesture events from SDL2. Do not reuse these values! sdl2-compat needs them! }
183192
184193 { Clipboard events }
185- SDL_EVENT_CLIPBOARD_UPDATE = TSDL_EventType($900 ); { *< The clipboard or primary selection changed }
194+ SDL_EVENT_CLIPBOARD_UPDATE = TSDL_EventType($900 ); { *< The clipboard changed }
186195
187196 { Drag and drop events }
188197 SDL_EVENT_DROP_FILE = TSDL_EventType($1000 ); { *< The system requests a file open }
264273 PPSDL_DisplayEvent = ^PSDL_DisplayEvent;
265274 PSDL_DisplayEvent = ^TSDL_DisplayEvent;
266275 TSDL_DisplayEvent = record
267- type_: TSDL_EventType; { *< SDL_DISPLAYEVENT_ * }
276+ type_: TSDL_EventType; { *< SDL_EVENT_DISPLAY_ * }
268277 reserved: cuint32;
269278 timestamp: cuint64; { *< In nanoseconds, populated using SDL_GetTicksNS() }
270279 displayID: TSDL_DisplayID; { *< The associated display }
@@ -688,6 +697,10 @@ type
688697{ *
689698 * Audio device event structure (event.adevice.*)
690699 *
700+ * Note that SDL will send a SDL_EVENT_AUDIO_DEVICE_ADDED event for every
701+ * device it discovers during initialization. After that, this event will only
702+ * arrive when a device is hotplugged during the program's run.
703+ *
691704 * \since This struct is available since SDL 3.2.0.
692705 }
693706 PPSDL_AudioDeviceEvent = ^PSDL_AudioDeviceEvent;
@@ -767,7 +780,20 @@ type
767780 end ;
768781
769782{ *
770- * Pressure-sensitive pen proximity event structure (event.pmotion.*)
783+ * Pinch event structure (event.pinch.*)
784+ }
785+ PPSDL_PinchFingerEvent = ^PSDL_PinchFingerEvent;
786+ PSDL_PinchFingerEvent = ^TSDL_PinchFingerEvent;
787+ TSDL_PinchFingerEvent = record
788+ type_: TSDL_EventType; { *<:: SDL_EVENT_PINCH_BEGIN or:: SDL_EVENT_PINCH_UPDATE or:: SDL_EVENT_PINCH_END }
789+ reserved: cuint32;
790+ timestamp: cuint64; { *< In nanoseconds, populated using SDL_GetTicksNS() }
791+ scale: cfloat; { *< The scale change since the last SDL_EVENT_PINCH_UPDATE. Scale < 1 is "zoom out". Scale > 1 is "zoom in". }
792+ windowID: TSDL_WindowID; { *< The window underneath the finger, if any }
793+ end ;
794+
795+ { *
796+ * Pressure-sensitive pen proximity event structure (event.pproximity.*)
771797 *
772798 * When a pen becomes visible to the system (it is close enough to a tablet,
773799 * etc), SDL will send an SDL_EVENT_PEN_PROXIMITY_IN event with the new pen's
779805 * is there." The pen touching and lifting off from the tablet while not
780806 * leaving the area are handled by SDL_EVENT_PEN_DOWN and SDL_EVENT_PEN_UP.
781807 *
808+ * Not all platforms have a window associated with the pen during proximity
809+ * events. Some wait until motion/button/etc events to offer this info.
810+ *
782811 * \since This struct is available since SDL 3.2.0.
783812 }
784813 PPSDL_PenProximityEvent = ^PSDL_PenProximityEvent;
963992 PPSDL_UserEvent = ^PSDL_UserEvent;
964993 PSDL_UserEvent = ^TSDL_UserEvent;
965994 TSDL_UserEvent = record
966- type_: cuint32; { *< SDL_EVENT_USER through SDL_EVENT_LAST-1 , Uint32 because these are not in the SDL_EventType enumeration }
995+ type_: cuint32; { *< SDL_EVENT_USER through SDL_EVENT_LAST, Uint32 because these are not in the SDL_EventType enumeration }
967996 reserved: cuint32;
968997 timestamp: cuint64; { *< In nanoseconds, populated using SDL_GetTicksNS() }
969998 windowID: TSDL_WindowID; { *< The associated window if any }
@@ -1015,14 +1044,15 @@ type
10151044 27 : (quit: TSDL_QuitEvent); { *< Quit request event data }
10161045 28 : (user: TSDL_UserEvent); { *< Custom event data }
10171046 29 : (tfinger: TSDL_TouchFingerEvent); { *< Touch finger event data }
1018- 30 : (pproximity: TSDL_PenProximityEvent); { *< Pen proximity event data }
1019- 31 : (ptouch: TSDL_PenTouchEvent); { *< Pen tip touching event data }
1020- 32 : (pmotion: TSDL_PenMotionEvent); { *< Pen motion event data }
1021- 33 : (pbutton: TSDL_PenButtonEvent); { *< Pen button event data }
1022- 34 : (paxis: TSDL_PenAxisEvent); { *< Pen axis event data }
1023- 35 : (render: TSDL_RenderEvent); { *< Render event data }
1024- 36 : (drop: TSDL_DropEvent); { *< Drag and drop event data }
1025- 37 : (clipboard: TSDL_ClipboardEvent); { *< Clipboard event data }
1047+ 30 : (pinch: TSDL_PinchFingerEvent); { Pinch event data }
1048+ 31 : (pproximity: TSDL_PenProximityEvent); { *< Pen proximity event data }
1049+ 32 : (ptouch: TSDL_PenTouchEvent); { *< Pen tip touching event data }
1050+ 33 : (pmotion: TSDL_PenMotionEvent); { *< Pen motion event data }
1051+ 34 : (pbutton: TSDL_PenButtonEvent); { *< Pen button event data }
1052+ 35 : (paxis: TSDL_PenAxisEvent); { *< Pen axis event data }
1053+ 36 : (render: TSDL_RenderEvent); { *< Render event data }
1054+ 37 : (drop: TSDL_DropEvent); { *< Drag and drop event data }
1055+ 38 : (clipboard: TSDL_ClipboardEvent); { *< Clipboard event data }
10261056
10271057 { This is necessary for ABI compatibility between Visual C++ and GCC.
10281058 Visual C++ will respect the push pack pragma and use 52 bytes (size of
@@ -1037,7 +1067,7 @@ type
10371067 the next multiple of 16, 64, and on architectures where pointers are
10381068 even larger the size of SDL_UserEvent will dominate as being 3 pointers.
10391069 }
1040- 37 : (padding: array [0 ..127 ] of cuint8);
1070+ 39 : (padding: array [0 ..127 ] of cuint8);
10411071 end ;
10421072
10431073{ #todo : SDL3-for-Pascal: Translation of SDL_COMPILE_TIME_ASSERT necessary? Looks like an internal test function. }
@@ -1228,16 +1258,14 @@ procedure SDL_FlushEvents(minType: cuint32; maxType: cuint32); cdecl;
12281258{ *
12291259 * Poll for currently pending events.
12301260 *
1231- * If `event` is not nil, the next event is removed from the queue and stored
1232- * in the SDL_Event structure pointed to by `event`. The 1 returned refers to
1233- * this event, immediately stored in the SDL Event structure -- not an event
1234- * to follow.
1261+ * If `event` is not NULL, the next event is removed from the queue and stored
1262+ * in the SDL_Event structure pointed to by `event`.
12351263 *
1236- * If `event` is nil , it simply returns 1 if there is an event in the queue,
1237- * but will not remove it from the queue.
1264+ * If `event` is NULL , it simply returns true if there is an event in the
1265+ * queue, but will not remove it from the queue.
12381266 *
12391267 * As this function may implicitly call SDL_PumpEvents(), you can only call
1240- * this function in the thread that set the video mode .
1268+ * this function in the thread that initialized the video subsystem .
12411269 *
12421270 * SDL_PollEvent() is the favored way of receiving system events since it can
12431271 * be done from the main loop and does not suspend the main loop while waiting
@@ -1257,6 +1285,13 @@ procedure SDL_FlushEvents(minType: cuint32; maxType: cuint32); cdecl;
12571285 *
12581286 * ```
12591287 *
1288+ * Note that Windows (and possibly other platforms) has a quirk about how it
1289+ * handles events while dragging/resizing a window, which can cause this
1290+ * function to block for significant amounts of time. Technical explanations
1291+ * and solutions are discussed on the wiki:
1292+ *
1293+ * https://wiki.libsdl.org/SDL3/AppFreezeDuringDrag
1294+ *
12601295 * \param event the SDL_Event structure to be filled with the next event from
12611296 * the queue, or nil.
12621297 * \returns true if this got an event or false if there are none available.
@@ -1384,7 +1419,7 @@ function SDL_PushEvent(event: PSDL_Event): Boolean; cdecl;
13841419 }
13851420type
13861421 PSDL_EventFilter = ^TSDL_EventFilter;
1387- TSDL_EventFilter = function (userdata: Pointer; event: PSDL_Event): Boolean; cdecl;
1422+ TSDL_EventFilter = function(userdata: Pointer; event: PSDL_Event): Boolean; cdecl;
13881423
13891424{ *
13901425 * Set up a filter to process all events before they are added to the internal
@@ -1399,7 +1434,10 @@ type
13991434 * allows selective filtering of dynamically arriving events.
14001435 *
14011436 * **WARNING**: Be very careful of what you do in the event filter function,
1402- * as it may run in a different thread!
1437+ * as it may run in a different thread! The exception is handling of
1438+ * SDL_EVENT_WINDOW_EXPOSED, which is guaranteed to be sent from the OS on the
1439+ * main thread and you are expected to redraw your window in response to this
1440+ * event.
14031441 *
14041442 * On platforms that support it, if the quit event is generated by an
14051443 * interrupt signal (e.g. pressing Ctrl-C), it will be delivered to the
@@ -1412,7 +1450,7 @@ type
14121450 * the event filter, but events pushed onto the queue with SDL_PeepEvents() do
14131451 * not.
14141452 *
1415- * \param filter an SDL_EventFilter function to call when an event happens.
1453+ * \param filter a function to call when an event happens.
14161454 * \param userdata a Pointer that is passed to `filter`.
14171455 *
14181456 * \threadsafety It is safe to call this function from any thread.
@@ -1583,3 +1621,37 @@ function SDL_RegisterEvents(numevents: cint): cuint32; cdecl;
15831621 }
15841622function SDL_GetWindowFromEvent (event: PSDL_Event): PSDL_Window; cdecl;
15851623 external SDL_LibName { $IFDEF DELPHI} { $IFDEF MACOS} name ' _SDL_GetWindowFromEvent' { $ENDIF} { $ENDIF} ;
1624+
1625+ { *
1626+ * Generate an English description of an event.
1627+ *
1628+ * This will fill `buf` with a null-terminated string that might look
1629+ * something like this:
1630+ *
1631+ * ```
1632+ * SDL_EVENT_MOUSE_MOTION (timestamp=1140256324 windowid=2 which=0 state=0 x=492.99 y=139.09 xrel=52 yrel=6)
1633+ * ```
1634+ *
1635+ * The exact format of the string is not guaranteed; it is intended for
1636+ * logging purposes, to be read by a human, and not parsed by a computer.
1637+ *
1638+ * The returned value follows the same rules as SDL_snprintf(): `buf` will
1639+ * always be nil-terminated (unless `buflen` is zero), and will be truncated
1640+ * if `buflen` is too small. The return code is the number of bytes needed for
1641+ * the complete string, not counting the nil-terminator, whether the string
1642+ * was truncated or not. Unlike SDL_snprintf(), though, this function never
1643+ * returns -1.
1644+ *
1645+ * \param event an event to describe. May be nil.
1646+ * \param buf the buffer to fill with the description string. May be nil.
1647+ * \param buflen the maximum bytes that can be written to `buf`.
1648+ * \returns number of bytes needed for the full string, not counting the
1649+ * null-terminator byte.
1650+ *
1651+ * \threadsafety It is safe to call this function from any thread.
1652+ *
1653+ * \since This function is available since SDL 3.4.0.
1654+ }
1655+ function SDL_GetEventDescription (event: PSDL_Event; buf: PAnsiChar; buflen: cint): cint; cdecl;
1656+ external SDL_LibName { $IFDEF DELPHI} { $IFDEF MACOS} name ' _SDL_GetEventDescription' { $ENDIF} { $ENDIF} ;
1657+
0 commit comments