#include <src/core/input/KeyBinder.h>
Public Member Functions | |
void | clearBindings () |
Overwrites all bindings with "". | |
KeyBinder () | |
Constructor that does as little as necessary. | |
void | loadBindings (const std::string &filename) |
Loads the key and button bindings. | |
void | resetJoyStickAxes () |
bool | setBinding (const std::string &binding, const std::string &name, bool bTemporary=false) |
void | setConfigValues () |
Loader for the key bindings, managed by config values. | |
virtual | ~KeyBinder () |
Destructor. | |
Protected Member Functions | |
void | buttonThresholdChanged () |
void | compilePointerLists () |
void | initialiseJoyStickBindings () |
void | joyStickAxisMoved (unsigned int joyStickID, unsigned int axis, float value) |
void | joyStickButtonHeld (unsigned int joyStickID, JoyStickButtonCode::ByEnum id) |
void | joyStickButtonPressed (unsigned int joyStickID, JoyStickButtonCode::ByEnum id) |
void | joyStickButtonReleased (unsigned int joyStickID, JoyStickButtonCode::ByEnum id) |
virtual void | JoyStickDeviceNumberChanged (unsigned int value) |
void | keyHeld (const KeyEvent &evt) |
void | keyPressed (const KeyEvent &evt) |
void | keyReleased (const KeyEvent &evt) |
void | mouseButtonHeld (MouseButtonCode::ByEnum id) |
void | mouseButtonPressed (MouseButtonCode::ByEnum id) |
void | mouseButtonReleased (MouseButtonCode::ByEnum id) |
void | mouseMoved (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) |
Event handler for the mouseMoved Event. | |
void | mouseScrolled (int abs, int rel) |
Event handler for the mouseScrolled Event. | |
void | tickHalfAxis (HalfAxis &halfAxis) |
void | updateInput (float dt) |
void | updateJoyStick (float dt, unsigned int joyStick) |
void | updateKey (float dt) |
void | updateMouse (float dt) |
Protected Attributes | |
std::map< std::string, Button * > | allButtons_ |
Pointer map with all Buttons, including half axes. | |
std::vector< HalfAxis * > | allHalfAxes_ |
Pointer list with all half axes. | |
ConfigFileType | configFile_ |
Config file used. ConfigFileType::NoType in case of KeyDetector. Also indicates whether we've already loaded. | |
float | deriveTime_ |
std::vector< JoyStickAxisVector > | joyStickAxes_ |
Actual key bindings for joy stick axes (and sliders). | |
std::vector< JoyStickButtonVector > | joyStickButtons_ |
Actual key bindings for joy stick buttons. | |
Button | keys_ [KeyCode::numberOfKeys] |
Actual key bindings for keys on the keyboard. | |
HalfAxis | mouseAxes_ [MouseAxisCode::numberOfAxes *2] |
Actual key bindings for mouse axes. | |
Button | mouseButtons_ [numberOfMouseButtons_] |
Actual key bindings for mouse buttons including the wheel(s). | |
int | mousePosition_ [2] |
Keeps track of the absolute mouse value (incl. scroll wheel). | |
int | mouseRelative_ [2] |
Used to derive mouse input if requested. | |
unsigned int | numberOfJoySticks_ |
Currently active joy sticks. | |
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. | |
Static Protected Attributes | |
static const unsigned int | numberOfMouseButtons_ = MouseButtonCode::numberOfButtons + 4 |
Number of mouse buttons in KeyBinder (+4). | |
Private Attributes | |
float | analogThreshold_ |
Threshold for analog triggers until which the state is 0. | |
bool | bDeriveMouseInput_ |
Derive mouse input for absolute values? | |
bool | bFilterAnalogNoise_ |
Whether to filter small value analog input. | |
float | buttonThreshold_ |
Threshold for analog triggers until which the button is not pressed. | |
float | derivePeriod_ |
Accuracy of the mouse input deriver. The higher the more precise, but laggier. | |
float | mouseSensitivity_ |
mouse sensitivity | |
float | mouseSensitivityDerived_ |
mouse sensitivity if mouse input is derived | |
int | mouseWheelStepSize_ |
Equals one step of the mousewheel. | |
Static Private Attributes | |
static const int | mouseClippingSize_ = 1024 |
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... |
orxonox::KeyBinder::KeyBinder | ( | ) |
Constructor that does as little as necessary.
References orxonox::MouseAxisCode::ByString, orxonox::MouseButtonCode::ByString, orxonox::KeyCode::ByString, compilePointerLists(), configFile_, orxonox::InputManager::getInstance(), orxonox::Button::groupName_, initialiseJoyStickBindings(), keys_, mouseAxes_, mouseButtons_, mousePosition_, mouseRelative_, orxonox::Button::name_, orxonox::ConfigFileType::NoType, orxonox::MouseAxisCode::numberOfAxes, orxonox::MouseButtonCode::numberOfButtons, orxonox::InputManager::numberOfJoySticks(), numberOfJoySticks_, orxonox::KeyCode::numberOfKeys, numberOfMouseButtons_, paramCommandBuffer_, orxonox::Button::paramCommandBuffer_, RegisterRootObject, and setConfigValues().
orxonox::KeyBinder::~KeyBinder | ( | ) | [virtual] |
void orxonox::KeyBinder::buttonThresholdChanged | ( | ) | [protected] |
References allHalfAxes_, and buttonThreshold_.
Referenced by JoyStickDeviceNumberChanged(), and setConfigValues().
void orxonox::KeyBinder::clearBindings | ( | ) |
Overwrites all bindings with "".
References allButtons_, and paramCommandBuffer_.
Referenced by loadBindings(), orxonox::KeyDetector::setCallbackCommand(), and ~KeyBinder().
void orxonox::KeyBinder::compilePointerLists | ( | ) | [protected] |
References allButtons_, allHalfAxes_, joyStickAxes_, joyStickButtons_, keys_, mouseAxes_, mouseButtons_, orxonox::Button::name_, orxonox::JoyStickAxisCode::numberOfAxes, orxonox::MouseAxisCode::numberOfAxes, orxonox::JoyStickButtonCode::numberOfButtons, numberOfJoySticks_, orxonox::KeyCode::numberOfKeys, and numberOfMouseButtons_.
Referenced by JoyStickDeviceNumberChanged(), and KeyBinder().
void orxonox::KeyBinder::initialiseJoyStickBindings | ( | ) | [protected] |
References orxonox::JoyStickAxisCode::ByString, orxonox::JoyStickButtonCode::ByString, joyStickAxes_, joyStickButtons_, orxonox::multi_cast(), orxonox::JoyStickAxisCode::numberOfAxes, orxonox::JoyStickButtonCode::numberOfButtons, numberOfJoySticks_, and paramCommandBuffer_.
Referenced by JoyStickDeviceNumberChanged(), and KeyBinder().
void orxonox::KeyBinder::joyStickAxisMoved | ( | unsigned int | joyStickID, | |
unsigned int | axis, | |||
float | value | |||
) | [protected, virtual] |
void orxonox::KeyBinder::joyStickButtonHeld | ( | unsigned int | joyStickID, | |
JoyStickButtonCode::ByEnum | id | |||
) | [inline, protected, virtual] |
void orxonox::KeyBinder::joyStickButtonPressed | ( | unsigned int | joyStickID, | |
JoyStickButtonCode::ByEnum | id | |||
) | [inline, protected, virtual] |
Implements orxonox::JoyStickHandler.
References joyStickButtons_, and orxonox::KeybindMode::OnPress.
void orxonox::KeyBinder::joyStickButtonReleased | ( | unsigned int | joyStickID, | |
JoyStickButtonCode::ByEnum | id | |||
) | [inline, protected, virtual] |
Implements orxonox::JoyStickHandler.
References joyStickButtons_, and orxonox::KeybindMode::OnRelease.
void orxonox::KeyBinder::JoyStickDeviceNumberChanged | ( | unsigned int | value | ) | [protected, virtual] |
Implements orxonox::JoyStickDeviceNumberListener.
Reimplemented in orxonox::KeyDetector.
References buttonThresholdChanged(), compilePointerLists(), configFile_, initialiseJoyStickBindings(), joyStickAxes_, joyStickButtons_, orxonox::ConfigFileType::NoType, orxonox::JoyStickAxisCode::numberOfAxes, orxonox::JoyStickButtonCode::numberOfButtons, and numberOfJoySticks_.
Referenced by orxonox::KeyDetector::JoyStickDeviceNumberChanged().
void orxonox::KeyBinder::keyHeld | ( | const KeyEvent & | evt | ) | [inline, protected, virtual] |
Implements orxonox::KeyHandler.
References orxonox::Button::execute(), orxonox::KeyEvent::key, keys_, orxonox::Button::name_, and orxonox::KeybindMode::OnHold.
void orxonox::KeyBinder::keyPressed | ( | const KeyEvent & | evt | ) | [inline, protected, virtual] |
Implements orxonox::KeyHandler.
References orxonox::Button::execute(), orxonox::KeyEvent::key, keys_, orxonox::Button::name_, and orxonox::KeybindMode::OnPress.
void orxonox::KeyBinder::keyReleased | ( | const KeyEvent & | evt | ) | [inline, protected, virtual] |
Implements orxonox::KeyHandler.
References orxonox::Button::execute(), orxonox::KeyEvent::key, keys_, orxonox::Button::name_, and orxonox::KeybindMode::OnRelease.
void orxonox::KeyBinder::loadBindings | ( | const std::string & | filename | ) |
Loads the key and button bindings.
References allButtons_, clearBindings(), configFile_, COUT, orxonox::ConfigFileManager::getInstance(), orxonox::ConfigFileManager::getNewConfigFileType(), orxonox::ConfigFileType::NoType, and orxonox::ConfigFileManager::setFilename().
void orxonox::KeyBinder::mouseButtonHeld | ( | MouseButtonCode::ByEnum | id | ) | [inline, protected, virtual] |
Implements orxonox::MouseHandler.
References orxonox::Button::execute(), mouseButtons_, and orxonox::KeybindMode::OnHold.
void orxonox::KeyBinder::mouseButtonPressed | ( | MouseButtonCode::ByEnum | id | ) | [inline, protected, virtual] |
Implements orxonox::MouseHandler.
References orxonox::Button::execute(), mouseButtons_, and orxonox::KeybindMode::OnPress.
void orxonox::KeyBinder::mouseButtonReleased | ( | MouseButtonCode::ByEnum | id | ) | [inline, protected, virtual] |
Implements orxonox::MouseHandler.
References orxonox::Button::execute(), mouseButtons_, and orxonox::KeybindMode::OnRelease.
void orxonox::KeyBinder::mouseMoved | ( | IntVector2 | abs_, | |
IntVector2 | rel_, | |||
IntVector2 | clippingSize | |||
) | [protected, virtual] |
Event handler for the mouseMoved Event.
e | Mouse state information |
Implements orxonox::MouseHandler.
References orxonox::HalfAxis::absVal_, bDeriveMouseInput_, orxonox::HalfAxis::hasChanged_, mouseAxes_, mouseClippingSize_, mousePosition_, mouseRelative_, mouseSensitivity_, orxonox::HalfAxis::relVal_, orxonox::IntVector2::x, and orxonox::IntVector2::y.
void orxonox::KeyBinder::mouseScrolled | ( | int | abs, | |
int | rel | |||
) | [protected, virtual] |
Event handler for the mouseScrolled Event.
e | Mouse state information |
Implements orxonox::MouseHandler.
References mouseButtons_, mouseWheelStepSize_, and orxonox::KeybindMode::OnPress.
void orxonox::KeyBinder::resetJoyStickAxes | ( | ) |
References joyStickAxes_, orxonox::JoyStickAxisCode::numberOfAxes, and numberOfJoySticks_.
bool orxonox::KeyBinder::setBinding | ( | const std::string & | binding, | |
const std::string & | name, | |||
bool | bTemporary = false | |||
) |
void orxonox::KeyBinder::setConfigValues | ( | ) |
Loader for the key bindings, managed by config values.
Reimplemented from orxonox::OrxonoxClass.
References analogThreshold_, bDeriveMouseInput_, bFilterAnalogNoise_, buttonThreshold_, buttonThresholdChanged(), derivePeriod_, mouseSensitivity_, mouseSensitivityDerived_, mouseWheelStepSize_, and SetConfigValue.
Referenced by KeyBinder().
void orxonox::KeyBinder::tickHalfAxis | ( | HalfAxis & | halfAxis | ) | [protected] |
References orxonox::HalfAxis::absVal_, analogThreshold_, bFilterAnalogNoise_, orxonox::Button::buttonThreshold_, orxonox::HalfAxis::execute(), orxonox::HalfAxis::hasChanged_, orxonox::Button::nCommands_, orxonox::KeybindMode::OnHold, orxonox::KeybindMode::OnPress, orxonox::KeybindMode::OnRelease, orxonox::HalfAxis::pressed_, and orxonox::HalfAxis::relVal_.
Referenced by updateJoyStick(), and updateMouse().
void orxonox::KeyBinder::updateInput | ( | float | dt | ) | [inline, protected, virtual] |
Implements orxonox::InputHandler.
References mouseAxes_, orxonox::MouseAxisCode::numberOfAxes, and paramCommandBuffer_.
void orxonox::KeyBinder::updateJoyStick | ( | float | dt, | |
unsigned int | joyStick | |||
) | [protected, virtual] |
Implements orxonox::JoyStickHandler.
References joyStickAxes_, orxonox::JoyStickAxisCode::numberOfAxes, and tickHalfAxis().
void orxonox::KeyBinder::updateKey | ( | float | dt | ) | [inline, protected, virtual] |
Implements orxonox::KeyHandler.
void orxonox::KeyBinder::updateMouse | ( | float | dt | ) | [protected, virtual] |
std::map<std::string, Button*> orxonox::KeyBinder::allButtons_ [protected] |
Pointer map with all Buttons, including half axes.
Referenced by clearBindings(), compilePointerLists(), loadBindings(), setBinding(), and orxonox::KeyDetector::setCallbackCommand().
std::vector<HalfAxis*> orxonox::KeyBinder::allHalfAxes_ [protected] |
float orxonox::KeyBinder::analogThreshold_ [private] |
Threshold for analog triggers until which the state is 0.
Referenced by setConfigValues(), and tickHalfAxis().
bool orxonox::KeyBinder::bDeriveMouseInput_ [private] |
Derive mouse input for absolute values?
Referenced by mouseMoved(), setConfigValues(), and updateMouse().
bool orxonox::KeyBinder::bFilterAnalogNoise_ [private] |
float orxonox::KeyBinder::buttonThreshold_ [private] |
Threshold for analog triggers until which the button is not pressed.
Referenced by buttonThresholdChanged(), and setConfigValues().
ConfigFileType orxonox::KeyBinder::configFile_ [protected] |
Config file used. ConfigFileType::NoType in case of KeyDetector. Also indicates whether we've already loaded.
Referenced by JoyStickDeviceNumberChanged(), KeyBinder(), and loadBindings().
float orxonox::KeyBinder::derivePeriod_ [private] |
Accuracy of the mouse input deriver. The higher the more precise, but laggier.
Referenced by setConfigValues(), and updateMouse().
float orxonox::KeyBinder::deriveTime_ [protected] |
Referenced by updateMouse().
std::vector<JoyStickAxisVector> orxonox::KeyBinder::joyStickAxes_ [protected] |
Actual key bindings for joy stick axes (and sliders).
Referenced by compilePointerLists(), initialiseJoyStickBindings(), joyStickAxisMoved(), JoyStickDeviceNumberChanged(), resetJoyStickAxes(), and updateJoyStick().
std::vector<JoyStickButtonVector> orxonox::KeyBinder::joyStickButtons_ [protected] |
Actual key bindings for joy stick buttons.
Referenced by compilePointerLists(), initialiseJoyStickBindings(), joyStickButtonHeld(), joyStickButtonPressed(), joyStickButtonReleased(), and JoyStickDeviceNumberChanged().
Button orxonox::KeyBinder::keys_[KeyCode::numberOfKeys] [protected] |
Actual key bindings for keys on the keyboard.
Referenced by compilePointerLists(), KeyBinder(), keyHeld(), keyPressed(), and keyReleased().
HalfAxis orxonox::KeyBinder::mouseAxes_[MouseAxisCode::numberOfAxes *2] [protected] |
Actual key bindings for mouse axes.
Referenced by compilePointerLists(), KeyBinder(), mouseMoved(), updateInput(), and updateMouse().
Button orxonox::KeyBinder::mouseButtons_[numberOfMouseButtons_] [protected] |
Actual key bindings for mouse buttons including the wheel(s).
Referenced by compilePointerLists(), KeyBinder(), mouseButtonHeld(), mouseButtonPressed(), mouseButtonReleased(), and mouseScrolled().
const int orxonox::KeyBinder::mouseClippingSize_ = 1024 [static, private] |
Referenced by mouseMoved().
int orxonox::KeyBinder::mousePosition_[2] [protected] |
Keeps track of the absolute mouse value (incl. scroll wheel).
Referenced by KeyBinder(), and mouseMoved().
int orxonox::KeyBinder::mouseRelative_[2] [protected] |
Used to derive mouse input if requested.
Referenced by KeyBinder(), mouseMoved(), and updateMouse().
float orxonox::KeyBinder::mouseSensitivity_ [private] |
float orxonox::KeyBinder::mouseSensitivityDerived_ [private] |
int orxonox::KeyBinder::mouseWheelStepSize_ [private] |
unsigned int orxonox::KeyBinder::numberOfJoySticks_ [protected] |
Currently active joy sticks.
Referenced by compilePointerLists(), initialiseJoyStickBindings(), JoyStickDeviceNumberChanged(), KeyBinder(), and resetJoyStickAxes().
const unsigned int orxonox::KeyBinder::numberOfMouseButtons_ = MouseButtonCode::numberOfButtons + 4 [static, protected] |
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.
Referenced by clearBindings(), initialiseJoyStickBindings(), KeyBinder(), and updateInput().