Skip to content

Commit 20eb3d3

Browse files
committed
Update SDL_init.inc to match SDL 3.2.20
1 parent 9ea96d3 commit 20eb3d3

File tree

2 files changed

+141
-15
lines changed

2 files changed

+141
-15
lines changed

units/SDL3.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ interface
7676
corresponding C header file.
7777
Inc file was updated against
7878
SDL_init.inc --> SDL_init.h this version of the header file: }
79-
{$I SDL_init.inc} // 3.1.6-prev
8079
{$I SDL_log.inc} // 3.1.6-prev
8180
{$I SDL_version.inc} // 3.1.6-prev
8281
{$I SDL_revision.inc} // 3.1.6-prev
@@ -111,6 +110,7 @@ interface
111110
{$I SDL_touch.inc} // 3.1.6-prev
112111
{$I SDL_camera.inc} // 3.1.6-prev
113112
{$I SDL_events.inc} // 3.1.6-prev
113+
{$I SDL_init.inc} // 3.2.20
114114
{$I SDL_render.inc} // 3.1.6-prev
115115
{$I SDL_gpu.inc} // 3.2.0
116116
{$I SDL_clipboard.inc} // 3.2.0

units/SDL_init.inc

Lines changed: 140 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
* These are the flags which may be passed to SDL_Init(). You should specify
4242
* the subsystems which you will be using in your application.
4343
*
44-
* \since This datatype is available since SDL 3.1.3.
44+
* \since This datatype is available since SDL 3.2.0.
4545
*
4646
* \sa SDL_Init
4747
* \sa SDL_Quit
@@ -56,8 +56,8 @@ type
5656

