MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Protected Attributes | Friends | List of all members
Mezzanine::Input::InputManager Class Reference

This is the manager responsible for the handling of input devices and events. More...

#include <inputmanager.h>

+ Inheritance diagram for Mezzanine::Input::InputManager:
+ Collaboration diagram for Mezzanine::Input::InputManager:

Public Types

typedef
ControllerContainer::const_iterator 
ConstControllerIterator
 
typedef std::vector< Controller * > ControllerContainer
 
typedef
ControllerContainer::iterator 
ControllerIterator
 
- Public Types inherited from Mezzanine::ManagerBase
enum  ManagerType {
  MT_AudioManager = 1, MT_AnimationManager, MT_CollisionShapeManager, MT_CompositorManager,
  MT_GraphicsManager, MT_EventManager, MT_InputManager, MT_LogManager,
  MT_MaterialManager, MT_MeshManager, MT_NetworkManager, MT_ResourceManager,
  MT_ScriptingManager, MT_UIManager, MT_ActorManager = 100, MT_AreaEffectManager,
  MT_CameraManager, MT_DebrisManager, MT_PagingManager, MT_PhysicsManager,
  MT_SceneManager, MT_SoundScapeManager, MT_TerrainManager, MT_VehicleManager,
  MT_UserCreated = 512
}
 

Public Member Functions

 InputManager ()
 Class constructor.
 
 InputManager (XML::Node &XMLNode)
 XML constructor. More...
 
virtual ~InputManager ()
 Class destructor.
 
void AddInputSequence (const MetaCodeContainer &Codes, const Int32 &SequenceID)
 Adds a custom sequence of inputs that this system will look for and generate MetaCode's for when they occur.

Exceptions
Ifthe vector of MetaCode's doesn't end with a null MetaCode, an exception will be thrown. An exception can also be thrown if the ID provided is the max value of an Int32.
More...
 
virtual void Deinitialize ()
 Removes this manager from any necessary configuration so it can be safely disposed of. More...
 
UInt16 DetectControllers ()
 Gathers all of the controllers that are connected to the system and creates corresponding devices for each one. More...
 
ControllerGetController (const UInt16 Index) const
 Gets a controller by index. More...
 
DeviceUpdateWorkUnitGetDeviceUpdateWork ()
 Gets the work unit responsible for updating the input device classes. More...
 
Int32 GetIDofInputSequence (const MetaCodeContainer &Codes)
 Gets the ID of the provided sequence of MetaCode's.

Exceptions
Ifthe vector of MetaCode's doesn't end with a null MetaCode, an exception will be thrown.
More...
 
virtual String GetImplementationTypeName () const
 This Allows any manager name to be sent to a stream. Primarily used for logging. More...
 
const MetaCodeContainer & GetInputDeltas () const
 Gets all the input codes that were generated this frame. More...
 
virtual ManagerType GetInterfaceType () const
 This returns the type of this manager. More...
 
UInt16 GetNumControllers () const
 Gets the number of controllers detected. More...
 
KeyboardGetSystemKeyboard () const
 Gets the system keyboard. More...
 
MouseGetSystemMouse () const
 Gets the system mouse. More...
 
virtual void Initialize ()
 Configures this manager for use prior to entering the main loop. More...
 
bool InputSequenceExists (const MetaCodeContainer &Codes)
 Checks to see if the provided sequence of MetaCode's is already being checked for.

Exceptions
Ifthe vector of MetaCode's doesn't end with a null MetaCode, an exception will be thrown.
More...
 
void ReleaseAllControllers ()
 Releases all controller devices from this manager.
 
void RemoveAllInputSequences ()
 Removes all stored input sequences. More...
 
void RemoveInputSequence (const MetaCodeContainer &Codes)
 Removes the specified custom sequence of MetaCode's.

Exceptions
Ifthe vector of MetaCode's doesn't end with a null MetaCode, an exception will be thrown.
More...
 
- Public Member Functions inherited from Mezzanine::ManagerBase
 ManagerBase ()
 Class constructor.
 
virtual ~ManagerBase ()
 Class destructor.
 
virtual String GetInterfaceTypeAsString () const
 Gets a string of the interface type of this manager. More...
 
bool IsInitialized () const
 Gets whether or not this manager has been initialized. More...
 
- Public Member Functions inherited from Mezzanine::Singleton< InputManager >
 Singleton ()
 Class constructor.
 
 ~Singleton ()
 Class destructor.
 

Protected Attributes

DeviceUpdateWorkUnitDeviceUpdateWork
 The work unit that updates the input devices with the newest data. More...
 
InputManagerInternalDataIMID
 The pointer to the internal data handled by this manager. More...
 
MetaCodeContainer InputDeltas
 Container storing all the MetaCodes generated for the current frame. More...
 
SequenceContainer Sequences
 Container storing all the cross-device sequences this manager is to check for. More...
 
KeyboardSystemKeyboard
 The pointer to the object representing the system keyboard. More...
 
