Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/core/input/KeyBinder.h @ 1788

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

merged gui back to trunk.
update the media repository!

  • Property svn:eol-style set to native
File size: 5.4 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
32    Different definitions of input processing.
33*/
34
35#ifndef _KeyBinder_H__
36#define _KeyBinder_H__
37
38#include "core/CorePrereqs.h"
39
40#include <vector>
41
42#include "core/OrxonoxClass.h"
43#include "InputInterfaces.h"
44#include "Button.h"
45#include "HalfAxis.h"
46
47namespace orxonox
48{
49    /**
50    @brief
51        Handles mouse, keyboard and joy stick input while in the actual game mode.
52        Manages the key bindings.
53    */
54    class _CoreExport KeyBinder : public KeyHandler, public MouseHandler, public JoyStickHandler, public OrxonoxClass
55    {
56    public:
57        KeyBinder ();
58        virtual ~KeyBinder();
59
60        void loadBindings();
61        void clearBindings();
62        void setConfigValues();
63        void resetJoyStickAxes();
64
65    protected: // functions
66        void tickInput(float dt);
67        //void tickInput(float dt, int device);
68        void tickKey(float dt) { }
69        void tickMouse(float dt);
70        void tickJoyStick(float dt, unsigned int joyStick);
71        void tickDevices(unsigned int begin, unsigned int end);
72
73        virtual void readTrigger(Button& button);
74
75        void keyPressed (const KeyEvent& evt);
76        void keyReleased(const KeyEvent& evt);
77        void keyHeld    (const KeyEvent& evt);
78
79        void mouseButtonPressed (MouseButton::Enum id);
80        void mouseButtonReleased(MouseButton::Enum id);
81        void mouseButtonHeld    (MouseButton::Enum id);
82        void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize);
83        void mouseScrolled      (int abs, int rel);
84
85        void joyStickButtonPressed (unsigned int joyStickID, JoyStickButton::Enum id);
86        void joyStickButtonReleased(unsigned int joyStickID, JoyStickButton::Enum id);
87        void joyStickButtonHeld    (unsigned int joyStickID, JoyStickButton::Enum id);
88        void joyStickAxisMoved     (unsigned int joyStickID, unsigned int axis, float value);
89
90    protected: // variables
91        //! denotes the number of different keys there are in OIS.
92        static const unsigned int nKeys_s = 0xEE;
93        //! Actual key bindings as bundle for Press, Hold and Release
94        Button keys_ [nKeys_s];
95
96        //! denotes the number of different mouse buttons there are in OIS.
97        static const unsigned int nMouseButtons_s = 8 + 2*2; // 8 buttons and 2 scroll wheels
98        //! Actual key bindings as bundle for Press, Hold and Release
99        Button mouseButtons_ [nMouseButtons_s];
100
101        //! denotes the number of different joy stick buttons there are in OIS.
102        static const unsigned int nJoyStickButtons_s = 32 + 4 * 4; // 32 buttons and 4 POVs with 4 buttons
103        //! Actual key bindings as bundle for Press, Hold and Release
104        Button joyStickButtons_ [nJoyStickButtons_s];
105
106        //! denotes the number of half axes (every axis twice) there can be.
107        static const unsigned int nHalfAxes_s = 56;
108        /**
109        * Array with all the half axes for mouse and joy sticks.
110        * Keep in mind that the positions are fixed and that the first entry is the
111        * positive one and the second is negative.
112        * Sequence is as follows:
113        *  0 -  3: Mouse x and y
114        *  4 -  7: empty
115        *  8 - 23: joy stick slider axes 1 to 8
116        * 24 - 55: joy stick axes 1 - 16
117        */
118        HalfAxis halfAxes_[nHalfAxes_s];
119
120        /**
121        @brief
122            Commands that have additional parameters (axes) are executed at the end of
123            the tick() so that all values can be buffered for single execution.
124        */
125        std::vector<BufferedParamCommand*> paramCommandBuffer_;
126
127        //! Keeps track of the absolute mouse value (incl. scroll wheel)
128        int mousePosition_[2];
129        //! Used to derive mouse input if requested
130        int mouseRelative_[2];
131        float deriveTime_;
132
133
134        //##### ConfigValues #####
135
136        //! Threshold for analog triggers until which the state is 0.
137        float analogThreshold_;
138        //! Threshold for analog triggers until which the button is not pressed.
139        float buttonThreshold_;
140        //! Derive mouse input for absolute values?
141        bool bDeriveMouseInput_;
142        //! Accuracy of the mouse input deriver. The higher the more precise, but laggier.
143        float derivePeriod_;
144        //! mouse sensitivity
145        float mouseSensitivity_;
146        //! mouse sensitivity if mouse input is derived
147        float mouseSensitivityDerived_;
148        //! Whether or not to clip abslute mouse values to 1024
149        bool bClipMouse_;
150    };
151}
152
153#endif /* _KeyBinder_H__ */
Note: See TracBrowser for help on using the repository browser.