SDL
2.0
|
#include "../SDL_internal.h"
#include "SDL.h"
#include "SDL_events.h"
#include "SDL_thread.h"
#include "SDL_events_c.h"
#include "../timer/SDL_timer_c.h"
#include "../joystick/SDL_joystick_c.h"
#include "../video/SDL_sysvideo.h"
#include "SDL_syswm.h"
Go to the source code of this file.
Data Structures | |
struct | SDL_EventWatcher |
struct | SDL_DisabledEventBlock |
struct | SDL_EventEntry |
struct | SDL_SysWMEntry |
Macros | |
#define | SDL_MAX_QUEUED_EVENTS 65535 |
Variables | |
static SDL_mutex * | SDL_event_watchers_lock |
static SDL_EventWatcher | SDL_EventOK |
static SDL_EventWatcher * | SDL_event_watchers = NULL |
static int | SDL_event_watchers_count = 0 |
static SDL_bool | SDL_event_watchers_dispatching = SDL_FALSE |
static SDL_bool | SDL_event_watchers_removed = SDL_FALSE |
static SDL_DisabledEventBlock * | SDL_disabled_events [256] |
static Uint32 | SDL_userevents = SDL_USEREVENT |
struct { | |
SDL_mutex * lock | |
SDL_atomic_t active | |
SDL_atomic_t count | |
int max_events_seen | |
SDL_EventEntry * head | |
SDL_EventEntry * tail | |
SDL_EventEntry * free | |
SDL_SysWMEntry * wmmsg_used | |
SDL_SysWMEntry * wmmsg_free | |
} | SDL_EventQ = { NULL, { 1 }, { 0 }, 0, NULL, NULL, NULL, NULL, NULL } |
#define SDL_MAX_QUEUED_EVENTS 65535 |
Definition at line 39 of file SDL_events.c.
Referenced by SDL_AddEvent().
|
static |
Definition at line 429 of file SDL_events.c.
References SDL_EventEntry::event, SDL_EventEntry::msg, SDL_SysWMmsg::msg, SDL_SysWMEvent::msg, SDL_EventEntry::next, NULL, SDL_EventEntry::prev, SDL_assert, SDL_AtomicAdd, SDL_AtomicGet, SDL_EventQ, SDL_malloc, SDL_MAX_QUEUED_EVENTS, SDL_SetError, SDL_SYSWMEVENT, SDL_Event::syswm, and SDL_Event::type.
Referenced by SDL_PeepEvents().
void SDL_AddEventWatch | ( | SDL_EventFilter | filter, |
void * | userdata | ||
) |
Add a function which is called when an event is added to the queue.
Definition at line 796 of file SDL_events.c.
References SDL_EventWatcher::callback, SDL_EventWatcher::removed, SDL_event_watchers_count, SDL_FALSE, SDL_LockMutex, SDL_realloc, SDL_UnlockMutex, and SDL_EventWatcher::userdata.
|
static |
Definition at line 483 of file SDL_events.c.
References SDL_EventEntry::next, NULL, SDL_EventEntry::prev, SDL_assert, SDL_AtomicAdd, SDL_AtomicGet, and SDL_EventQ.
Referenced by SDL_FilterEvents(), SDL_FlushEvents(), and SDL_PeepEvents().
void SDL_DelEventWatch | ( | SDL_EventFilter | filter, |
void * | userdata | ||
) |
Remove an event watch function added with SDL_AddEventWatch()
Definition at line 820 of file SDL_events.c.
References SDL_EventWatcher::callback, i, SDL_EventWatcher::removed, SDL_event_watchers_count, SDL_event_watchers_dispatching, SDL_event_watchers_removed, SDL_LockMutex, SDL_memmove, SDL_TRUE, and SDL_UnlockMutex.
This function allows you to set the state of processing certain events.
state
is set to SDL_IGNORE, that event will be automatically dropped from the event queue and will not be filtered.state
is set to SDL_ENABLE, that event will be processed normally.state
is set to SDL_QUERY, SDL_EventState() will return the current processing state of the specified event. Definition at line 864 of file SDL_events.c.
References SDL_DisabledEventBlock::bits, SDL_calloc, SDL_DISABLE, SDL_ENABLE, and SDL_FlushEvent().
Referenced by SDL_StartEventLoop().
void SDL_FilterEvents | ( | SDL_EventFilter | filter, |
void * | userdata | ||
) |
Run the filter function on the current event queue, removing any events for which the filter returns 0.
Definition at line 847 of file SDL_events.c.
References SDL_EventEntry::event, SDL_EventEntry::next, SDL_CutEvent(), SDL_EventQ, SDL_LockMutex, and SDL_UnlockMutex.
This function clears events from the event queue This function only affects currently queued events. If you want to make sure that all pending OS events are flushed, you can call SDL_PumpEvents() on the main thread immediately before the flush call.
Definition at line 599 of file SDL_events.c.
References SDL_FlushEvents().
Referenced by SDL_EventState().
Definition at line 605 of file SDL_events.c.
References SDL_EventEntry::event, SDL_EventEntry::next, SDL_AtomicGet, SDL_CutEvent(), SDL_EventQ, SDL_LockMutex, SDL_PumpEvents(), SDL_UnlockMutex, and SDL_Event::type.
Referenced by SDL_FlushEvent(), and SDL_SetEventFilter().
SDL_bool SDL_GetEventFilter | ( | SDL_EventFilter * | filter, |
void ** | userdata | ||
) |
Return the current event filter - can be used to "chain" filters. If there is no event filter set, this function returns SDL_FALSE.
Definition at line 772 of file SDL_events.c.
References SDL_EventWatcher::callback, SDL_EventOK, SDL_FALSE, SDL_LockMutex, SDL_TRUE, SDL_UnlockMutex, SDL_zero, and SDL_EventWatcher::userdata.
Checks to see if certain event types are in the event queue.
Definition at line 587 of file SDL_events.c.
References NULL, SDL_PEEKEVENT, and SDL_PeepEvents().
Definition at line 593 of file SDL_events.c.
References NULL, SDL_PEEKEVENT, and SDL_PeepEvents().
int SDL_PeepEvents | ( | SDL_Event * | events, |
int | numevents, | ||
SDL_eventaction | action, | ||
Uint32 | minType, | ||
Uint32 | maxType | ||
) |
Checks the event queue for messages and optionally returns them.
If action
is SDL_ADDEVENT, up to numevents
events will be added to the back of the event queue.
If action
is SDL_PEEKEVENT, up to numevents
events at the front of the event queue, within the specified minimum and maximum type, will be returned and will not be removed from the queue.
If action
is SDL_GETEVENT, up to numevents
events at the front of the event queue, within the specified minimum and maximum type, will be returned and will be removed from the queue.
This function is thread-safe.
Definition at line 509 of file SDL_events.c.
References SDL_EventEntry::event, i, SDL_SysWMEntry::msg, SDL_SysWMEvent::msg, SDL_EventEntry::next, SDL_SysWMEntry::next, NULL, SDL_AddEvent(), SDL_ADDEVENT, SDL_AtomicGet, SDL_CutEvent(), SDL_EventQ, SDL_GETEVENT, SDL_LockMutex, SDL_malloc, SDL_SetError, SDL_SYSWMEVENT, SDL_UnlockMutex, SDL_Event::syswm, and SDL_Event::type.
Referenced by SDL_HasEvent(), SDL_HasEvents(), SDL_PushEvent(), and SDL_WaitEventTimeout().
int SDL_PollEvent | ( | SDL_Event * | event | ) |
Polls for currently pending events.
event | If not NULL, the next event is removed from the queue and stored in that area. |
Definition at line 660 of file SDL_events.c.
References SDL_WaitEventTimeout().
Pumps the event loop, gathering events from the input devices.
This function updates the event queue and internal input device state.
This should only be run in the thread that sets the video mode.
Definition at line 639 of file SDL_events.c.
References _this, SDL_VideoDevice::PumpEvents, SDL_GetVideoDevice(), SDL_JOYAXISMOTION, SDL_JoystickEventState, SDL_JoystickUpdate, SDL_QUERY, and SDL_SendPendingQuit().
Referenced by SDL_FlushEvents(), and SDL_WaitEventTimeout().
int SDL_PushEvent | ( | SDL_Event * | event | ) |
Add an event to the event queue.
Definition at line 703 of file SDL_events.c.
References SDL_EventWatcher::callback, i, SDL_EventWatcher::removed, SDL_ADDEVENT, SDL_event_watchers_count, SDL_event_watchers_dispatching, SDL_event_watchers_removed, SDL_FALSE, SDL_GestureProcessEvent(), SDL_GetTicks(), SDL_LockMutex, SDL_memmove, SDL_PeepEvents(), SDL_TRUE, SDL_UnlockMutex, and SDL_EventWatcher::userdata.
Referenced by SDL_SendAppEvent(), and SDL_SendSysWMEvent().
Uint32 SDL_RegisterEvents | ( | int | numevents | ) |
This function allocates a set of user-defined events, and returns the beginning event number for that set of events.
If there aren't enough user-defined events left, this function returns (Uint32)-1
Definition at line 905 of file SDL_events.c.
References SDL_LASTEVENT, and SDL_userevents.
int SDL_SendAppEvent | ( | SDL_EventType | eventType | ) |
Definition at line 919 of file SDL_events.c.
References SDL_ENABLE, SDL_GetEventState, and SDL_PushEvent().
Referenced by IsSDLWindowEventPending(), SDL_OnApplicationDidBecomeActive(), SDL_OnApplicationDidEnterBackground(), SDL_OnApplicationDidReceiveMemoryWarning(), SDL_OnApplicationWillEnterForeground(), SDL_OnApplicationWillResignActive(), SDL_OnApplicationWillTerminate(), SDL_SendKeymapChangedEvent(), and SDL_SendQuit().
int SDL_SendKeymapChangedEvent | ( | void | ) |
Definition at line 950 of file SDL_events.c.
References SDL_KEYMAPCHANGED, and SDL_SendAppEvent().
int SDL_SendSysWMEvent | ( | SDL_SysWMmsg * | message | ) |
Definition at line 933 of file SDL_events.c.
References SDL_ENABLE, SDL_GetEventState, SDL_memset, SDL_PushEvent(), and SDL_SYSWMEVENT.
void SDL_SetEventFilter | ( | SDL_EventFilter | filter, |
void * | userdata | ||
) |
Sets up a filter to process all events before they change internal state and are posted to the internal event queue.
The filter is prototyped as:
If the filter returns 1, then the event will be added to the internal queue. If it returns 0, then the event will be dropped from the queue, but the internal state will still be updated. This allows selective filtering of dynamically arriving events.
There is one caveat when dealing with the SDL_QuitEvent event type. The event filter is only called when the window manager desires to close the application window. If the event filter returns 1, then the window will be closed, otherwise the window will remain open if possible.
If the quit event is generated by an interrupt signal, it will bypass the internal queue and be delivered to the application at the next event poll.
Definition at line 757 of file SDL_events.c.
References SDL_EventWatcher::callback, SDL_FIRSTEVENT, SDL_FlushEvents(), SDL_LASTEVENT, SDL_LockMutex, SDL_UnlockMutex, and SDL_EventWatcher::userdata.
int SDL_StartEventLoop | ( | void | ) |
Definition at line 391 of file SDL_events.c.
References NULL, SDL_AtomicSet, SDL_CreateMutex, SDL_DISABLE, SDL_EventQ, SDL_EventState(), SDL_SYSWMEVENT, SDL_TEXTEDITING, and SDL_TEXTINPUT.
Referenced by SDL_InitSubSystem().
Definition at line 317 of file SDL_events.c.
References i, SDL_EventEntry::next, SDL_SysWMEntry::next, NULL, SDL_arraysize, SDL_atoi, SDL_AtomicSet, SDL_DestroyMutex, SDL_event_watchers_count, SDL_EventQ, SDL_free, SDL_GetHint, SDL_LockMutex, SDL_Log, SDL_UnlockMutex, and SDL_zero.
Referenced by SDL_QuitSubSystem().
int SDL_WaitEvent | ( | SDL_Event * | event | ) |
Waits indefinitely for the next available event.
event | If not NULL, the next event is removed from the queue and stored in that area. |
Definition at line 666 of file SDL_events.c.
References SDL_WaitEventTimeout().
int SDL_WaitEventTimeout | ( | SDL_Event * | event, |
int | timeout | ||
) |
Waits until the specified timeout (in milliseconds) for the next available event.
event | If not NULL, the next event is removed from the queue and stored in that area. |
timeout | The timeout (in milliseconds) to wait for next event. |
Definition at line 672 of file SDL_events.c.
References SDL_Delay, SDL_FIRSTEVENT, SDL_GETEVENT, SDL_GetTicks(), SDL_LASTEVENT, SDL_PeepEvents(), SDL_PumpEvents(), and SDL_TICKS_PASSED.
Referenced by SDL_PollEvent(), and SDL_WaitEvent().
SDL_atomic_t active |
Definition at line 79 of file SDL_events.c.
Definition at line 80 of file SDL_events.c.
SDL_EventEntry* free |
Definition at line 84 of file SDL_events.c.
Referenced by decode_edid(), SDL_BWin::DirectConnected(), glGetConfig(), main(), SDL_PromptAssertion(), and SDL_BWin::~ SDL_BWin().
SDL_EventEntry* head |
Definition at line 82 of file SDL_events.c.
Referenced by change_mparam(), and mmap_alloc().
SDL_mutex* lock |
Definition at line 78 of file SDL_events.c.
Referenced by RunBasicTest(), SDL_AtomicTryLock(), SDL_SYS_GetTLSData(), and SDL_ThreadID().
int max_events_seen |
Definition at line 81 of file SDL_events.c.
|
static |
Definition at line 58 of file SDL_events.c.
|
static |
Definition at line 49 of file SDL_events.c.
|
static |
Definition at line 50 of file SDL_events.c.
Referenced by SDL_AddEventWatch(), SDL_DelEventWatch(), SDL_PushEvent(), and SDL_StopEventLoop().
Definition at line 51 of file SDL_events.c.
Referenced by SDL_DelEventWatch(), and SDL_PushEvent().
|
static |
Definition at line 47 of file SDL_events.c.
Definition at line 52 of file SDL_events.c.
Referenced by SDL_DelEventWatch(), and SDL_PushEvent().
|
static |
Definition at line 48 of file SDL_events.c.
Referenced by SDL_GetEventFilter().
struct { ... } SDL_EventQ |
Referenced by SDL_AddEvent(), SDL_CutEvent(), SDL_FilterEvents(), SDL_FlushEvents(), SDL_PeepEvents(), SDL_StartEventLoop(), and SDL_StopEventLoop().
|
static |
Definition at line 59 of file SDL_events.c.
Referenced by SDL_RegisterEvents().
SDL_EventEntry* tail |
Definition at line 83 of file SDL_events.c.
SDL_SysWMEntry* wmmsg_free |
Definition at line 86 of file SDL_events.c.
SDL_SysWMEntry* wmmsg_used |
Definition at line 85 of file SDL_events.c.