Changeset 1193 for code/branches/input/src/core/InputManager.h
- Timestamp:
- Apr 27, 2008, 1:50:28 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/input/src/core/InputManager.h
r1182 r1193 56 56 public OIS::MouseListener, public OIS::KeyListener, public OIS::JoyStickListener 57 57 { 58 public: 58 public: // enumerations 59 59 /** 60 @brief Designates the way input is handled currently. 61 IM_GUI: All the OIS input events are passed to CEGUI 62 IM_BUFFER: Only keyboard input is captured and passed to the InputBuffer 63 IM_NORMAL: Normal game mode. Key bindings and mouse are active. 60 @brief Designates the way input is handled and redirected. 64 61 */ 65 62 enum InputState 66 63 { 67 IS_UNINIT, 68 IS_NONE, 69 IS_NORMAL, 70 IS_GUI, 71 IS_CONSOLE, 72 IS_CUSTOM 64 IS_UNINIT, //!< InputManager has not yet been initialised. 65 IS_NONE, //!< Input is discarded. 66 IS_NORMAL, //!< Normal play state. Key and button bindings are active. 67 IS_GUI, //!< All OIS input events are passed to CEGUI. 68 IS_CONSOLE, //!< Keyboard input is redirected to the InputBuffer. 69 IS_CUSTOM //!< Any possible configuration. 73 70 }; 74 71 75 public: 76 void tick(float dt); 77 78 static bool initialise(size_t windowHnd, int windowWidth, int windowHeight); 72 public: // functions 73 // METHODS OF THE STATIC INTERFACE 74 75 static bool initialise(size_t windowHnd, int windowWidth, int windowHeight, 76 bool createKeyboard = true, bool createMouse = true, bool createJoySticks = false); 79 77 static void destroy(); 80 78 81 79 static void setWindowExtents(int width, int height); 80 82 81 static void setInputState(const InputState state); 83 82 static InputState getInputState(); 83 static void setKeyBindingState (bool bActive); 84 static void setMouseButtonBindingState (bool bActive); 85 static void setJoyStickButtonBindingState(bool bActive); 84 86 85 87 static bool addKeyListener(OIS::KeyListener* listener, const std::string& name); 86 //static bool removeKeyListener(OIS::KeyListener* listener);87 static bool removeKeyListener(const std::string& name);88 static bool enableKeyListener(const std::string& name);89 static bool disableKeyListener(const std::string& name);88 static bool removeKeyListener (const std::string& name); 89 static bool enableKeyListener (const std::string& name); 90 static bool disableKeyListener (const std::string& name); 91 static bool isKeyListenerActive(const std::string& name); 90 92 static OIS::KeyListener* getKeyListener(const std::string& name); 91 static bool isKeyListenerActive(const std::string& name);92 93 93 94 static bool addMouseListener(OIS::MouseListener* listener, const std::string& name); 94 //static bool removeMouseListener(OIS::MouseListener* listener);95 static bool removeMouseListener(const std::string& name);96 static bool enableMouseListener(const std::string& name);97 static bool disableMouseListener(const std::string& name);95 static bool removeMouseListener (const std::string& name); 96 static bool enableMouseListener (const std::string& name); 97 static bool disableMouseListener (const std::string& name); 98 static bool isMouseListenerActive(const std::string& name); 98 99 static OIS::MouseListener* getMouseListener(const std::string& name); 99 static bool isMouseListenerActive(const std::string& name);100 100 101 101 static bool addJoyStickListener(OIS::JoyStickListener* listener, const std::string& name); 102 //static bool removeJoyStickListener(OIS::JoyStickListener* listener);103 static bool removeJoyStickListener(const std::string& name);104 static bool enableJoyStickListener(const std::string& name);105 static bool disableJoyStickListener(const std::string& name);102 static bool removeJoyStickListener (const std::string& name); 103 static bool enableJoyStickListener (const std::string& name); 104 static bool disableJoyStickListener (const std::string& name); 105 static bool isJoyStickListenerActive(const std::string& name); 106 106 static OIS::JoyStickListener* getJoyStickListener(const std::string& name); 107 static bool isJoyStickListenerActive(const std::string& name);108 107 109 108 // Temporary solutions. Will be removed soon! … … 111 110 static OIS::Keyboard* getKeyboard() { return _getSingleton().keyboard_; } 112 111 113 private: 112 private: // functions 114 113 // don't mess with a Singleton 115 114 InputManager (); … … 117 116 ~InputManager(); 118 117 119 bool _initialise(size_t windowHnd, int windowWidth, int windowHeight); 118 // Intenal methods 119 bool _initialise(size_t, int, int, bool, bool, bool); 120 void _initialiseKeyboard(); 121 void _initialiseMouse(); 122 void _initialiseJoySticks(); 120 123 void _destroy(); 121 void _setDefaultState(); 122 void _loadBindings(); 124 //void _setDefaultState(); 125 bool _loadBindings(); 126 void _clearBindings(); 127 void _setNumberOfJoysticks(int size); 128 129 void tick(float dt); 123 130 124 131 // input events … … 137 144 static InputManager* _getSingletonPtr() { return &_getSingleton(); } 138 145 139 private: 146 private: // variables 140 147 OIS::InputManager* inputSystem_; //!< OIS input manager 141 148 OIS::Keyboard* keyboard_; //!< OIS mouse 142 149 OIS::Mouse* mouse_; //!< OIS keyboard 150 std::vector<OIS::JoyStick*> joySticks_; //!< OIS joy sticks 143 151 144 152 InputState state_; 145 153 InputState stateRequest_; 146 154 147 std::list<OIS::KeyCode> keysDown_; 148 149 bool bDefaultKeyInput; 150 bool bDefaultMouseInput; 151 bool bDefaultJoyStickInput; 152 153 std::map<std::string, OIS::KeyListener*> keyListeners_; 154 std::list<OIS::KeyListener*> activeKeyListeners_; 155 std::map<std::string, OIS::MouseListener*> mouseListeners_; 156 std::list<OIS::MouseListener*> activeMouseListeners_; 157 std::map<std::string, OIS::JoyStickListener*> joystickListeners_; 158 std::list<OIS::JoyStickListener*> activeJoyStickListeners_; 155 bool bKeyBindingsActive_; 156 bool bMouseButtonBindingsActive_; 157 std::vector<bool> bJoyStickButtonBindingsActive_; 158 159 std::map<std::string, OIS::KeyListener*> listenersKey_; 160 std::map<std::string, OIS::MouseListener*> listenersMouse_; 161 std::map<std::string, OIS::JoyStickListener*> listenersJoySticks_; 162 163 std::list<OIS::KeyListener*> listenersKeyActive_; 164 std::list<OIS::MouseListener*> listenersMouseActive_; 165 std::list<OIS::JoyStickListener*> listenersJoySticksActive_; 166 167 std::list<OIS::KeyCode> keysDown_; 168 std::list<OIS::MouseButtonID> mouseButtonsDown_; 169 std::vector< std::list<int> > joyStickButtonsDown_; 159 170 160 171 161 172 /** denotes the maximum number of different keys there are in OIS. 162 256 should be ok since the highest number in the enum is 237. */173 256 should be ok since the highest number in the OIS enum is 237. */ 163 174 static const int numberOfKeys_s = 256; 164 175 //! Array of input events for every pressed key … … 170 181 171 182 /** denotes the maximum number of different buttons there are in OIS. 172 16 should be ok since the highest number in the enum is 7. */183 16 should be ok since the highest number in the OIS enum is 7. */ 173 184 static const int numberOfMouseButtons_s = 16; 174 185 //! Array of input events for every pressed mouse button … … 182 193 32 should be ok. */ 183 194 static const int numberOfJoyStickButtons_s = 32; 184 //! Array of input events for every pressed joystick button 185 std::string bindingsJoyStickButtonPress_ [numberOfJoyStickButtons_s]; 186 //! Array of input events for every released joystick button 187 std::string bindingsJoyStickButtonRelease_[numberOfJoyStickButtons_s]; 188 //! Array of input events for every held joystick button 189 std::string bindingsJoyStickButtonHold_ [numberOfJoyStickButtons_s]; 195 std::vector< std::vector< std::string > > bindingsJoyStickButtonPress_; 196 std::vector< std::vector< std::string > > bindingsJoyStickButtonRelease_; 197 std::vector< std::vector< std::string > > bindingsJoyStickButtonHold_; 190 198 191 199 };
Note: See TracChangeset
for help on using the changeset viewer.