MouseSystemMouse
 The pointer to the object representing the system mouse. More...
 
Threading::DefaultThreadSpecificStorage::TypeThreadResources
 Can be used for thread safe logging and other thread specific resources. More...
 
- Protected Attributes inherited from Mezzanine::ManagerBase
bool Initialized
 Simple bool indicating whether or not this manager has been initialized. More...
 
EntresolTheEntresol
 The actual pointer to the Entresol core class. More...
 

Friends

class DeviceUpdateWorkUnit
 

Additional Inherited Members

- Static Public Member Functions inherited from Mezzanine::ManagerBase
static String GetTypeAsString (const ManagerType &ManagerType)
 Gets the string form of the type of manager. More...
 
static ManagerType GetTypeFromString (const String &ManagerName)
 Gets the type of manager requested from a string. More...
 
- Static Public Member Functions inherited from Mezzanine::Singleton< InputManager >
static InputManager * GetSingletonPtr ()
 Fetches a pointer to the singleton. More...
 
static bool SingletonValid ()
 Checks to see if the singleton pointer is valid. More...
 
- Static Protected Attributes inherited from Mezzanine::Singleton< InputManager >
static InputManager * SingletonPtr
 

Detailed Description

This is the manager responsible for the handling of input devices and events.

Inputs can be checked one of two ways in the input system. Either you can get the class instance for the device you want to query and use the query methods on it to check it's current state, or you can access the inputs that were raised for the current frame by getting the container storing the Input Delta's.

Another feature of the input system is the ability to set custom input sequences that can be raised via MetaCode for use elsewhere (such as the UI system). These sequences can be any number of MetaCode's of any type (that is valid) in any order. Any sequence passed in must be terminated with a "Null" MetaCode. A "Null" MetaCode is a MetaCode constructed using the default constructor, having it's Input code set to "KEY_UNKNOWN", it's meta value to 0, and it's device index set to the max value of UInt16. If the sequence is not terminated an exception will be thrown.

Input Sequences can be stored on the manager, or any input device, and their behavior is different based on where it is inserted. Input Sequences stored on the manager will look at all of the most recent inputs from all devices and use that to compare against the stored Input Sequences. If you have a single player game on the PC and want to use an Input Sequence that combines input from both the mouse and keyboard, then the InputManager is the place to store it. If however, you have a multiplayer fighter game (or split screen shooter) and want to track inputs from each of two or more controllers individually, then you'll want to place the Input Sequences on the proper controller device.

The InputManager can take any sequence, provided it is terminated. Input devices however can only take sequences with MetaCode's that pertain to their own device, otherwise an exception will be thrown. At each place of storage Input Sequences are forced to be unique(but they can exist on multiple devices). Input Sequence ID's however are not forced to be unique at any point in the system. Furthermore when a MetaCode is generated after an Input Sequence occurs, it is only given the ID the sequence, but not which sequence generated it. In the case of controllers they will be given a device ID, but otherwise the origin will not be reported. This allows you to provide multiple ways to generating the appropriate MetaCode(which could trigger something else in the UI system), but this also means great care must be taken when deciding on the ID's for each Input Sequence.

Definition at line 128 of file inputmanager.h.

Constructor & Destructor Documentation

Mezzanine::Input::InputManager::InputManager ( XML::Node XMLNode)

XML constructor.

Parameters
XMLNodeThe node of the xml document to construct from.

Definition at line 191 of file inputmanager.cpp.

Member Function Documentation

void Mezzanine::Input::InputManager::AddInputSequence ( const MetaCodeContainer &  Codes,
const Int32 SequenceID 
)

Adds a custom sequence of inputs that this system will look for and generate MetaCode's for when they occur.

Exceptions
Ifthe vector of MetaCode's doesn't end with a null MetaCode, an exception will be thrown. An exception can also be thrown if the ID provided is the max value of an Int32.

Parameters
CodesA vector containing the sequence of MetaCode's to be added.
SequenceIDA unique UInt32 to be used as the identifier for this sequence when a MetaCode is generated.

Definition at line 284 of file inputmanager.cpp.

void Mezzanine::Input::InputManager::Deinitialize ( )
virtual

Removes this manager from any necessary configuration so it can be safely disposed of.

Implements Mezzanine::ManagerBase.

Definition at line 320 of file inputmanager.cpp.

UInt16 Mezzanine::Input::InputManager::DetectControllers ( )

Gathers all of the controllers that are connected to the system and creates corresponding devices for each one.

Returns
Returns the number of controllers that have been detected.

Definition at line 256 of file inputmanager.cpp.

Controller * Mezzanine::Input::InputManager::GetController ( const UInt16  Index) const

Gets a controller by index.

Returns
Returns a pointer to the controller at the specified index.

Definition at line 243 of file inputmanager.cpp.

DeviceUpdateWorkUnit * Mezzanine::Input::InputManager::GetDeviceUpdateWork ( )

