Orxonox  0.0.5 Codename: Arcturus
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
orxonox::KeyBinder Class Reference

Maps mouse, keyboard and joy stick input to command strings and executes them. More...

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

Inheritance diagram for orxonox::KeyBinder:
orxonox::InputHandler orxonox::JoyStickQuantityListener orxonox::Listable orxonox::Identifiable orxonox::KeyDetector

Classes

struct  JoyStickAxisVector
 Helper class to use something like std:vector<HalfAxis[48]> More...
 
struct  JoyStickButtonVector
 Helper class to use something like std:vector<Button[64]> More...
 

Public Member Functions

 KeyBinder (const std::string &filename)
 Constructor that does as little as necessary. More...
 
virtual ~KeyBinder ()
 Destructor. More...
 
void changeMode (ConsoleCommand *command, KeybindMode::Value mode)
 Changes the keybind mode of a given console command. More...
 
void clearBindings ()
 Overwrites all bindings with "". More...
 
std::string getBinding (const std::string &commandName)
 Return the first key name for a specific command. More...
 
std::string getBinding (const std::string &commandName, unsigned int index)
 Return the key name for a specific command at a given index. More...
 
std::string getBindingReadable (const std::string &commandName)
 Return the first key name for a specific command in a human readable form. More...
 
const std::string & getBindingsFilename ()
 
unsigned int getNumberOfBindings (const std::string &commandName)
 Get the number of different key bindings of a specific command. More...
 
void resetJoyStickAxes ()
 
void resetMouseAxes ()
 Sets the position of the mouse back to 0/0. More...
 
bool setBinding (const std::string &binding, const std::string &name, bool bTemporary=false)
 
void setConfigValues ()
 Loader for the key bindings, managed by config values. More...
 
- Public Member Functions inherited from orxonox::InputHandler
virtual ~InputHandler ()=default
 
template<class T >
void buttonEvent (unsigned int device, T button, ButtonEvent::TPress)
 
template<class T >
void buttonEvent (unsigned int device, T button, ButtonEvent::TRelease)
 
template<class T >
void buttonEvent (unsigned int device, T button, ButtonEvent::THold)
 
virtual void keyboardUpdated (float dt)
 
- 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...
 

Protected Member Functions

virtual void allDevicesUpdated (float dt) override
 
virtual void axisMoved (unsigned int device, unsigned int axis, float value) override
 
virtual void buttonHeld (const KeyEvent &evt) override
 
virtual void buttonHeld (MouseButtonCode::ByEnum button) override
 
virtual void buttonHeld (unsigned int device, JoyStickButtonCode::ByEnum button) override
 
virtual void buttonPressed (const KeyEvent &evt) override
 
virtual void buttonPressed (MouseButtonCode::ByEnum button) override
 
virtual void buttonPressed (unsigned int device, JoyStickButtonCode::ByEnum button) override
 
virtual void buttonReleased (const KeyEvent &evt) override
 
virtual void buttonReleased (MouseButtonCode::ByEnum button) override
 
virtual void buttonReleased (unsigned int device, JoyStickButtonCode::ByEnum button) override
 
void buttonThresholdChanged ()
 
void compilePointerLists ()
 
void initialiseJoyStickBindings ()
 
virtual void JoyStickQuantityChanged (const std::vector< JoyStick * > &joyStickList) override
 Called whenever joy sticks get added/removed. More...
 
virtual void joyStickUpdated (unsigned int joyStick, float dt) override
 
void loadBindings ()
 Loads the key and button bindings. More...
 
virtual void mouseMoved (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) override
 Event handler for the mouseMoved Event. More...
 
virtual void mouseScrolled (int abs, int rel) override
 Event handler for the mouseScrolled Event. More...
 
virtual void mouseUpdated (float dt) override
 
void tickHalfAxis (HalfAxis &halfAxis)
 
- 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...
 

Protected Attributes

std::map< std::string, Button * > allButtons_
 Pointer map with all Buttons, including half axes. More...
 
std::map< std::string, std::vector< std::string > > allCommands_
 Maps input commands to all Button names, including half axes. More...
 
