Spinning Topp Logo BlackTopp Studios
inc
Public Types | Public Member Functions | Static Public Attributes | 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
 Const Iterator type for game controller instances stored by this class.
 
typedef std::vector< Controller * > ControllerContainer
 Basic container type for game controller instances.
 
typedef ControllerContainer::iterator ControllerIterator
 Iterator type for game controller instances stored by this class.
 
- Public Types inherited from Mezzanine::ManagerBase
enum  ManagerType {
  MT_Undefined = 0, MT_AudioManager = 1, MT_AnimationManager = 2, MT_CollisionShapeManager = 3,
  MT_CompositorManager = 4, MT_GraphicsManager = 5, MT_EventManager = 6, MT_InputManager = 7,
  MT_LogManager = 8, MT_MaterialManager = 9, MT_MeshManager = 10, MT_NetworkManager = 11,
  MT_ResourceManager = 12, MT_ScriptingManager = 13, MT_TextureManager = 14, MT_UIManager = 15,
  MT_ActorManager = 101, MT_AreaEffectManager = 102, MT_DebrisManager = 103, MT_PagingManager = 104,
  MT_PhysicsManager = 105, MT_SceneManager = 106, MT_SoundScapeManager = 107, MT_TerrainManager = 108,
  MT_VehicleManager = 109, MT_UserCreated = 512
}
 A listing of Manager Types. More...
 

Public Member Functions

 InputManager ()
 Class constructor.
 
 InputManager (const 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 MetaCodeContainerGetInputDeltas () 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...
 
Boole 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::EntresolManager
 EntresolManager ()
 Class constructor.
 
virtual ~EntresolManager ()
 Class destructor.
 
- 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...
 
Boole IsInitialized () const
 Gets whether or not this manager has been initialized. More...
 
- Public Member Functions inherited from Mezzanine::Singleton< InputManager >
 ~Singleton ()
 Class destructor.
 

Static Public Attributes

static const String ImplementationName = "DefaultInputManager"
 A String containing the name of this manager implementation.
 
static const ManagerBase::ManagerType InterfaceType = ManagerBase::MT_InputManager
 A ManagerType enum value used to describe the type of interface/functionality this manager provides.
 

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
Boole Initialized
 Simple Boole 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 Boole SingletonValid ()
 Checks to see if the singleton pointer is valid. More...
 
- Protected Member Functions inherited from Mezzanine::Singleton< InputManager >
 Singleton ()
 Class constructor.
 
- Static Protected Attributes inherited from Mezzanine::Singleton< InputManager >
static InputManager * SingletonPtr
 The one and only pointer to the single object. More...
 

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 ( const XML::Node XMLNode)

XML constructor.

Parameters
XMLNodeThe node of the xml document to construct from.

Definition at line 193 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 286 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 322 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 258 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 245 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 333 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 292 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 344 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 304 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 341 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 250 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 240 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 235 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 309 of file inputmanager.cpp.

Boole 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 289 of file inputmanager.cpp.

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

Removes all stored input sequences.

Definition at line 298 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 295 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 164 of file inputmanager.h.

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

The pointer to the internal data handled by this manager.

Definition at line 154 of file inputmanager.h.

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

Container storing all the MetaCodes generated for the current frame.

Definition at line 150 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 147 of file inputmanager.h.

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

The pointer to the object representing the system keyboard.

Definition at line 160 of file inputmanager.h.

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

The pointer to the object representing the system mouse.

Definition at line 157 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 167 of file inputmanager.h.


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