events topic
CategoryEvents
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 occurred 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.
Classes
- SdlAudioDeviceEvent events
- SdlCameraDeviceEvent events
- SdlClipboardEvent events
- SdlCommonEvent events
- SdlDisplayEvent events
- SdlDropEvent events
- SdlEvent events
- SdlGamepadAxisEvent events
- SdlGamepadButtonEvent events
- SdlGamepadDeviceEvent events
- SdlGamepadSensorEvent events
- SdlGamepadTouchpadEvent events
- SdlJoyAxisEvent events
- SdlJoyBallEvent events
- SdlJoyBatteryEvent events
- SdlJoyButtonEvent events
- SdlJoyDeviceEvent events
- SdlJoyHatEvent events
- SdlkEvent events
- SdlKeyboardDeviceEvent events
- SdlKeyboardEvent events
- SdlMouseButtonEvent events
- SdlMouseDeviceEvent events
- SdlMouseMotionEvent events
- SdlMouseWheelEvent events
- SdlPenAxisEvent events
- SdlPenButtonEvent events
- SdlPenMotionEvent events
- SdlPenProximityEvent events
- SdlPenTouchEvent events
- SdlQuitEvent events
- SdlRenderEvent events
- SdlSensorEvent events
- SdlTextEditingCandidatesEvent events
- SdlTextEditingEvent events
- SdlTextInputEvent events
- SdlTouchFingerEvent events
- SdlUserEvent events
- SdlWindowEvent events
Extensions
Functions
-
sdlAddEventWatch(
Pointer< eventsNativeFunction< filter, Pointer<SdlEventFilter> >NativeType> userdata) → bool - Add a callback to be triggered when an event is added to the event queue.
-
sdlEventEnabled(
int type) → bool events - Query the state of processing events by type.
-
sdlFilterEvents(
Pointer< eventsNativeFunction< filter, Pointer<SdlEventFilter> >NativeType> userdata) → void - Run a specific filter function on the current event queue, removing any events for which the filter returns false.
-
sdlFlushEvent(
int type) → void events - Clear events of a specific type from the event queue.
-
sdlFlushEvents(
int minType, int maxType) → void events - Clear events of a range of types from the event queue.
-
sdlGetEventDescription(
Pointer< eventsSdlEvent> event, Pointer<Int8> buf, int buflen) → int - Generate a human-readable description of an event.
-
sdlGetEventFilter(
Pointer< eventsPointer< filter, Pointer<NativeFunction< >SdlEventFilter> >Pointer< userdata) → boolNativeType> > - Query the current event filter.
-
sdlGetWindowFromEvent(
Pointer< eventsSdlEvent> event) → Pointer<SdlWindow> - Get window associated with an event.
-
sdlHasEvent(
int type) → bool events - Check for the existence of a certain event type in the event queue.
-
sdlHasEvents(
int minType, int maxType) → bool events - Check for the existence of certain event types in the event queue.
-
sdlPeepEvents(
Pointer< eventsSdlEvent> events, int numevents, int action, int minType, int maxType) → int - Check the event queue for messages and optionally return them.
-
sdlPollEvent(
Pointer< eventsSdlEvent> event) → bool - Poll for currently pending events.
-
sdlPumpEvents(
) → void events - Pump the event loop, gathering events from the input devices.
-
sdlPushEvent(
Pointer< eventsSdlEvent> event) → bool - Add an event to the event queue.
-
sdlRegisterEvents(
int numevents) → int events - Allocate a set of user-defined events, and return the beginning event number for that set of events.
-
sdlRemoveEventWatch(
Pointer< eventsNativeFunction< filter, Pointer<SdlEventFilter> >NativeType> userdata) → void - Remove an event watch callback added with SDL_AddEventWatch().
-
sdlSetEventEnabled(
int type, bool enabled) → void events - Set the state of processing events by type.
-
sdlSetEventFilter(
Pointer< eventsNativeFunction< filter, Pointer<SdlEventFilter> >NativeType> userdata) → void - Set up a filter to process all events before they are added to the internal event queue.
-
sdlWaitEvent(
Pointer< eventsSdlEvent> event) → bool - Wait indefinitely for the next available event.
-
sdlWaitEventTimeout(
Pointer< eventsSdlEvent> event, int timeoutMs) → bool - Wait until the specified timeout (in milliseconds) for the next available event.