std::vector< HalfAxis * > allHalfAxes_
 Pointer list with all half axes. More...
 
ConfigFileconfigFile_
 Config file used. nullptr in case of KeyDetector. Also indicates whether we've already loaded. More...
 
float deriveTime_
 
ConfigFilefallbackConfigFile_
 Config file from the data directory that only serves as fallback. More...
 
const std::string filename_
 Name of the file used in this KeyBinder (constant!) More...
 
std::vector< std::shared_ptr< JoyStickAxisVector > > joyStickAxes_
 Actual key bindings for joy stick axes (and sliders) More...
 
std::vector< std::shared_ptr< JoyStickButtonVector > > joyStickButtons_
 Actual key bindings for joy stick buttons. More...
 
std::vector< JoyStick * > joySticks_
 Currently active joy sticks. More...
 
Button keys_ [KeyCode::numberOfKeys]
 Actual key bindings for keys on the keyboard. More...
 
HalfAxis mouseAxes_ [MouseAxisCode::numberOfAxes *2]
 Actual key bindings for mouse axes. More...
 
Button mouseButtons_ [numberOfMouseButtons_]
 Actual key bindings for mouse buttons including the wheel(s) More...
 
float mousePosition_ [2]
 Keeps track of the absolute mouse value. More...
 
int mouseRelative_ [2]
 Used to derive mouse input if requested. More...
 
std::vector< BufferedParamCommand * > paramCommandBuffer_
 Commands that have additional parameters (axes) are executed at the end of update() so that all values can be buffered for single execution. More...
 

Static Protected Attributes

static const unsigned int numberOfMouseButtons_ = MouseButtonCode::numberOfButtons + 4
 Number of mouse buttons in KeyBinder (+4) More...
 

Private Member Functions

void addButtonToCommand (const std::string &command, Button *button)
 

Private Attributes

float analogThreshold_
 Threshold for analog triggers until which the state is 0. More...
 
bool bDeriveMouseInput_
 Derive mouse input for absolute values? More...
 
bool bFilterAnalogNoise_
 Whether to filter small value analog input. More...
 
float buttonThreshold_
 Threshold for analog triggers until which the button is not pressed. More...
 
float derivePeriod_
 Accuracy of the mouse input deriver. The higher the more precise, but laggier. More...
 
float mouseSensitivity_
 mouse sensitivity More...
 
float mouseSensitivityDerived_
 mouse sensitivity if mouse input is derived More...
 
int mouseWheelStepSize_
 Equals one step of the mouse wheel. More...
 
float totalMouseSensitivity_
 Multiplication of mouse sensitivity and clipping size. More...
 

Static Private Attributes

static const int mouseClippingSize_ = 1024
 

Additional Inherited Members

- Static Public Attributes inherited from orxonox::InputHandler
static InputHandler EMPTY
 Use this input handler if you want to occupy a device in an input state. More...
 

Detailed Description

Maps mouse, keyboard and joy stick input to command strings and executes them.

The bindings are stored in ini-files (like the one for configValues) in the config Path.

Remarks
You cannot change the filename because the KeyBinderManager maps these filenames to the KeyBinders. If you need to load other bindings, just create a new one.

Constructor & Destructor Documentation

orxonox::KeyBinder::KeyBinder ( const std::string &  filename)

Constructor that does as little as necessary.

orxonox::KeyBinder::~KeyBinder ( )
virtual

Destructor.

Member Function Documentation

void orxonox::KeyBinder::addButtonToCommand ( const std::string &  command,
Button button 
)
private
void orxonox::KeyBinder::allDevicesUpdated ( float  dt)
inlineoverrideprotectedvirtual

Reimplemented from orxonox::InputHandler.

void orxonox::KeyBinder::axisMoved ( unsigned int  device,
unsigned int  axis,
float  value 
)
overrideprotectedvirtual

Reimplemented from orxonox::InputHandler.

void orxonox::KeyBinder::buttonHeld ( const KeyEvent evt)
inlineoverrideprotectedvirtual

Reimplemented from orxonox::InputHandler.

