SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
Typedefs | Functions | Variables
Platform-specific Functionality

Platform-specific SDL API functions. More...

Typedefs

using SDL::WindowsMessageHook = SDL_WindowsMessageHook
 A callback to be used with SetWindowsMessageHook.
 
using SDL::WindowsMessageHookCB = std::function< bool(MSG *)>
 A callback to be used with SetWindowsMessageHook.
 
using SDL::X11EventHook = SDL_X11EventHook
 A callback to be used with SetX11EventHook.
 
using SDL::X11EventHookCB = std::function< bool(XEvent *)>
 A callback to be used with SetX11EventHook.
 
using SDL::iOSAnimationCallback = SDL_iOSAnimationCallback
 The prototype for an Apple iOS animation callback.
 
using SDL::iOSAnimationCB = std::function< void()>
 The prototype for an Apple iOS animation callback.
 
using SDL::RequestAndroidPermissionCallback = SDL_RequestAndroidPermissionCallback
 Callback that presents a response from a RequestAndroidPermission call.
 
using SDL::RequestAndroidPermissionCB = std::function< void(const char *, bool)>
 Callback that presents a response from a RequestAndroidPermission call.
 
using SDL::Sandbox = SDL_Sandbox
 Application sandbox environment.
 

Functions

void SDL::SetWindowsMessageHook (WindowsMessageHook callback, void *userdata)
 Set a callback for every Windows message, run before TranslateMessage().
 
void SDL::SetWindowsMessageHook (WindowsMessageHookCB callback)
 Set a callback for every Windows message, run before TranslateMessage().
 
int SDL::GetDirect3D9AdapterIndex (Display displayID)
 Get the D3D9 adapter index that matches the specified display.
 
void SDL::GetDXGIOutputInfo (Display displayID, int *adapterIndex, int *outputIndex)
 Get the DXGI Adapter and Output indices for the specified display.
 
void SDL::SetX11EventHook (X11EventHook callback, void *userdata)
 Set a callback for every X11 event.
 
void SDL::SetX11EventHook (X11EventHookCB callback)
 Set a callback for every X11 event.
 
void SDL::SetLinuxThreadPriority (Sint64 threadID, int priority)
 Sets the UNIX nice value for a thread.
 
void SDL::SetLinuxThreadPriorityAndPolicy (Sint64 threadID, int sdlPriority, int schedPolicy)
 Sets the priority (not nice level) and scheduling policy for a thread.
 
void SDL::SetiOSAnimationCallback (WindowBase &window, int interval, iOSAnimationCallback callback, void *callbackParam)
 Use this function to set the animation callback on Apple iOS.
 
void SDL::SetiOSAnimationCallback (WindowBase &window, int interval, iOSAnimationCB callback)
 Use this function to set the animation callback on Apple iOS.
 
void SDL::SetiOSEventPump (bool enabled)
 Use this function to enable or disable the SDL event pump on Apple iOS.
 
void * SDL::GetAndroidJNIEnv ()
 Get the Android Java Native Interface Environment of the current thread.
 
void * SDL::GetAndroidActivity ()
 Retrieve the Java instance of the Android activity class.
 
int SDL::GetAndroidSDKVersion ()
 Query Android API level of the current device.
 
bool SDL::IsChromebook ()
 Query if the application is running on a Chromebook.
 
bool SDL::IsDeXMode ()
 Query if the application is running on a Samsung DeX docking station.
 
void SDL::SendAndroidBackButton ()
 Trigger the Android system back button behavior.
 
const char * SDL::GetAndroidInternalStoragePath ()
 Get the path used for internal storage for this Android application.
 
Uint32 SDL::GetAndroidExternalStorageState ()
 Get the current state of external storage for this Android application.
 
const char * SDL::GetAndroidExternalStoragePath ()
 Get the path used for external storage for this Android application.
 
const char * SDL::GetAndroidCachePath ()
 Get the path used for caching data for this Android application.
 
