[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> |
---|
[973] | 40 | #include <OIS/OIS.h> |
---|
| 41 | |
---|
[1022] | 42 | #include "InputEvent.h" |
---|
[973] | 43 | |
---|
| 44 | namespace orxonox |
---|
| 45 | { |
---|
[1112] | 46 | namespace KeybindSetting |
---|
| 47 | { |
---|
| 48 | enum KeybindSetting |
---|
| 49 | { |
---|
| 50 | none, |
---|
| 51 | onPress, |
---|
| 52 | onRelease, |
---|
| 53 | continuous, |
---|
| 54 | }; |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | class _CoreExport BaseInputHandler |
---|
| 58 | : public OIS::KeyListener, public OIS::MouseListener |
---|
| 59 | { |
---|
| 60 | }; |
---|
| 61 | |
---|
[973] | 62 | /** |
---|
[1022] | 63 | @brief Captures mouse and keyboard input while in the actual game mode. |
---|
| 64 | Manages the key bindings. |
---|
[973] | 65 | */ |
---|
[1112] | 66 | class _CoreExport InputHandlerGame : public BaseInputHandler |
---|
[973] | 67 | { |
---|
| 68 | public: |
---|
[1022] | 69 | InputHandlerGame (); |
---|
| 70 | ~InputHandlerGame(); |
---|
[973] | 71 | |
---|
[1022] | 72 | bool loadBindings(); |
---|
| 73 | |
---|
[973] | 74 | private: |
---|
| 75 | // input events |
---|
| 76 | bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButtonID id); |
---|
| 77 | bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id); |
---|
| 78 | bool mouseMoved (const OIS::MouseEvent &arg); |
---|
| 79 | bool keyPressed (const OIS::KeyEvent &arg); |
---|
| 80 | bool keyReleased (const OIS::KeyEvent &arg); |
---|
[1022] | 81 | |
---|
| 82 | // temporary hack |
---|
| 83 | void callListeners(InputEvent &evt); |
---|
| 84 | |
---|
| 85 | /** denotes the maximum number of different keys there are in OIS. |
---|
| 86 | 256 should be ok since the highest number in the enum is 237. */ |
---|
| 87 | static const int numberOfKeys_s = 256; |
---|
| 88 | //! Array of input events for every pressed key |
---|
[1112] | 89 | std::string bindingsKeyPress_[numberOfKeys_s]; |
---|
[1022] | 90 | //! Array of input events for every released key |
---|
[1112] | 91 | std::string bindingsKeyRelease_[numberOfKeys_s]; |
---|
| 92 | //! Array of input events for every holding key |
---|
| 93 | std::string bindingsKeyHold_[numberOfKeys_s]; |
---|
[1022] | 94 | |
---|
| 95 | /** denotes the maximum number of different buttons there are in OIS. |
---|
| 96 | 16 should be ok since the highest number in the enum is 7. */ |
---|
| 97 | static const int numberOfButtons_s = 16; |
---|
| 98 | //! Array of input events for every pressed key |
---|
| 99 | std::string bindingsButtonPressed_[numberOfButtons_s]; |
---|
| 100 | //! Array of input events for every released key |
---|
| 101 | std::string bindingsButtonReleased_[numberOfButtons_s]; |
---|
| 102 | |
---|
[973] | 103 | }; |
---|
| 104 | |
---|
| 105 | |
---|
| 106 | /** |
---|
[1022] | 107 | @brief Captures mouse and keyboard input and distributes it to the |
---|
| 108 | GUI. |
---|
[973] | 109 | */ |
---|
[1112] | 110 | class _CoreExport InputHandlerGUI : public BaseInputHandler |
---|
[973] | 111 | { |
---|
| 112 | public: |
---|
[1022] | 113 | InputHandlerGUI (); |
---|
| 114 | ~InputHandlerGUI(); |
---|
[973] | 115 | |
---|
| 116 | private: |
---|
| 117 | // input events |
---|
| 118 | bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButtonID id); |
---|
| 119 | bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id); |
---|
| 120 | bool mouseMoved (const OIS::MouseEvent &arg); |
---|
| 121 | bool keyPressed (const OIS::KeyEvent &arg); |
---|
| 122 | bool keyReleased (const OIS::KeyEvent &arg); |
---|
| 123 | }; |
---|
| 124 | |
---|
| 125 | } |
---|
| 126 | |
---|
| 127 | #endif /* _InputHandler_H__ */ |
---|