Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/core/InputHandler.h @ 1308

Last change on this file since 1308 was 1293, checked in by scheusso, 17 years ago

merged changes from input & camera & network branch into trunk

File size: 6.0 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
41#include "ois/OIS.h"
42#include "OrxonoxClass.h"
43#include "CommandExecutor.h"
44#include "InputInterfaces.h"
45
46namespace orxonox
47{
48  namespace KeybindSetting
49  {
50    enum KeybindSetting
51    {
52      None,
53      OnPress,
54      OnRelease,
55      Continuous,
56    };
57  }
58
59  struct _CoreExport KeyBinding
60  {
61    std::string commandStr;
62    CommandEvaluation evaluation;
63  };
64 
65
66  /**
67    @brief Captures mouse, keyboard and joy stick input while in the actual game mode.
68           Manages the key bindings.
69  */
70  class _CoreExport KeyBinder : public KeyHandler, public MouseHandler, public JoyStickHandler, public OrxonoxClass
71  {
72  public:
73    KeyBinder ();
74    ~KeyBinder();
75
76    bool loadBindings();
77    void clearBindings();
78
79    void setConfigValues();
80
81  private: // functions
82
83    bool executeSimpleBinding(KeyBinding &binding);
84
85    bool keyPressed (const KeyEvent& evt);
86    bool keyReleased(const KeyEvent& evt);
87    bool keyHeld    (const KeyEvent& evt);
88
89    bool mouseButtonPressed (const MouseState& state, MouseButton::Enum id);
90    bool mouseButtonReleased(const MouseState& state, MouseButton::Enum id);
91    bool mouseButtonHeld    (const MouseState& state, MouseButton::Enum id);
92    bool mouseMoved         (const MouseState& state);
93    bool mouseScrolled      (const MouseState& state);
94
95    bool joyStickButtonPressed (const JoyStickState& state, int button);
96    bool joyStickButtonReleased(const JoyStickState& state, int button);
97    bool joyStickButtonHeld    (const JoyStickState& state, int button);
98    bool joyStickAxisMoved     (const JoyStickState& state, int axis)  ;
99    bool joyStickSliderMoved   (const JoyStickState& state, int index) ;
100    bool joyStickPovMoved      (const JoyStickState& state, int index) ;
101    bool joyStickVector3Moved  (const JoyStickState& state, int index) ;
102
103  private: // variables
104
105    //! denotes the number of different keys there are in OIS.
106    static const int numberOfKeys_s = 0xEE;
107    //! Array of input events for every pressed key
108    KeyBinding bindingsKeyPress_  [numberOfKeys_s];
109    //! Array of input events for every released key
110    KeyBinding bindingsKeyRelease_[numberOfKeys_s];
111    //! Array of input events for every held key
112    KeyBinding bindingsKeyHold_   [numberOfKeys_s];
113    //! Names of the keys as strings
114    std::string keyNames_[numberOfKeys_s];
115
116    //! denotes the number of different mouse buttons there are in OIS.
117    static const int numberOfMouseButtons_s = 8;
118    //! Array of input events for every pressed mouse button
119    KeyBinding bindingsMouseButtonPress_  [numberOfMouseButtons_s];
120    //! Array of input events for every released mouse button
121    KeyBinding bindingsMouseButtonRelease_[numberOfMouseButtons_s];
122    //! Array of input events for every held mouse button
123    KeyBinding bindingsMouseButtonHold_   [numberOfMouseButtons_s];
124    //! Key binding for mouse moved event
125    KeyBinding bindingMouseMoved_;
126    //! Key binding for mouse scrolled event
127    KeyBinding bindingMouseScrolled_;
128    //! Names of the mouse buttons as strings
129    std::string mouseButtonNames_[numberOfMouseButtons_s];
130
131    //! denotes the number of different joy stick buttons there are in OIS.
132    static const int numberOfJoyStickButtons_s = 32;
133    //! Array of input events for every pressed joy stick button
134    KeyBinding bindingsJoyStickButtonPress_  [numberOfJoyStickButtons_s];
135    //! Array of input events for every released joy stick button
136    KeyBinding bindingsJoyStickButtonRelease_[numberOfJoyStickButtons_s];
137    //! Array of input events for every held joy stick button
138    KeyBinding bindingsJoyStickButtonHold_   [numberOfJoyStickButtons_s];
139    //! Names of the joy stick buttons as strings
140    std::string joyStickButtonNames_[numberOfJoyStickButtons_s];
141
142  };
143
144
145  /**
146    @brief Captures mouse and keyboard input and distributes it to the
147    GUI.
148  */
149  //class _CoreExport GUIInputHandler : public KeyHandler, public MouseHandler, public JoyStickHandler
150  //{
151  //public:
152  //  GUIInputHandler ();
153  //  ~GUIInputHandler();
154
155  //private:
156  //  // input events
157    //bool keyPressed   (const OIS::KeyEvent   &arg);
158    //bool keyReleased  (const OIS::KeyEvent   &arg);
159    //bool keyHeld      (const OIS::KeyEvent   &arg);
160
161  //  bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButton id);
162    //bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButton id);
163    //bool mouseHeld    (const OIS::MouseEvent &arg, OIS::MouseButton id);
164  //  bool mouseMoved   (const OIS::MouseEvent &arg);
165
166    //bool buttonPressed (const OIS::JoyStickEvent &arg, int button);
167    //bool buttonReleased(const OIS::JoyStickEvent &arg, int button);
168    //bool buttonHeld    (const OIS::JoyStickEvent &arg, int button);
169    //bool axisMoved     (const OIS::JoyStickEvent &arg, int axis);
170    //bool sliderMoved   (const OIS::JoyStickEvent &arg, int id);
171    //bool povMoved      (const OIS::JoyStickEvent &arg, int id);
172  //};
173
174}
175
176#endif /* _InputHandler_H__ */
Note: See TracBrowser for help on using the repository browser.