bool SDL::RequestAndroidPermission (StringParam permission, RequestAndroidPermissionCallback cb, void *userdata)
 Request permissions at runtime, asynchronously.
 
bool SDL::RequestAndroidPermission (StringParam permission, RequestAndroidPermissionCB cb)
 Request permissions at runtime, asynchronously.
 
void SDL::ShowAndroidToast (StringParam message, int duration, int gravity, int xoffset, int yoffset)
 Shows an Android toast notification.
 
void SDL::SendAndroidMessage (Uint32 command, int param)
 Send a user command to SDLActivity.
 
bool SDL::IsTablet ()
 Query if the current device is a tablet.
 
bool SDL::IsTV ()
 Query if the current device is a TV.
 
Sandbox SDL::GetSandbox ()
 Get the application sandbox environment, if any.
 
void SDL::OnApplicationWillTerminate ()
 Let iOS apps with external event handling report onApplicationWillTerminate.
 
void SDL::OnApplicationDidReceiveMemoryWarning ()
 Let iOS apps with external event handling report onApplicationDidReceiveMemoryWarning.
 
void SDL::OnApplicationWillEnterBackground ()
 Let iOS apps with external event handling report onApplicationWillResignActive.
 
void SDL::OnApplicationDidEnterBackground ()
 Let iOS apps with external event handling report onApplicationDidEnterBackground.
 
void SDL::OnApplicationWillEnterForeground ()
 Let iOS apps with external event handling report onApplicationWillEnterForeground.
 
void SDL::OnApplicationDidEnterForeground ()
 Let iOS apps with external event handling report onApplicationDidBecomeActive.
 
void SDL::OnApplicationDidChangeStatusBarOrientation ()
 Let iOS apps with external event handling report onApplicationDidChangeStatusBarOrientation.
 
void SDL::GetGDKTaskQueue (XTaskQueueHandle *outTaskQueue)
 Gets a reference to the global async task queue handle for GDK, initializing if needed.
 
bool SDL::GetGDKDefaultUser (XUserHandle *outUserHandle)
 Gets a reference to the default user handle for GDK.
 

Variables

constexpr Uint32 SDL::ANDROID_EXTERNAL_STORAGE_READ
 See the official Android developer guide for more information: http://developer.android.com/guide/topics/data/data-storage.html.
 
constexpr Uint32 SDL::ANDROID_EXTERNAL_STORAGE_WRITE
 See the official Android developer guide for more information: http://developer.android.com/guide/topics/data/data-storage.html.
 
constexpr Sandbox SDL::SANDBOX_NONE = SDL_SANDBOX_NONE
 NONE.
 
constexpr Sandbox SDL::SANDBOX_UNKNOWN_CONTAINER
 UNKNOWN_CONTAINER.
 
constexpr Sandbox SDL::SANDBOX_FLATPAK = SDL_SANDBOX_FLATPAK
 FLATPAK.
 
constexpr Sandbox SDL::SANDBOX_SNAP = SDL_SANDBOX_SNAP
 SNAP.
 
constexpr Sandbox SDL::SANDBOX_MACOS = SDL_SANDBOX_MACOS
 MACOS.
 

Detailed Description

These are functions that deal with needs of specific operating systems, that didn't make sense to offer as platform-independent, generic APIs.

Most apps can make do without these functions, but they can be useful for integrating with other parts of a specific system, adding platform-specific polish to an app, or solving problems that only affect one target.

Typedef Documentation

◆ iOSAnimationCallback

using SDL::iOSAnimationCallback = typedef SDL_iOSAnimationCallback

This datatype is only useful on Apple iOS.

After passing a function pointer of this type to SetiOSAnimationCallback, the system will call that function pointer at a regular interval.

Parameters
userdatawhat was passed as callbackParam to SetiOSAnimationCallback as callbackParam.
Since
This datatype is available since SDL 3.2.0.
See also
SetiOSAnimationCallback

◆ iOSAnimationCB

using SDL::iOSAnimationCB = typedef std::function<void ()>

This datatype is only useful on Apple iOS.

