zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SDL_events.c File Reference
#include "SDL_config.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.

Macros

#define SDL_MAX_QUEUED_EVENTS   65535
 

Typedefs

typedef struct _SDL_EventEntry SDL_EventEntry
 
typedef struct SDL_EventWatcher SDL_EventWatcher
 
typedef struct _SDL_SysWMEntry SDL_SysWMEntry
 

Functions

static int SDL_AddEvent (SDL_Event *event)
 
void SDL_AddEventWatch (SDL_EventFilter filter, void *userdata)
 
static void SDL_CutEvent (SDL_EventEntry *entry)
 
void SDL_DelEventWatch (SDL_EventFilter filter, void *userdata)
 
Uint8 SDL_EventState (Uint32 type, int state)
 
void SDL_FilterEvents (SDL_EventFilter filter, void *userdata)
 
void SDL_FlushEvent (Uint32 type)
 
void SDL_FlushEvents (Uint32 minType, Uint32 maxType)
 
SDL_bool SDL_GetEventFilter (SDL_EventFilter *filter, void **userdata)
 
SDL_bool SDL_HasEvent (Uint32 type)
 
SDL_bool SDL_HasEvents (Uint32 minType, Uint32 maxType)
 
int SDL_PeepEvents (SDL_Event *events, int numevents, SDL_eventaction action, Uint32 minType, Uint32 maxType)
 
int SDL_PollEvent (SDL_Event *event)
 Polls for currently pending events. More...
 
void SDL_PumpEvents (void)
 
int SDL_PushEvent (SDL_Event *event)
 Add an event to the event queue. More...
 
Uint32 SDL_RegisterEvents (int numevents)
 
int SDL_SendAppEvent (SDL_EventType eventType)
 
int SDL_SendSysWMEvent (SDL_SysWMmsg *message)
 
void SDL_SetEventFilter (SDL_EventFilter filter, void *userdata)
 
static __inline__ SDL_bool SDL_ShouldPollJoystick ()
 
int SDL_StartEventLoop (void)
 
void SDL_StopEventLoop (void)
 
int SDL_WaitEvent (SDL_Event *event)
 Waits indefinitely for the next available event. More...
 
int SDL_WaitEventTimeout (SDL_Event *event, int timeout)
 Waits until the specified timeout (in milliseconds) for the next available event. More...
 

Variables

static SDL_DisabledEventBlock * SDL_disabled_events [256]
 
static SDL_EventWatcherSDL_event_watchers = NULL
 
SDL_EventFilter SDL_EventOK = NULL
 
voidSDL_EventOKParam
 
struct {
   volatile SDL_bool   active
 
   volatile int   count
 
   SDL_EventEntry *   free
 
   SDL_EventEntry *   head
 
   SDL_mutex *   lock
 
   SDL_EventEntry *   tail
 
   SDL_SysWMEntry *   wmmsg_free
 
   SDL_SysWMEntry *   wmmsg_used
 
SDL_EventQ = { NULL, SDL_TRUE }
 
static Uint32 SDL_userevents = SDL_USEREVENT
 

Macro Definition Documentation

#define SDL_MAX_QUEUED_EVENTS   65535

Definition at line 37 of file SDL_events.c.

Referenced by SDL_AddEvent().

Typedef Documentation

typedef struct _SDL_EventEntry SDL_EventEntry
typedef struct SDL_EventWatcher SDL_EventWatcher
typedef struct _SDL_SysWMEntry SDL_SysWMEntry

Function Documentation

static int SDL_AddEvent ( SDL_Event event)
static
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 504 of file SDL_events.c.

References SDL_event_watchers, and SDL_malloc().

Referenced by SDL_CreateRenderer(), and SDL_GameControllerInit().

static void SDL_CutEvent ( SDL_EventEntry entry)
static

Definition at line 239 of file SDL_events.c.

References NULL, 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 521 of file SDL_events.c.

References NULL, and SDL_free().

Referenced by SDL_DestroyRenderer(), and SDL_GameControllerQuit().

Uint8 SDL_EventState ( Uint32  type,
int  state 
)

This function allows you to set the state of processing certain events.

