Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/input/src/orxonox/core/InputManager.h @ 1022

Last change on this file since 1022 was 1022, checked in by rgrieder, 16 years ago
  • modified the input handler
  • few more little changes
File size: 3.2 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *
4 *
5 *   License notice:
6 *
7 *   This program is free software; you can redistribute it and/or
8 *   modify it under the terms of the GNU General Public License
9 *   as published by the Free Software Foundation; either version 2
10 *   of the License, or (at your option) any later version.
11 *
12 *   This program is distributed in the hope that it will be useful,
13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 *   GNU General Public License for more details.
16 *
17 *   You should have received a copy of the GNU General Public License
18 *   along with this program; if not, write to the Free Software
19 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 *
21 *   Author:
22 *      Reto Grieder
23 *   Co-authors:
24 *      ...
25 *
26 */
27
28/**
29 @file
30 @brief Implementation of a little Input handler that distributes everything
31        coming from OIS.
32 */
33
34#ifndef _InputManager_H__
35#define _InputManager_H__
36
37#include <OIS/OIS.h>
38
39#include "CorePrereqs.h"
40#include "core/Tickable.h"
41#include "InputEvent.h"
42
43namespace orxonox
44{
45  /**
46    @brief Designates the way input is handled currently.
47    IM_GUI:      All the OIS input events are passed to CEGUI
48    IM_KEYBOARD: Only keyboard input is captured and passed to the InputBuffer
49    IM_INGAME:   Normal game mode. Key bindings and mouse are active.
50  */
51  enum InputMode
52  {
53    IM_GUI      = 0,
54    IM_KEYBOARD = 1,
55    IM_INGAME   = 2,
56    IM_UNINIT   = 3,
57  };
58
59  /**
60    @brief Captures and distributes mouse and keyboard input.
61    It resolves the key bindings to InputEvents which can be heard by
62    implementing the InputEventListener interface.
63  */
64  class _CoreExport InputManager
65        : public Tickable
66  {
67  public:
68    bool initialise(size_t windowHnd, int windowWidth, int windowHeight);
69    void destroyDevices();
70    void tick(float dt);
71    void setWindowExtents(int width, int height);
72    void setInputMode(InputMode mode);
73    InputMode getInputMode();
74
75    // Temporary solutions. Will be removed soon!
76    OIS::Mouse    *getMouse()    { return this->mouse_   ; }
77    OIS::Keyboard *getKeyboard() { return this->keyboard_; }
78
79    static InputManager* getSingleton();
80    static void destroySingleton();
81
82  private:
83    // don't mess with a Singleton
84    InputManager ();
85    InputManager (const InputManager&);
86    InputManager& operator=(const InputManager& instance);
87    ~InputManager();
88
89    OIS::InputManager *inputSystem_;    //!< OIS input manager
90    OIS::Keyboard     *keyboard_;       //!< OIS mouse
91    OIS::Mouse        *mouse_;          //!< OIS keyboard
92
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
99
100    //! Pointer to the instance of the singleton
101    static InputManager *singletonRef_s;
102  };
103}
104
105#endif /* _InputManager_H__ */
Note: See TracBrowser for help on using the repository browser.