After passing a function pointer of this type to SetiOSAnimationCallback, the system will call that function pointer at a regular interval.

Parameters
userdatawhat was passed as callbackParam to SetiOSAnimationCallback as callbackParam.
Since
This datatype is available since SDL 3.2.0.
See also
SetiOSAnimationCallback
iOSAnimationCallback

◆ RequestAndroidPermissionCallback

using SDL::RequestAndroidPermissionCallback = typedef SDL_RequestAndroidPermissionCallback
Parameters
userdataan app-controlled pointer that is passed to the callback.
permissionthe Android-specific permission name that was requested.
grantedtrue if permission is granted, false if denied.
Since
This datatype is available since SDL 3.2.0.
See also
RequestAndroidPermission

◆ RequestAndroidPermissionCB

using SDL::RequestAndroidPermissionCB = typedef std::function<void (const char *, bool)>
Parameters
userdataan app-controlled pointer that is passed to the callback.
permissionthe Android-specific permission name that was requested.
grantedtrue if permission is granted, false if denied.
Since
This datatype is available since SDL 3.2.0.
See also
RequestAndroidPermission
RequestAndroidPermissionCallback

◆ Sandbox

using SDL::Sandbox = typedef SDL_Sandbox
Since
This enum is available since SDL 3.2.0.

◆ WindowsMessageHook

using SDL::WindowsMessageHook = typedef SDL_WindowsMessageHook

This callback may modify the message, and should return true if the message should continue to be processed, or false to prevent further processing.

As this is processing a message directly from the Windows event loop, this callback should do the minimum required work and return quickly.

Parameters
userdatathe app-defined pointer provided to SetWindowsMessageHook.
msga pointer to a Win32 event structure to process.
Returns
true to let event continue on, false to drop it.
Thread safety:
This may only be called (by SDL) from the thread handling the Windows event loop.
Since
This datatype is available since SDL 3.2.0.
See also
SetWindowsMessageHook
SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP

◆ WindowsMessageHookCB

using SDL::WindowsMessageHookCB = typedef std::function<bool (MSG *)>

This callback may modify the message, and should return true if the message should continue to be processed, or false to prevent further processing.

As this is processing a message directly from the Windows event loop, this callback should do the minimum required work and return quickly.

Parameters
userdatathe app-defined pointer provided to SetWindowsMessageHook.
msga pointer to a Win32 event structure to process.
Returns
true to let event continue on, false to drop it.
Thread safety:
This may only be called (by SDL) from the thread handling the Windows event loop.
Since
This datatype is available since SDL 3.2.0.
See also
SetWindowsMessageHook
SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP
WindowsMessageHook

◆ X11EventHook

using SDL::X11EventHook = typedef SDL_X11EventHook

This callback may modify the event, and should return true if the event should continue to be processed, or false to prevent further processing.

As this is processing an event directly from the X11 event loop, this callback should do the minimum required work and return quickly.

Parameters
userdatathe app-defined pointer provided to SetX11EventHook.
xeventa pointer to an Xlib XEvent union to process.
Returns
true to let event continue on, false to drop it.
Thread safety:
This may only be called (by SDL) from the thread handling the X11 event loop.
Since
This datatype is available since SDL 3.2.0.
See also
SetX11EventHook

◆ X11EventHookCB

using SDL::X11EventHookCB = typedef std::function<bool(XEvent*)>

This callback may modify the event, and should return true if the event should continue to be processed, or false to prevent further processing.

As this is processing an event directly from the X11 event loop, this callback should do the minimum required work and return quickly.

Parameters
userdatathe app-defined pointer provided to SetX11EventHook.
xeventa pointer to an Xlib XEvent union to process.
Returns
true to let event continue on, false to drop it.
Thread safety:
This may only be called (by SDL) from the thread handling the X11 event loop.
Since
This datatype is available since SDL 3.2.0.
See also
SetX11EventHook
X11EventHook

Function Documentation

◆ GetAndroidActivity()

void * SDL::GetAndroidActivity ( )
inline

