Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/input/src/core/InputHandler.h @ 1112

Last change on this file since 1112 was 1112, checked in by rgrieder, 16 years ago

added calculate command ;)
In the console, you can now type something like "calculate sin(cos(3+4) - 8)*7" or even "calculate 7>8" and you'll get the result as a double.
The parser was something I've written 3 years ago when I first used C++ (the parser is mainly C).

File size: 3.5 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
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 */
28
29/**
30 @file
31 @brief Different definitions of input processing.
32 */
33
34#ifndef _InputHandler_H__
35#define _InputHandler_H__
36
37#include "CorePrereqs.h"
38
39#include <string>
40#include <OIS/OIS.h>
41
42#include "InputEvent.h"
43
44namespace orxonox
45{
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   
62  /**
63    @brief Captures mouse and keyboard input while in the actual game mode.
64    Manages the key bindings.
65  */
66  class _CoreExport InputHandlerGame : public BaseInputHandler
67  {
68  public:
69    InputHandlerGame ();
70    ~InputHandlerGame();
71
72    bool loadBindings();
73
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);
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
89    std::string bindingsKeyPress_[numberOfKeys_s];
90    //! Array of input events for every released key
91    std::string bindingsKeyRelease_[numberOfKeys_s];
92    //! Array of input events for every holding key
93    std::string bindingsKeyHold_[numberOfKeys_s];
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
103  };
104
105
106  /**
107    @brief Captures mouse and keyboard input and distributes it to the
108    GUI.
109  */
110  class _CoreExport InputHandlerGUI : public BaseInputHandler
111  {
112  public:
113    InputHandlerGUI ();
114    ~InputHandlerGUI();
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__ */
Note: See TracBrowser for help on using the repository browser.