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());
168 SystemKeyboard(NULL),
170 DeviceUpdateWork(NULL),
171 ThreadResources(NULL)
173 UInt32 InitSDLSystems = SDL_WasInit(0);
174 if( (SDL_INIT_JOYSTICK & InitSDLSystems) == 0 )
176 if( SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE) < 0 )
179 if( !(SDL_INIT_GAMECONTROLLER | InitSDLSystems) )
181 if( SDL_Init(SDL_INIT_GAMECONTROLLER | SDL_INIT_NOPARACHUTE) < 0 )
196 SystemKeyboard(NULL),
198 DeviceUpdateWork(NULL),
199 ThreadResources(NULL)
201 UInt32 InitSDLSystems = SDL_WasInit(0);
202 if( (SDL_INIT_JOYSTICK & InitSDLSystems) == 0 )
204 if( SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE) < 0 )
207 if( !(SDL_INIT_GAMECONTROLLER | InitSDLSystems) )
209 if( SDL_Init(SDL_INIT_GAMECONTROLLER | SDL_INIT_NOPARACHUTE) < 0 )
247 return this->
IMID->Controllers.at(Index).first;
252 return this->
IMID->Controllers.size();
261 for( Count = 0 ; Count < SDL_NumJoysticks() ; ++Count )
263 SDL_Joystick* InternalControl = SDL_JoystickOpen(Count);
265 this->
IMID->Controllers.push_back( InternalControlPair(NewController,InternalControl) );
272 if( this->
IMID->Controllers.empty() )
275 for( InternalControlIterator ContIt = this->
IMID->Controllers.begin() ; ContIt != this->
IMID->Controllers.end() ; ++ContIt )
277 delete (*ContIt).first;
278 SDL_JoystickClose( (SDL_Joystick*)(*ContIt).second );
280 this->
IMID->Controllers.clear();
379 {
delete ToBeDestroyed; }
int32_t Int32
An 32-bit integer.
virtual void AddDependency(iWorkUnit *NewDependency)
Force this WorkUnit to Start after another has completed.
std::list< EventUserInput * > * GetAllUserInputEvents()
This returns a complete list of all the User Input events.
Thrown when an unknown internal error occurred.
bool Boole
Generally acts a single bit, true or false.
virtual void AddWorkUnitMain(iWorkUnit *MoreWork, const String &WorkUnitName)
Add a normal Mezzanine::Threading::iWorkUnit to this For fcheduling.
ManagerType
A listing of Manager Types.
virtual void RemoveWorkUnitMain(iWorkUnit *LessWork)
Remove a WorkUnit from the main pool of WorkUnits (and not from the groups of Affinity or MonpolyWork...
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
Threading::FrameScheduler & GetScheduler()
Gets the core structure responsible for scheduling work in the Entresol main loop.
EventPumpWorkUnit * GetEventPumpWork()
Gets the work unit responsible for pumping events from the OS.
A thread specific collection of double-buffered and algorithm specific resources. ...
static Boole SingletonValid()
Checks to see if the singleton pointer is valid.
uint16_t UInt16
An 16-bit unsigned integer.
static EventManager * GetSingletonPtr()
Fetches a pointer to the singleton.
This is the base class for all managers that do no describe properties of a single world...
A light-weight handle for manipulating nodes in DOM tree.
uint32_t UInt32
An 32-bit unsigned integer.
void RemoveAllSpecificEvents(EventBase::EventType SpecificType)
This removes all the events of the specified type.
Entresol * TheEntresol
The actual pointer to the Entresol core class.
std::list< NameValuePair > NameValuePairList
This is a datatype mostly used for describing settings or parameters that can't be declared in advanc...
virtual void ClearDependencies()
Drop any information about what work units this one depends on.
Input::MetaCode::MetaCodeContainer MetaCodeContainer
Convenience datatype for storage of MetaCodes.
The bulk of the engine components go in this namspace.
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
This is a container for Events and facilitates the transfer of data.
std::string String
A datatype used to a series of characters.
Boole Initialized
Simple Boole indicating whether or not this manager has been initialized.