The prototype of the function in SDL's code actually declares a void* return type, even if the implementation returns a jobject. The rationale being that the SDL headers can avoid including jni.h.

The jobject returned by the function is a local reference and must be released by the caller. See the PushLocalFrame() and PopLocalFrame() or DeleteLocalRef() functions of the Java native interface:

https://docs.oracle.com/javase/1.5.0/docs/guide/jni/spec/functions.html

Returns
the jobject representing the instance of the Activity class of the Android application, or nullptr on failure; call GetError() for more information.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
GetAndroidJNIEnv

◆ GetAndroidCachePath()

const char * SDL::GetAndroidCachePath ( )
inline

This path is unique to your application, but is public and can be written to by other applications.

Your cache path is typically: /data/data/your.app.package/cache/.

This is a C wrapper over android.content.Context.getCacheDir():

https://developer.android.com/reference/android/content/Context#getCacheDir()

Returns
the path used for caches for this application on success.
Exceptions
Erroron failure.
Since
This function is available since SDL 3.2.0.
See also
GetAndroidInternalStoragePath
GetAndroidExternalStoragePath

◆ GetAndroidExternalStoragePath()

const char * SDL::GetAndroidExternalStoragePath ( )
inline

This path is unique to your application, but is public and can be written to by other applications.

Your external storage path is typically: /storage/sdcard0/Android/data/your.app.package/files.

This is a C wrapper over android.content.Context.getExternalFilesDir():

https://developer.android.com/reference/android/content/Context#getExternalFilesDir()

Returns
the path used for external storage for this application on success.
Exceptions
Erroron failure.
Since
This function is available since SDL 3.2.0.
See also
GetAndroidExternalStorageState
GetAndroidInternalStoragePath
GetAndroidCachePath

◆ GetAndroidExternalStorageState()

Uint32 SDL::GetAndroidExternalStorageState ( )
inline

The current state of external storage, a bitmask of these values: ANDROID_EXTERNAL_STORAGE_READ, ANDROID_EXTERNAL_STORAGE_WRITE.

If external storage is currently unavailable, this will return 0.

Returns
the current state of external storage, or 0 if external storage is currently unavailable.
Since
This function is available since SDL 3.2.0.
See also
GetAndroidExternalStoragePath

◆ GetAndroidInternalStoragePath()

const char * SDL::GetAndroidInternalStoragePath ( )
inline

This path is unique to your application and cannot be written to by other applications.

Your internal storage path is typically: /data/data/your.app.package/files.

This is a C wrapper over android.content.Context.getFilesDir():

https://developer.android.com/reference/android/content/Context#getFilesDir()

Returns
the path used for internal storage or nullptr on failure; call GetError() for more information.
Since
This function is available since SDL 3.2.0.
See also
GetAndroidExternalStoragePath
GetAndroidCachePath

◆ GetAndroidJNIEnv()

void * SDL::GetAndroidJNIEnv ( )
inline

This is the JNIEnv one needs to access the Java virtual machine from native code, and is needed for many Android APIs to be usable from C.

The prototype of the function in SDL's code actually declare a void* return type, even if the implementation returns a pointer to a JNIEnv. The rationale being that the SDL headers can avoid including jni.h.

Returns
a pointer to Java native interface object (JNIEnv) to which the current thread is attached, or nullptr on failure; call GetError() for more information.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
GetAndroidActivity

◆ GetAndroidSDKVersion()

