Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

merged changes from input & camera & network branch into trunk

File size: 6.0 KB
RevLine 
[971]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
[1056]3 *                    > www.orxonox.net <
[971]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
[971]29/**
30 @file
[1022]31 @brief Different definitions of input processing.
[971]32 */
[973]33
34#ifndef _InputHandler_H__
35#define _InputHandler_H__
36
[1062]37#include "CorePrereqs.h"
38
[1022]39#include <string>
[1293]40
[1219]41#include "ois/OIS.h"
42#include "OrxonoxClass.h"
43#include "CommandExecutor.h"
[1293]44#include "InputInterfaces.h"
[973]45
46namespace orxonox
47{
[1219]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
[1022]76    bool loadBindings();
[1219]77    void clearBindings();
78
79    void setConfigValues();
[1022]80
[1219]81  private: // functions
82
[1293]83    bool executeSimpleBinding(KeyBinding &binding);
[1219]84
[1293]85    bool keyPressed (const KeyEvent& evt);
86    bool keyReleased(const KeyEvent& evt);
87    bool keyHeld    (const KeyEvent& evt);
[1022]88
[1293]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);
[1022]94
[1293]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) ;
[1022]102
[1219]103  private: // variables
104
105    //! denotes the number of different keys there are in OIS.
106    static const int numberOfKeys_s = 0xEE;
[1022]107    //! Array of input events for every pressed key
[1219]108    KeyBinding bindingsKeyPress_  [numberOfKeys_s];
[1022]109    //! Array of input events for every released key
[1219]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];
[1022]115
[1219]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
[1293]119    KeyBinding bindingsMouseButtonPress_  [numberOfMouseButtons_s];
[1219]120    //! Array of input events for every released mouse button
[1293]121    KeyBinding bindingsMouseButtonRelease_[numberOfMouseButtons_s];
[1219]122    //! Array of input events for every held mouse button
[1293]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_;
[1219]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
[1293]134    KeyBinding bindingsJoyStickButtonPress_  [numberOfJoyStickButtons_s];
[1219]135    //! Array of input events for every released joy stick button
[1293]136    KeyBinding bindingsJoyStickButtonRelease_[numberOfJoyStickButtons_s];
[1219]137    //! Array of input events for every held joy stick button
[1293]138    KeyBinding bindingsJoyStickButtonHold_   [numberOfJoyStickButtons_s];
[1219]139    //! Names of the joy stick buttons as strings
140    std::string joyStickButtonNames_[numberOfJoyStickButtons_s];
141
[973]142  };
143
144
145  /**
[1022]146    @brief Captures mouse and keyboard input and distributes it to the
147    GUI.
[973]148  */
[1219]149  //class _CoreExport GUIInputHandler : public KeyHandler, public MouseHandler, public JoyStickHandler
150  //{
151  //public:
152  //  GUIInputHandler ();
153  //  ~GUIInputHandler();
[973]154
[1219]155  //private:
156  //  // input events
[1293]157    //bool keyPressed   (const OIS::KeyEvent   &arg);
158    //bool keyReleased  (const OIS::KeyEvent   &arg);
159    //bool keyHeld      (const OIS::KeyEvent   &arg);
[973]160
[1293]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);
[1219]164  //  bool mouseMoved   (const OIS::MouseEvent &arg);
165
[1293]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);
[1219]172  //};
173
[973]174}
175
176#endif /* _InputHandler_H__ */
Note: See TracBrowser for help on using the repository browser.