DRAFT |
SDL_EventType
An enumeration of the types of events that can be delivered.
Contents
Values
SDL_FIRSTEVENT |
do not remove (unused) |
Application events |
|
SDL_QUIT |
user-requested quit; see Remarks for details |
Android and iOS events; see Remarks for details |
|
SDL_APP_TERMINATING |
OS is terminating the application |
SDL_APP_LOWMEMORY |
OS is low on memory; free some |
SDL_APP_WILLENTERBACKGROUND |
Application is entering background |
SDL_APP_DIDENTERBACKGROUND |
Application entered background |
SDL_APP_WILLENTERFOREGROUND |
Application is entering foreground |
SDL_APP_DIDENTERFOREGROUND |
Application entered foreground |
Window events |
|
window state change |
|
system specific event |
|
Keyboard events |
|
key pressed |
|
key released |
|
keyboard text editing (composition) |
|
keyboard text input |
|
Mouse events |
|
mouse moved |
|
mouse button pressed |
|
mouse button released |
|
mouse wheel motion |
|
Joystick events |
|
joystick axis motion |
|
joystick trackball motion |
|
joystick hat position change |
|
joystick button pressed |
|
joystick button released |
|
joystick connected |
|
joystick disconnected |
|
Controller events |
|
controller axis motion |
|
controller button pressed |
|
controller button released |
|
controller connected |
|
controller disconnected |
|
controller mapping updated |
|
Touch events |
|
Gesture events |
|
Clipboard events |
|
SDL_CLIPBOARDUPDATE |
the clipboard changed |
Drag and drop events |
|
the system requests a file open |
|
These are for your use, and should be allocated with SDL_RegisterEvents() |
|
SDL_USEREVENT |
a user-specified event |
SDL_LASTEVENT |
only for bounding internal arrays |
Code Examples
You can add your code example here
Remarks
Application Events
An SDL_QUIT event is generated when the user tries to close the last remaining SDL_Window. If it is ignored or filtered out, the window will remain open. If it is not ignored or filtered, it is queued normally and the window is allowed to close. When the window is closed, screen updates will complete, but have no effect.
On Mac OS X, pressing Command-Q (the standard keyboard shortcut for "Quit this application") will cause SDL to generate an SDL_QUIT event. The application is still responsible for terminating itself, however.
SDL_Init() installs signal handlers for SIGINT (keyboard interrupt) and SIGTERM (system termination request), if handlers do not already exist, that generate SDL_QUIT events as well. There is no way to determine the cause of an SDL_QUIT event, but setting a signal handler in your application will override the default generation of quit events for that signal.
Android and iOS Events
What we currently label as "Android and iOS events" are specific to mobile and embedded devices that have different requirements than your usual desktop application. These events must be handled in an event filter, since often the OS needs an immediate response and will terminate your process shortly after sending the event, and if it sits in the SDL event queue, it'll be too late. You can handle everything else through a normal SDL_PollEvent() loop, but you should set up a callback with [[SDL_SetEventFilter|SDL_SetEventFilter()] for these specific events.
This is how these events currently map to the underlying OS:
SDL event |
What |
iOS |
Android |
SDL_APP_TERMINATING |
The application is being terminated by the OS. |
applicationWillTerminate() |
onDestroy() |
SDL_APP_LOWMEMORY |
The application is low on memory, free memory if possible. |
applicationDidReceiveMemoryWarning() |
onLowMemory() |
SDL_APP_WILLENTERBACKGROUND |
The application is about to enter the background. |
applicationWillResignActive() |
onPause() |
SDL_APP_DIDENTERBACKGROUND |
The application did enter the background and may not get CPU for some time. |
applicationDidEnterBackground() |
onPause() |
SDL_APP_WILLENTERFOREGROUND |
The application is about to enter the foreground. |
applicationWillEnterForeground() |
onResume() |
SDL_APP_DIDENTERFOREGROUND |
The application is now interactive. |
applicationDidBecomeActive() |
onResume() |
Related Structures