int SDL::GetAndroidSDKVersion ( )
inline
  • API level 35: Android 15 (VANILLA_ICE_CREAM)
  • API level 34: Android 14 (UPSIDE_DOWN_CAKE)
  • API level 33: Android 13 (TIRAMISU)
  • API level 32: Android 12L (S_V2)
  • API level 31: Android 12 (S)
  • API level 30: Android 11 (R)
  • API level 29: Android 10 (Q)
  • API level 28: Android 9 (P)
  • API level 27: Android 8.1 (O_MR1)
  • API level 26: Android 8.0 (O)
  • API level 25: Android 7.1 (N_MR1)
  • API level 24: Android 7.0 (N)
  • API level 23: Android 6.0 (M)
  • API level 22: Android 5.1 (LOLLIPOP_MR1)
  • API level 21: Android 5.0 (LOLLIPOP, L)
  • API level 20: Android 4.4W (KITKAT_WATCH)
  • API level 19: Android 4.4 (KITKAT)
  • API level 18: Android 4.3 (JELLY_BEAN_MR2)
  • API level 17: Android 4.2 (JELLY_BEAN_MR1)
  • API level 16: Android 4.1 (JELLY_BEAN)
  • API level 15: Android 4.0.3 (ICE_CREAM_SANDWICH_MR1)
  • API level 14: Android 4.0 (ICE_CREAM_SANDWICH)
  • API level 13: Android 3.2 (HONEYCOMB_MR2)
  • API level 12: Android 3.1 (HONEYCOMB_MR1)
  • API level 11: Android 3.0 (HONEYCOMB)
  • API level 10: Android 2.3.3 (GINGERBREAD_MR1)
Returns
the Android API level.
Since
This function is available since SDL 3.2.0.

◆ GetDirect3D9AdapterIndex()

int SDL::GetDirect3D9AdapterIndex ( Display  displayID)
inline

The returned adapter index can be passed to IDirect3D9::CreateDevice and controls on which monitor a full screen application will appear.

Parameters
displayIDthe instance of the display to query.
Returns
the D3D9 adapter index on success.
Exceptions
Erroron failure.
Since
This function is available since SDL 3.2.0.

◆ GetDXGIOutputInfo()

void SDL::GetDXGIOutputInfo ( Display  displayID,
int *  adapterIndex,
int *  outputIndex 
)
inline

The DXGI Adapter and Output indices can be passed to EnumAdapters and EnumOutputs respectively to get the objects required to create a DX10 or DX11 device and swap chain.

Parameters
displayIDthe instance of the display to query.
adapterIndexa pointer to be filled in with the adapter index.
outputIndexa pointer to be filled in with the output index.
Exceptions
Erroron failure.
Since
This function is available since SDL 3.2.0.

◆ GetGDKDefaultUser()

bool SDL::GetGDKDefaultUser ( XUserHandle *  outUserHandle)
inline

This is effectively a synchronous version of XUserAddAsync, which always prefers the default user and allows a sign-in UI.

Parameters
outUserHandlea pointer to be filled in with the default user handle.
Returns
true if success or false on failure; call GetError() for more information.
Since
This function is available since SDL 3.2.0.

◆ GetGDKTaskQueue()

void SDL::GetGDKTaskQueue ( XTaskQueueHandle *  outTaskQueue)
inline

Once you are done with the task queue, you should call XTaskQueueCloseHandle to reduce the reference count to avoid a resource leak.

Parameters
outTaskQueuea pointer to be filled in with task queue handle.
Exceptions
Erroron failure.
Since
This function is available since SDL 3.2.0.

◆ GetSandbox()

Sandbox SDL::GetSandbox ( )
inline
Returns
the application sandbox environment or SANDBOX_NONE if the application is not running in a sandbox environment.
Since
This function is available since SDL 3.2.0.

◆ IsChromebook()

bool SDL::IsChromebook ( )
inline
Returns
true if this is a Chromebook, false otherwise.
Since
This function is available since SDL 3.2.0.

◆ IsDeXMode()

bool SDL::IsDeXMode ( )
inline
Returns
true if this is a DeX docking station, false otherwise.
Since
This function is available since SDL 3.2.0.

◆ IsTablet()

bool SDL::IsTablet ( )
inline

If SDL can't determine this, it will return false.

Returns
true if the device is a tablet, false otherwise.
Since
This function is available since SDL 3.2.0.

◆ IsTV()

bool SDL::IsTV ( )
inline

If SDL can't determine this, it will return false.

Returns
true if the device is a TV, false otherwise.
Since
This function is available since SDL 3.2.0.

◆ OnApplicationDidChangeStatusBarOrientation()

