changed event hooking, event thread now safe
This commit is contained in:
parent
6bec0bc602
commit
9f0b7ec75e
@ -13,7 +13,7 @@
|
|||||||
\brief Definition file for core ZEngine class.
|
\brief Definition file for core ZEngine class.
|
||||||
|
|
||||||
ZEngine Game Engine core Engine definition.
|
ZEngine Game Engine core Engine definition.
|
||||||
<br>$Id: ZE_ZEngine.h,v 1.37 2003/06/07 00:34:43 cozman Exp $<br>
|
<br>$Id: ZE_ZEngine.h,v 1.38 2003/06/09 02:46:22 cozman Exp $<br>
|
||||||
\author James Turk
|
\author James Turk
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@ -107,6 +107,8 @@ class ZEngine
|
|||||||
bool mLogAllErrors;
|
bool mLogAllErrors;
|
||||||
//! C-style FILE* for error logging.
|
//! C-style FILE* for error logging.
|
||||||
FILE *mErrlog;
|
FILE *mErrlog;
|
||||||
|
//! Event filter, for users who need to process their own events.
|
||||||
|
SDL_EventFilter mEventFilter;
|
||||||
|
|
||||||
#ifdef USE_SDL_MIXER
|
#ifdef USE_SDL_MIXER
|
||||||
//! Sound Bitrate
|
//! Sound Bitrate
|
||||||
@ -477,9 +479,11 @@ class ZEngine
|
|||||||
/*!
|
/*!
|
||||||
\brief Add a SDL Event Filter for user processing of events.
|
\brief Add a SDL Event Filter for user processing of events.
|
||||||
|
|
||||||
This is only needed when you need tight control with ZEngine. The parameter is simply passed to SDL_SetEventFilter,
|
This is only needed when you need tight control with ZEngine. The parameter processed as if it were passed to
|
||||||
generally only those with a good amount of SDL experience should use this function or ZEngine's internal message
|
SDL_SetEventFilter, generally only those with a good amount of SDL experience should use this function or
|
||||||
state could be corrupted. For more information on SDL_SetEventFilter see http://sdldoc.csn.ul.ie/sdlseteventfilter.php.
|
ZEngine's internal message state could be corrupted. For more information on SDL_SetEventFilter see
|
||||||
|
http://sdldoc.csn.ul.ie/sdlseteventfilter.php. (FYI: The parameter is now actually processed in check events,
|
||||||
|
not passed to the SDL function, this is done because of problems with singletons and event threading.)
|
||||||
\since 0.8.2
|
\since 0.8.2
|
||||||
\param filter An SDL_EventFilter (A function that takes a const SDL_Event* and returns 0 if the event should be removed from
|
\param filter An SDL_EventFilter (A function that takes a const SDL_Event* and returns 0 if the event should be removed from
|
||||||
the event queue and 1 otherwise.)
|
the event queue and 1 otherwise.)
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
\brief Central source file for ZEngine.
|
\brief Central source file for ZEngine.
|
||||||
|
|
||||||
Actual implementation of ZEngine singleton class, the core of ZEngine.
|
Actual implementation of ZEngine singleton class, the core of ZEngine.
|
||||||
<br>$Id: ZE_ZEngine.cpp,v 1.42 2003/06/06 18:55:57 cozman Exp $<br>
|
<br>$Id: ZE_ZEngine.cpp,v 1.43 2003/06/09 02:46:22 cozman Exp $<br>
|
||||||
\author James Turk
|
\author James Turk
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@ -41,6 +41,7 @@ ZEngine::ZEngine()
|
|||||||
|
|
||||||
mScreen = NULL;
|
mScreen = NULL;
|
||||||
|
|
||||||
|
mEventFilter = NULL;
|
||||||
mActive = mQuit = false;
|
mActive = mQuit = false;
|
||||||
mKeyIsPressed = NULL;
|
mKeyIsPressed = NULL;
|
||||||
mMouseX = mMouseY = 0;
|
mMouseX = mMouseY = 0;
|
||||||
@ -499,6 +500,8 @@ void ZEngine::CheckEvents()
|
|||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
|
|
||||||
while(SDL_PollEvent(&event))
|
while(SDL_PollEvent(&event))
|
||||||
|
{
|
||||||
|
if(!mEventFilter || mEventFilter(&event)) //if the filter returns 0 it is removing the event, it will not be processed
|
||||||
{
|
{
|
||||||
switch(event.type)
|
switch(event.type)
|
||||||
{
|
{
|
||||||
@ -540,6 +543,7 @@ void ZEngine::CheckEvents()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mKeyIsPressed = SDL_GetKeyState(NULL); //recommended but not needed (says Sam)
|
mKeyIsPressed = SDL_GetKeyState(NULL); //recommended but not needed (says Sam)
|
||||||
|
|
||||||
@ -553,7 +557,7 @@ void ZEngine::CheckEvents()
|
|||||||
|
|
||||||
void ZEngine::SetEventFilter(SDL_EventFilter filter)
|
void ZEngine::SetEventFilter(SDL_EventFilter filter)
|
||||||
{
|
{
|
||||||
SDL_SetEventFilter(filter);
|
mEventFilter = filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_PHYSFS
|
#ifdef USE_PHYSFS
|
||||||
|
Loading…
Reference in New Issue
Block a user