Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 1237 was 1237, checked in by rgrieder, 16 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: 12.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 Declarations of various interface classes for the input management.
32*/
33
34#ifndef _InputInterfaces_H__
35#define _InputInterfaces_H__
36
37#include "CorePrereqs.h"
38
39#include "ois/OIS.h"
40
41namespace orxonox
42{
43  namespace KeyCode
44  {
45    // note: KeyCode comments were directly taken from OISKeyboard.h
46    enum Enum
47    {
48      Unassigned    = OIS::KC_UNASSIGNED, 
49      Escape        = OIS::KC_ESCAPE,     
50      _1            = OIS::KC_1,           
51      _2            = OIS::KC_2,           
52      _3            = OIS::KC_3,           
53      _4            = OIS::KC_4,           
54      _5            = OIS::KC_5,           
55      _6            = OIS::KC_6,           
56      _7            = OIS::KC_7,           
57      _8            = OIS::KC_8,           
58      _9            = OIS::KC_9,           
59      _0            = OIS::KC_0,           
60      Minus         = OIS::KC_MINUS,           // - on main keyboard
61      Equals        = OIS::KC_EQUALS,     
62      Back          = OIS::KC_BACK,            // backspace
63      Tab           = OIS::KC_TAB,         
64      Q             = OIS::KC_Q,           
65      W             = OIS::KC_W,           
66      E             = OIS::KC_E,           
67      R             = OIS::KC_R,           
68      T             = OIS::KC_T,           
69      Y             = OIS::KC_Y,           
70      U             = OIS::KC_U,           
71      I             = OIS::KC_I,           
72      O             = OIS::KC_O,           
73      P             = OIS::KC_P,           
74      LeftBracket   = OIS::KC_LBRACKET,   
75      RightBracket  = OIS::KC_RBRACKET,   
76      Return        = OIS::KC_RETURN,          // Enter on main keyboard
77      LeftControl   = OIS::KC_LCONTROL,   
78      A             = OIS::KC_A,           
79      S             = OIS::KC_S,           
80      D             = OIS::KC_D,           
81      F             = OIS::KC_F,           
82      G             = OIS::KC_G,           
83      H             = OIS::KC_H,           
84      J             = OIS::KC_J,           
85      K             = OIS::KC_K,           
86      L             = OIS::KC_L,           
87      Semicolon     = OIS::KC_SEMICOLON,   
88      Apostrophe    = OIS::KC_APOSTROPHE, 
89      Grave         = OIS::KC_GRAVE,           // accent
90      LeftShift     = OIS::KC_LSHIFT,     
91      Backslash     = OIS::KC_BACKSLASH,   
92      Z             = OIS::KC_Z,           
93      X             = OIS::KC_X,           
94      C             = OIS::KC_C,           
95      V             = OIS::KC_V,           
96      B             = OIS::KC_B,           
97      N             = OIS::KC_N,           
98      M             = OIS::KC_M,           
99      Comma         = OIS::KC_COMMA,       
100      Period        = OIS::KC_PERIOD,          // . on main keyboard
101      Slash         = OIS::KC_SLASH,           // / on main keyboard
102      RightShift    = OIS::KC_RSHIFT,     
103      Multiply      = OIS::KC_MULTIPLY,        // * on numeric keypad
104      LeftAlt       = OIS::KC_LMENU,           // left Alt
105      Space         = OIS::KC_SPACE,       
106      CapsLock      = OIS::KC_CAPITAL,     
107      F1            = OIS::KC_F1,         
108      F2            = OIS::KC_F2,         
109      F3            = OIS::KC_F3,         
110      F4            = OIS::KC_F4,         
111      F5            = OIS::KC_F5,         
112      F6            = OIS::KC_F6,         
113      F7            = OIS::KC_F7,         
114      F8            = OIS::KC_F8,         
115      F9            = OIS::KC_F9,         
116      F10           = OIS::KC_F10,         
117      Numlock       = OIS::KC_NUMLOCK,     
118      Scrolllock    = OIS::KC_SCROLL,          // Scroll Lock
119      Numpad7       = OIS::KC_NUMPAD7,     
120      Numpad8       = OIS::KC_NUMPAD8,     
121      Numpad9       = OIS::KC_NUMPAD9,     
122      NumpadSubtract= OIS::KC_SUBTRACT,        // - on numeric keypad
123      Numpad4       = OIS::KC_NUMPAD4,     
124      Numpad5       = OIS::KC_NUMPAD5,     
125      Numpad6       = OIS::KC_NUMPAD6,     
126      NumpadAdd     = OIS::KC_ADD,             // + on numeric keypad
127      Numpad1       = OIS::KC_NUMPAD1,     
128      Numpad2       = OIS::KC_NUMPAD2,     
129      Numpad3       = OIS::KC_NUMPAD3,     
130      Numpad0       = OIS::KC_NUMPAD0,     
131      NumpadPeriod  = OIS::KC_DECIMAL,         // . on numeric keypad
132      LessThan      = OIS::KC_OEM_102,         // < > | on UK/Germany keyboards
133      F11           = OIS::KC_F11,         
134      F12           = OIS::KC_F12,         
135      F13           = OIS::KC_F13,             //                     (NEC PC98)
136      F14           = OIS::KC_F14,             //                     (NEC PC98)
137      F15           = OIS::KC_F15,             //                     (NEC PC98)
138      Kana          = OIS::KC_KANA,            // (Japanese keyboard)
139      ABNT_C1       = OIS::KC_ABNT_C1,         // / ? on Portugese (Brazilian) keyboards
140      Convert       = OIS::KC_CONVERT,         // (Japanese keyboard)
141      NoConvert     = OIS::KC_NOCONVERT,       // (Japanese keyboard)
142      Yen           = OIS::KC_YEN,             // (Japanese keyboard)
143      ABNT_C2       = OIS::KC_ABNT_C2,         // Numpad . on Portugese (Brazilian) keyboards
144      NumpadEquals  = OIS::KC_NUMPADEQUALS,    // = on numeric keypad (NEC PC98)
145      PreviousTrack = OIS::KC_PREVTRACK,       // Previous Track (KC_CIRCUMFLEX on Japanese keyboard)
146      AT            = OIS::KC_AT,              //                     (NEC PC98)
147      Colon         = OIS::KC_COLON,           //                     (NEC PC98)
148      Underline     = OIS::KC_UNDERLINE,       //                     (NEC PC98)
149      Kanji         = OIS::KC_KANJI,           // (Japanese keyboard)
150      Stop          = OIS::KC_STOP,            //                     (NEC PC98)
151      AX            = OIS::KC_AX,              //                     (Japan AX)
152      Unlabeled     = OIS::KC_UNLABELED,       //                        (J3100)
153      NextTrack     = OIS::KC_NEXTTRACK,       // Next Track
154      NumpadEnter   = OIS::KC_NUMPADENTER,     // Enter on numeric keypad
155      RightControl  = OIS::KC_RCONTROL,   
156      Mute          = OIS::KC_MUTE,            // Mute
157      Calculator    = OIS::KC_CALCULATOR,      // Calculator
158      PlayPause     = OIS::KC_PLAYPAUSE,       // Play / Pause
159      MediaStop     = OIS::KC_MEDIASTOP,       // Media Stop
160      VolumeDown    = OIS::KC_VOLUMEDOWN,      // Volume -
161      VolumeUp      = OIS::KC_VOLUMEUP,        // Volume +
162      WebHome       = OIS::KC_WEBHOME,         // Web home
163      NumpadComma   = OIS::KC_NUMPADCOMMA,     // , on numeric keypad (NEC PC98)
164      Divide        = OIS::KC_DIVIDE,          // / on numeric keypad
165      SYSRQ         = OIS::KC_SYSRQ,       
166      RightAlt      = OIS::KC_RMENU,           // right Alt
167      Pause         = OIS::KC_PAUSE,           // Pause
168      Home          = OIS::KC_HOME,            // Home on arrow keypad
169      Up            = OIS::KC_UP,              // UpArrow on arrow keypad
170      PageUp        = OIS::KC_PGUP,            // PgUp on arrow keypad
171      Left          = OIS::KC_LEFT,            // LeftArrow on arrow keypad
172      Right         = OIS::KC_RIGHT,           // RightArrow on arrow keypad
173      End           = OIS::KC_END,             // End on arrow keypad
174      Down          = OIS::KC_DOWN,            // DownArrow on arrow keypad
175      PageDown      = OIS::KC_PGDOWN,          // PgDn on arrow keypad
176      Insert        = OIS::KC_INSERT,          // Insert on arrow keypad
177      Delete        = OIS::KC_DELETE,          // Delete on arrow keypad
178      LeftWindows   = OIS::KC_LWIN,            // Left Windows key
179      RightWindows  = OIS::KC_RWIN,            // Right Windows key
180      Apps          = OIS::KC_APPS,            // AppMenu key
181      Power         = OIS::KC_POWER,           // System Power
182      Sleep         = OIS::KC_SLEEP,           // System Sleep
183      Wake          = OIS::KC_WAKE,            // System Wake
184      WebSearch     = OIS::KC_WEBSEARCH,       // Web Search
185      WebFavorites  = OIS::KC_WEBFAVORITES,    // Web Favorites
186      WebRefresh    = OIS::KC_WEBREFRESH,      // Web Refresh
187      WebStop       = OIS::KC_WEBSTOP,         // Web Stop
188      WebForward    = OIS::KC_WEBFORWARD,      // Web Forward
189      WebBack       = OIS::KC_WEBBACK,         // Web Back
190      MyComputer    = OIS::KC_MYCOMPUTER,      // My Computer
191      Mail          = OIS::KC_MAIL,            // Mail
192      MediaSelect   = OIS::KC_MEDIASELECT      // Media Select
193    };
194  }
195
196  namespace MouseButton
197  {
198    enum Enum
199    {
200      Left    = OIS::MB_Left,
201      Right   = OIS::MB_Right,
202      Middle  = OIS::MB_Middle,
203      Button3 = OIS::MB_Button3,
204      Button4 = OIS::MB_Button4,
205      Button5 = OIS::MB_Button5,
206      Button6 = OIS::MB_Button6,
207      Button7 = OIS::MB_Button7
208    };
209  }
210
211  namespace KeyboardModifier
212  {
213    enum Enum
214    {
215      Shift = 0x0000001,
216      Ctrl  = 0x0000010,
217      Alt   = 0x0000100
218    };
219  }
220
221  class _CoreExport KeyboardState
222  {
223  public:
224  };
225
226  struct _CoreExport Key
227  {
228    Key(const OIS::KeyEvent& evt) : key((KeyCode::Enum)evt.key), text(evt.text) { }
229    KeyCode::Enum key;
230    unsigned int text;
231  };
232
233  class _CoreExport KeyEvent
234  {
235  public:
236    KeyEvent(KeyCode::Enum key, unsigned int text) : key(key), text(text) { }
237    KeyEvent(const OIS::KeyEvent& evt, unsigned int mod) : key((KeyCode::Enum)evt.key), text(evt.text), modifiers(mod) { }
238    KeyEvent(const Key& key, unsigned int mod) : key(key.key), text(key.text), modifiers(mod) { }
239    bool isModifierDown(KeyboardModifier::Enum modifier) const { return (KeyboardModifier::Enum)modifier&modifiers; }
240
241    const KeyCode::Enum key;
242    unsigned int text;
243    unsigned int modifiers;
244  };
245
246  typedef OIS::MouseState MouseState;
247
248  class _CoreExport JoyStickState : OIS::JoyStickState
249  {
250  public:
251    JoyStickState(const OIS::JoyStickState& state, int ID) : OIS::JoyStickState(state), JoyStickID(ID) { }
252    JoyStickState() { clear(); }
253    int JoyStickID;
254  };
255
256  /**
257    @brief Interface class used for key input listeners.
258  */
259  class _CoreExport KeyHandler
260  {
261  public:
262    virtual ~KeyHandler() { }
263    virtual bool keyPressed (const KeyEvent& evt) = 0;
264    virtual bool keyReleased(const KeyEvent& evt) = 0;
265    virtual bool keyHeld    (const KeyEvent& evt) = 0;
266  };
267
268  /**
269    @brief Interface class used for mouse input listeners.
270  */
271  class _CoreExport MouseHandler
272  {
273  public:
274    virtual ~MouseHandler() { }
275    virtual bool mouseButtonPressed (const MouseState& state, MouseButton::Enum id) = 0;
276    virtual bool mouseButtonReleased(const MouseState& state, MouseButton::Enum id) = 0;
277    virtual bool mouseButtonHeld    (const MouseState& state, MouseButton::Enum id) = 0;
278    virtual bool mouseMoved         (const MouseState& state) = 0;
279    virtual bool mouseWheelTurned   (const MouseState& state) = 0;
280  };
281
282
283  /**
284    @brief Interface class used for joy stick input listeners.
285  */
286  class _CoreExport JoyStickHandler
287  {
288  public:
289    virtual ~JoyStickHandler() { }
290    virtual bool joyStickButtonPressed (const JoyStickState& state, int button) = 0;
291    virtual bool joyStickButtonReleased(const JoyStickState& state, int button) = 0;
292    virtual bool joyStickButtonHeld    (const JoyStickState& state, int button) = 0;
293    virtual bool joyStickAxisMoved     (const JoyStickState& state, int axis)   = 0;
294    virtual bool joyStickSliderMoved   (const JoyStickState& state, int index) {return true;}
295    virtual bool joyStickPovMoved      (const JoyStickState& state, int index) {return true;}
296    virtual bool joyStickVector3Moved  (const JoyStickState& state, int index) {return true;}
297  };
298
299}
300
301#endif /* _InputInterfaces_H__ */
Note: See TracBrowser for help on using the repository browser.