  • If state is set to SDL_IGNORE, that event will be automatically dropped from the event queue and will not event be filtered.
  • If state is set to SDL_ENABLE, that event will be processed normally.
  • If state is set to SDL_QUERY, SDL_EventState() will return the current processing state of the specified event.

Definition at line 555 of file SDL_events.c.

References cordic::hi, cordic::lo, SDL_calloc(), SDL_DISABLE, SDL_disabled_events, SDL_ENABLE, and SDL_FlushEvent().

Referenced by SDL_GameControllerEventState(), SDL_JoystickEventState(), SDL_SetKeyboardFocus(), SDL_StartEventLoop(), SDL_StartTextInput(), and SDL_StopTextInput().

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 540 of file SDL_events.c.

References SDL_CutEvent(), SDL_EventQ, SDL_LockMutex(), and SDL_UnlockMutex().

Referenced by SDL_SendWindowEvent().

void SDL_FlushEvent ( Uint32  type)

This function clears events from the event queue

Definition at line 358 of file SDL_events.c.

References SDL_FlushEvents().

Referenced by SDL_EventState(), and SDL_SetRelativeMouseMode().

void SDL_FlushEvents ( Uint32  minType,
Uint32  maxType 
)
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 491 of file SDL_events.c.

References SDL_EventOK, SDL_EventOKParam, SDL_FALSE, and SDL_TRUE.

SDL_bool SDL_HasEvent ( Uint32  type)

Checks to see if certain event types are in the event queue.

Definition at line 346 of file SDL_events.c.

References NULL, SDL_PEEKEVENT, and SDL_PeepEvents().

SDL_bool SDL_HasEvents ( Uint32  minType,
Uint32  maxType 
)

Definition at line 352 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.

Returns
The number of events actually stored, or -1 if there was an error.

This function is thread-safe.

Definition at line 265 of file SDL_events.c.

References i, SDL_SysWMmsg::msg, SDL_SysWMEvent::msg, NULL, SDL_AddEvent(), SDL_ADDEVENT, SDL_CutEvent(), SDL_EventQ, SDL_GETEVENT, SDL_LockMutex(), SDL_malloc(), SDL_PEEKEVENT, SDL_SetError(), SDL_SYSWMEVENT, SDL_UnlockMutex(), and SDL_Event::syswm.

Referenced by SDL_HasEvent(), SDL_HasEvents(), SDL_PushEvent(), and SDL_WaitEventTimeout().

int SDL_PollEvent ( SDL_Event event)

Polls for currently pending events.

Returns
1 if there are any pending events, or 0 if there are none available.
Parameters
eventIf not NULL, the next event is removed from the queue and stored in that area.

Definition at line 415 of file SDL_events.c.

References SDL_WaitEventTimeout().

Referenced by Zeni::Game::run().

void SDL_PumpEvents ( void  )

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 396 of file SDL_events.c.

References _this, SDL_VideoDevice::PumpEvents, SDL_GetVideoDevice(), SDL_JoystickUpdate(), and SDL_ShouldPollJoystick().

Referenced by SDL_FlushEvents(), and SDL_WaitEventTimeout().

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 596 of file SDL_events.c.

References SDL_LASTEVENT, and SDL_userevents.

int SDL_SendAppEvent ( SDL_EventType  eventType)

Definition at line 610 of file SDL_events.c.

References SDL_ENABLE, SDL_GetEventState, and SDL_PushEvent().

Referenced by SDL_SendQuit().

int SDL_SendSysWMEvent ( SDL_SysWMmsg message)

Definition at line 624 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:

* int SDL_EventFilter(void *userdata, SDL_Event * event);
*

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.

Warning
Be very careful of what you do in the event filter function, as it may run in a different thread!

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 481 of file SDL_events.c.

References NULL, SDL_EventOK, SDL_EventOKParam, SDL_FIRSTEVENT, SDL_FlushEvents(), and SDL_LASTEVENT.

static __inline__ SDL_bool SDL_ShouldPollJoystick ( )
static
int SDL_StartEventLoop ( void  )
int SDL_WaitEvent ( SDL_Event event)

Waits indefinitely for the next available event.

Returns
1, or 0 if there was an error while waiting for events.
Parameters
eventIf not NULL, the next event is removed from the queue and stored in that area.

Definition at line 421 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.

Returns
1, or 0 if there was an error while waiting for events.
Parameters
eventIf not NULL, the next event is removed from the queue and stored in that area.
timeoutThe timeout (in milliseconds) to wait for next event.

Definition at line 427 of file SDL_events.c.

References SDL_Delay(), SDL_FIRSTEVENT, SDL_GETEVENT, SDL_GetTicks(), SDL_LASTEVENT, SDL_PeepEvents(), and SDL_PumpEvents().

Referenced by SDL_PollEvent(), and SDL_WaitEvent().

Variable Documentation

volatile SDL_bool active

Definition at line 76 of file SDL_events.c.

Referenced by HandleClient(), HandleServer(), HandleServerData(), and SendBuf().

volatile int count

Definition at line 77 of file SDL_events.c.

Definition at line 80 of file SDL_events.c.

Referenced by al_free(), alc_alsa_deinit(), alc_alsa_probe(), alc_cleanup(), alcCreateContext(), alcDSoundDeinit(), alcDSoundProbe(), alcGetString(), alcMMDevApiDeinit(), alcWinMMDeinit(), alDeleteBuffers(), alDeleteEffects(), alDeleteFilters(), alDeleteSources(), alGenBuffers(), alGenEffects(), alGenFilters(), allocate_buffer_list(), alsa_capture_samples(), alsa_close_capture(), alsa_close_playback(), alsa_open_capture(), alsa_open_playback(), alsa_start_playback(), alsa_stop_playback(), alSourceQueueBuffers(), alSourceUnqueueBuffers(), build_tree_from_lengths(), build_tree_from_lengths0(), ca_close_capture(), ca_close_playback(), ca_open_capture(), ca_open_playback(), closeAVFile(), ClosePlayerFile(), decode_edid(), DedicatedDestroy(), DeletePlayer(), destroy_buffer_list(), DestroyArray(), DestroyRingBuffer(), SDL_BWin::DirectConnected(), DSoundCloseCapture(), DSoundClosePlayback(), DSoundOpenCapture(), DSoundOpenPlayback(), EchoDestroy(), face_array_write(), free_node_and_childs(), FreeALConfig(), FreeContext(), FreeDevice(), FreeHrtfs(), getAVAudioStream(), gz_error(), gz_head(), gz_init(), gz_open(), gzclose_r(), gzclose_w(), gzdopen(), kfdata_read(), lib3ds_camera_free(), lib3ds_file_free(), lib3ds_file_open(), lib3ds_io_cleanup(), lib3ds_light_free(), lib3ds_material_free(), lib3ds_mesh_calculate_vertex_normals(), lib3ds_mesh_free(), lib3ds_track_free(), LoadConfigFromFile(), LoadHrtf00(), LoadHrtf01(), LoadSound(), main(), MMDevApiClosePlayback(), MMDevApiMsgProc(), MMDevApiOpenPlayback(), ModulatorDestroy(), NoneDestroy(), null_close_playback(), openAVCustom(), openAVData(), openAVFile(), opensl_close_playback(), opensl_open_playback(), opensl_start_playback(), opensl_stop_playback(), oss_close_capture(), oss_close_playback(), oss_open_capture(), oss_open_playback(), oss_start_playback(), oss_stop_playback(), pa_close_capture(), pa_close_playback(), pa_open_capture(), pa_open_playback(), png_destroy_struct_2(), png_free_default(), ppfree(), ProbeCaptureDevices(), ProbeList(), ProbePlaybackDevices(), ProcessSources(), PSPAUD_CloseDevice(), PSPAUD_OpenDevice(), ReleaseALBuffers(), ReleaseALEffects(), ReleaseALFilters(), ReleaseALSources(), ResetUIntMap(), ReverbDestroy(), SDL_CreateSemaphore(), SDL_DestroySemaphore(), SDLNet_AllocSocketSet(), SDLNet_FreePacket(), SDLNet_FreePacketV(), SDLNet_FreeSocketSet(), SDLNet_GetLocalAddresses(), SDLNet_ResizePacket(), SDLNet_TCP_Close(), SDLNet_UDP_Close(), SetSourceiv(), SetSpeakerArrangement(), sndio_close_playback(), sndio_open_playback(), sndio_start_playback(), sndio_stop_playback(), solaris_close_playback(), solaris_open_playback(), solaris_start_playback(), solaris_stop_playback(), StartThread(), StopThread(), ThunkExit(), UpdateDeviceParams(), vqgen_iterate(), wave_close_playback(), wave_open_playback(), wave_start_playback(), wave_stop_playback(), WinMMCloseCapture(), WinMMClosePlayback(), WinMMOpenCapture(), WinMMOpenPlayback(), WinMMStopPlayback(), yyfree(), zcfree(), and SDL_BWin::~SDL_BWin().

SDL_mutex* lock

Definition at line 75 of file SDL_events.c.

Referenced by SDL_SYS_GetTLSData().

SDL_DisabledEventBlock* SDL_disabled_events[256]
static

Definition at line 55 of file SDL_events.c.

Referenced by SDL_EventState(), SDL_ShouldPollJoystick(), and SDL_StopEventLoop().

SDL_EventWatcher* SDL_event_watchers = NULL
static

Definition at line 49 of file SDL_events.c.

Referenced by SDL_AddEventWatch(), and SDL_StopEventLoop().

SDL_EventFilter SDL_EventOK = NULL
void* SDL_EventOKParam

Definition at line 41 of file SDL_events.c.

Referenced by SDL_GetEventFilter(), SDL_PushEvent(), and SDL_SetEventFilter().

Uint32 SDL_userevents = SDL_USEREVENT
static

Definition at line 56 of file SDL_events.c.

Referenced by SDL_RegisterEvents().

Definition at line 79 of file SDL_events.c.

SDL_SysWMEntry* wmmsg_free

Definition at line 82 of file SDL_events.c.

SDL_SysWMEntry* wmmsg_used

Definition at line 81 of file SDL_events.c.