Module events
dep_sdl3
only.Expand description
Event queue management.
It’s extremely common–often required–that an app deal with SDL’s event queue. Almost all useful information about interactions with the real world flow through here: the user interacting with the computer and app, hardware coming and going, the system changing in some way, etc.
An app generally takes a moment, perhaps at the start of a new frame, to
examine any events that have occured since the last time and process or
ignore them. This is generally done by calling SDL_PollEvent()
in a loop
until it returns false (or, if using the main callbacks, events are
provided one at a time in calls to [SDL_AppEvent()
] before the next call to
[SDL_AppIterate()
]; in this scenario, the app does not call SDL_PollEvent()
at all).
There is other forms of control, too: SDL_PeepEvents()
has more
functionality at the cost of more complexity, and SDL_WaitEvent()
can block
the process until something interesting happens, which might be beneficial
for certain types of programs on low-power hardware. One may also call
SDL_AddEventWatch()
to set a callback when new events arrive.
The app is free to generate their own events, too: SDL_PushEvent
allows the
app to put events onto the queue for later retrieval; SDL_RegisterEvents
can guarantee that these events have a type that isn’t in use by other
parts of the system.
Structs§
- SDL_
Audio Device Event - Audio device event structure (event.adevice.*)
- SDL_
Camera Device Event - Camera device event structure (event.cdevice.*)
- SDL_
Clipboard Event - An event triggered when the clipboard contents have changed (event.clipboard.*)
- SDL_
Common Event - Fields shared by every event
- SDL_
Display Event - Display state change event data (event.display.*)
- SDL_
Drop Event - An event used to drop text or request a file open by the system (event.drop.*)
- SDL_
Event Action - The type of action to request from
SDL_PeepEvents()
. - SDL_
Event Type - The types of events that can be delivered.
- SDL_
Gamepad Axis Event - Gamepad axis motion event structure (event.gaxis.*)
- SDL_
Gamepad Button Event - Gamepad button event structure (event.gbutton.*)
- SDL_
Gamepad Device Event - Gamepad device event structure (event.gdevice.*)
- SDL_
Gamepad Sensor Event - Gamepad sensor event structure (event.gsensor.*)
- SDL_
Gamepad Touchpad Event - Gamepad touchpad event structure (event.gtouchpad.*)
- SDL_
JoyAxis Event - Joystick axis motion event structure (event.jaxis.*)
- SDL_
JoyBall Event - Joystick trackball motion event structure (event.jball.*)
- SDL_
JoyBattery Event - Joystick battery level change event structure (event.jbattery.*)
- SDL_
JoyButton Event - Joystick button event structure (event.jbutton.*)
- SDL_
JoyDevice Event - Joystick device event structure (event.jdevice.*)
- SDL_
JoyHat Event - Joystick hat position change event structure (event.jhat.*)
- SDL_
Keyboard Device Event - Keyboard device event structure (event.kdevice.*)
- SDL_
Keyboard Event - Keyboard button event structure (event.key.*)
- SDL_
Mouse Button Event - Mouse button event structure (event.button.*)
- SDL_
Mouse Device Event - Mouse device event structure (event.mdevice.*)
- SDL_
Mouse Motion Event - Mouse motion event structure (event.motion.*)
- SDL_
Mouse Wheel Event - Mouse wheel event structure (event.wheel.*)
- SDL_
PenAxis Event - Pressure-sensitive pen pressure / angle event structure (event.paxis.*)
- SDL_
PenButton Event - Pressure-sensitive pen button event structure (event.pbutton.*)
- SDL_
PenMotion Event - Pressure-sensitive pen motion event structure (event.pmotion.*)
- SDL_
PenProximity Event - Pressure-sensitive pen proximity event structure (event.pmotion.*)
- SDL_
PenTouch Event - Pressure-sensitive pen touched event structure (event.ptouch.*)
- SDL_
Quit Event - The “quit requested” event
- SDL_
Render Event - Renderer event structure (event.render.*)
- SDL_
Sensor Event - Sensor event structure (event.sensor.*)
- SDL_
Text Editing Candidates Event - Keyboard IME candidates event structure (event.edit_candidates.*)
- SDL_
Text Editing Event - Keyboard text editing event structure (event.edit.*)
- SDL_
Text Input Event - Keyboard text input event structure (event.text.*)
- SDL_
Touch Finger Event - Touch finger event structure (event.tfinger.*)
- SDL_
User Event - A user-defined event type (event.user.*)
- SDL_
Window Event - Window state change event data (event.window.*)
Constants§
- SDL_
ADDEVENT - Add events to the back of the queue.
- SDL_
EVENT_ AUDIO_ DEVICE_ ADDED - A new audio device is available
- SDL_
EVENT_ AUDIO_ DEVICE_ FORMAT_ CHANGED - An audio device’s format has been changed by the system.
- SDL_
EVENT_ AUDIO_ DEVICE_ REMOVED - An audio device has been removed.
- SDL_
EVENT_ CAMERA_ DEVICE_ ADDED - A new camera device is available
- SDL_
EVENT_ CAMERA_ DEVICE_ APPROVED - A camera device has been approved for use by the user.
- SDL_
EVENT_ CAMERA_ DEVICE_ DENIED - A camera device has been denied for use by the user.
- SDL_
EVENT_ CAMERA_ DEVICE_ REMOVED - A camera device has been removed.
- SDL_
EVENT_ CLIPBOARD_ UPDATE - The clipboard or primary selection changed
- SDL_
EVENT_ DID_ ENTER_ BACKGROUND - The application did enter the background and may not get CPU for some time. This event must be handled in a callback set with
SDL_AddEventWatch()
. Called on iOS in applicationDidEnterBackground() Called on Android in onPause() - SDL_
EVENT_ DID_ ENTER_ FOREGROUND - The application is now interactive. This event must be handled in a callback set with
SDL_AddEventWatch()
. Called on iOS in applicationDidBecomeActive() Called on Android in onResume() - SDL_
EVENT_ DISPLAY_ ADDED - Display has been added to the system
- SDL_
EVENT_ DISPLAY_ CONTENT_ SCALE_ CHANGED - Display has changed content scale
- SDL_
EVENT_ DISPLAY_ CURRENT_ MODE_ CHANGED - Display has changed current mode
- SDL_
EVENT_ DISPLAY_ DESKTOP_ MODE_ CHANGED - Display has changed desktop mode
- SDL_
EVENT_ DISPLAY_ FIRST - SDL_
EVENT_ DISPLAY_ LAST - SDL_
EVENT_ DISPLAY_ MOVED - Display has changed position
- SDL_
EVENT_ DISPLAY_ ORIENTATION - Display orientation has changed to data1
- SDL_
EVENT_ DISPLAY_ REMOVED - Display has been removed from the system
- SDL_
EVENT_ DROP_ BEGIN - A new set of drops is beginning (NULL filename)
- SDL_
EVENT_ DROP_ COMPLETE - Current set of drops is now complete (NULL filename)
- SDL_
EVENT_ DROP_ FILE - The system requests a file open
- SDL_
EVENT_ DROP_ POSITION - Position while moving over the window
- SDL_
EVENT_ DROP_ TEXT - text/plain drag-and-drop event
- SDL_
EVENT_ ENUM_ PADDING - SDL_
EVENT_ FINGER_ CANCELED - SDL_
EVENT_ FINGER_ DOWN - SDL_
EVENT_ FINGER_ MOTION - SDL_
EVENT_ FINGER_ UP - SDL_
EVENT_ FIRST - Unused (do not remove)
- SDL_
EVENT_ GAMEPAD_ ADDED - A new gamepad has been inserted into the system
- SDL_
EVENT_ GAMEPAD_ AXIS_ MOTION - Gamepad axis motion
- SDL_
EVENT_ GAMEPAD_ BUTTON_ DOWN - Gamepad button pressed
- SDL_
EVENT_ GAMEPAD_ BUTTON_ UP - Gamepad button released
- SDL_
EVENT_ GAMEPAD_ REMAPPED - The gamepad mapping was updated
- SDL_
EVENT_ GAMEPAD_ REMOVED - A gamepad has been removed
- SDL_
EVENT_ GAMEPAD_ SENSOR_ UPDATE - Gamepad sensor was updated
- SDL_
EVENT_ GAMEPAD_ STEAM_ HANDLE_ UPDATED - Gamepad Steam handle has changed
- SDL_
EVENT_ GAMEPAD_ TOUCHPAD_ DOWN - Gamepad touchpad was touched
- SDL_
EVENT_ GAMEPAD_ TOUCHPAD_ MOTION - Gamepad touchpad finger was moved
- SDL_
EVENT_ GAMEPAD_ TOUCHPAD_ UP - Gamepad touchpad finger was lifted
- SDL_
EVENT_ GAMEPAD_ UPDATE_ COMPLETE - Gamepad update is complete
- SDL_
EVENT_ JOYSTICK_ ADDED - A new joystick has been inserted into the system
- SDL_
EVENT_ JOYSTICK_ AXIS_ MOTION - Joystick axis motion
- SDL_
EVENT_ JOYSTICK_ BALL_ MOTION - Joystick trackball motion
- SDL_
EVENT_ JOYSTICK_ BATTERY_ UPDATED - Joystick battery level change
- SDL_
EVENT_ JOYSTICK_ BUTTON_ DOWN - Joystick button pressed
- SDL_
EVENT_ JOYSTICK_ BUTTON_ UP - Joystick button released
- SDL_
EVENT_ JOYSTICK_ HAT_ MOTION - Joystick hat position change
- SDL_
EVENT_ JOYSTICK_ REMOVED - An opened joystick has been removed
- SDL_
EVENT_ JOYSTICK_ UPDATE_ COMPLETE - Joystick update is complete
- SDL_
EVENT_ KEYBOARD_ ADDED - A new keyboard has been inserted into the system
- SDL_
EVENT_ KEYBOARD_ REMOVED - A keyboard has been removed
- SDL_
EVENT_ KEYMAP_ CHANGED - Keymap changed due to a system event such as an input language or keyboard layout change.
- SDL_
EVENT_ KEY_ DOWN - Key pressed
- SDL_
EVENT_ KEY_ UP - Key released
- SDL_
EVENT_ LAST - This last event is only for bounding internal arrays
- SDL_
EVENT_ LOCALE_ CHANGED - The user’s locale preferences have changed.
- SDL_
EVENT_ LOW_ MEMORY - The application is low on memory, free memory if possible. This event must be handled in a callback set with
SDL_AddEventWatch()
. Called on iOS in applicationDidReceiveMemoryWarning() Called on Android in onTrimMemory() - SDL_
EVENT_ MOUSE_ ADDED - A new mouse has been inserted into the system
- SDL_
EVENT_ MOUSE_ BUTTON_ DOWN - Mouse button pressed
- SDL_
EVENT_ MOUSE_ BUTTON_ UP - Mouse button released
- SDL_
EVENT_ MOUSE_ MOTION - Mouse moved
- SDL_
EVENT_ MOUSE_ REMOVED - A mouse has been removed
- SDL_
EVENT_ MOUSE_ WHEEL - Mouse wheel motion
- SDL_
EVENT_ PEN_ AXIS - Pressure-sensitive pen angle/pressure/etc changed
- SDL_
EVENT_ PEN_ BUTTON_ DOWN - Pressure-sensitive pen button pressed
- SDL_
EVENT_ PEN_ BUTTON_ UP - Pressure-sensitive pen button released
- SDL_
EVENT_ PEN_ DOWN - Pressure-sensitive pen touched drawing surface
- SDL_
EVENT_ PEN_ MOTION - Pressure-sensitive pen is moving on the tablet
- SDL_
EVENT_ PEN_ PROXIMITY_ IN - Pressure-sensitive pen has become available
- SDL_
EVENT_ PEN_ PROXIMITY_ OUT - Pressure-sensitive pen has become unavailable
- SDL_
EVENT_ PEN_ UP - Pressure-sensitive pen stopped touching drawing surface
- SDL_
EVENT_ POLL_ SENTINEL - Signals the end of an event poll cycle
- SDL_
EVENT_ PRIVAT E0 - SDL_
EVENT_ PRIVAT E1 - SDL_
EVENT_ PRIVAT E2 - SDL_
EVENT_ PRIVAT E3 - SDL_
EVENT_ QUIT - User-requested quit
- SDL_
EVENT_ RENDER_ DEVICE_ LOST - The device has been lost and can’t be recovered.
- SDL_
EVENT_ RENDER_ DEVICE_ RESET - The device has been reset and all textures need to be recreated
- SDL_
EVENT_ RENDER_ TARGETS_ RESET - The render targets have been reset and their contents need to be updated
- SDL_
EVENT_ SENSOR_ UPDATE - A sensor was updated
- SDL_
EVENT_ SYSTEM_ THEME_ CHANGED - The system theme changed
- SDL_
EVENT_ TERMINATING - The application is being terminated by the OS. This event must be handled in a callback set with
SDL_AddEventWatch()
. Called on iOS in applicationWillTerminate() Called on Android in onDestroy() - SDL_
EVENT_ TEXT_ EDITING - Keyboard text editing (composition)
- SDL_
EVENT_ TEXT_ EDITING_ CANDIDATES - Keyboard text editing candidates
- SDL_
EVENT_ TEXT_ INPUT - Keyboard text input
- SDL_
EVENT_ USER - Events
SDL_EVENT_USER
throughSDL_EVENT_LAST
are for your use, and should be allocated withSDL_RegisterEvents()
- SDL_
EVENT_ WILL_ ENTER_ BACKGROUND - The application is about to enter the background. This event must be handled in a callback set with
SDL_AddEventWatch()
. Called on iOS in applicationWillResignActive() Called on Android in onPause() - SDL_
EVENT_ WILL_ ENTER_ FOREGROUND - The application is about to enter the foreground. This event must be handled in a callback set with
SDL_AddEventWatch()
. Called on iOS in applicationWillEnterForeground() Called on Android in onResume() - SDL_
EVENT_ WINDOW_ CLOSE_ REQUESTED - The window manager requests that the window be closed
- SDL_
EVENT_ WINDOW_ DESTROYED - The window with the associated ID is being or has been destroyed. If this message is being handled in an event watcher, the window handle is still valid and can still be used to retrieve any properties associated with the window. Otherwise, the handle has already been destroyed and all resources associated with it are invalid
- SDL_
EVENT_ WINDOW_ DISPLAY_ CHANGED - Window has been moved to display data1
- SDL_
EVENT_ WINDOW_ DISPLAY_ SCALE_ CHANGED - Window display scale has been changed
- SDL_
EVENT_ WINDOW_ ENTER_ FULLSCREEN - The window has entered fullscreen mode
- SDL_
EVENT_ WINDOW_ EXPOSED - Window has been exposed and should be redrawn, and can be redrawn directly from event watchers for this event
- SDL_
EVENT_ WINDOW_ FIRST - SDL_
EVENT_ WINDOW_ FOCUS_ GAINED - Window has gained keyboard focus
- SDL_
EVENT_ WINDOW_ FOCUS_ LOST - Window has lost keyboard focus
- SDL_
EVENT_ WINDOW_ HDR_ STATE_ CHANGED - Window HDR properties have changed
- SDL_
EVENT_ WINDOW_ HIDDEN - Window has been hidden
- SDL_
EVENT_ WINDOW_ HIT_ TEST - Window had a hit test that wasn’t
SDL_HITTEST_NORMAL
- SDL_
EVENT_ WINDOW_ ICCPROF_ CHANGED - The ICC profile of the window’s display has changed
- SDL_
EVENT_ WINDOW_ LAST - SDL_
EVENT_ WINDOW_ LEAVE_ FULLSCREEN - The window has left fullscreen mode
- SDL_
EVENT_ WINDOW_ MAXIMIZED - Window has been maximized
- SDL_
EVENT_ WINDOW_ METAL_ VIEW_ RESIZED - The pixel size of a Metal view associated with the window has changed
- SDL_
EVENT_ WINDOW_ MINIMIZED - Window has been minimized
- SDL_
EVENT_ WINDOW_ MOUSE_ ENTER - Window has gained mouse focus
- SDL_
EVENT_ WINDOW_ MOUSE_ LEAVE - Window has lost mouse focus
- SDL_
EVENT_ WINDOW_ MOVED - Window has been moved to data1, data2
- SDL_
EVENT_ WINDOW_ OCCLUDED - The window has been occluded
- SDL_
EVENT_ WINDOW_ PIXEL_ SIZE_ CHANGED - The pixel size of the window has changed to data1xdata2
- SDL_
EVENT_ WINDOW_ RESIZED - Window has been resized to data1xdata2
- SDL_
EVENT_ WINDOW_ RESTORED - Window has been restored to normal size and position
- SDL_
EVENT_ WINDOW_ SAFE_ AREA_ CHANGED - The window safe area has been changed
- SDL_
EVENT_ WINDOW_ SHOWN - Window has been shown
- SDL_
GETEVENT - Retrieve/remove events from the front of the queue.
- SDL_
PEEKEVENT - Check but don’t remove events from the queue front.
Functions§
- SDL_
AddEvent ⚠Watch - Add a callback to be triggered when an event is added to the event queue.
- SDL_
Event ⚠Enabled - Query the state of processing events by type.
- SDL_
Filter ⚠Events - Run a specific filter function on the current event queue, removing any events for which the filter returns false.
- SDL_
Flush ⚠Event - Clear events of a specific type from the event queue.
- SDL_
Flush ⚠Events - Clear events of a range of types from the event queue.
- SDL_
GetEvent ⚠Filter - Query the current event filter.
- SDL_
GetWindow ⚠From Event - Get window associated with an event.
- SDL_
HasEvent ⚠ - Check for the existence of a certain event type in the event queue.
- SDL_
HasEvents ⚠ - Check for the existence of certain event types in the event queue.
- SDL_
Peep ⚠Events - Check the event queue for messages and optionally return them.
- SDL_
Poll ⚠Event - Poll for currently pending events.
- SDL_
Pump ⚠Events - Pump the event loop, gathering events from the input devices.
- SDL_
Push ⚠Event - Add an event to the event queue.
- SDL_
Register ⚠Events - Allocate a set of user-defined events, and return the beginning event number for that set of events.
- SDL_
Remove ⚠Event Watch - Remove an event watch callback added with
SDL_AddEventWatch()
. - SDL_
SetEvent ⚠Enabled - Set the state of processing events by type.
- SDL_
SetEvent ⚠Filter - Set up a filter to process all events before they are added to the internal event queue.
- SDL_
Wait ⚠Event - Wait indefinitely for the next available event.
- SDL_
Wait ⚠Event Timeout - Wait until the specified timeout (in milliseconds) for the next available event.
Type Aliases§
- SDL_
Event Filter - A function pointer used for callbacks that watch the event queue.
Unions§
- SDL_
Event - The structure for all events in SDL.