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 | processMouseMotionEvent (const OIS::MouseEvent &arg) |
void | processMousePressEvent (const OIS::MouseEvent &arg, OIS::MouseButtonID _id) |
void | processMouseReleaseEvent (const OIS::MouseEvent &arg, OIS::MouseButtonID _id) |
void | ProcessKeyPress (const OIS::KeyEvent &arg) |
void | ProcessKeyRelease (const OIS::KeyEvent &arg) |
void | ProcessJoystickEvent (const OIS::JoyStickEvent &arg) |
void | resetKeysAndMouseButtons () |
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 |
size_t | m_oisworkaround_frames_since_reset = 0u |
size_t | m_oisworkaround_lmbdowns_since_reset = 0u |
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 1246 of file InputEngine.cpp.
void InputEngine::addEvent | ( | int | eventID, |
event_trigger_t & | t | ||
) |
Registers new trigger for this event.
Definition at line 1240 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 1261 of file InputEngine.cpp.
|
protected |
void InputEngine::Capture | ( | ) |
void InputEngine::clearAllEvents | ( | ) |
Purges all configured bindings.
Definition at line 1326 of file InputEngine.cpp.
void InputEngine::clearEvents | ( | int | eventID | ) |
Clears all bindings for given event.
Definition at line 1300 of file InputEngine.cpp.
void InputEngine::clearEventsByDevice | ( | int | deviceID | ) |
Clears all bindings with given deviceID (-1 is no exception).
Definition at line 1308 of file InputEngine.cpp.
|
protected |
Definition at line 1877 of file InputEngine.cpp.
|
protected |
Definition at line 865 of file InputEngine.cpp.
|
protected |
Definition at line 887 of file InputEngine.cpp.
|
protected |
void InputEngine::destroy | ( | ) |
void InputEngine::eraseEvent | ( | int | eventID, |
const event_trigger_t * | t | ||
) |
|
static |
Definition at line 2068 of file InputEngine.cpp.
|
static |
int InputEngine::getCurrentJoyButton | ( | int & | joystickNumber, |
int & | button | ||
) |
Definition at line 1672 of file InputEngine.cpp.
JoyStickState * InputEngine::getCurrentJoyState | ( | int | joystickNumber | ) |
Definition at line 1737 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 1744 of file InputEngine.cpp.
int InputEngine::getCurrentPovValue | ( | int & | joystickNumber, |
int & | pov, | ||
int & | povdir | ||
) |
Definition at line 1689 of file InputEngine.cpp.
String InputEngine::getDeviceName | ( | event_trigger_t const & | evt | ) |
bool InputEngine::getEventBoolValue | ( | int | eventID | ) |
Definition at line 757 of file InputEngine.cpp.
bool InputEngine::getEventBoolValueBounce | ( | int | eventID, |
float | time = 0.2f |
||
) |
Definition at line 762 of file InputEngine.cpp.
float InputEngine::getEventBounceTime | ( | int | eventID | ) |
String InputEngine::getEventCommand | ( | int | eventID | ) |
Definition at line 820 of file InputEngine.cpp.
std::string InputEngine::getEventCommandTrimmed | ( | int | eventID | ) |
Omits 'EXPL' modifier.
Definition at line 831 of file InputEngine.cpp.
String InputEngine::getEventConfig | ( | int | eventID | ) |
String InputEngine::getEventDefaultConfig | ( | int | eventID | ) |
|
protected |
|
inline |
|
static |
Enum to string helper.
Definition at line 1220 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 958 of file InputEngine.cpp.
|
inline |
int InputEngine::getJoyComponentCount | ( | OIS::ComponentType | type, |
int | joystickNumber | ||
) |
Definition at line 1723 of file InputEngine.cpp.
std::string InputEngine::getJoyVendor | ( | int | joystickNumber | ) |
int InputEngine::getKeboardKeyForCommand | ( | int | eventID | ) |
Returns -1 if not Keyboard.
Definition at line 919 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 1948 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 1707 of file InputEngine.cpp.
OIS::MouseState InputEngine::getMouseState | ( | ) |
|
inline |
Definition at line 509 of file InputEngine.h.
|
inline |
String InputEngine::getTriggerCommand | ( | event_trigger_t const & | evt | ) |
|
protected |
bool InputEngine::isEventAnalog | ( | int | eventID | ) |
Definition at line 931 of file InputEngine.cpp.
bool InputEngine::isEventDefined | ( | int | eventID | ) |
bool InputEngine::isKeyDown | ( | OIS::KeyCode | mod | ) |
Asks OIS directly.
Definition at line 1170 of file InputEngine.cpp.
bool InputEngine::isKeyDownEffective | ( | OIS::KeyCode | mod | ) |
Reads RoR internal buffer.
Definition at line 1177 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 1894 of file InputEngine.cpp.
|
protected |
Definition at line 1957 of file InputEngine.cpp.
|
protected |
Definition at line 811 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 1332 of file InputEngine.cpp.
void InputEngine::processMouseMotionEvent | ( | const OIS::MouseEvent & | arg | ) |
void InputEngine::processMousePressEvent | ( | const OIS::MouseEvent & | arg, |
OIS::MouseButtonID | _id | ||
) |
void InputEngine::processMouseReleaseEvent | ( | const OIS::MouseEvent & | arg, |
OIS::MouseButtonID | _id | ||
) |
void InputEngine::resetKeysAndMouseButtons | ( | ) |
|
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 1938 of file InputEngine.cpp.
|
protected |
Definition at line 1991 of file InputEngine.cpp.
void InputEngine::setEventSimulatedValue | ( | RoR::events | eventID, |
float | value | ||
) |
Definition at line 747 of file InputEngine.cpp.
void InputEngine::setEventStatusSupressed | ( | RoR::events | eventID, |
bool | supress | ||
) |
Definition at line 752 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 1809 of file InputEngine.cpp.
void InputEngine::updateEvent | ( | int | eventID, |
const event_trigger_t & | t | ||
) |
Definition at line 1271 of file InputEngine.cpp.
void InputEngine::updateKeyBounces | ( | float | dt | ) |
void InputEngine::windowResized | ( | Ogre::RenderWindow * | rw | ) |
|
protected |
Definition at line 601 of file InputEngine.h.
|
protected |
Definition at line 600 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 592 of file InputEngine.h.
|
protected |
Definition at line 591 of file InputEngine.h.
|
protected |
Definition at line 590 of file InputEngine.h.
|
protected |
Definition at line 589 of file InputEngine.h.
|
protected |
Number of detected game controllers.
Definition at line 579 of file InputEngine.h.
|
protected |
Definition at line 585 of file InputEngine.h.
|
protected |
Definition at line 584 of file InputEngine.h.
|
protected |
Definition at line 593 of file InputEngine.h.
|
protected |
Definition at line 617 of file InputEngine.h.
|
protected |
Definition at line 618 of file InputEngine.h.
|
protected |
Definition at line 580 of file InputEngine.h.
|
protected |
Definition at line 569 of file InputEngine.h.
|
protected |
Definition at line 578 of file InputEngine.h.
|
protected |
Definition at line 577 of file InputEngine.h.
|
protected |
Definition at line 576 of file InputEngine.h.
|
protected |
Definition at line 586 of file InputEngine.h.
|
protected |
Definition at line 581 of file InputEngine.h.