Orxonox  0.0.5 Codename: Arcturus
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
orxonox::InputState Class Reference

InputStates allow you to customise the input event targets at runtime. More...

#include </home/jenkins/workspace/orxonox_doxygen_trunk/src/libraries/core/input/InputState.h>

Inheritance diagram for orxonox::InputState:
orxonox::JoyStickQuantityListener orxonox::Listable orxonox::Identifiable

Public Member Functions

template<typename EventType , class ButtonTypeParam >
void buttonEvent (unsigned int device, ButtonTypeParam button)
 Generic function that distributes all 9 button events. More...
 
template<typename EventType , class ButtonTypeParam >
ORX_FORCEINLINE void buttonEvent (unsigned int device, ButtonTypeParam button)
 
void entered ()
 Called when the state is being activated (even if it doesn't get any events afterwards!) More...
 
tribool getMouseExclusive () const
 
const std::string & getName () const
 Returns the name of the state (which is unique!) More...
 
int getPriority () const
 Returns the priority of the state (which is unique if != 0) More...
 
bool hasExpired ()
 Returns true if the handler situation has changed. More...
 
bool isInputDeviceEnabled (unsigned int device)
 Tells whether there a handler installed for a specific device. More...
 
void joyStickAxisMoved (unsigned int device, unsigned int axis, float value)
 Event handler. More...
 
void left ()
 Called upon deactivation of the state. More...
 
void mouseMoved (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize)
 Event handler. More...
 
void mouseScrolled (int abs, int rel)
 Event handler. More...
 
void resetExpiration ()
 Call this if you have applied the changes resulting from changed handlers. More...
 
void setEnterFunctor (const FunctorPtr &functor)
 Sets a functor to be called upon activation of the state. More...
 
void setHandler (InputHandler *handler)
 Sets an InputHandler to be used for all devices. More...
 
bool setJoyStickHandler (InputHandler *handler, unsigned int joyStick)
 Sets the joy stick event handler for one specific joy stick (overwrites if there already was one!) More...
 
void setJoyStickHandler (InputHandler *handler)
 Sets the joy stick event handler for all joy sticks (overwrites if there already was one!) More...
 
void setKeyHandler (InputHandler *handler)
 Sets the keyboard event handler (overwrites if there already was one!) More...
 
void setLeaveFunctor (const FunctorPtr &functor)
 Sets a functor to be called upon deactivation of the state. More...
 
void setMouseExclusive (tribool value)
 
void setMouseHandler (InputHandler *handler)
 Sets the mouse event handler (overwrites if there already was one!) More...
 
void update (float dt, unsigned int device)
 Updates one specific device handler with deviceUpdated. More...
 
void update (float dt)
 Updates all handlers with allDevicesUpdated. 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...
 
ContextgetContext () 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 voidgetDerivedPointer (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...
 
IdentifiergetIdentifier () 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...
 

Private Member Functions

 InputState (const std::string &name, bool bAlwaysGetsInput, bool bTransparent, InputStatePriority priority)
 Sets priority of it's a high priority and resizes the handler list. More...
 
 ~InputState ()=default
 
virtual void JoyStickQuantityChanged (const std::vector< JoyStick * > &joyStickList) override
 Called by JoyStickQuantityListener upon joy stick adding/removal. More...
 
void setPriority (int priority)
 Sets the priority (only to be used by the InputManager!) More...
 

Private Attributes

const bool bAlwaysGetsInput_
 See class declaration for explanation. More...
 
bool bExpired_
 See hasExpired() More...
 
const bool bTransparent_
 See class declaration for explanation. More...
 
FunctorPtr enterFunctor_
 Functor to be executed on enter. More...
 
tribool exclusiveMouse_
 See class declaration for explanation. More...
 
std::vector< InputHandler * > handlers_
 Vector with all handlers where the index is the device ID. More...
 
InputHandlerjoyStickHandlerAll_
 Handler to be used for all joy sticks (needs to be saved in case another joy stick gets attached) More...
 
FunctorPtr leaveFunctor_
 Functor to be executed on leave. More...
 
const std::string name_
 Name of the state. More...
 
int priority_
 Current priority (might change) More...
 

Static Private Attributes

static const InputDeviceEnumerator::Value firstJoyStickIndex_s = InputDeviceEnumerator::FirstJoyStick
 Marks the index in the handler vector for the first joy stick handler. More...
 
static const InputDeviceEnumerator::Value keyboardIndex_s = InputDeviceEnumerator::Keyboard
 Marks the index in the handler vector for the keyboard handler. More...
 
static const InputDeviceEnumerator::Value mouseIndex_s = InputDeviceEnumerator::Mouse
 Marks the index in the handler vector for the mouse handler. More...
 

Friends

class InputManager
 

Additional Inherited Members

- Protected Member Functions inherited from orxonox::JoyStickQuantityListener
 JoyStickQuantityListener ()
 
virtual ~JoyStickQuantityListener ()=default
 
const std::vector< JoyStick * > & getJoyStickList () const
 Returns a list with all JoySticks currently loaded. More...
 

Detailed Description

InputStates allow you to customise the input event targets at runtime.

The general idea is a stack: Every activated InputState will be pushed on that stack and only the top one gets the input events. This is done for every device (keyboard, mouse, all joy sticks) separately to allow for instance keyboard input capturing for the console while you can still steer a ship with the mouse. There are two exceptions to this behaviour though:

Priorities
Every InputState has a priority when on the stack, but mostly this priority is dynamic (InputStatePriority::Dynamic) which means that a state pushed onto the stack will simply have a higher priority than the top one. This behaviour really only applies to normal states that don't have a high priority (InputStatePriority::HighPriority). These 'special' ones are used for features like the KeyDetector or the console. Use with care!
Exclusive/Non-Exclusive mouse Mode
You can select a specific mouse mode that tells whether the application should have exclusive access to it or not. When in non-exclusive mode, you can move the mouse out of the window like with any other normal window (only for windowed mode!). The setting is dictated by the topmost InputState that gets mouse events.

Constructor & Destructor Documentation

orxonox::InputState::InputState ( const std::string &  name,
bool  bAlwaysGetsInput,
bool  bTransparent,
InputStatePriority  priority 
)
private

Sets priority of it's a high priority and resizes the handler list.

orxonox::InputState::~InputState ( )
privatedefault

Member Function Documentation

template<typename EventType , class ButtonTypeParam >
void orxonox::InputState::buttonEvent ( unsigned int  device,
ButtonTypeParam  button 
)

Generic function that distributes all 9 button events.

template<typename EventType , class ButtonTypeParam >
ORX_FORCEINLINE void orxonox::InputState::buttonEvent ( unsigned int  device,
ButtonTypeParam  button 
)
void orxonox::InputState::entered ( )

Called when the state is being activated (even if it doesn't get any events afterwards!)

tribool orxonox::InputState::getMouseExclusive ( ) const
inline
const std::string& orxonox::InputState::getName ( void  ) const
inline

Returns the name of the state (which is unique!)

int orxonox::InputState::getPriority ( ) const
inline

Returns the priority of the state (which is unique if != 0)

bool orxonox::InputState::hasExpired ( )
inline

Returns true if the handler situation has changed.

bool orxonox::InputState::isInputDeviceEnabled ( unsigned int  device)

Tells whether there a handler installed for a specific device.

ORX_FORCEINLINE void orxonox::InputState::joyStickAxisMoved ( unsigned int  device,
unsigned int  axis,
float  value 
)

Event handler.

void orxonox::InputState::JoyStickQuantityChanged ( const std::vector< JoyStick * > &  joyStickList)
overrideprivatevirtual

Called by JoyStickQuantityListener upon joy stick adding/removal.

Implements orxonox::JoyStickQuantityListener.

void orxonox::InputState::left ( )

Called upon deactivation of the state.

ORX_FORCEINLINE void orxonox::InputState::mouseMoved ( IntVector2  abs,
IntVector2  rel,
IntVector2  clippingSize 
)

Event handler.

ORX_FORCEINLINE void orxonox::InputState::mouseScrolled ( int  abs,
int  rel 
)

Event handler.

void orxonox::InputState::resetExpiration ( )
inline

Call this if you have applied the changes resulting from changed handlers.

void orxonox::InputState::setEnterFunctor ( const FunctorPtr functor)
inline

Sets a functor to be called upon activation of the state.

void orxonox::InputState::setHandler ( InputHandler handler)

Sets an InputHandler to be used for all devices.

bool orxonox::InputState::setJoyStickHandler ( InputHandler handler,
unsigned int  joyStick 
)

Sets the joy stick event handler for one specific joy stick (overwrites if there already was one!)

Returns
Returns false if the specified device was not found
void orxonox::InputState::setJoyStickHandler ( InputHandler handler)

Sets the joy stick event handler for all joy sticks (overwrites if there already was one!)

void orxonox::InputState::setKeyHandler ( InputHandler handler)
inline

Sets the keyboard event handler (overwrites if there already was one!)

void orxonox::InputState::setLeaveFunctor ( const FunctorPtr functor)
inline

Sets a functor to be called upon deactivation of the state.

void orxonox::InputState::setMouseExclusive ( tribool  value)
inline
void orxonox::InputState::setMouseHandler ( InputHandler handler)
inline

Sets the mouse event handler (overwrites if there already was one!)

void orxonox::InputState::setPriority ( int  priority)
inlineprivate

Sets the priority (only to be used by the InputManager!)

ORX_FORCEINLINE void orxonox::InputState::update ( float  dt,
unsigned int  device 
)

Updates one specific device handler with deviceUpdated.

ORX_FORCEINLINE void orxonox::InputState::update ( float  dt)

Updates all handlers with allDevicesUpdated.

Friends And Related Function Documentation

friend class InputManager
friend

Member Data Documentation

const bool orxonox::InputState::bAlwaysGetsInput_
private

See class declaration for explanation.

bool orxonox::InputState::bExpired_
private
const bool orxonox::InputState::bTransparent_
private

See class declaration for explanation.

FunctorPtr orxonox::InputState::enterFunctor_
private

Functor to be executed on enter.

tribool orxonox::InputState::exclusiveMouse_
private

See class declaration for explanation.

const InputDeviceEnumerator::Value orxonox::InputState::firstJoyStickIndex_s = InputDeviceEnumerator::FirstJoyStick
staticprivate

Marks the index in the handler vector for the first joy stick handler.

std::vector<InputHandler*> orxonox::InputState::handlers_
private

Vector with all handlers where the index is the device ID.

InputHandler* orxonox::InputState::joyStickHandlerAll_
private

Handler to be used for all joy sticks (needs to be saved in case another joy stick gets attached)

const InputDeviceEnumerator::Value orxonox::InputState::keyboardIndex_s = InputDeviceEnumerator::Keyboard
staticprivate

Marks the index in the handler vector for the keyboard handler.

FunctorPtr orxonox::InputState::leaveFunctor_
private

Functor to be executed on leave.

const InputDeviceEnumerator::Value orxonox::InputState::mouseIndex_s = InputDeviceEnumerator::Mouse
staticprivate

Marks the index in the handler vector for the mouse handler.

const std::string orxonox::InputState::name_
private

Name of the state.

int orxonox::InputState::priority_
private

Current priority (might change)


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