void orxonox::KeyBinder::buttonHeld ( MouseButtonCode::ByEnum  button)
inlineoverrideprotectedvirtual

Reimplemented from orxonox::InputHandler.

void orxonox::KeyBinder::buttonHeld ( unsigned int  device,
JoyStickButtonCode::ByEnum  button 
)
inlineoverrideprotectedvirtual

Reimplemented from orxonox::InputHandler.

void orxonox::KeyBinder::buttonPressed ( const KeyEvent evt)
inlineoverrideprotectedvirtual

Reimplemented from orxonox::InputHandler.

void orxonox::KeyBinder::buttonPressed ( MouseButtonCode::ByEnum  button)
inlineoverrideprotectedvirtual

Reimplemented from orxonox::InputHandler.

void orxonox::KeyBinder::buttonPressed ( unsigned int  device,
JoyStickButtonCode::ByEnum  button 
)
inlineoverrideprotectedvirtual

Reimplemented from orxonox::InputHandler.

void orxonox::KeyBinder::buttonReleased ( const KeyEvent evt)
inlineoverrideprotectedvirtual

Reimplemented from orxonox::InputHandler.

void orxonox::KeyBinder::buttonReleased ( MouseButtonCode::ByEnum  button)
inlineoverrideprotectedvirtual

Reimplemented from orxonox::InputHandler.

void orxonox::KeyBinder::buttonReleased ( unsigned int  device,
JoyStickButtonCode::ByEnum  button 
)
inlineoverrideprotectedvirtual

Reimplemented from orxonox::InputHandler.

void orxonox::KeyBinder::buttonThresholdChanged ( )
protected
void orxonox::KeyBinder::changeMode ( ConsoleCommand command,
KeybindMode::Value  mode 
)

Changes the keybind mode of a given console command.

void orxonox::KeyBinder::clearBindings ( )

Overwrites all bindings with "".

void orxonox::KeyBinder::compilePointerLists ( )
protected
std::string orxonox::KeyBinder::getBinding ( const std::string &  commandName)

Return the first key name for a specific command.

std::string orxonox::KeyBinder::getBinding ( const std::string &  commandName,
unsigned int  index 
)

Return the key name for a specific command at a given index.

Parameters
commandNameThe command name the key name is returned for.
indexThe index at which the key name is returned for.
std::string orxonox::KeyBinder::getBindingReadable ( const std::string &  commandName)

Return the first key name for a specific command in a human readable form.

const std::string& orxonox::KeyBinder::getBindingsFilename ( )
inline
unsigned int orxonox::KeyBinder::getNumberOfBindings ( const std::string &  commandName)

Get the number of different key bindings of a specific command.

Parameters
commandNameThe command.
void orxonox::KeyBinder::initialiseJoyStickBindings ( )
protected
void orxonox::KeyBinder::JoyStickQuantityChanged ( const std::vector< JoyStick * > &  joyStickList)
overrideprotectedvirtual

Called whenever joy sticks get added/removed.

Implements orxonox::JoyStickQuantityListener.

Reimplemented in orxonox::KeyDetector.

void orxonox::KeyBinder::joyStickUpdated ( unsigned int  joyStick,
float  dt 
)
overrideprotectedvirtual

Reimplemented from orxonox::InputHandler.

void orxonox::KeyBinder::loadBindings ( )
protected

Loads the key and button bindings.

void orxonox::KeyBinder::mouseMoved ( IntVector2  abs_,
IntVector2  rel_,
IntVector2  clippingSize 
)
overrideprotectedvirtual

Event handler for the mouseMoved Event.

Parameters
abs_The absolute position of the mouse
rel_The relative movement of the mouse
clippingSizeMouse screen area in pixels (usually 1024x1024)

Reimplemented from orxonox::InputHandler.

void orxonox::KeyBinder::mouseScrolled ( int  abs,
int  rel 
)
overrideprotectedvirtual

Event handler for the mouseScrolled Event.

Parameters
absThe absolute position of the scroll wheel
relThe relative movement of the scroll wheel

Reimplemented from orxonox::InputHandler.