void SDL::OnApplicationDidChangeStatusBarOrientation ( )
inline

This functions allows iOS apps that have their own event handling to hook into SDL to generate SDL events. This maps directly to an iOS-specific event, but since it doesn't do anything iOS-specific internally, it is available on all platforms, in case it might be useful for some specific paradigm. Most apps do not need to use this directly; SDL's internal event code will handle all this for windows created by WindowBase.WindowBase!

Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

◆ OnApplicationDidEnterBackground()

void SDL::OnApplicationDidEnterBackground ( )
inline

This functions allows iOS apps that have their own event handling to hook into SDL to generate SDL events. This maps directly to an iOS-specific event, but since it doesn't do anything iOS-specific internally, it is available on all platforms, in case it might be useful for some specific paradigm. Most apps do not need to use this directly; SDL's internal event code will handle all this for windows created by WindowBase.WindowBase!

Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

◆ OnApplicationDidEnterForeground()

void SDL::OnApplicationDidEnterForeground ( )
inline

This functions allows iOS apps that have their own event handling to hook into SDL to generate SDL events. This maps directly to an iOS-specific event, but since it doesn't do anything iOS-specific internally, it is available on all platforms, in case it might be useful for some specific paradigm. Most apps do not need to use this directly; SDL's internal event code will handle all this for windows created by WindowBase.WindowBase!

Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

◆ OnApplicationDidReceiveMemoryWarning()

void SDL::OnApplicationDidReceiveMemoryWarning ( )
inline

This functions allows iOS apps that have their own event handling to hook into SDL to generate SDL events. This maps directly to an iOS-specific event, but since it doesn't do anything iOS-specific internally, it is available on all platforms, in case it might be useful for some specific paradigm. Most apps do not need to use this directly; SDL's internal event code will handle all this for windows created by WindowBase.WindowBase!

Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

◆ OnApplicationWillEnterBackground()

void SDL::OnApplicationWillEnterBackground ( )
inline

This functions allows iOS apps that have their own event handling to hook into SDL to generate SDL events. This maps directly to an iOS-specific event, but since it doesn't do anything iOS-specific internally, it is available on all platforms, in case it might be useful for some specific paradigm. Most apps do not need to use this directly; SDL's internal event code will handle all this for windows created by WindowBase.WindowBase!

Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

◆ OnApplicationWillEnterForeground()

void SDL::OnApplicationWillEnterForeground ( )
inline

This functions allows iOS apps that have their own event handling to hook into SDL to generate SDL events. This maps directly to an iOS-specific event, but since it doesn't do anything iOS-specific internally, it is available on all platforms, in case it might be useful for some specific paradigm. Most apps do not need to use this directly; SDL's internal event code will handle all this for windows created by WindowBase.WindowBase!

Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

◆ OnApplicationWillTerminate()

void SDL::OnApplicationWillTerminate ( )
inline

This functions allows iOS apps that have their own event handling to hook into SDL to generate SDL events. This maps directly to an iOS-specific event, but since it doesn't do anything iOS-specific internally, it is available on all platforms, in case it might be useful for some specific paradigm. Most apps do not need to use this directly; SDL's internal event code will handle all this for windows created by WindowBase.WindowBase!

Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

◆ RequestAndroidPermission() [1/2]

bool SDL::RequestAndroidPermission ( StringParam  permission,
RequestAndroidPermissionCallback  cb,
void *  userdata 
)
inline

You do not need to call this for built-in functionality of SDL; recording from a microphone or reading images from a camera, using standard SDL APIs, will manage permission requests for you.

This function never blocks. Instead, the app-supplied callback will be called when a decision has been made. This callback may happen on a different thread, and possibly much later, as it might wait on a user to respond to a system dialog. If permission has already been granted for a specific entitlement, the callback will still fire, probably on the current thread and before this function returns.

If the request submission fails, this function returns -1 and the callback will NOT be called, but this should only happen in catastrophic conditions, like memory running out. Normally there will be a yes or no to the request through the callback.

For the permission parameter, choose a value from here:

