40 #ifndef _inputinputmanager_cpp
41 #define _inputinputmanager_cpp
43 #include "inputmanager.h"
44 #include "eventmanager.h"
45 #include "eventuserinput.h"
47 #include "Input/mouse.h"
48 #include "Input/keyboard.h"
49 #include "Input/controller.h"
56 template<> Input::InputManager* Singleton<Input::InputManager>::SingletonPtr = NULL;
68 typedef std::pair<Input::Controller*,SDL_Joystick*> ControllerPair;
69 typedef std::vector< ControllerPair > ControllerContainer;
70 typedef ControllerContainer::iterator ControllerIterator;
71 typedef ControllerContainer::const_iterator ConstControllerIterator;
74 ControllerContainer Controllers;
81 { this->Controllers.clear(); }
84 typedef InputManagerInternalData::ControllerPair InternalControlPair;
85 typedef InputManagerInternalData::ControllerIterator InternalControlIterator;
97 TargetManager(Target) { }
109 std::vector< Input::MetaCode > MouseCodes;
110 std::vector< Input::MetaCode > KeyboardCodes;
111 std::vector< std::vector< Input::MetaCode > > ControllerCodes;
114 std::vector< Input::MetaCode > GeneratedCodes;
121 while( !UserInput->empty() )
124 for(
Whole X = 0 ; X < CurrEvent->size() ; ++X )
129 MouseCodes.push_back( CurrCode );
131 KeyboardCodes.push_back( CurrCode );
133 ControllerCodes[ CurrCode.
GetDeviceIndex() ].push_back( CurrCode );
138 UserInput->pop_front();
148 this->
TargetManager->
IMID->Controllers.at(X).first->_Update( ControllerCodes.at(X) , GeneratedCodes );
154 if( !GeneratedCodes.empty() )
155 this->
TargetManager->
InputDeltas.insert(this->TargetManager->InputDeltas.end(),GeneratedCodes.begin(),GeneratedCodes.end());
166 SystemKeyboard(NULL),
168 DeviceUpdateWork(NULL),
169 ThreadResources(NULL)
171 UInt32 InitSDLSystems = SDL_WasInit(0);
172 if( (SDL_INIT_JOYSTICK & InitSDLSystems) == 0 )
174 if( SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE) < 0 )
177 if( !(SDL_INIT_GAMECONTROLLER | InitSDLSystems) )
179 if( SDL_Init(SDL_INIT_GAMECONTROLLER | SDL_INIT_NOPARACHUTE) < 0 )
194 SystemKeyboard(NULL),
196 DeviceUpdateWork(NULL),
197 ThreadResources(NULL)
199 UInt32 InitSDLSystems = SDL_WasInit(0);
200 if( (SDL_INIT_JOYSTICK & InitSDLSystems) == 0 )
202 if( SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE) < 0 )
205 if( !(SDL_INIT_GAMECONTROLLER | InitSDLSystems) )
207 if( SDL_Init(SDL_INIT_GAMECONTROLLER | SDL_INIT_NOPARACHUTE) < 0 )
245 return this->
IMID->Controllers.at(Index).first;
250 return this->
IMID->Controllers.size();
259 for( Count = 0 ; Count < SDL_NumJoysticks() ; ++Count )
261 SDL_Joystick* InternalControl = SDL_JoystickOpen(Count);
263 this->
IMID->Controllers.push_back( InternalControlPair(NewController,InternalControl) );
270 if( this->
IMID->Controllers.empty() )
273 for( InternalControlIterator ContIt = this->
IMID->Controllers.begin() ; ContIt != this->
IMID->Controllers.end() ; ++ContIt )
275 delete (*ContIt).first;
276 SDL_JoystickClose( (SDL_Joystick*)(*ContIt).second );
278 this->
IMID->Controllers.clear();
340 {
return ManagerBase::MT_InputManager; }
343 {
return "DefaultInputManager"; }
358 return "DefaultInputManager";
381 delete ToBeDestroyed;