Changeset 1203 for code/branches/input/src/core/InputHandler.h
- Timestamp:
- Apr 29, 2008, 11:13:11 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/input/src/core/InputHandler.h
r1182 r1203 38 38 39 39 #include <string> 40 #include <list> 41 #include <OIS/OIS.h> 42 43 #include "InputEvent.h" 40 #include "ois/OIS.h" 44 41 45 42 namespace orxonox … … 56 53 } 57 54 58 class _CoreExport BaseInputHandler59 : public OIS::KeyListener, public OIS::MouseListener60 {61 virtual void tick(float dt) = 0;62 };63 64 55 /** 65 @brief Captures mouse and keyboard input while in the actual game mode. 66 Manages the key bindings. 56 @brief Interface class used for key input listeners. 67 57 */ 68 class _CoreExport InputHandlerGame : public BaseInputHandler58 class _CoreExport KeyHandler : public OIS::KeyListener 69 59 { 70 60 public: 71 InputHandlerGame (); 72 ~InputHandlerGame(); 61 virtual bool keyHeld(const OIS::KeyEvent &arg) = 0; 62 }; 63 64 /** 65 @brief Interface class used for mouse input listeners. 66 */ 67 class _CoreExport MouseHandler : public OIS::MouseListener 68 { 69 public: 70 virtual bool mouseHeld(const OIS::MouseEvent &arg, OIS::MouseButtonID id) = 0; 71 }; 72 73 /** 74 @brief Interface class used for joy stick input listeners. 75 */ 76 class _CoreExport JoyStickHandler : public OIS::JoyStickListener 77 { 78 public: 79 virtual bool buttonHeld(const OIS::JoyStickEvent &arg, int button) = 0; 80 }; 81 82 83 /** 84 @brief Captures mouse, keyboard and joy stick input while in the actual game mode. 85 Manages the key bindings. 86 */ 87 class _CoreExport KeyBinder : public KeyHandler, public MouseHandler, public JoyStickHandler 88 { 89 public: 90 KeyBinder (); 91 ~KeyBinder(); 73 92 74 93 bool loadBindings(); 94 void clearBindings(); 75 95 76 private: 77 // input events 78 bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButtonID id); 79 bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id); 80 bool mouseMoved (const OIS::MouseEvent &arg); 96 private: // functions 81 97 bool keyPressed (const OIS::KeyEvent &arg); 82 98 bool keyReleased (const OIS::KeyEvent &arg); 99 bool keyHeld (const OIS::KeyEvent &arg); 83 100 84 void tick(float dt); 101 bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButtonID id); 102 bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id); 103 bool mouseHeld (const OIS::MouseEvent &arg, OIS::MouseButtonID id); 104 bool mouseMoved (const OIS::MouseEvent &arg); 85 105 86 // temporary hack 87 void callListeners(InputEvent &evt); 106 bool buttonPressed (const OIS::JoyStickEvent &arg, int button); 107 bool buttonReleased(const OIS::JoyStickEvent &arg, int button); 108 bool buttonHeld (const OIS::JoyStickEvent &arg, int button); 109 bool axisMoved (const OIS::JoyStickEvent &arg, int axis); 110 bool sliderMoved (const OIS::JoyStickEvent &arg, int id); 111 bool povMoved (const OIS::JoyStickEvent &arg, int id); 88 112 89 //! Stores all the keys that are down 90 std::list<OIS::KeyCode> keysDown_; 91 113 private: // variables 92 114 /** denotes the maximum number of different keys there are in OIS. 93 256 should be ok since the highest number in the enum is 237. */115 256 should be ok since the highest number in the OIS enum is 237. */ 94 116 static const int numberOfKeys_s = 256; 95 117 //! Array of input events for every pressed key 96 std::string bindingsKeyPress_ [numberOfKeys_s];118 std::string bindingsKeyPress_ [numberOfKeys_s]; 97 119 //! Array of input events for every released key 98 120 std::string bindingsKeyRelease_[numberOfKeys_s]; 99 //! Array of input events for every holdingkey100 std::string bindingsKeyHold_ [numberOfKeys_s];121 //!Array of input events for every held key 122 std::string bindingsKeyHold_ [numberOfKeys_s]; 101 123 102 124 /** denotes the maximum number of different buttons there are in OIS. 103 16 should be ok since the highest number in the enum is 7. */ 104 static const int numberOfButtons_s = 16; 105 //! Array of input events for every pressed key 106 std::string bindingsButtonPressed_[numberOfButtons_s]; 107 //! Array of input events for every released key 108 std::string bindingsButtonReleased_[numberOfButtons_s]; 125 16 should be ok since the highest number in the OIS enum is 7. */ 126 static const int numberOfMouseButtons_s = 16; 127 //! Array of input events for every pressed mouse button 128 std::string bindingsMouseButtonPress_ [numberOfMouseButtons_s]; 129 //! Array of input events for every released mouse button 130 std::string bindingsMouseButtonRelease_[numberOfMouseButtons_s]; 131 //! Array of input events for every held mouse button 132 std::string bindingsMouseButtonHold_ [numberOfMouseButtons_s]; 133 134 /** denotes the maximum number of different buttons there are in OIS. 135 32 should be ok. */ 136 static const int numberOfJoyStickButtons_s = 32; 137 //! Array of input events for every pressed joy stick button 138 std::string bindingsJoyStickButtonPress_ [numberOfJoyStickButtons_s]; 139 //! Array of input events for every released joy stick button 140 std::string bindingsJoyStickButtonRelease_[numberOfJoyStickButtons_s]; 141 //! Array of input events for every held joy stick button 142 std::string bindingsJoyStickButtonHold_ [numberOfJoyStickButtons_s]; 109 143 110 144 }; … … 115 149 GUI. 116 150 */ 117 class _CoreExport InputHandlerGUI : public BaseInputHandler118 {119 public:120 InputHandlerGUI();121 ~InputHandlerGUI();151 //class _CoreExport GUIInputHandler : public KeyHandler, public MouseHandler, public JoyStickHandler 152 //{ 153 //public: 154 // GUIInputHandler (); 155 // ~GUIInputHandler(); 122 156 123 void tick(float dt); 157 //private: 158 // // input events 159 //bool keyPressed (const OIS::KeyEvent &arg); 160 //bool keyReleased (const OIS::KeyEvent &arg); 161 //bool keyHeld (const OIS::KeyEvent &arg); 124 162 125 private: 126 // input events 127 bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButtonID id); 128 bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id); 129 bool mouseMoved (const OIS::MouseEvent &arg); 130 bool keyPressed (const OIS::KeyEvent &arg); 131 bool keyReleased (const OIS::KeyEvent &arg); 132 }; 163 // bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButtonID id); 164 //bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id); 165 //bool mouseHeld (const OIS::MouseEvent &arg, OIS::MouseButtonID id); 166 // bool mouseMoved (const OIS::MouseEvent &arg); 167 168 //bool buttonPressed (const OIS::JoyStickEvent &arg, int button); 169 //bool buttonReleased(const OIS::JoyStickEvent &arg, int button); 170 //bool buttonHeld (const OIS::JoyStickEvent &arg, int button); 171 //bool axisMoved (const OIS::JoyStickEvent &arg, int axis); 172 //bool sliderMoved (const OIS::JoyStickEvent &arg, int id); 173 //bool povMoved (const OIS::JoyStickEvent &arg, int id); 174 //}; 133 175 134 176 }
Note: See TracChangeset
for help on using the changeset viewer.