5757
const
5858
SDL_INIT_AUDIO = TSDL_InitFlags($00000010); { `SDL_INIT_AUDIO` implies `SDL_INIT_EVENTS` }
59-
SDL_INIT_VIDEO = TSDL_InitFlags($00000020); { `SDL_INIT_VIDEO` implies `SDL_INIT_EVENTS` }
60-
SDL_INIT_JOYSTICK = TSDL_InitFlags($00000200); { `SDL_INIT_JOYSTICK` implies `SDL_INIT_EVENTS`, should be initialized on the same thread as SDL_INIT_VIDEO on Windows if you don't set SDL_HINT_JOYSTICK_THREAD }
59+
SDL_INIT_VIDEO = TSDL_InitFlags($00000020); { `SDL_INIT_VIDEO` implies `SDL_INIT_EVENTS`, should be initialized on the main thread }
60+
SDL_INIT_JOYSTICK = TSDL_InitFlags($00000200); { `SDL_INIT_JOYSTICK` implies `SDL_INIT_EVENTS` }
6161
SDL_INIT_HAPTIC = TSDL_InitFlags($00001000);
6262
SDL_INIT_GAMEPAD = TSDL_InitFlags($00002000); { `SDL_INIT_GAMEPAD` implies `SDL_INIT_JOYSTICK` }
6363
SDL_INIT_EVENTS = TSDL_InitFlags($00004000);
@@ -82,7 +82,7 @@ const
8282
* [Main callbacks in SDL3](https://wiki.libsdl.org/SDL3/README/main-functions#main-callbacks-in-sdl3)
8383
* for complete details.
8484
*
85-
* \since This enum is available since SDL 3.1.3.
85+
* \since This enum is available since SDL 3.2.0.
8686
}
8787
type
8888
PPSDL_AppResult = ^PSDL_AppResult;
@@ -94,9 +94,68 @@ const
9494
SDL_APP_FAILURE = 2; {*< Value that requests termination with error from the main callbacks. }
9595

9696
type
97+
{*
98+
* Function pointer typedef for SDL_AppInit.
99+
*
100+
* These are used by SDL_EnterAppMainCallbacks. This mechanism operates behind
101+
* the scenes for apps using the optional main callbacks. Apps that want to
102+
* use this should just implement SDL_AppInit directly.
103+
*
104+
* \param appstate a place where the app can optionally store a pointer for
105+
* future use.
106+
* \param argc the standard ANSI C main's argc; number of elements in `argv`.
107+
* \param argv the standard ANSI C main's argv; array of command line
108+
* arguments.
109+
* \returns SDL_APP_FAILURE to terminate with an error, SDL_APP_SUCCESS to
110+
* terminate with success, SDL_APP_CONTINUE to continue.
111+
*
112+
* \since This datatype is available since SDL 3.2.0.
113+
*}
97114
TSDL_AppInit_func = function(appstate: PPointer; argc: cint; argv: PPAnsiChar): TSDL_AppResult; cdecl;
115+
116+
{**
117+
* Function pointer typedef for SDL_AppIterate.
118+
*
119+
* These are used by SDL_EnterAppMainCallbacks. This mechanism operates behind
120+
* the scenes for apps using the optional main callbacks. Apps that want to
121+
* use this should just implement SDL_AppIterate directly.
122+
*
123+
* \param appstate an optional pointer, provided by the app in SDL_AppInit.
124+
* \returns SDL_APP_FAILURE to terminate with an error, SDL_APP_SUCCESS to
125+
* terminate with success, SDL_APP_CONTINUE to continue.
126+
*
127+
* \since This datatype is available since SDL 3.2.0.
128+
*}
98129
TSDL_AppIterate_func = function(appstate: Pointer): TSDL_AppResult; cdecl;
99-
//TSDL_AppEvent_func = function(appstate: Pointer; event: PSDL_Event): TSDL_AppResult; cdecl; // uncomment after EVENT translation
130+
131+
{**
132+
* Function pointer typedef for SDL_AppEvent.
133+
*
134+
* These are used by SDL_EnterAppMainCallbacks. This mechanism operates behind
135+
* the scenes for apps using the optional main callbacks. Apps that want to
136+
* use this should just implement SDL_AppEvent directly.
137+
*
138+
* \param appstate an optional pointer, provided by the app in SDL_AppInit.
139+
* \param event the new event for the app to examine.
140+
* \returns SDL_APP_FAILURE to terminate with an error, SDL_APP_SUCCESS to
141+
* terminate with success, SDL_APP_CONTINUE to continue.
142+
*
143+
* \since This datatype is available since SDL 3.2.0.
144+
*}
145+
TSDL_AppEvent_func = function(appstate: Pointer; event: PSDL_Event): TSDL_AppResult; cdecl;
146+
147+
{**
148+
* Function pointer typedef for SDL_AppQuit.
149+
*
150+
* These are used by SDL_EnterAppMainCallbacks. This mechanism operates behind
151+
* the scenes for apps using the optional main callbacks. Apps that want to
152+
* use this should just implement SDL_AppEvent directly.
153+
*
154+
* \param appstate an optional pointer, provided by the app in SDL_AppInit.
155+
* \param result the result code that terminated the app (success or failure).
156+
*
157+
* \since This datatype is available since SDL 3.2.0.
158+
*}
100159
TSDL_AppQuit_func = procedure(appstate: Pointer; result: TSDL_AppResult); cdecl;
101160

102161
{*
@@ -120,7 +179,7 @@ type
120179
* - `SDL_INIT_AUDIO`: audio subsystem; automatically initializes the events
121180
* subsystem
122181
* - `SDL_INIT_VIDEO`: video subsystem; automatically initializes the events
123-
* subsystem
182+
* subsystem, should be initialized on the main thread.
124183
* - `SDL_INIT_JOYSTICK`: joystick subsystem; automatically initializes the
125184
* events subsystem
126185
* - `SDL_INIT_HAPTIC`: haptic (force feedback) subsystem
@@ -145,7 +204,7 @@ type
145204
* \returns true on success or false on failure; call SDL_GetError() for more
146205
* information.
147206
*
148-
* \since This function is available since SDL 3.1.3.
207+
* \since This function is available since SDL 3.2.0.
149208
*
150209
* \sa SDL_SetAppMetadata
151210
* \sa SDL_SetAppMetadataProperty
@@ -167,7 +226,7 @@ function SDL_Init(flags: TSDL_InitFlags): Boolean; cdecl;
167226
* \returns true on success or false on failure; call SDL_GetError() for more
168227
* information.
169228
*
170-
* \since This function is available since SDL 3.1.3.
229+
* \since This function is available since SDL 3.2.0.
171230
*
172231
* \sa SDL_Init
173232
* \sa SDL_Quit
@@ -184,7 +243,7 @@ function SDL_InitSubSystem(flags: TSDL_InitFlags): Boolean; cdecl;
184243
*
185244
* \param flags any of the flags used by SDL_Init(); see SDL_Init for details.
186245
*
187-
* \since This function is available since SDL 3.1.3.
246+
* \since This function is available since SDL 3.2.0.
188247
*
189248
* \sa SDL_InitSubSystem
190249
* \sa SDL_Quit
@@ -199,7 +258,7 @@ procedure SDL_QuitSubSystem(flags: TSDL_InitFlags); cdecl;
199258
* \returns a mask of all initialized subsystems if `flags` is 0, otherwise it
200259
* returns the initialization status of the specified subsystems.
201260
*
202-
* \since This function is available since SDL 3.1.3.
261+
* \since This function is available since SDL 3.2.0.
203262
*
204263
* \sa SDL_Init
205264
* \sa SDL_InitSubSystem
@@ -226,6 +285,73 @@ function SDL_WasInit(flags: TSDL_InitFlags): TSDL_InitFlags; cdecl;
226285
procedure SDL_Quit; cdecl;
227286
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_Quit' {$ENDIF} {$ENDIF};
228287

288+
{**
289+
* Return whether this is the main thread.
290+
*
291+
* On Apple platforms, the main thread is the thread that runs your program's
292+
* main() entry point. On other platforms, the main thread is the one that
293+
* calls SDL_Init(SDL_INIT_VIDEO), which should usually be the one that runs
294+
* your program's main() entry point. If you are using the main callbacks,
295+
* SDL_AppInit(), SDL_AppIterate(), and SDL_AppQuit() are all called on the
296+
* main thread.
297+
*
298+
* \returns true if this thread is the main thread, or false otherwise.
299+
*
300+
* \threadsafety It is safe to call this function from any thread.
301+
*
302+
* \since This function is available since SDL 3.2.0.
303+
*
304+
* \sa SDL_RunOnMainThread
305+
*}
306+
function SDL_IsMainThread(): Boolean; cdecl;
307+
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_IsMainThread' {$ENDIF} {$ENDIF};
308+
309+
type
310+
PPSDL_MainThreadCallback = ^PSDL_MainThreadCallback;
311+
PSDL_MainThreadCallback = ^TSDL_MainThreadCallback;
312+
313+
{**
314+
* Callback run on the main thread.
315+
*
316+
* \param userdata an app-controlled pointer that is passed to the callback.
317+
*
318+
* \since This datatype is available since SDL 3.2.0.
319+
*
320+
* \sa SDL_RunOnMainThread
321+
*}
322+
TSDL_MainThreadCallback = procedure(userdata: Pointer); cdecl;
323+
324+
{**
325+
* Call a function on the main thread during event processing.
326+
*
327+
* If this is called on the main thread, the callback is executed immediately.
328+
* If this is called on another thread, this callback is queued for execution
329+
* on the main thread during event processing.
330+
*
331+
* Be careful of deadlocks when using this functionality. You should not have
332+
* the main thread wait for the current thread while this function is being
333+
* called with `wait_complete` true.
334+
*
335+
* \param callback the callback to call on the main thread.
336+
* \param userdata a pointer that is passed to `callback`.
337+
* \param wait_complete true to wait for the callback to complete, false to
338+
* return immediately.
339+
* \returns true on success or false on failure; call SDL_GetError() for more
340+
* information.
341+
*
342+
* \threadsafety It is safe to call this function from any thread.
343+
*
344+
* \since This function is available since SDL 3.2.0.
345+
*
346+
* \sa SDL_IsMainThread
347+
*}
348+
function SDL_RunOnMainThread(
349+
callback: TSDL_MainThreadCallback;
350+
userdata: Pointer;
351+
wait_complete: Boolean
352+
): Boolean; cdecl;
353+
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RunOnMainThread' {$ENDIF} {$ENDIF};
354+
229355
{*
230356
* Specify basic metadata about your app.
231357
*
@@ -258,7 +384,7 @@ procedure SDL_Quit; cdecl;
258384
*
259385
* \threadsafety It is safe to call this function from any thread.
260386
*
261-
* \since This function is available since SDL 3.1.3.
387+
* \since This function is available since SDL 3.2.0.
262388
*
263389
* \sa SDL_SetAppMetadataProperty
264390
}
@@ -280,7 +406,7 @@ function SDL_SetAppMetadata(appname: PAnsiChar; appversion: PAnsiChar; appidenti
280406
* Multiple calls to this function are allowed, but various state might not
281407
* change once it has been set up with a previous call to this function.
282408
*
283-
* Once set, this metadata can be read using SDL_GetMetadataProperty().
409+
* Once set, this metadata can be read using SDL_GetAppMetadataProperty().
284410
*
285411
* These are the supported properties:
286412
*
@@ -321,7 +447,7 @@ function SDL_SetAppMetadata(appname: PAnsiChar; appversion: PAnsiChar; appidenti
321447
*
322448
* \threadsafety It is safe to call this function from any thread.
323449
*
324-
* \since This function is available since SDL 3.1.3.
450+
* \since This function is available since SDL 3.2.0.
325451
*
326452
* \sa SDL_GetAppMetadataProperty
327453
* \sa SDL_SetAppMetadata
@@ -354,7 +480,7 @@ const
354480
* freed if you call SDL_SetAppMetadataProperty() to set that
355481
* property from another thread.
356482
*
357-
* \since This function is available since SDL 3.1.3.
483+
* \since This function is available since SDL 3.2.0.
358484
*
359485
* \sa SDL_SetAppMetadata
360486
* \sa SDL_SetAppMetadataProperty

0 commit comments

Comments
 (0)