|
Size: 6949
Comment: Fixed link syntax.
|
Size: 7096
Comment: Updated, removed DRAFT
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 3: | Line 3: |
| ||<tablewidth="100%" style="color: #FF0000;" :> DRAFT|| | |
| Line 67: | Line 66: |
| You can add your code example here | SDL_Event e; while (SDL_PollEvent(&e) { if (e.type == SDL_KEYDOWN) { printf("User just pressed down a key!\n"); } } |
| Line 72: | Line 76: |
| 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. | An SDL_QUIT event is generated when the last existing window is destroyed via [[SDL_DestroyWindow]]. If the application continues after this event and creates another window, SDL_QUIT will be sent again next time the last remaining window is destroyed. |
| Line 74: | Line 78: |
| 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_QUIT is not limited to window destruction. 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. Applications that ignore Command-Q will fail Mac App Store certification. |
| Line 79: | Line 83: |
| 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|SDL_PollEvent()]] loop, but you should set up a callback with [[SDL_SetEventFilter|SDL_SetEventFilter()]] for these specific 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|SDL_PollEvent()]] loop, but you should set up a callback with [[SDL_SetEventFilter]]() for these specific events. |
| Line 84: | Line 88: |
| ||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()|| |
||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()`|| |
| Line 117: | Line 121: |
| . [[SDL_PollEvent]] . [[SDL_SetEventFilter]] |
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 |
|
User has touched input device |
|
User stopped touching input device |
|
User is dragging finger on input device |
|
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
SDL_Event e;
while (SDL_PollEvent(&e) {
if (e.type == SDL_KEYDOWN) {
printf("User just pressed down a key!\n");
}
}
Remarks
Application Events
An SDL_QUIT event is generated when the last existing window is destroyed via SDL_DestroyWindow. If the application continues after this event and creates another window, SDL_QUIT will be sent again next time the last remaining window is destroyed.
SDL_QUIT is not limited to window destruction. 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. Applications that ignore Command-Q will fail Mac App Store certification.
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() 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
