40 #ifndef _eventmanager_cpp
41 #define _eventmanager_cpp
49 #include "eventmanager.h"
50 #include "eventbase.h"
51 #include "eventgamewindow.h"
52 #include "eventquit.h"
53 #include "eventuserinput.h"
54 #include "Input/metacode.h"
55 #include "Input/inputmanager.h"
75 TargetManager(Target) { }
86 Log <<
"Getting Events from OS." << std::endl;
107 int MezzSDLFilter(
void *userdata, SDL_Event *event )
110 static bool DroppedQuit=
false;
114 if ( event->type == SDL_QUIT )
144 PollingKeyPress = Polling|Keypress
171 Which->second = (
PollingType)(Which->second | _PollingCheck);
182 static_cast<Mezzanine::Input::InputCode>(OneCode),
183 static_cast<Mezzanine::Internal::EventManagerInternalData::PollingType>(_PollingCheck)
200 for ( std::vector<Input::MetaCode>::const_iterator Iter=Transport.begin(); Iter!=Transport.end(); ++Iter)
215 if(Reduce->second == _PollingCheck)
218 { Reduce->second = (
PollingType)(Reduce->second & (~_PollingCheck)); }
245 for ( std::vector<Input::MetaCode>::iterator Iter=Transport.begin(); Iter!=Transport.end(); ++Iter)
270 template<> EventManager* Singleton<EventManager>::SingletonPtr = NULL;
276 UInt32 InitSDLSystems = SDL_WasInit(0);
277 if( (SDL_INIT_JOYSTICK & InitSDLSystems) == 0 )
279 if( SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE) < 0 )
282 if( !(SDL_INIT_GAMECONTROLLER | InitSDLSystems) )
284 if( SDL_Init(SDL_INIT_GAMECONTROLLER | SDL_INIT_NOPARACHUTE) < 0 )
293 UInt32 InitSDLSystems = SDL_WasInit(0);
294 if( (SDL_INIT_JOYSTICK & InitSDLSystems) == 0 )
296 if( SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE) < 0 )
299 if( !(SDL_INIT_GAMECONTROLLER | InitSDLSystems) )
301 if( SDL_Init(SDL_INIT_GAMECONTROLLER | SDL_INIT_NOPARACHUTE) < 0 )
316 for(std::list<EventBase*>::iterator Iter = _Data->
EventQ.begin(); Iter!=_Data->
EventQ.end(); Iter++)
323 UInt32 InitSDLSystems = SDL_WasInit(0);
324 if( SDL_INIT_JOYSTICK | InitSDLSystems )
326 SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
328 if( SDL_INIT_GAMECONTROLLER | InitSDLSystems )
330 SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER);
334 void EventManager::UpdateQuitEvents()
337 if(SDL_FALSE == SDL_GetEventFilter(0, 0))
339 SDL_SetEventFilter( Internal::MezzSDLFilter, 0);
341 if(4==Internal::MezzSDLFilter(0,0))
354 {
return _Data->
EventQ.size(); }
369 _Data->
EventQ.pop_front();
374 { _Data->
EventQ.pop_front(); }
377 { _Data->
EventQ.push_back(EventToAdd); }
381 for( std::list<EventBase*>::iterator EvIt = _Data->
EventQ.begin() ; EvIt != _Data->
EventQ.end() ; ++EvIt )
383 if(EventToRemove == (*EvIt))
385 _Data->
EventQ.erase(EvIt);
403 if(Internal::EventManagerInternalData::Keypress & Iter->second)
454 while(SDL_PollEvent(&FromSDLRaw))
456 switch(FromSDLRaw.type)
459 case SDL_MOUSEBUTTONUP:
case SDL_KEYUP:
case SDL_JOYBUTTONUP:
470 case SDL_MOUSEBUTTONDOWN:
case SDL_JOYBUTTONDOWN:
474 case SDL_MOUSEMOTION:
case SDL_JOYAXISMOTION:
case SDL_JOYHATMOTION:
case SDL_JOYBALLMOTION:
478 case SDL_WINDOWEVENT: {
522 _Data->
EventQ.push_back(FromSDLEvent);
577 for(std::list<EventBase*>::iterator Iter = _Data->
EventQ.begin(); Iter!=_Data->
EventQ.end(); ++Iter)
579 if((*Iter)->GetType()==SpecificType)
591 for(std::list<EventBase*>::iterator Iter = _Data->
EventQ.begin(); Iter!=_Data->
EventQ.end(); ++Iter)
593 if((*Iter)->GetType()==SpecificType)
596 _Data->
EventQ.erase(Iter);
605 for(std::list<EventBase*>::iterator Iter = _Data->
EventQ.begin(); Iter!=_Data->
EventQ.end(); ++Iter)
607 if((*Iter)->GetType()==SpecificType)
609 _Data->
EventQ.erase(Iter);
617 std::list<EventBase*>* TempList =
new std::list<EventBase*>;
619 for(std::list<EventBase*>::iterator Iter = _Data->
EventQ.begin(); Iter!=_Data->
EventQ.end(); ++Iter)
621 if((*Iter)->GetType()==SpecificType)
623 TempList->push_back(*Iter);
631 for( std::list<EventBase*>::iterator Iter = _Data->
EventQ.begin() ; Iter!=_Data->
EventQ.end() ; )
633 if((*Iter)->GetType()==SpecificType)
635 std::list<EventBase*>::iterator prev = Iter++;
636 this->_Data->
EventQ.erase(prev);
688 {
return ManagerBase::MT_EventManager; }
691 {
return "DefaultEventManager"; }
706 return "DefaultEventManager";
729 delete ToBeDestroyed;
739 stream <<
"<EventManager Version=\"1\">";
740 for(std::list<Mezzanine::EventBase*>::iterator Iter = Mgr._Data->
EventQ.begin(); Iter!=Mgr._Data->
EventQ.end(); ++Iter)
741 { stream << **Iter; }
743 { stream <<
"<ManualCheck Version=\"1\" PollingType=\"" << Iter->second <<
"\" InputCode=\"" << Iter->first <<
"\" />"; }
744 stream <<
"</EventManager>";
769 if(TagName.length()>6)