Changeset 1203 for code/branches/input/src/core/InputManager.h
- Timestamp:
- Apr 29, 2008, 11:13:11 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/input/src/core/InputManager.h
r1195 r1203 43 43 #include "ois/OIS.h" 44 44 #include "Tickable.h" 45 #include "InputEvent.h" 45 //#include "InputEvent.h" 46 #include "InputHandler.h" 46 47 47 48 namespace orxonox 48 49 { 50 class Mouse : public OIS::Mouse 51 { 52 }; 53 49 54 /** 50 55 @brief Captures and distributes mouse and keyboard input. … … 70 75 }; 71 76 72 public: // functions 73 // METHODS OF THE STATIC INTERFACE 74 77 public: // static functions 75 78 static bool initialise(size_t windowHnd, int windowWidth, int windowHeight, 76 79 bool createKeyboard = true, bool createMouse = true, bool createJoySticks = false); 80 static bool initialiseKeyboard(); 81 static bool initialiseMouse(); 82 static bool initialiseJoySticks(); 83 77 84 static void destroy(); 85 static void destroyKeyboard(); 86 static void destroyMouse(); 87 static void destroyJoySticks(); 78 88 79 89 static void setWindowExtents(int width, int height); … … 85 95 static void setJoyStickButtonBindingState(bool bActive); 86 96 87 static bool addKeyListener( OIS::KeyListener* listener, const std::string& name);97 static bool addKeyListener(KeyHandler* listener, const std::string& name); 88 98 static bool removeKeyListener (const std::string& name); 89 99 static bool enableKeyListener (const std::string& name); 90 100 static bool disableKeyListener (const std::string& name); 91 101 static bool isKeyListenerActive(const std::string& name); 92 static OIS::KeyListener* getKeyListener(const std::string& name);102 static KeyHandler* getKeyListener(const std::string& name); 93 103 94 static bool addMouseListener( OIS::MouseListener* listener, const std::string& name);104 static bool addMouseListener(MouseHandler* listener, const std::string& name); 95 105 static bool removeMouseListener (const std::string& name); 96 106 static bool enableMouseListener (const std::string& name); 97 107 static bool disableMouseListener (const std::string& name); 98 108 static bool isMouseListenerActive(const std::string& name); 99 static OIS::MouseListener* getMouseListener(const std::string& name);109 static MouseHandler* getMouseListener(const std::string& name); 100 110 101 static bool addJoyStickListener( OIS::JoyStickListener* listener, const std::string& name);111 static bool addJoyStickListener(JoyStickHandler* listener, const std::string& name); 102 112 static bool removeJoyStickListener (const std::string& name); 103 static bool enableJoyStickListener (const std::string& name );104 static bool disableJoyStickListener (const std::string& name );113 static bool enableJoyStickListener (const std::string& name, const int id); 114 static bool disableJoyStickListener (const std::string& name, const int id); 105 115 static bool isJoyStickListenerActive(const std::string& name); 106 static OIS::JoyStickListener* getJoyStickListener(const std::string& name);116 static JoyStickHandler* getJoyStickListener(const std::string& name); 107 117 108 118 // Temporary solutions. Will be removed soon! … … 118 128 // Intenal methods 119 129 bool _initialise(size_t, int, int, bool, bool, bool); 120 void _initialiseKeyboard(); 121 void _initialiseMouse(); 122 void _initialiseJoySticks(); 130 bool _initialiseKeyboard(); 131 bool _initialiseMouse(); 132 bool _initialiseJoySticks(); 133 123 134 void _destroy(); 124 //void _setDefaultState(); 125 bool _loadBindings(); 126 void _clearBindings(); 127 void _setNumberOfJoysticks(int size); 135 void _destroyKeyboard(); 136 void _destroyMouse(); 137 void _destroyJoySticks(); 138 139 //void _setNumberOfJoysticks(int size); 128 140 129 141 void tick(float dt); … … 145 157 146 158 private: // variables 147 OIS::InputManager* inputSystem_; //!< OIS input manager148 OIS::Keyboard* keyboard_; //!< OIS mouse149 OIS::Mouse* mouse_; //!< OIS keyboard150 std:: vector<OIS::JoyStick*> joySticks_;//!< OIS joy sticks159 OIS::InputManager* inputSystem_; //!< OIS input manager 160 OIS::Keyboard* keyboard_; //!< OIS mouse 161 OIS::Mouse* mouse_; //!< OIS keyboard 162 std::map<int, OIS::JoyStick*> joySticks_; //!< OIS joy sticks 151 163 152 164 InputState state_; 153 165 InputState stateRequest_; 154 166 155 bool bKeyBindingsActive_;156 bool bMouseButtonBindingsActive_;157 std:: vector<bool> bJoyStickButtonBindingsActive_;167 std::map<std::string, KeyHandler*> listenersKey_; 168 std::map<std::string, MouseHandler*> listenersMouse_; 169 std::map<std::string, JoyStickHandler*> listenersJoySticks_; 158 170 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_; 171 std::list<KeyHandler*> listenersKeyActive_; 172 std::list<MouseHandler*> listenersMouseActive_; 173 std::map< int, std::list<JoyStickHandler*> > listenersJoySticksActive_; 166 174 167 175 std::list<OIS::KeyCode> keysDown_; 168 176 std::list<OIS::MouseButtonID> mouseButtonsDown_; 169 std::vector< std::list<int> > joyStickButtonsDown_; 170 171 172 /** denotes the maximum number of different keys there are in OIS. 173 256 should be ok since the highest number in the OIS enum is 237. */ 174 static const int numberOfKeys_s = 256; 175 //! Array of input events for every pressed key 176 std::string bindingsKeyPress_ [numberOfKeys_s]; 177 //! Array of input events for every released key 178 std::string bindingsKeyRelease_[numberOfKeys_s]; 179 //! Array of input events for every held key 180 std::string bindingsKeyHold_ [numberOfKeys_s]; 181 182 /** denotes the maximum number of different buttons there are in OIS. 183 16 should be ok since the highest number in the OIS enum is 7. */ 184 static const int numberOfMouseButtons_s = 16; 185 //! Array of input events for every pressed mouse button 186 std::string bindingsMouseButtonPress_ [numberOfMouseButtons_s]; 187 //! Array of input events for every released mouse button 188 std::string bindingsMouseButtonRelease_[numberOfMouseButtons_s]; 189 //! Array of input events for every held mouse button 190 std::string bindingsMouseButtonHold_ [numberOfMouseButtons_s]; 191 192 /** denotes the maximum number of different buttons there are in OIS. 193 32 should be ok. */ 194 static const int numberOfJoyStickButtons_s = 32; 195 std::vector< std::vector< std::string > > bindingsJoyStickButtonPress_; 196 std::vector< std::vector< std::string > > bindingsJoyStickButtonRelease_; 197 std::vector< std::vector< std::string > > bindingsJoyStickButtonHold_; 177 std::map< int, std::list<int> > joySticksButtonsDown_; 198 178 199 179 };
Note: See TracChangeset
for help on using the changeset viewer.