https://developer.android.com/reference/android/Manifest.permission

Parameters
permissionthe permission to request.
cbthe callback to trigger when the request has a response.
userdataan app-controlled pointer that is passed to the callback.
Returns
true if the request was submitted, false if there was an error submitting. The result of the request is only ever reported through the callback, not this return value.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

◆ RequestAndroidPermission() [2/2]

bool SDL::RequestAndroidPermission ( StringParam  permission,
RequestAndroidPermissionCB  cb 
)
inline

You do not need to call this for built-in functionality of SDL; recording from a microphone or reading images from a camera, using standard SDL APIs, will manage permission requests for you.

This function never blocks. Instead, the app-supplied callback will be called when a decision has been made. This callback may happen on a different thread, and possibly much later, as it might wait on a user to respond to a system dialog. If permission has already been granted for a specific entitlement, the callback will still fire, probably on the current thread and before this function returns.

If the request submission fails, this function returns -1 and the callback will NOT be called, but this should only happen in catastrophic conditions, like memory running out. Normally there will be a yes or no to the request through the callback.

For the permission parameter, choose a value from here:

https://developer.android.com/reference/android/Manifest.permission

Parameters
permissionthe permission to request.
cbthe callback to trigger when the request has a response.
Returns
true if the request was submitted, false if there was an error submitting. The result of the request is only ever reported through the callback, not this return value.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

◆ SendAndroidBackButton()

void SDL::SendAndroidBackButton ( )
inline
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

◆ SendAndroidMessage()

void SDL::SendAndroidMessage ( Uint32  command,
int  param 
)
inline

Override "boolean onUnhandledMessage(Message msg)" to handle the message.

Parameters
commanduser command that must be greater or equal to 0x8000.
paramuser parameter.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

◆ SetiOSAnimationCallback() [1/2]

void SDL::SetiOSAnimationCallback ( WindowBase window,
int  interval,
iOSAnimationCallback  callback,
void *  callbackParam 
)
inline

The function prototype for callback is:

void callback(void *callbackParam);

Where its parameter, callbackParam, is what was passed as callbackParam to SetiOSAnimationCallback().

This function is only available on Apple iOS.

For more information see:

https://wiki.libsdl.org/SDL3/README/ios

Note that if you use the "main callbacks" instead of a standard C main function, you don't have to use this API, as SDL will manage this for you.

Details on main callbacks are here:

https://wiki.libsdl.org/SDL3/README/main-functions

Parameters
windowthe window for which the animation callback should be set.
intervalthe number of frames after which callback will be called.
callbackthe function to call for every frame.
callbackParama pointer that is passed to callback.
Exceptions
Erroron failure.
Since
This function is available since SDL 3.2.0.
See also
SetiOSEventPump

◆ SetiOSAnimationCallback() [2/2]

void SDL::SetiOSAnimationCallback ( WindowBase window,
int  interval,
iOSAnimationCB  callback 
)
inline

The function prototype for callback is:

void callback(void *callbackParam);

Where its parameter, callbackParam, is what was passed as callbackParam to SetiOSAnimationCallback().

This function is only available on Apple iOS.

For more information see:

https://wiki.libsdl.org/SDL3/README/ios

Note that if you use the "main callbacks" instead of a standard C main function, you don't have to use this API, as SDL will manage this for you.

Details on main callbacks are here:

https://wiki.libsdl.org/SDL3/README/main-functions

Parameters
windowthe window for which the animation callback should be set.
intervalthe number of frames after which callback will be called.
callbackthe function to call for every frame.
Exceptions
Erroron failure.
Since
This function is available since SDL 3.2.0.
See also
SetiOSEventPump

◆ SetiOSEventPump()

void SDL::SetiOSEventPump ( bool  enabled)
inline

This function is only available on Apple iOS.

Parameters
enabledtrue to enable the event pump, false to disable it.
Since
This function is available since SDL 3.2.0.
See also
SetiOSAnimationCallback

◆ SetLinuxThreadPriority()

void SDL::SetLinuxThreadPriority ( Sint64  threadID,
int  priority 
)
inline

