Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 1237 was 1237, checked in by rgrieder, 17 years ago
  • I hate tabulators… And I always wondered how they got into my files.. Now I know: Line indentation with multiple lines has a bug in VC.
File size: 5.8 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    std::string testtest;
82
83  private: // functions
84
85    bool executeBinding(KeyBinding &binding);
86
87    bool keyPressed (const KeyEvent& evt);
88    bool keyReleased(const KeyEvent& evt);
89    bool keyHeld    (const KeyEvent& evt);
90
91    bool mouseButtonPressed (const MouseState& state, MouseButton::Enum id);
92    bool mouseButtonReleased(const MouseState& state, MouseButton::Enum id);
93    bool mouseButtonHeld    (const MouseState& state, MouseButton::Enum id);
94    bool mouseMoved         (const MouseState& state);
95    bool mouseWheelTurned   (const MouseState& state);
96
97    bool joyStickButtonPressed (const JoyStickState& state, int button);
98    bool joyStickButtonReleased(const JoyStickState& state, int button);
99    bool joyStickButtonHeld    (const JoyStickState& state, int button);
100    bool joyStickAxisMoved     (const JoyStickState& state, int axis)  ;
101    bool joyStickSliderMoved   (const JoyStickState& state, int index) ;
102    bool joyStickPovMoved      (const JoyStickState& state, int index) ;
103    bool joyStickVector3Moved  (const JoyStickState& state, int index) ;
104
105  private: // variables
106
107    //! denotes the number of different keys there are in OIS.
108    static const int numberOfKeys_s = 0xEE;
109    //! Array of input events for every pressed key
110    KeyBinding bindingsKeyPress_  [numberOfKeys_s];
111    //! Array of input events for every released key
112    KeyBinding bindingsKeyRelease_[numberOfKeys_s];
113    //! Array of input events for every held key
114    KeyBinding bindingsKeyHold_   [numberOfKeys_s];
115    //! Names of the keys as strings
116    std::string keyNames_[numberOfKeys_s];
117
118    //! denotes the number of different mouse buttons there are in OIS.
119    static const int numberOfMouseButtons_s = 8;
120    //! Array of input events for every pressed mouse button
121    KeyBinding bindingsMouseButtonPress_  [numberOfMouseButtons_s];
122    //! Array of input events for every released mouse button
123    KeyBinding bindingsMouseButtonRelease_[numberOfMouseButtons_s];
124    //! Array of input events for every held mouse button
125    KeyBinding bindingsMouseButtonHold_   [numberOfMouseButtons_s];
126    //! Names of the mouse buttons as strings
127    std::string mouseButtonNames_[numberOfMouseButtons_s];
128
129    //! denotes the number of different joy stick buttons there are in OIS.
130    static const int numberOfJoyStickButtons_s = 32;
131    //! Array of input events for every pressed joy stick button
132    KeyBinding bindingsJoyStickButtonPress_  [numberOfJoyStickButtons_s];
133    //! Array of input events for every released joy stick button
134    KeyBinding bindingsJoyStickButtonRelease_[numberOfJoyStickButtons_s];
135    //! Array of input events for every held joy stick button
136    KeyBinding bindingsJoyStickButtonHold_   [numberOfJoyStickButtons_s];
137    //! Names of the joy stick buttons as strings
138    std::string joyStickButtonNames_[numberOfJoyStickButtons_s];
139
140  };
141
142
143  /**
144    @brief Captures mouse and keyboard input and distributes it to the
145    GUI.
146  */
147  //class _CoreExport GUIInputHandler : public KeyHandler, public MouseHandler, public JoyStickHandler
148  //{
149  //public:
150  //  GUIInputHandler ();
151  //  ~GUIInputHandler();
152
153  //private:
154  //  // input events
155    //bool keyPressed   (const OIS::KeyEvent   &arg);
156    //bool keyReleased  (const OIS::KeyEvent   &arg);
157    //bool keyHeld      (const OIS::KeyEvent   &arg);
158
159  //  bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButton id);
160    //bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButton id);
161    //bool mouseHeld    (const OIS::MouseEvent &arg, OIS::MouseButton id);
162  //  bool mouseMoved   (const OIS::MouseEvent &arg);
163
164    //bool buttonPressed (const OIS::JoyStickEvent &arg, int button);
165    //bool buttonReleased(const OIS::JoyStickEvent &arg, int button);
166    //bool buttonHeld    (const OIS::JoyStickEvent &arg, int button);
167    //bool axisMoved     (const OIS::JoyStickEvent &arg, int axis);
168    //bool sliderMoved   (const OIS::JoyStickEvent &arg, int id);
169    //bool povMoved      (const OIS::JoyStickEvent &arg, int id);
170  //};
171
172}
173
174#endif /* _InputHandler_H__ */
Note: See TracBrowser for help on using the repository browser.