[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 | |
---|
[1062] | 38 | #include "CorePrereqs.h" |
---|
| 39 | |
---|
[973] | 40 | #include <OIS/OIS.h> |
---|
| 41 | |
---|
[1062] | 42 | #include "Tickable.h" |
---|
[973] | 43 | #include "InputEvent.h" |
---|
| 44 | |
---|
| 45 | namespace orxonox |
---|
| 46 | { |
---|
| 47 | /** |
---|
| 48 | @brief Designates the way input is handled currently. |
---|
| 49 | IM_GUI: All the OIS input events are passed to CEGUI |
---|
| 50 | IM_KEYBOARD: Only keyboard input is captured and passed to the InputBuffer |
---|
| 51 | IM_INGAME: Normal game mode. Key bindings and mouse are active. |
---|
| 52 | */ |
---|
| 53 | |
---|
| 54 | /** |
---|
| 55 | @brief Captures and distributes mouse and keyboard input. |
---|
| 56 | It resolves the key bindings to InputEvents which can be heard by |
---|
| 57 | implementing the InputEventListener interface. |
---|
| 58 | */ |
---|
| 59 | class _CoreExport InputManager |
---|
[1022] | 60 | : public Tickable |
---|
[973] | 61 | { |
---|
| 62 | public: |
---|
| 63 | bool initialise(size_t windowHnd, int windowWidth, int windowHeight); |
---|
[1035] | 64 | void destroy(); |
---|
[973] | 65 | void tick(float dt); |
---|
| 66 | void setWindowExtents(int width, int height); |
---|
[1022] | 67 | InputMode getInputMode(); |
---|
[973] | 68 | |
---|
[1066] | 69 | // temporary hack |
---|
| 70 | void feedInputBuffer(InputBuffer* buffer); |
---|
| 71 | |
---|
[973] | 72 | // Temporary solutions. Will be removed soon! |
---|
| 73 | OIS::Mouse *getMouse() { return this->mouse_ ; } |
---|
| 74 | OIS::Keyboard *getKeyboard() { return this->keyboard_; } |
---|
| 75 | |
---|
[1035] | 76 | static InputManager& getSingleton(); |
---|
| 77 | static InputManager* getSingletonPtr() { return &getSingleton(); } |
---|
[973] | 78 | |
---|
[1154] | 79 | static void setInputHandler(std::string& name); |
---|
| 80 | |
---|
[973] | 81 | private: |
---|
| 82 | // don't mess with a Singleton |
---|
| 83 | InputManager (); |
---|
| 84 | InputManager (const InputManager&); |
---|
| 85 | ~InputManager(); |
---|
| 86 | |
---|
| 87 | OIS::InputManager *inputSystem_; //!< OIS input manager |
---|
| 88 | OIS::Keyboard *keyboard_; //!< OIS mouse |
---|
| 89 | OIS::Mouse *mouse_; //!< OIS keyboard |
---|
| 90 | |
---|
[1154] | 91 | BaseInputHandler* currentHandler_; |
---|
| 92 | BaseInputHandler* switchToHandler_; |
---|
| 93 | //! Maps the names of the input handlers to their instance |
---|
| 94 | std::map<std::string, BaseInputHandler*> handlers_; |
---|
[973] | 95 | |
---|
| 96 | }; |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | #endif /* _InputManager_H__ */ |
---|