This uses setpriority() if possible, and RealtimeKit if available.

Parameters
threadIDthe Unix thread ID to change priority of.
prioritythe new, Unix-specific, priority value.
Exceptions
Erroron failure.
Since
This function is available since SDL 3.2.0.

◆ SetLinuxThreadPriorityAndPolicy()

void SDL::SetLinuxThreadPriorityAndPolicy ( Sint64  threadID,
int  sdlPriority,
int  schedPolicy 
)
inline

This uses setpriority() if possible, and RealtimeKit if available.

Parameters
threadIDthe Unix thread ID to change priority of.
sdlPrioritythe new ThreadPriority value.
schedPolicythe new scheduling policy (SCHED_FIFO, SCHED_RR, SCHED_OTHER, etc...).
Exceptions
Erroron failure.
Since
This function is available since SDL 3.2.0.

◆ SetWindowsMessageHook() [1/2]

void SDL::SetWindowsMessageHook ( WindowsMessageHook  callback,
void *  userdata 
)
inline

The callback may modify the message, and should return true if the message should continue to be processed, or false to prevent further processing.

Parameters
callbackthe WindowsMessageHook function to call.
userdataa pointer to pass to every iteration of callback.
Since
This function is available since SDL 3.2.0.
See also
WindowsMessageHook
SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP

◆ SetWindowsMessageHook() [2/2]

void SDL::SetWindowsMessageHook ( WindowsMessageHookCB  callback)
inline

The callback may modify the message, and should return true if the message should continue to be processed, or false to prevent further processing.

Parameters
callbackthe WindowsMessageHook function to call.
Since
This function is available since SDL 3.2.0.
See also
WindowsMessageHook
SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP

◆ SetX11EventHook() [1/2]

void SDL::SetX11EventHook ( X11EventHook  callback,
void *  userdata 
)
inline

The callback may modify the event, and should return true if the event should continue to be processed, or false to prevent further processing.

Parameters
callbackthe X11EventHook function to call.
userdataa pointer to pass to every iteration of callback.
Since
This function is available since SDL 3.2.0.

◆ SetX11EventHook() [2/2]

void SDL::SetX11EventHook ( X11EventHookCB  callback)
inline

The callback may modify the event, and should return true if the event should continue to be processed, or false to prevent further processing.

Parameters
callbackthe X11EventHook function to call.
Since
This function is available since SDL 3.2.0.

◆ ShowAndroidToast()

void SDL::ShowAndroidToast ( StringParam  message,
int  duration,
int  gravity,
int  xoffset,
int  yoffset 
)
inline

Toasts are a sort of lightweight notification that are unique to Android.

https://developer.android.com/guide/topics/ui/notifiers/toasts

Shows toast in UI thread.

For the gravity parameter, choose a value from here, or -1 if you don't have a preference:

https://developer.android.com/reference/android/view/Gravity

Parameters
messagetext message to be shown.
duration0=short, 1=long.
gravitywhere the notification should appear on the screen.
xoffsetset this parameter only when gravity >=0.
yoffsetset this parameter only when gravity >=0.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

Variable Documentation

◆ ANDROID_EXTERNAL_STORAGE_READ

constexpr Uint32 SDL::ANDROID_EXTERNAL_STORAGE_READ
constexpr
Initial value:
=
SDL_ANDROID_EXTERNAL_STORAGE_READ
Since
This macro is available since SDL 3.2.0.

◆ ANDROID_EXTERNAL_STORAGE_WRITE

constexpr Uint32 SDL::ANDROID_EXTERNAL_STORAGE_WRITE
constexpr
Initial value:
=
SDL_ANDROID_EXTERNAL_STORAGE_WRITE
Since
This macro is available since SDL 3.2.0.

◆ SANDBOX_UNKNOWN_CONTAINER

constexpr Sandbox SDL::SANDBOX_UNKNOWN_CONTAINER
constexpr
Initial value:
=
SDL_SANDBOX_UNKNOWN_CONTAINER