[971] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
[1056] | 3 | * > www.orxonox.net < |
---|
[971] | 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
| 23 | * Reto Grieder |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
[973] | 28 | |
---|
[971] | 29 | /** |
---|
| 30 | @file |
---|
[1022] | 31 | @brief Different definitions of input processing. |
---|
[971] | 32 | */ |
---|
[973] | 33 | |
---|
| 34 | #ifndef _InputHandler_H__ |
---|
| 35 | #define _InputHandler_H__ |
---|
| 36 | |
---|
[1062] | 37 | #include "CorePrereqs.h" |
---|
| 38 | |
---|
[1022] | 39 | #include <string> |
---|
[1203] | 40 | #include "ois/OIS.h" |
---|
[973] | 41 | |
---|
| 42 | namespace orxonox |
---|
| 43 | { |
---|
[1182] | 44 | namespace KeybindSetting |
---|
| 45 | { |
---|
| 46 | enum KeybindSetting |
---|
| 47 | { |
---|
| 48 | None, |
---|
| 49 | OnPress, |
---|
| 50 | OnRelease, |
---|
| 51 | Continuous, |
---|
| 52 | }; |
---|
| 53 | } |
---|
| 54 | |
---|
[1203] | 55 | /** |
---|
| 56 | @brief Interface class used for key input listeners. |
---|
| 57 | */ |
---|
| 58 | class _CoreExport KeyHandler : public OIS::KeyListener |
---|
[1182] | 59 | { |
---|
[1203] | 60 | public: |
---|
| 61 | virtual bool keyHeld(const OIS::KeyEvent &arg) = 0; |
---|
[1182] | 62 | }; |
---|
[1203] | 63 | |
---|
[973] | 64 | /** |
---|
[1203] | 65 | @brief Interface class used for mouse input listeners. |
---|
[973] | 66 | */ |
---|
[1203] | 67 | class _CoreExport MouseHandler : public OIS::MouseListener |
---|
[973] | 68 | { |
---|
| 69 | public: |
---|
[1203] | 70 | virtual bool mouseHeld(const OIS::MouseEvent &arg, OIS::MouseButtonID id) = 0; |
---|
| 71 | }; |
---|
[973] | 72 | |
---|
[1203] | 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(); |
---|
| 92 | |
---|
[1022] | 93 | bool loadBindings(); |
---|
[1203] | 94 | void clearBindings(); |
---|
[1022] | 95 | |
---|
[1203] | 96 | private: // functions |
---|
[973] | 97 | bool keyPressed (const OIS::KeyEvent &arg); |
---|
| 98 | bool keyReleased (const OIS::KeyEvent &arg); |
---|
[1203] | 99 | bool keyHeld (const OIS::KeyEvent &arg); |
---|
[1022] | 100 | |
---|
[1203] | 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); |
---|
[1182] | 105 | |
---|
[1203] | 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); |
---|
[1022] | 112 | |
---|
[1203] | 113 | private: // variables |
---|
[1022] | 114 | /** denotes the maximum number of different keys there are in OIS. |
---|
[1203] | 115 | 256 should be ok since the highest number in the OIS enum is 237. */ |
---|
[1022] | 116 | static const int numberOfKeys_s = 256; |
---|
| 117 | //! Array of input events for every pressed key |
---|
[1203] | 118 | std::string bindingsKeyPress_ [numberOfKeys_s]; |
---|
[1022] | 119 | //! Array of input events for every released key |
---|
[1182] | 120 | std::string bindingsKeyRelease_[numberOfKeys_s]; |
---|
[1203] | 121 | //!Array of input events for every held key |
---|
| 122 | std::string bindingsKeyHold_ [numberOfKeys_s]; |
---|
[1022] | 123 | |
---|
| 124 | /** denotes the maximum number of different buttons there are in OIS. |
---|
[1203] | 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]; |
---|
[1022] | 133 | |
---|
[1203] | 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]; |
---|
| 143 | |
---|
[973] | 144 | }; |
---|
| 145 | |
---|
| 146 | |
---|
| 147 | /** |
---|
[1022] | 148 | @brief Captures mouse and keyboard input and distributes it to the |
---|
| 149 | GUI. |
---|
[973] | 150 | */ |
---|
[1203] | 151 | //class _CoreExport GUIInputHandler : public KeyHandler, public MouseHandler, public JoyStickHandler |
---|
| 152 | //{ |
---|
| 153 | //public: |
---|
| 154 | // GUIInputHandler (); |
---|
| 155 | // ~GUIInputHandler(); |
---|
[973] | 156 | |
---|
[1203] | 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); |
---|
[1182] | 162 | |
---|
[1203] | 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); |
---|
[973] | 167 | |
---|
[1203] | 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 | //}; |
---|
| 175 | |
---|
[973] | 176 | } |
---|
| 177 | |
---|
| 178 | #endif /* _InputHandler_H__ */ |
---|