RigsofRods
Soft-body Physics Simulation
|
Manages controller configuration, evaluates input events. More...
#include <InputEngine.h>
Public Types | |
typedef std::vector< event_trigger_t > | TriggerVec |
typedef std::map< int, TriggerVec > | EventMap |
Public Member Functions | |
InputEngine () | |
~InputEngine () | |
Setup | |
void | SetKeyboardListener (OIS::KeyListener *obj) |
OIS::Keyboard * | GetOisKeyboard () |
void | SetMouseListener (OIS::MouseListener *obj) |
void | SetJoystickListener (OIS::JoyStickListener *obj) |
void | destroy () |
Input processing | |
void | Capture () |
void | updateKeyBounces (float dt) |
void | ProcessMouseEvent (const OIS::MouseEvent &arg) |
void | ProcessKeyPress (const OIS::KeyEvent &arg) |
void | ProcessKeyRelease (const OIS::KeyEvent &arg) |
void | ProcessJoystickEvent (const OIS::JoyStickEvent &arg) |
void | resetKeys () |
void | setEventSimulatedValue (events eventID, float value) |
void | setEventStatusSupressed (events eventID, bool supress) |
Event info | |
Ogre::String | getKeyForCommand (int eventID) |
Ogre::String | getModifierKeyName (OIS::KeyCode key) |
Ogre::String | getDeviceName (event_trigger_t const &evt) |
Ogre::String | getEventCommand (int eventID) |
std::string | getEventCommandTrimmed (int eventID) |
Omits 'EXPL' modifier. More... | |
Ogre::String | getTriggerCommand (event_trigger_t const &evt) |
Ogre::String | getEventConfig (int eventID) |
Ogre::String | getEventDefaultConfig (int eventID) |
bool | isEventDefined (int eventID) |
int | getKeboardKeyForCommand (int eventID) |
Returns -1 if not Keyboard. More... | |
int | getJoyComponentCount (OIS::ComponentType type, int joystickNumber) |
std::string | getJoyVendor (int joystickNumber) |
int | getNumJoysticks () |
EventMap & | getEvents () |
Event config files | |
bool | loadConfigFile (int deviceID=-1) |
Loads config file specific to a device and OS (or default config if deviceID is -1). More... | |
bool | saveConfigFile (int deviceID=-1) |
Wites events with matching deviceID to loaded file with matching deviceID (or default file if deviceID is -1). More... | |
std::string const & | getLoadedConfigFile (int deviceID=-1) |
Returns filename from loadConfigFile() call. More... | |
bool | processLine (const char *line, int deviceID=-1) |
bool | updateConfigline (event_trigger_t *t) |
Event management | |
void | addEvent (int eventID, event_trigger_t &t) |
Registers new trigger for this event. More... | |
void | addEvent (int eventID) |
Registers new event without trigger. More... | |
void | addEventDefault (int eventID, int deviceID=-1) |
Adds a new trigger with builtin value for this event. More... | |
void | updateEvent (int eventID, const event_trigger_t &t) |
void | eraseEvent (int eventID, const event_trigger_t *t) |
void | clearEvents (int eventID) |
Clears all bindings for given event. More... | |
void | clearEventsByDevice (int deviceID) |
Clears all bindings with given deviceID (-1 is no exception). More... | |
void | clearAllEvents () |
Purges all configured bindings. More... | |
Event states | |
float | getEventValue (int eventID, bool pure=false, InputSourceType valueSource=InputSourceType::IST_ANY) |
valueSource: IST_ANY=digital and analog devices, IST_DIGITAL=only digital, IST_ANALOG=only analog More... | |
bool | getEventBoolValue (int eventID) |
bool | isEventAnalog (int eventID) |
bool | getEventBoolValueBounce (int eventID, float time=0.2f) |
float | getEventBounceTime (int eventID) |
bool | isKeyDownEffective (OIS::KeyCode mod) |
Reads RoR internal buffer. More... | |
bool | isKeyDownValueBounce (OIS::KeyCode mod, float time=0.2f) |
Direct input device states | |
OIS::JoyStickState * | getCurrentJoyState (int joystickNumber) |
OIS::MouseState | getMouseState () |
bool | isKeyDown (OIS::KeyCode mod) |
Asks OIS directly. More... | |
int | getCurrentKeyCombo (Ogre::String *combo) |
Returns number of non-modifier keys pressed (or modifier count as negative number). More... | |
int | getCurrentJoyButton (int &joystickNumber, int &button) |
int | getCurrentPovValue (int &joystickNumber, int &pov, int &povdir) |
Ogre::Vector2 | getMouseNormalizedScreenPos () |
Returns XY position in range from 0 (top/left) to 1 (bottom/right) More... | |
Misc | |
void | windowResized (Ogre::RenderWindow *rw) |
OIS::ForceFeedback * | getForceFeedbackDevice () |
Static Public Attributes | |
static const std::string | DEFAULT_MAPFILE = "input.map" |
= "input.map"; More... | |
static const int | DEFAULT_MAPFILE_DEVICEID = -1 |
virtual device ID for "input.map" entries More... | |
static const int | BUILTIN_MAPPING_DEVICEID = -2 |
virtual device ID for builtin defaults More... | |
Protected Member Functions | |
bool | loadMapping (Ogre::String fileName, int deviceID) |
bool | saveMapping (Ogre::String fileName, int deviceID) |
void | completeMissingEvents () |
void | initAllKeys () |
void | setup () |
float | deadZone (float axis, float dz) |
float | axisLinearity (float axisValue, float linearity) |
float | logval (float val) |
std::string | getEventGroup (Ogre::String eventName) |
std::string | composeEventConfigString (event_trigger_t const &trig) |
std::string | composeEventCommandString (event_trigger_t const &trig) |
event_trigger_t | newEvent () |
Protected Attributes | |
OIS::InputManager * | mInputManager |
OIS::Mouse * | mMouse |
OIS::Keyboard * | mKeyboard |
OIS::JoyStick * | mJoy [MAX_JOYSTICKS] |
int | free_joysticks |
Number of detected game controllers. More... | |
OIS::ForceFeedback * | mForceFeedback |
int | uniqueCounter |
std::map< int, bool > | keyState |
OIS::JoyStickState | joyState [MAX_JOYSTICKS] |
OIS::MouseState | mouseState |
std::map< int, std::vector< event_trigger_t > > | events |
std::map< int, float > | event_values_simulated |
std::map< int, float > | event_times |
std::map< int, bool > | event_states_supressed |
std::string | m_loaded_configs [MAX_JOYSTICKS] |
std::map< std::string, OIS::KeyCode > | allkeys |
std::map< std::string, OIS::KeyCode >::iterator | allit |
Event utils | |
std::string | getKeyNameForKeyCode (OIS::KeyCode keycode) |
static const char * | getEventTypeName (eventtypes type) |
Enum to string helper. More... | |
static int | resolveEventName (Ogre::String eventName) |
static Ogre::String | eventIDToName (int eventID) |
static Ogre::String | eventIDToDescription (int eventID) |
Manages controller configuration, evaluates input events.
Definition at line 458 of file InputEngine.h.
typedef std::map<int, TriggerVec> RoR::InputEngine::EventMap |
Definition at line 462 of file InputEngine.h.
typedef std::vector<event_trigger_t> RoR::InputEngine::TriggerVec |
Definition at line 461 of file InputEngine.h.
InputEngine::InputEngine | ( | ) |
InputEngine::~InputEngine | ( | ) |
void InputEngine::addEvent | ( | int | eventID | ) |
Registers new event without trigger.
Definition at line 1203 of file InputEngine.cpp.
void InputEngine::addEvent | ( | int | eventID, |
event_trigger_t & | t | ||
) |
Registers new trigger for this event.
Definition at line 1197 of file InputEngine.cpp.
void InputEngine::addEventDefault | ( | int | eventID, |
int | deviceID = -1 |
||
) |
Adds a new trigger with builtin value for this event.
Definition at line 1218 of file InputEngine.cpp.
|
protected |
void InputEngine::Capture | ( | ) |
void InputEngine::clearAllEvents | ( | ) |
Purges all configured bindings.
Definition at line 1283 of file InputEngine.cpp.
void InputEngine::clearEvents | ( | int | eventID | ) |
Clears all bindings for given event.
Definition at line 1257 of file InputEngine.cpp.
void InputEngine::clearEventsByDevice | ( | int | deviceID | ) |
Clears all bindings with given deviceID (-1 is no exception).
Definition at line 1265 of file InputEngine.cpp.
|
protected |
Definition at line 1834 of file InputEngine.cpp.
|
protected |
Definition at line 822 of file InputEngine.cpp.
|
protected |
Definition at line 844 of file InputEngine.cpp.
|
protected |
void InputEngine::destroy | ( | ) |
void InputEngine::eraseEvent | ( | int | eventID, |
const event_trigger_t * | t | ||
) |
|
static |
Definition at line 2025 of file InputEngine.cpp.
|
static |
int InputEngine::getCurrentJoyButton | ( | int & | joystickNumber, |
int & | button | ||
) |
Definition at line 1629 of file InputEngine.cpp.
JoyStickState * InputEngine::getCurrentJoyState | ( | int | joystickNumber | ) |
Definition at line 1694 of file InputEngine.cpp.
int InputEngine::getCurrentKeyCombo | ( | Ogre::String * | combo | ) |
Returns number of non-modifier keys pressed (or modifier count as negative number).
Definition at line 1701 of file InputEngine.cpp.
int InputEngine::getCurrentPovValue | ( | int & | joystickNumber, |
int & | pov, | ||
int & | povdir | ||
) |
Definition at line 1646 of file InputEngine.cpp.
String InputEngine::getDeviceName | ( | event_trigger_t const & | evt | ) |
bool InputEngine::getEventBoolValue | ( | int | eventID | ) |
Definition at line 714 of file InputEngine.cpp.
bool InputEngine::getEventBoolValueBounce | ( | int | eventID, |
float | time = 0.2f |
||
) |
Definition at line 719 of file InputEngine.cpp.
float InputEngine::getEventBounceTime | ( | int | eventID | ) |
String InputEngine::getEventCommand | ( | int | eventID | ) |
Definition at line 777 of file InputEngine.cpp.
std::string InputEngine::getEventCommandTrimmed | ( | int | eventID | ) |
Omits 'EXPL' modifier.
Definition at line 788 of file InputEngine.cpp.
String InputEngine::getEventConfig | ( | int | eventID | ) |
String InputEngine::getEventDefaultConfig | ( | int | eventID | ) |
|
protected |
|
inline |
|
static |
Enum to string helper.
Definition at line 1177 of file InputEngine.cpp.
float InputEngine::getEventValue | ( | int | eventID, |
bool | pure = false , |
||
InputSourceType | valueSource = InputSourceType::IST_ANY |
||
) |
valueSource: IST_ANY=digital and analog devices, IST_DIGITAL=only digital, IST_ANALOG=only analog
Definition at line 915 of file InputEngine.cpp.
|
inline |
int InputEngine::getJoyComponentCount | ( | OIS::ComponentType | type, |
int | joystickNumber | ||
) |
Definition at line 1680 of file InputEngine.cpp.
std::string InputEngine::getJoyVendor | ( | int | joystickNumber | ) |
int InputEngine::getKeboardKeyForCommand | ( | int | eventID | ) |
Returns -1 if not Keyboard.
Definition at line 876 of file InputEngine.cpp.
String InputEngine::getKeyForCommand | ( | int | eventID | ) |
String InputEngine::getKeyNameForKeyCode | ( | OIS::KeyCode | keycode | ) |
std::string const & InputEngine::getLoadedConfigFile | ( | int | deviceID = -1 | ) |
Returns filename from loadConfigFile()
call.
Definition at line 1905 of file InputEngine.cpp.
Ogre::String InputEngine::getModifierKeyName | ( | OIS::KeyCode | key | ) |
Ogre::Vector2 InputEngine::getMouseNormalizedScreenPos | ( | ) |
Returns XY position in range from 0 (top/left) to 1 (bottom/right)
Definition at line 1664 of file InputEngine.cpp.
OIS::MouseState InputEngine::getMouseState | ( | ) |
|
inline |
Definition at line 507 of file InputEngine.h.
|
inline |
String InputEngine::getTriggerCommand | ( | event_trigger_t const & | evt | ) |
|
protected |
bool InputEngine::isEventAnalog | ( | int | eventID | ) |
Definition at line 888 of file InputEngine.cpp.
bool InputEngine::isEventDefined | ( | int | eventID | ) |
bool InputEngine::isKeyDown | ( | OIS::KeyCode | mod | ) |
Asks OIS directly.
Definition at line 1127 of file InputEngine.cpp.
bool InputEngine::isKeyDownEffective | ( | OIS::KeyCode | mod | ) |
Reads RoR internal buffer.
Definition at line 1134 of file InputEngine.cpp.
bool InputEngine::isKeyDownValueBounce | ( | OIS::KeyCode | mod, |
float | time = 0.2f |
||
) |
bool InputEngine::loadConfigFile | ( | int | deviceID = -1 | ) |
Loads config file specific to a device and OS (or default config if deviceID is -1).
Definition at line 1851 of file InputEngine.cpp.
|
protected |
Definition at line 1914 of file InputEngine.cpp.
|
protected |
Definition at line 768 of file InputEngine.cpp.
|
protected |
void InputEngine::ProcessJoystickEvent | ( | const OIS::JoyStickEvent & | arg | ) |
void InputEngine::ProcessKeyPress | ( | const OIS::KeyEvent & | arg | ) |
void InputEngine::ProcessKeyRelease | ( | const OIS::KeyEvent & | arg | ) |
bool InputEngine::processLine | ( | const char * | line, |
int | deviceID = -1 |
||
) |
Definition at line 1289 of file InputEngine.cpp.
void InputEngine::ProcessMouseEvent | ( | const OIS::MouseEvent & | arg | ) |
void InputEngine::resetKeys | ( | ) |
|
static |
bool InputEngine::saveConfigFile | ( | int | deviceID = -1 | ) |
Wites events with matching deviceID to loaded file with matching deviceID (or default file if deviceID is -1).
Definition at line 1895 of file InputEngine.cpp.
|
protected |
Definition at line 1948 of file InputEngine.cpp.
void InputEngine::setEventSimulatedValue | ( | RoR::events | eventID, |
float | value | ||
) |
Definition at line 704 of file InputEngine.cpp.
void InputEngine::setEventStatusSupressed | ( | RoR::events | eventID, |
bool | supress | ||
) |
Definition at line 709 of file InputEngine.cpp.
void InputEngine::SetJoystickListener | ( | OIS::JoyStickListener * | obj | ) |
void InputEngine::SetKeyboardListener | ( | OIS::KeyListener * | obj | ) |
void InputEngine::SetMouseListener | ( | OIS::MouseListener * | obj | ) |
|
protected |
Definition at line 470 of file InputEngine.cpp.
bool InputEngine::updateConfigline | ( | event_trigger_t * | t | ) |
Definition at line 1766 of file InputEngine.cpp.
void InputEngine::updateEvent | ( | int | eventID, |
const event_trigger_t & | t | ||
) |
Definition at line 1228 of file InputEngine.cpp.
void InputEngine::updateKeyBounces | ( | float | dt | ) |
void InputEngine::windowResized | ( | Ogre::RenderWindow * | rw | ) |
|
protected |
Definition at line 599 of file InputEngine.h.
|
protected |
Definition at line 598 of file InputEngine.h.
|
static |
virtual device ID for builtin defaults
Definition at line 466 of file InputEngine.h.
|
static |
= "input.map";
Definition at line 464 of file InputEngine.h.
|
static |
virtual device ID for "input.map" entries
Definition at line 465 of file InputEngine.h.
|
protected |
Definition at line 590 of file InputEngine.h.
|
protected |
Definition at line 589 of file InputEngine.h.
|
protected |
Definition at line 588 of file InputEngine.h.
|
protected |
Definition at line 587 of file InputEngine.h.
|
protected |
Number of detected game controllers.
Definition at line 577 of file InputEngine.h.
|
protected |
Definition at line 583 of file InputEngine.h.
|
protected |
Definition at line 582 of file InputEngine.h.
|
protected |
Definition at line 591 of file InputEngine.h.
|
protected |
Definition at line 578 of file InputEngine.h.
|
protected |
Definition at line 567 of file InputEngine.h.
|
protected |
Definition at line 576 of file InputEngine.h.
|
protected |
Definition at line 575 of file InputEngine.h.
|
protected |
Definition at line 574 of file InputEngine.h.
|
protected |
Definition at line 584 of file InputEngine.h.
|
protected |
Definition at line 579 of file InputEngine.h.