Gets the work unit responsible for updating the input device classes.

Returns
Returns a pointer to the DeviceUpdateWorkUnit used by this manager.

Definition at line 331 of file inputmanager.cpp.

Int32 Mezzanine::Input::InputManager::GetIDofInputSequence ( const MetaCodeContainer &  Codes)

Gets the ID of the provided sequence of MetaCode's.

Exceptions
Ifthe vector of MetaCode's doesn't end with a null MetaCode, an exception will be thrown.

Parameters
CodesA vector containing the sequence of MetaCode's to get the ID for.
Returns
Returns the ID of the provided sequence, or the max value of an Int32 if the sequence does not exist.

Definition at line 290 of file inputmanager.cpp.

String Mezzanine::Input::InputManager::GetImplementationTypeName ( ) const
virtual

This Allows any manager name to be sent to a stream. Primarily used for logging.

Returns
This returns a String that contains the name.

Implements Mezzanine::ManagerBase.

Definition at line 342 of file inputmanager.cpp.

const MetaCodeContainer & Mezzanine::Input::InputManager::GetInputDeltas ( ) const

Gets all the input codes that were generated this frame.

Returns
Returns a const reference to a vector containing all the inputs updated this frame.

Definition at line 302 of file inputmanager.cpp.

ManagerBase::ManagerType Mezzanine::Input::InputManager::GetInterfaceType ( ) const
virtual

This returns the type of this manager.

This is intended to make using and casting from Manager base easier. With this is is possible to cast from ManagerBase to the correct Manager Type.

Returns
This returns a ManagerTypeName to identify what this can be safely cast to.

Implements Mezzanine::ManagerBase.

Definition at line 339 of file inputmanager.cpp.

UInt16 Mezzanine::Input::InputManager::GetNumControllers ( ) const

Gets the number of controllers detected.

Returns
Returns the number of controllers that have been detected on this system.

Definition at line 248 of file inputmanager.cpp.

Keyboard * Mezzanine::Input::InputManager::GetSystemKeyboard ( ) const

Gets the system keyboard.

Returns
Returns a pointer to the keyboard device.

Definition at line 238 of file inputmanager.cpp.

Mouse * Mezzanine::Input::InputManager::GetSystemMouse ( ) const

Gets the system mouse.

Returns
Returns a pointer to the mouse device.

Definition at line 233 of file inputmanager.cpp.

void Mezzanine::Input::InputManager::Initialize ( )
virtual

Configures this manager for use prior to entering the main loop.

Implements Mezzanine::ManagerBase.

Definition at line 307 of file inputmanager.cpp.

bool Mezzanine::Input::InputManager::InputSequenceExists ( const MetaCodeContainer &  Codes)

Checks to see if the provided sequence of MetaCode's is already being checked for.

Exceptions
Ifthe vector of MetaCode's doesn't end with a null MetaCode, an exception will be thrown.

Parameters
CodesA vector containing the sequence of MetaCode's to check for.
Returns
Returns true if the sequence already exists, false otherwise.

Definition at line 287 of file inputmanager.cpp.

void Mezzanine::Input::InputManager::RemoveAllInputSequences ( )

Removes all stored input sequences.

Definition at line 296 of file inputmanager.cpp.

void Mezzanine::Input::InputManager::RemoveInputSequence ( const MetaCodeContainer &  Codes)

Removes the specified custom sequence of MetaCode's.

Exceptions
Ifthe vector of MetaCode's doesn't end with a null MetaCode, an exception will be thrown.

Parameters
CodesA vector containing the sequence of MetaCode's to be removed.

Definition at line 293 of file inputmanager.cpp.

Member Data Documentation

DeviceUpdateWorkUnit* Mezzanine::Input::InputManager::DeviceUpdateWork
protected

The work unit that updates the input devices with the newest data.

Definition at line 156 of file inputmanager.h.

InputManagerInternalData* Mezzanine::Input::InputManager::IMID
protected

The pointer to the internal data handled by this manager.

Definition at line 146 of file inputmanager.h.

MetaCodeContainer Mezzanine::Input::InputManager::InputDeltas
protected

Container storing all the MetaCodes generated for the current frame.

Definition at line 142 of file inputmanager.h.

SequenceContainer Mezzanine::Input::InputManager::Sequences
protected

Container storing all the cross-device sequences this manager is to check for.

Definition at line 139 of file inputmanager.h.

Keyboard* Mezzanine::Input::InputManager::SystemKeyboard
protected

The pointer to the object representing the system keyboard.

Definition at line 152 of file inputmanager.h.

Mouse* Mezzanine::Input::InputManager::SystemMouse
protected

The pointer to the object representing the system mouse.

Definition at line 149 of file inputmanager.h.

Threading::DefaultThreadSpecificStorage::Type* Mezzanine::Input::InputManager::ThreadResources
protected

Can be used for thread safe logging and other thread specific resources.

Definition at line 159 of file inputmanager.h.


The documentation for this class was generated from the following files: