SDL 3.0
SDL_system.h File Reference
Include dependency graph for SDL_system.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef union _XEvent XEvent
typedef bool(* SDL_X11EventHook) (void *userdata, XEvent *xevent)

Enumerations

enum  SDL_FormFactor {
  SDL_FORMFACTOR_UNKNOWN = 0 ,
  SDL_FORMFACTOR_DESKTOP ,
  SDL_FORMFACTOR_LAPTOP ,
  SDL_FORMFACTOR_PHONE ,
  SDL_FORMFACTOR_TABLET ,
  SDL_FORMFACTOR_CONSOLE ,
  SDL_FORMFACTOR_HANDHELD ,
  SDL_FORMFACTOR_WATCH ,
  SDL_FORMFACTOR_TV ,
  SDL_FORMFACTOR_HEADSET ,
  SDL_FORMFACTOR_CAR
}
enum  SDL_Sandbox {
  SDL_SANDBOX_NONE = 0 ,
  SDL_SANDBOX_UNKNOWN_CONTAINER ,
  SDL_SANDBOX_FLATPAK ,
  SDL_SANDBOX_SNAP ,
  SDL_SANDBOX_MACOS ,
  SDL_SANDBOX_LOMIRI
}

Functions

void SDL_SetX11EventHook (SDL_X11EventHook callback, void *userdata)
bool SDL_IsPhone (void)
bool SDL_IsTablet (void)
bool SDL_IsTV (void)
SDL_FormFactor SDL_GetDeviceFormFactor (void)
const char * SDL_GetDeviceFormFactorName (SDL_FormFactor form_factor)
SDL_Sandbox SDL_GetSandbox (void)
void SDL_OnApplicationWillTerminate (void)
void SDL_OnApplicationDidReceiveMemoryWarning (void)
void SDL_OnApplicationWillEnterBackground (void)
void SDL_OnApplicationDidEnterBackground (void)
void SDL_OnApplicationWillEnterForeground (void)
void SDL_OnApplicationDidEnterForeground (void)

Typedef Documentation

◆ SDL_X11EventHook

typedef bool(* SDL_X11EventHook) (void *userdata, XEvent *xevent)

A callback to be used with SDL_SetX11EventHook.

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 SDL_SetX11EventHook.
xeventa pointer to an Xlib XEvent union to process.
Returns
true to let event continue on, false to drop it.

\threadsafety 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
SDL_SetX11EventHook

Definition at line 163 of file SDL_system.h.

◆ XEvent

typedef union _XEvent XEvent

CategorySystem

Platform-specific SDL API functions. 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.

Definition at line 141 of file SDL_system.h.

Enumeration Type Documentation

◆ SDL_FormFactor

The possible form factors for a device.

Since
This enum is available since SDL 3.4.0.
See also
SDL_GetDeviceFormFactor
SDL_GetDeviceFormFactorName
Enumerator
SDL_FORMFACTOR_UNKNOWN 
SDL_FORMFACTOR_DESKTOP 
SDL_FORMFACTOR_LAPTOP 
SDL_FORMFACTOR_PHONE 
SDL_FORMFACTOR_TABLET 
SDL_FORMFACTOR_CONSOLE 
SDL_FORMFACTOR_HANDHELD 
SDL_FORMFACTOR_WATCH 
SDL_FORMFACTOR_TV 
SDL_FORMFACTOR_HEADSET 
SDL_FORMFACTOR_CAR 

Definition at line 668 of file SDL_system.h.

668 {
SDL_FormFactor
Definition SDL_system.h:668
@ SDL_FORMFACTOR_HEADSET
Definition SDL_system.h:678
@ SDL_FORMFACTOR_DESKTOP
Definition SDL_system.h:670
@ SDL_FORMFACTOR_UNKNOWN
Definition SDL_system.h:669
@ SDL_FORMFACTOR_LAPTOP
Definition SDL_system.h:671
@ SDL_FORMFACTOR_HANDHELD
Definition SDL_system.h:675
@ SDL_FORMFACTOR_WATCH
Definition SDL_system.h:676
@ SDL_FORMFACTOR_CONSOLE
Definition SDL_system.h:674
@ SDL_FORMFACTOR_PHONE
Definition SDL_system.h:672
@ SDL_FORMFACTOR_TABLET
Definition SDL_system.h:673
@ SDL_FORMFACTOR_CAR
Definition SDL_system.h:679
@ SDL_FORMFACTOR_TV
Definition SDL_system.h:677

◆ SDL_Sandbox

Application sandbox environment.

Since
This enum is available since SDL 3.2.0.
Enumerator
SDL_SANDBOX_NONE 
SDL_SANDBOX_UNKNOWN_CONTAINER 
SDL_SANDBOX_FLATPAK 
SDL_SANDBOX_SNAP 
SDL_SANDBOX_MACOS 
SDL_SANDBOX_LOMIRI 

Definition at line 724 of file SDL_system.h.

725{
SDL_Sandbox
Definition SDL_system.h:725
@ SDL_SANDBOX_FLATPAK
Definition SDL_system.h:728
@ SDL_SANDBOX_SNAP
Definition SDL_system.h:729
@ SDL_SANDBOX_UNKNOWN_CONTAINER
Definition SDL_system.h:727
@ SDL_SANDBOX_MACOS
Definition SDL_system.h:730
@ SDL_SANDBOX_LOMIRI
Definition SDL_system.h:731
@ SDL_SANDBOX_NONE
Definition SDL_system.h:726

Function Documentation

◆ SDL_GetDeviceFormFactor()

SDL_FormFactor SDL_GetDeviceFormFactor ( void )
extern

Get the form factor of the current device.

This function guesses what the device may be, but may report inaccurate or outright wrong results. For example, it may report a laptop as a desktop, or a car device as a phone.

Depending on the usage, there may be different functions better suited for each purpose. For example, activating touch controls can be done by detecting the presence of a touchscreen rather than restricting to phones and tablets.

Returns
the best guess for the form factor of the current device.
Since
This function is available since SDL 3.6.0.
See also
SDL_FormFactor
SDL_GetDeviceFormFactorName

◆ SDL_GetDeviceFormFactorName()

const char * SDL_GetDeviceFormFactorName ( SDL_FormFactor form_factor)
extern

Get a short name for the current device.

The name will be in English.

Parameters
form_factorthe form factor to query.
Returns
a human-readable name for the given form factor, or "SDL_FORMFACTOR_UNKNOWN" if the form factor isn't recognized.
Since
This function is available since SDL 3.6.0.
See also
SDL_FormFactor
SDL_GetDeviceFormFactor

◆ SDL_GetSandbox()

SDL_Sandbox SDL_GetSandbox ( void )
extern

Get the application sandbox environment, if any.

Returns
the application sandbox environment or SDL_SANDBOX_NONE if the application is not running in a sandbox environment.
Since
This function is available since SDL 3.2.0.

◆ SDL_IsPhone()

bool SDL_IsPhone ( void )
extern

Query if the current device is a phone.

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

Returns
true if the device is a phone, false otherwise.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.6.0.
See also
SDL_IsTablet

◆ SDL_IsTablet()

bool SDL_IsTablet ( void )
extern

Query if the current device is a tablet.

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

Returns
true if the device is a tablet, false otherwise.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.2.0.

◆ SDL_IsTV()

bool SDL_IsTV ( void )
extern

Query if the current device is a TV.

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

Returns
true if the device is a TV, false otherwise.

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.2.0.

◆ SDL_OnApplicationDidEnterBackground()

void SDL_OnApplicationDidEnterBackground ( void )
extern

Let iOS apps with external event handling report onApplicationDidEnterBackground.

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 SDL_CreateWindow!

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.2.0.

◆ SDL_OnApplicationDidEnterForeground()

void SDL_OnApplicationDidEnterForeground ( void )
extern

Let iOS apps with external event handling report onApplicationDidBecomeActive.

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 SDL_CreateWindow!

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.2.0.

◆ SDL_OnApplicationDidReceiveMemoryWarning()

void SDL_OnApplicationDidReceiveMemoryWarning ( void )
extern

Let iOS apps with external event handling report onApplicationDidReceiveMemoryWarning.

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 SDL_CreateWindow!

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.2.0.

◆ SDL_OnApplicationWillEnterBackground()

void SDL_OnApplicationWillEnterBackground ( void )
extern

Let iOS apps with external event handling report onApplicationWillResignActive.

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 SDL_CreateWindow!

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.2.0.

◆ SDL_OnApplicationWillEnterForeground()

void SDL_OnApplicationWillEnterForeground ( void )
extern

Let iOS apps with external event handling report onApplicationWillEnterForeground.

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 SDL_CreateWindow!

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.2.0.

◆ SDL_OnApplicationWillTerminate()

void SDL_OnApplicationWillTerminate ( void )
extern

Let iOS apps with external event handling report onApplicationWillTerminate.

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 SDL_CreateWindow!

\threadsafety It is safe to call this function from any thread.

Since
This function is available since SDL 3.2.0.

◆ SDL_SetX11EventHook()

void SDL_SetX11EventHook ( SDL_X11EventHook callback,
void * userdata )
extern

Set a callback for every X11 event.

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 SDL_X11EventHook function to call.
userdataa pointer to pass to every iteration of callback.

\threadsafety This function should only be called on the main thread.

Since
This function is available since SDL 3.2.0.

References window.