void orxonox::KeyBinder::mouseUpdated ( float  dt)
overrideprotectedvirtual

Reimplemented from orxonox::InputHandler.

void orxonox::KeyBinder::resetJoyStickAxes ( )
void orxonox::KeyBinder::resetMouseAxes ( )

Sets the position of the mouse back to 0/0.

bool orxonox::KeyBinder::setBinding ( const std::string &  binding,
const std::string &  name,
bool  bTemporary = false 
)
void orxonox::KeyBinder::setConfigValues ( void  )

Loader for the key bindings, managed by config values.

void orxonox::KeyBinder::tickHalfAxis ( HalfAxis halfAxis)
protected

Member Data Documentation

std::map<std::string, Button*> orxonox::KeyBinder::allButtons_
protected

Pointer map with all Buttons, including half axes.

std::map< std::string, std::vector<std::string> > orxonox::KeyBinder::allCommands_
protected

Maps input commands to all Button names, including half axes.

std::vector<HalfAxis*> orxonox::KeyBinder::allHalfAxes_
protected

Pointer list with all half axes.

float orxonox::KeyBinder::analogThreshold_
private

Threshold for analog triggers until which the state is 0.

bool orxonox::KeyBinder::bDeriveMouseInput_
private

Derive mouse input for absolute values?

bool orxonox::KeyBinder::bFilterAnalogNoise_
private

Whether to filter small value analog input.

float orxonox::KeyBinder::buttonThreshold_
private

Threshold for analog triggers until which the button is not pressed.

ConfigFile* orxonox::KeyBinder::configFile_
protected

Config file used. nullptr in case of KeyDetector. Also indicates whether we've already loaded.

float orxonox::KeyBinder::derivePeriod_
private

Accuracy of the mouse input deriver. The higher the more precise, but laggier.

float orxonox::KeyBinder::deriveTime_
protected
ConfigFile* orxonox::KeyBinder::fallbackConfigFile_
protected

Config file from the data directory that only serves as fallback.

const std::string orxonox::KeyBinder::filename_
protected

Name of the file used in this KeyBinder (constant!)

std::vector<std::shared_ptr<JoyStickAxisVector> > orxonox::KeyBinder::joyStickAxes_
protected

Actual key bindings for joy stick axes (and sliders)

std::vector<std::shared_ptr<JoyStickButtonVector> > orxonox::KeyBinder::joyStickButtons_
protected

Actual key bindings for joy stick buttons.

std::vector<JoyStick*> orxonox::KeyBinder::joySticks_
protected

Currently active joy sticks.

Button orxonox::KeyBinder::keys_[KeyCode::numberOfKeys]
protected

Actual key bindings for keys on the keyboard.

HalfAxis orxonox::KeyBinder::mouseAxes_[MouseAxisCode::numberOfAxes *2]
protected

Actual key bindings for mouse axes.

Button orxonox::KeyBinder::mouseButtons_[numberOfMouseButtons_]
protected

Actual key bindings for mouse buttons including the wheel(s)

const int orxonox::KeyBinder::mouseClippingSize_ = 1024
staticprivate
float orxonox::KeyBinder::mousePosition_[2]
protected

Keeps track of the absolute mouse value.

int orxonox::KeyBinder::mouseRelative_[2]
protected

Used to derive mouse input if requested.

float orxonox::KeyBinder::mouseSensitivity_
private

mouse sensitivity

float orxonox::KeyBinder::mouseSensitivityDerived_
private

mouse sensitivity if mouse input is derived

int orxonox::KeyBinder::mouseWheelStepSize_
private

Equals one step of the mouse wheel.

const unsigned int orxonox::KeyBinder::numberOfMouseButtons_ = MouseButtonCode::numberOfButtons + 4
staticprotected

Number of mouse buttons in KeyBinder (+4)

std::vector<BufferedParamCommand*> orxonox::KeyBinder::paramCommandBuffer_
protected

Commands that have additional parameters (axes) are executed at the end of update() so that all values can be buffered for single execution.

float orxonox::KeyBinder::totalMouseSensitivity_
private

Multiplication of mouse sensitivity and clipping size.


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