Changeset 1637 for code/branches/input/src/core/input/InputManager.h
- Timestamp:
- Jul 20, 2008, 6:49:24 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/input/src/core/input/InputManager.h
r1630 r1637 41 41 #include <map> 42 42 #include <vector> 43 #include <stack> 43 44 #include "util/Math.h" 44 45 #include "core/OrxonoxClass.h" … … 68 69 }; 69 70 70 /**71 @brief72 Struct for storing a custom input state73 */74 struct StoredState75 {76 std::vector<KeyHandler*> activeKeyHandlers_;77 std::vector<MouseHandler*> activeMouseHandlers_;78 std::vector<std::vector<JoyStickHandler*> > activeJoyStickHandlers_;79 std::vector<std::pair<InputTickable*, HandlerState> > activeHandlers_;80 };81 82 71 struct JoyStickCalibration 83 72 { … … 95 84 public OIS::KeyListener, public OIS::MouseListener, public OIS::JoyStickListener 96 85 { 97 public: // enumerations 98 /** 99 @brief 100 Designates the way input is handled and redirected. 101 */ 102 enum InputState 103 { 104 IS_UNINIT, //!< InputManager has not yet been initialised. 105 IS_NONE, //!< Input is discarded. 106 IS_NORMAL, //!< Normal play state. Key and button bindings are active. 107 IS_GUI, //!< All OIS input events are passed to CEGUI. 108 IS_CONSOLE, //!< Keyboard input is redirected to the InputBuffer. 109 IS_DETECT, //!< All the input additionally goes to the KeyDetector 110 IS_NODETECT, //!< remove KeyDetector 111 IS_NOCALIBRATE, 112 IS_CALIBRATE, 113 IS_CUSTOM //!< Any possible configuration. 114 }; 115 116 public: // member functions 117 void setConfigValues(); 86 // --> setConfigValues is private 87 friend ClassIdentifier<InputManager>; 118 88 119 89 public: // static functions … … 139 109 static void setWindowExtents(const int width, const int height); 140 110 141 static void setInputState(const InputState state);142 static InputState getInputState();143 144 111 static void storeKeyStroke(const std::string& name); 145 112 static void keyBind(const std::string& command); … … 149 116 static void tick(float dt); 150 117 151 static bool addKeyHandler (KeyHandler* handler, const std::string& name); 152 static bool removeKeyHandler (const std::string& name); 153 static KeyHandler* getKeyHandler (const std::string& name); 154 static bool enableKeyHandler (const std::string& name); 155 static bool disableKeyHandler (const std::string& name); 156 static bool isKeyHandlerActive (const std::string& name); 157 158 static bool addMouseHandler (MouseHandler* handler, const std::string& name); 159 static bool removeMouseHandler (const std::string& name); 160 static MouseHandler* getMouseHandler (const std::string& name); 161 static bool enableMouseHandler (const std::string& name); 162 static bool disableMouseHandler (const std::string& name); 163 static bool isMouseHandlerActive (const std::string& name); 164 165 static bool addJoyStickHandler (JoyStickHandler* handler, const std::string& name); 166 static bool removeJoyStickHandler (const std::string& name); 167 static JoyStickHandler* getJoyStickHandler(const std::string& name); 168 static bool enableJoyStickHandler (const std::string& name, unsigned int id); 169 static bool disableJoyStickHandler (const std::string& name, unsigned int id); 170 static bool isJoyStickHandlerActive (const std::string& name, unsigned int id); 118 static SimpleInputState* createSimpleInputState (const std::string& name, int priority); 119 static ExtendedInputState* createExtendedInputState(const std::string& name, int priority); 120 static bool destroyState (const std::string& name); 121 //static bool removeState (const std::string& name); 122 static InputState* getState (const std::string& name); 123 static InputState* getCurrentState(); 124 static bool requestEnterState (const std::string& name); 125 static bool requestLeaveState (const std::string& name); 171 126 172 127 private: // functions … … 181 136 bool _initialiseMouse(); 182 137 bool _initialiseJoySticks(); 138 void _redimensionLists(); 183 139 184 140 void _destroy(); … … 186 142 void _destroyMouse(); 187 143 void _destroyJoySticks(); 188 189 void _updateTickables(); 190 191 void _saveState(); 192 void _restoreState(); 144 void _destroyState(InputState* state); 193 145 194 146 void _completeCalibration(); … … 198 150 199 151 void _tick(float dt); 152 153 void _updateActiveStates(); 154 bool _configureInputState(InputState* state, const std::string& name, int priority); 200 155 201 156 // input events … … 210 165 bool sliderMoved (const OIS::JoyStickEvent &arg, int id); 211 166 bool povMoved (const OIS::JoyStickEvent &arg, int id); 212 //bool vector3Moved (const OIS::JoyStickEvent &arg, int id); 213 214 static InputManager& _getSingleton(); 215 static InputManager * _getSingletonPtr() { return &_getSingleton(); }167 168 void setConfigValues(); 169 170 static InputManager& _getInstance(); 216 171 217 172 private: // variables … … 221 176 std::vector<OIS::JoyStick*> joySticks_; //!< OIS joy sticks 222 177 unsigned int joySticksSize_; 223 224 KeyBinder* keyBinder_; //!< KeyBinder instance 225 KeyDetector* keyDetector_; //!< KeyDetector instance 226 InputBuffer* buffer_; //!< InputBuffer instance 227 CalibratorCallback* calibratorCallback_; 228 229 InputState state_; 230 InputState stateRequest_; 231 InputState savedState_; 232 unsigned int keyboardModifiers_; 233 StoredState savedHandlers_; 178 unsigned int devicesNum_; 179 180 // some internally handled states 181 SimpleInputState* stateDetector_; //!< KeyDetector instance 182 SimpleInputState* stateCalibrator_; 183 SimpleInputState* stateEmpty_; 184 185 std::map<std::string, InputState*> inputStatesByName_; 186 std::map<int, InputState*> inputStatesByPriority_; 187 188 std::vector<InputState*> stateEnterRequests_; //!< Request to enter a new state 189 std::vector<InputState*> stateLeaveRequests_; //!< Request to leave the current state 190 191 std::map<int, InputState*> activeStates_; 192 std::vector<InputState*> activeStatesTop_; //!< Current input states for joy stick events. 193 std::vector<InputState*> activeStatesTicked_; //!< Current input states for joy stick events. 234 194 235 195 // joystick calibration … … 239 199 int marginalsMin_[24]; 240 200 bool bCalibrated_; 241 201 bool bCalibrating_; 202 203 unsigned int keyboardModifiers_; //!< Bit mask representing keyboard modifiers 242 204 //! Keeps track of the joy stick POV states 243 205 std::vector<POVStates> povStates_; … … 246 208 std::vector<JoyStickCalibration> joySticksCalibration_; 247 209 248 std::map<std::string, KeyHandler*> keyHandlers_;249 std::map<std::string, MouseHandler*> mouseHandlers_;250 std::map<std::string, JoyStickHandler*> joyStickHandlers_;251 252 std::vector<KeyHandler*> activeKeyHandlers_;253 std::vector<MouseHandler*> activeMouseHandlers_;254 std::vector<std::vector<JoyStickHandler*> > activeJoyStickHandlers_;255 std::vector<std::pair<InputTickable*, HandlerState> > activeHandlers_;256 257 210 std::vector<Key> keysDown_; 258 211 std::vector<MouseButton::Enum> mouseButtonsDown_;
Note: See TracChangeset
for help on using the changeset viewer.