[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" |
---|
[1213] | 41 | #include "OrxonoxClass.h" |
---|
[973] | 42 | |
---|
| 43 | namespace orxonox |
---|
| 44 | { |
---|
[1182] | 45 | namespace KeybindSetting |
---|
| 46 | { |
---|
| 47 | enum KeybindSetting |
---|
| 48 | { |
---|
| 49 | None, |
---|
| 50 | OnPress, |
---|
| 51 | OnRelease, |
---|
| 52 | Continuous, |
---|
| 53 | }; |
---|
| 54 | } |
---|
| 55 | |
---|
[1203] | 56 | /** |
---|
| 57 | @brief Interface class used for key input listeners. |
---|
| 58 | */ |
---|
| 59 | class _CoreExport KeyHandler : public OIS::KeyListener |
---|
[1182] | 60 | { |
---|
[1203] | 61 | public: |
---|
| 62 | virtual bool keyHeld(const OIS::KeyEvent &arg) = 0; |
---|
[1182] | 63 | }; |
---|
[1203] | 64 | |
---|
[973] | 65 | /** |
---|
[1203] | 66 | @brief Interface class used for mouse input listeners. |
---|
[973] | 67 | */ |
---|
[1203] | 68 | class _CoreExport MouseHandler : public OIS::MouseListener |
---|
[973] | 69 | { |
---|
| 70 | public: |
---|
[1203] | 71 | virtual bool mouseHeld(const OIS::MouseEvent &arg, OIS::MouseButtonID id) = 0; |
---|
| 72 | }; |
---|
[973] | 73 | |
---|
[1203] | 74 | /** |
---|
| 75 | @brief Interface class used for joy stick input listeners. |
---|
| 76 | */ |
---|
| 77 | class _CoreExport JoyStickHandler : public OIS::JoyStickListener |
---|
| 78 | { |
---|
| 79 | public: |
---|
| 80 | virtual bool buttonHeld(const OIS::JoyStickEvent &arg, int button) = 0; |
---|
| 81 | }; |
---|
| 82 | |
---|
| 83 | |
---|
| 84 | /** |
---|
| 85 | @brief Captures mouse, keyboard and joy stick input while in the actual game mode. |
---|
| 86 | Manages the key bindings. |
---|
| 87 | */ |
---|
[1213] | 88 | class _CoreExport KeyBinder : public KeyHandler, public MouseHandler, public JoyStickHandler, public OrxonoxClass |
---|
[1203] | 89 | { |
---|
| 90 | public: |
---|
| 91 | KeyBinder (); |
---|
| 92 | ~KeyBinder(); |
---|
| 93 | |
---|
[1022] | 94 | bool loadBindings(); |
---|
[1203] | 95 | void clearBindings(); |
---|
[1213] | 96 | |
---|
| 97 | void setConfigValues(); |
---|
| 98 | |
---|
| 99 | std::string testtest; |
---|
[1022] | 100 | |
---|
[1203] | 101 | private: // functions |
---|
[973] | 102 | bool keyPressed (const OIS::KeyEvent &arg); |
---|
| 103 | bool keyReleased (const OIS::KeyEvent &arg); |
---|
[1203] | 104 | bool keyHeld (const OIS::KeyEvent &arg); |
---|
[1022] | 105 | |
---|
[1203] | 106 | bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButtonID id); |
---|
| 107 | bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id); |
---|
| 108 | bool mouseHeld (const OIS::MouseEvent &arg, OIS::MouseButtonID id); |
---|
| 109 | bool mouseMoved (const OIS::MouseEvent &arg); |
---|
[1182] | 110 | |
---|
[1203] | 111 | bool buttonPressed (const OIS::JoyStickEvent &arg, int button); |
---|
| 112 | bool buttonReleased(const OIS::JoyStickEvent &arg, int button); |
---|
| 113 | bool buttonHeld (const OIS::JoyStickEvent &arg, int button); |
---|
| 114 | bool axisMoved (const OIS::JoyStickEvent &arg, int axis); |
---|
| 115 | bool sliderMoved (const OIS::JoyStickEvent &arg, int id); |
---|
| 116 | bool povMoved (const OIS::JoyStickEvent &arg, int id); |
---|
[1022] | 117 | |
---|
[1203] | 118 | private: // variables |
---|
[1213] | 119 | |
---|
| 120 | //! denotes the number of different keys there are in OIS. |
---|
| 121 | static const int numberOfKeys_s = 0xEE; |
---|
[1022] | 122 | //! Array of input events for every pressed key |
---|
[1203] | 123 | std::string bindingsKeyPress_ [numberOfKeys_s]; |
---|
[1022] | 124 | //! Array of input events for every released key |
---|
[1182] | 125 | std::string bindingsKeyRelease_[numberOfKeys_s]; |
---|
[1213] | 126 | //! Array of input events for every held key |
---|
[1203] | 127 | std::string bindingsKeyHold_ [numberOfKeys_s]; |
---|
[1213] | 128 | //! Names of the keys as strings |
---|
| 129 | std::string keyNames_[numberOfKeys_s]; |
---|
[1022] | 130 | |
---|
[1213] | 131 | //! denotes the number of different mouse buttons there are in OIS. |
---|
| 132 | static const int numberOfMouseButtons_s = 8; |
---|
[1203] | 133 | //! Array of input events for every pressed mouse button |
---|
| 134 | std::string bindingsMouseButtonPress_ [numberOfMouseButtons_s]; |
---|
| 135 | //! Array of input events for every released mouse button |
---|
| 136 | std::string bindingsMouseButtonRelease_[numberOfMouseButtons_s]; |
---|
| 137 | //! Array of input events for every held mouse button |
---|
| 138 | std::string bindingsMouseButtonHold_ [numberOfMouseButtons_s]; |
---|
[1213] | 139 | //! Names of the mouse buttons as strings |
---|
| 140 | std::string mouseButtonNames_[numberOfMouseButtons_s]; |
---|
[1022] | 141 | |
---|
[1213] | 142 | //! denotes the number of different joy stick buttons there are in OIS. |
---|
[1203] | 143 | static const int numberOfJoyStickButtons_s = 32; |
---|
| 144 | //! Array of input events for every pressed joy stick button |
---|
| 145 | std::string bindingsJoyStickButtonPress_ [numberOfJoyStickButtons_s]; |
---|
| 146 | //! Array of input events for every released joy stick button |
---|
| 147 | std::string bindingsJoyStickButtonRelease_[numberOfJoyStickButtons_s]; |
---|
| 148 | //! Array of input events for every held joy stick button |
---|
| 149 | std::string bindingsJoyStickButtonHold_ [numberOfJoyStickButtons_s]; |
---|
[1213] | 150 | //! Names of the joy stick buttons as strings |
---|
| 151 | std::string joyStickButtonNames_[numberOfJoyStickButtons_s]; |
---|
[1203] | 152 | |
---|
[973] | 153 | }; |
---|
| 154 | |
---|
| 155 | |
---|
| 156 | /** |
---|
[1022] | 157 | @brief Captures mouse and keyboard input and distributes it to the |
---|
| 158 | GUI. |
---|
[973] | 159 | */ |
---|
[1203] | 160 | //class _CoreExport GUIInputHandler : public KeyHandler, public MouseHandler, public JoyStickHandler |
---|
| 161 | //{ |
---|
| 162 | //public: |
---|
| 163 | // GUIInputHandler (); |
---|
| 164 | // ~GUIInputHandler(); |
---|
[973] | 165 | |
---|
[1203] | 166 | //private: |
---|
| 167 | // // input events |
---|
| 168 | //bool keyPressed (const OIS::KeyEvent &arg); |
---|
| 169 | //bool keyReleased (const OIS::KeyEvent &arg); |
---|
| 170 | //bool keyHeld (const OIS::KeyEvent &arg); |
---|
[1182] | 171 | |
---|
[1203] | 172 | // bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButtonID id); |
---|
| 173 | //bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id); |
---|
| 174 | //bool mouseHeld (const OIS::MouseEvent &arg, OIS::MouseButtonID id); |
---|
| 175 | // bool mouseMoved (const OIS::MouseEvent &arg); |
---|
[973] | 176 | |
---|
[1203] | 177 | //bool buttonPressed (const OIS::JoyStickEvent &arg, int button); |
---|
| 178 | //bool buttonReleased(const OIS::JoyStickEvent &arg, int button); |
---|
| 179 | //bool buttonHeld (const OIS::JoyStickEvent &arg, int button); |
---|
| 180 | //bool axisMoved (const OIS::JoyStickEvent &arg, int axis); |
---|
| 181 | //bool sliderMoved (const OIS::JoyStickEvent &arg, int id); |
---|
| 182 | //bool povMoved (const OIS::JoyStickEvent &arg, int id); |
---|
| 183 | //}; |
---|
| 184 | |
---|
[973] | 185 | } |
---|
| 186 | |
---|
| 187 | #endif /* _InputHandler_H__ */ |
---|