Orxonox
0.0.5 Codename: Arcturus
|
Manages the input devices (mouse, keyboard, joy sticks) and the input states. More...
#include </home/jenkins/workspace/orxonox_doxygen_trunk/src/libraries/core/input/InputManager.h>
Public Types | |
enum | State { Nothing = 0x00, Bad = 0x02, Calibrating = 0x04 } |
Represents internal states of the InputManager. More... | |
Public Member Functions | |
InputManager () | |
Loads the devices and initialises the KeyDetector and the Calibrator. More... | |
~InputManager () | |
Destroys all devices AND all input states! More... | |
void | calibrate () |
Starts joy stick calibration. More... | |
void | clearBuffers () |
Clears all input device buffers. This usually only includes the pressed button list. More... | |
InputState * | createInputState (const std::string &name, bool bAlwaysGetsInput=false, bool bTransparent=false, InputStatePriority priority=InputStatePriority::Dynamic) |
Creates a new InputState that gets managed by the InputManager. More... | |
bool | destroyState (const std::string &name) |
Removes and destroys an input state. More... | |
bool | enterState (const std::string &name) |
Activates a specific input state. More... | |
unsigned int | getJoyStickQuantity () const |
Returns the number of joy stick that have been created since the c'tor or last call to reload(). More... | |
std::pair< int, int > | getMousePosition () const |
Returns the position of the cursor as std::pair of ints. More... | |
OIS::InputManager * | getOISInputManager () |
Returns a pointer to the OIS InputManager. Only you if you know what you're doing! More... | |
InputState * | getState (const std::string &name) |
Returns a pointer to a InputState referenced by name. More... | |
bool | isMouseExclusive () const |
Tells whether the mouse is used exclusively to the game. More... | |
bool | leaveState (const std::string &name) |
Deactivates a specific input state. More... | |
void | preUpdate (const Clock &time) |
Updates the devices (which distribute the input events) and the input states. More... | |
void | pushCall (const std::function< void()> &function) |
void | reload () |
Reloads all the input devices. More... | |
void | setConfigValues () |
bool | setMouseExclusive (const std::string &name, tribool value) |
Changes the mouse mode of an input state. More... | |
Public Member Functions inherited from orxonox::Listable | |
Listable () | |
Constructor: Allocates space in the element list. More... | |
Listable (Context *context) | |
Constructor: Allocates space in the element list and assigns the context. More... | |
virtual | ~Listable () |
Destructor: Removes the object from the object-lists. More... | |
Context * | getContext () const |
void | setContext (Context *context) |
Changes the context. More... | |
void | unregisterObject () |
Removes this object from the object-lists. More... | |
Public Member Functions inherited from orxonox::Identifiable | |
Identifiable () | |
Constructor: Sets the default values. More... | |
virtual | ~Identifiable () |
ORX_FORCEINLINE void * | getDerivedPointer (unsigned int classID) |
Returns a valid pointer of any derived type that is registered in the class hierarchy. More... | |
template<class T > | |
ORX_FORCEINLINE T * | getDerivedPointer (unsigned int classID) |
Version of getDerivedPointer with template. More... | |
template<class T > | |
ORX_FORCEINLINE const T * | getDerivedPointer (unsigned int classID) const |
Const version of getDerivedPointer with template. More... | |
Identifier * | getIdentifier () const |
Returns the Identifier of the object. More... | |
bool | isA (const Identifier *identifier) |
Returns true if the object's class is of the given type or a derivative. More... | |
template<class B > | |
bool | isA (const SubclassIdentifier< B > *identifier) |
Returns true if the object's class is of the given type or a derivative. More... | |
bool | isA (const Identifiable *object) |
Returns true if the object's class is of the given type or a derivative. More... | |
bool | isChildOf (const Identifier *identifier) |
Returns true if the object's class is a child of the given type. More... | |
template<class B > | |
bool | isChildOf (const SubclassIdentifier< B > *identifier) |
Returns true if the object's class is a child of the given type. More... | |
bool | isChildOf (const Identifiable *object) |
Returns true if the object's class is a child of the given type. More... | |
bool | isDirectChildOf (const Identifier *identifier) |
Returns true if the object's class is a direct child of the given type. More... | |
template<class B > | |
bool | isDirectChildOf (const SubclassIdentifier< B > *identifier) |
Returns true if the object's class is a direct child of the given type. More... | |
bool | isDirectChildOf (const Identifiable *object) |
Returns true if the object's class is a direct child of the given type. More... | |
bool | isDirectParentOf (const Identifier *identifier) |
Returns true if the object's class is a direct parent of the given type. More... | |
template<class B > | |
bool | isDirectParentOf (const SubclassIdentifier< B > *identifier) |
Returns true if the object's class is a direct parent of the given type. More... | |
bool | isDirectParentOf (const Identifiable *object) |
Returns true if the object's class is a direct child of the given type. More... | |
bool | isExactlyA (const Identifier *identifier) |
Returns true if the object's class is exactly of the given type. More... | |
template<class B > | |
bool | isExactlyA (const SubclassIdentifier< B > *identifier) |
Returns true if the object's class is exactly of the given type. More... | |
bool | isExactlyA (const Identifiable *object) |
Returns true if the object's class is exactly of the given type. More... | |
bool | isParentOf (const Identifier *identifier) |
Returns true if the object's class is a parent of the given type. More... | |
template<class B > | |
bool | isParentOf (const SubclassIdentifier< B > *identifier) |
Returns true if the object's class is a parent of the given type. More... | |
bool | isParentOf (const Identifiable *object) |
Returns true if the object's class is a parent of the given type. More... | |
Static Public Member Functions | |
static InputManager & | getInstance () |
Static Public Member Functions inherited from orxonox::Singleton< InputManager > | |
static bool | exists () |
Tells whether the singleton has been created. More... | |
static InputManager & | getInstance () |
Returns a reference to the singleton instance. More... | |
Private Member Functions | |
InputManager (const InputManager &)=delete | |
void | destroyDevices () |
Destoys all input devices (joy sticks, mouse, keyboard and OIS::InputManager) More... | |
void | destroyStateInternal (InputState *state) |
Destroys an InputState internally. More... | |
void | loadDevices () |
Creates the OIS::InputMananger, the keyboard, the mouse and the joys ticks. More... | |
void | loadJoySticks () |
Creates as many joy sticks as are available. More... | |
void | loadMouse () |
Creates a new orxonox::Mouse. More... | |
InputManager & | operator= (const InputManager &)=delete |
void | reloadInternal () |
Internal reload method. Destroys the OIS devices and loads them again. More... | |
void | stopCalibration () |
Tells all devices to stop the calibration and evaluate it. Buffers are being cleared as well! More... | |
void | updateActiveStates () |
Updates the currently active states (according to activeStates_) for each device. More... | |
virtual void | windowFocusChanged (bool bFocus) override |
Gets called by WindowEventListener upon focus change –> clear buffers. More... | |
Private Attributes | |
std::map< int, InputState * > | activeStates_ |
Contains all active input states by priority (std::map is sorted!) More... | |
std::vector< InputState * > | activeStatesTicked_ |
Like activeStates_, but only contains the ones that currently receive events. More... | |
InputBuffer * | calibratorCallbackHandler_ |
InputBuffer that reacts to the Enter key when calibrating the joy sticks. More... | |
std::vector< std::function< void()> > | callBuffer_ |
Caches all calls from InputStates to be executed afterwards (see preUpdate) More... | |
std::vector< InputDevice * > | devices_ |
List of all input devices (keyboard, mouse, joy sticks) More... | |
InputState * | emptyState_ |
Lowest priority states (makes handling easier) More... | |
bool | exclusiveMouse_ |
Currently applied mouse mode. More... | |
State | internalState_ |
Current internal state. More... | |
OIS::InputManager * | oisInputManager_ |
OIS input manager. More... | |
std::map< std::string, InputState * > | statesByName_ |
Contains all the created input states by name. More... | |
Static Private Attributes | |
static InputManager * | singletonPtr_s = nullptr |
Pointer reference to the singleton. More... | |
Friends | |
class | Singleton< InputManager > |
Additional Inherited Members | |
Protected Member Functions inherited from orxonox::Singleton< InputManager > | |
Singleton () | |
Constructor sets the singleton instance pointer. More... | |
virtual | ~Singleton () |
Destructor resets the singleton instance pointer. More... | |
Protected Member Functions inherited from orxonox::WindowEventListener | |
WindowEventListener () | |
virtual | ~WindowEventListener ()=default |
unsigned int | getWindowHeight () const |
Returns the current render window height. More... | |
unsigned int | getWindowWidth () const |
Returns the current render window width. More... | |
Manages the input devices (mouse, keyboard, joy sticks) and the input states.
Every input device has its own wrapper class which does the actually input event distribution. The InputManager only creates reloads (on request) those devices.
The other functionality concerns handling InputStates. They act as a layer between InputHandlers (like the KeyBinder or the GUIManager) and InputDevices. InputStates are memory managed by the IputManager. You cannot create or destroy them on your own. Therefore all states get destroyed with the InputManager d'tor.
Represents internal states of the InputManager.
Enumerator | |
---|---|
Nothing | |
Bad | |
Calibrating |
orxonox::InputManager::InputManager | ( | ) |
Loads the devices and initialises the KeyDetector and the Calibrator.
If either the OIS input system and/or the keyboard could not be created, the constructor fails with an std::exception.
orxonox::InputManager::~InputManager | ( | ) |
Destroys all devices AND all input states!
|
privatedelete |
void orxonox::InputManager::calibrate | ( | ) |
Starts joy stick calibration.
void orxonox::InputManager::clearBuffers | ( | ) |
Clears all input device buffers. This usually only includes the pressed button list.
InputState * orxonox::InputManager::createInputState | ( | const std::string & | name, |
bool | bAlwaysGetsInput = false , |
||
bool | bTransparent = false , |
||
InputStatePriority | priority = InputStatePriority::Dynamic |
||
) |
Creates a new InputState that gets managed by the InputManager.
name | Unique name of the InputState when referenced as string |
bAlwaysGetsInput | InputState always gets the input when activated |
bTransparent | InputState will not prevent underlaying state from receiving input |
priority | Priority matters when multiple states are active. You can specify any number, but 1 - 99 is preferred (99 means high priority). |
|
private |
Destoys all input devices (joy sticks, mouse, keyboard and OIS::InputManager)
Method | does not throw |
bool orxonox::InputManager::destroyState | ( | const std::string & | name | ) |
Removes and destroys an input state.
|
private |
Destroys an InputState internally.
bool orxonox::InputManager::enterState | ( | const std::string & | name | ) |
Activates a specific input state.
It might not actually be activated if the priority is too low!
|
inlinestatic |
|
inline |
Returns the number of joy stick that have been created since the c'tor or last call to reload().
std::pair< int, int > orxonox::InputManager::getMousePosition | ( | ) | const |
Returns the position of the cursor as std::pair of ints.
|
inline |
Returns a pointer to the OIS InputManager. Only you if you know what you're doing!
InputState * orxonox::InputManager::getState | ( | const std::string & | name | ) |
Returns a pointer to a InputState referenced by name.
|
inline |
Tells whether the mouse is used exclusively to the game.
bool orxonox::InputManager::leaveState | ( | const std::string & | name | ) |
Deactivates a specific input state.
|
private |
Creates the OIS::InputMananger, the keyboard, the mouse and the joys ticks.
If either of the first two fail, this method throws an exception.
|
private |
Creates as many joy sticks as are available.
|
private |
Creates a new orxonox::Mouse.
|
privatedelete |
Updates the devices (which distribute the input events) and the input states.
Any InpuStates changes (destroy, enter, leave) and happens here. If a reload request was submitted while updating, the request will be postponed until the next update call.
void orxonox::InputManager::reload | ( | ) |
Reloads all the input devices.
Use this method to initialise new joy sticks.
|
private |
Internal reload method. Destroys the OIS devices and loads them again.
bool orxonox::InputManager::setMouseExclusive | ( | const std::string & | name, |
tribool | value | ||
) |
Changes the mouse mode of an input state.
|
private |
Tells all devices to stop the calibration and evaluate it. Buffers are being cleared as well!
|
private |
Updates the currently active states (according to activeStates_) for each device.
Also, a list of all active states (no duplicates!) is compiled for the general preUpdate().
|
overrideprivatevirtual |
Gets called by WindowEventListener upon focus change –> clear buffers.
Reimplemented from orxonox::WindowEventListener.
|
friend |
|
private |
Contains all active input states by priority (std::map is sorted!)
|
private |
Like activeStates_, but only contains the ones that currently receive events.
|
private |
InputBuffer that reacts to the Enter key when calibrating the joy sticks.
|
private |
Caches all calls from InputStates to be executed afterwards (see preUpdate)
|
private |
List of all input devices (keyboard, mouse, joy sticks)
|
private |
Lowest priority states (makes handling easier)
|
private |
Currently applied mouse mode.
|
private |
Current internal state.
|
private |
OIS input manager.
|
staticprivate |
Pointer reference to the singleton.
|
private |
Contains all the created input states by name.