[918] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
[1056] | 3 | * > www.orxonox.net < |
---|
[918] | 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 | |
---|
[918] | 29 | /** |
---|
| 30 | @file |
---|
| 31 | @brief Implementation of a little Input handler that distributes everything |
---|
| 32 | coming from OIS. |
---|
| 33 | */ |
---|
[973] | 34 | |
---|
| 35 | #ifndef _InputManager_H__ |
---|
| 36 | #define _InputManager_H__ |
---|
| 37 | |
---|
| 38 | #include <OIS/OIS.h> |
---|
| 39 | |
---|
| 40 | #include "CorePrereqs.h" |
---|
| 41 | #include "core/Tickable.h" |
---|
| 42 | #include "InputEvent.h" |
---|
| 43 | |
---|
| 44 | namespace orxonox |
---|
| 45 | { |
---|
| 46 | /** |
---|
| 47 | @brief Designates the way input is handled currently. |
---|
| 48 | IM_GUI: All the OIS input events are passed to CEGUI |
---|
| 49 | IM_KEYBOARD: Only keyboard input is captured and passed to the InputBuffer |
---|
| 50 | IM_INGAME: Normal game mode. Key bindings and mouse are active. |
---|
| 51 | */ |
---|
| 52 | enum InputMode |
---|
| 53 | { |
---|
| 54 | IM_GUI = 0, |
---|
| 55 | IM_KEYBOARD = 1, |
---|
| 56 | IM_INGAME = 2, |
---|
[1022] | 57 | IM_UNINIT = 3, |
---|
[973] | 58 | }; |
---|
| 59 | |
---|
| 60 | /** |
---|
| 61 | @brief Captures and distributes mouse and keyboard input. |
---|
| 62 | It resolves the key bindings to InputEvents which can be heard by |
---|
| 63 | implementing the InputEventListener interface. |
---|
| 64 | */ |
---|
| 65 | class _CoreExport InputManager |
---|
[1022] | 66 | : public Tickable |
---|
[973] | 67 | { |
---|
| 68 | public: |
---|
| 69 | bool initialise(size_t windowHnd, int windowWidth, int windowHeight); |
---|
[1035] | 70 | void destroy(); |
---|
[973] | 71 | void tick(float dt); |
---|
| 72 | void setWindowExtents(int width, int height); |
---|
[1022] | 73 | void setInputMode(InputMode mode); |
---|
| 74 | InputMode getInputMode(); |
---|
[973] | 75 | |
---|
| 76 | // Temporary solutions. Will be removed soon! |
---|
| 77 | OIS::Mouse *getMouse() { return this->mouse_ ; } |
---|
| 78 | OIS::Keyboard *getKeyboard() { return this->keyboard_; } |
---|
| 79 | |
---|
[1035] | 80 | static InputManager& getSingleton(); |
---|
| 81 | static InputManager* getSingletonPtr() { return &getSingleton(); } |
---|
[973] | 82 | |
---|
| 83 | private: |
---|
| 84 | // don't mess with a Singleton |
---|
| 85 | InputManager (); |
---|
| 86 | InputManager (const InputManager&); |
---|
| 87 | ~InputManager(); |
---|
| 88 | |
---|
| 89 | OIS::InputManager *inputSystem_; //!< OIS input manager |
---|
| 90 | OIS::Keyboard *keyboard_; //!< OIS mouse |
---|
| 91 | OIS::Mouse *mouse_; //!< OIS keyboard |
---|
| 92 | |
---|
[1022] | 93 | InputMode currentMode_; //!< Input mode currently used |
---|
| 94 | InputMode setMode_; //!< Input mode that has been set lately |
---|
| 95 | InputHandlerGUI *handlerGUI_; //!< Handles the input if in GUI mode |
---|
| 96 | // FIXME: insert the InputBuffer once merged with core2 |
---|
| 97 | InputHandlerGUI *handlerBuffer_; //!< Handles the input if in Buffer mode |
---|
| 98 | InputHandlerGame *handlerGame_; //!< Handles the input if in Game mode |
---|
[973] | 99 | |
---|
| 100 | //! Pointer to the instance of the singleton |
---|
[1035] | 101 | //static InputManager *singletonRef_s; |
---|
[973] | 102 | }; |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | #endif /* _InputManager_H__ */ |
---|