SDL
2.0
|
#include "../SDL_internal.h"
#include "SDL.h"
#include "SDL_events.h"
#include "SDL_syswm.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"
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 | |
SDL_EventFilter | SDL_EventOK = NULL |
void * | SDL_EventOKParam |
static SDL_EventWatcher * | SDL_event_watchers = NULL |
static SDL_DisabledEventBlock * | SDL_disabled_events [256] |
static Uint32 | SDL_userevents = SDL_USEREVENT |
struct { | |
SDL_mutex * lock | |
volatile SDL_bool active | |
volatile int count | |
volatile int max_events_seen | |
SDL_EventEntry * head | |
SDL_EventEntry * tail | |
SDL_EventEntry * free | |
SDL_SysWMEntry * wmmsg_used | |
SDL_SysWMEntry * wmmsg_free | |
} | SDL_EventQ = { NULL, SDL_TRUE, 0, 0, NULL, NULL, NULL, NULL, NULL } |
#define SDL_MAX_QUEUED_EVENTS 65535 |
Definition at line 37 of file SDL_events.c.
Referenced by SDL_AddEvent().
|
static |
Definition at line 191 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_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 505 of file SDL_events.c.
References SDL_EventWatcher::callback, SDL_EventWatcher::next, NULL, SDL_malloc, tail, and SDL_EventWatcher::userdata.
|
static |
Definition at line 239 of file SDL_events.c.
References SDL_EventEntry::next, NULL, SDL_EventEntry::prev, SDL_assert, 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 533 of file SDL_events.c.
References SDL_EventWatcher::next, NULL, and SDL_free().
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 event 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 567 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 552 of file SDL_events.c.
References SDL_EventEntry::event, SDL_EventWatcher::next, 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 357 of file SDL_events.c.
References SDL_FlushEvents().
Referenced by SDL_EventState().
Definition at line 363 of file SDL_events.c.
References SDL_EventEntry::event, SDL_EventWatcher::next, SDL_EventEntry::next, 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 492 of file SDL_events.c.
References SDL_EventOK, SDL_EventOKParam, SDL_FALSE, and SDL_TRUE.
Checks to see if certain event types are in the event queue.
Definition at line 345 of file SDL_events.c.
References NULL, SDL_PEEKEVENT, and SDL_PeepEvents().
Definition at line 351 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 265 of file SDL_events.c.
References SDL_EventEntry::event, i, SDL_SysWMEntry::msg, SDL_SysWMEvent::msg, SDL_EventWatcher::next, SDL_EventEntry::next, SDL_SysWMEntry::next, NULL, SDL_AddEvent(), SDL_ADDEVENT, SDL_CutEvent(), SDL_EventQ, SDL_GETEVENT, SDL_LockMutex, SDL_malloc, SDL_PEEKEVENT, 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 416 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 395 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 458 of file SDL_events.c.
References SDL_EventWatcher::callback, SDL_EventWatcher::next, SDL_ADDEVENT, SDL_EventOK, SDL_EventOKParam, SDL_GestureProcessEvent(), SDL_GetTicks(), SDL_PeepEvents(), 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 608 of file SDL_events.c.
References SDL_LASTEVENT, and SDL_userevents.
int SDL_SendAppEvent | ( | SDL_EventType | eventType | ) |
Definition at line 622 of file SDL_events.c.
References SDL_ENABLE, SDL_GetEventState, and SDL_PushEvent().
Referenced by IsSDLWindowEventPending(), SDL_SendKeymapChangedEvent(), and SDL_SendQuit().
int SDL_SendKeymapChangedEvent | ( | void | ) |
Definition at line 653 of file SDL_events.c.
References SDL_KEYMAPCHANGED, and SDL_SendAppEvent().
int SDL_SendSysWMEvent | ( | SDL_SysWMmsg * | message | ) |
Definition at line 636 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 482 of file SDL_events.c.
References NULL, SDL_EventOK, SDL_EventOKParam, SDL_FIRSTEVENT, SDL_FlushEvents(), SDL_LASTEVENT, and SDL_EventWatcher::userdata.
int SDL_StartEventLoop | ( | void | ) |
Definition at line 160 of file SDL_events.c.
References NULL, SDL_CreateMutex, SDL_DISABLE, SDL_EventQ, SDL_EventState(), SDL_SYSWMEVENT, SDL_TEXTEDITING, SDL_TEXTINPUT, and SDL_TRUE.
Referenced by SDL_InitSubSystem().
Definition at line 90 of file SDL_events.c.
References i, SDL_EventWatcher::next, SDL_EventEntry::next, SDL_SysWMEntry::next, NULL, SDL_arraysize, SDL_atoi, SDL_DestroyMutex, SDL_event_watchers, SDL_EventOK, SDL_EventQ, SDL_FALSE, SDL_free(), SDL_GetHint, SDL_LockMutex, SDL_Log, and SDL_UnlockMutex.
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 422 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 428 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().
volatile SDL_bool active |
Definition at line 76 of file SDL_events.c.
volatile int count |
Definition at line 77 of file SDL_events.c.
SDL_EventEntry* free |
Definition at line 81 of file SDL_events.c.
Referenced by decode_edid(), SDL_BWin::DirectConnected(), main(), and SDL_BWin::~SDL_BWin().
SDL_EventEntry* head |
Definition at line 79 of file SDL_events.c.
Referenced by change_mparam(), and mmap_alloc().
SDL_mutex* lock |
Definition at line 75 of file SDL_events.c.
Referenced by RunBasicTest(), SDL_AtomicTryLock(), SDL_SYS_GetTLSData(), and SDL_ThreadID().
volatile int max_events_seen |
Definition at line 78 of file SDL_events.c.
|
static |
Definition at line 55 of file SDL_events.c.
|
static |
Definition at line 49 of file SDL_events.c.
Referenced by SDL_StopEventLoop().
SDL_EventFilter SDL_EventOK = NULL |
Definition at line 40 of file SDL_events.c.
Referenced by SDL_GetEventFilter(), SDL_PushEvent(), SDL_SetEventFilter(), SDL_StopEventLoop(), SDL_SYS_AddJoystickDevice(), and SDL_SYS_RemoveJoystickDevice().
void* SDL_EventOKParam |
Definition at line 41 of file SDL_events.c.
Referenced by SDL_GetEventFilter(), SDL_PushEvent(), SDL_SetEventFilter(), SDL_SYS_AddJoystickDevice(), and SDL_SYS_RemoveJoystickDevice().
struct { ... } SDL_EventQ |
Referenced by SDL_AddEvent(), SDL_CutEvent(), SDL_FilterEvents(), SDL_FlushEvents(), SDL_PeepEvents(), SDL_StartEventLoop(), and SDL_StopEventLoop().
|
static |
Definition at line 56 of file SDL_events.c.
Referenced by SDL_RegisterEvents().
SDL_EventEntry* tail |
Definition at line 80 of file SDL_events.c.
Referenced by SDL_AddEventWatch().
SDL_SysWMEntry* wmmsg_free |
Definition at line 83 of file SDL_events.c.
SDL_SysWMEntry* wmmsg_used |
Definition at line 82 of file SDL_events.c.