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 | |
---|
41 | namespace 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 | NumRow1 = OIS::KC_1, |
---|
51 | NumRow2 = OIS::KC_2, |
---|
52 | NumRow3 = OIS::KC_3, |
---|
53 | NumRow4 = OIS::KC_4, |
---|
54 | NumRow5 = OIS::KC_5, |
---|
55 | NumRow6 = OIS::KC_6, |
---|
56 | NumRow7 = OIS::KC_7, |
---|
57 | NumRow8 = OIS::KC_8, |
---|
58 | NumRow9 = OIS::KC_9, |
---|
59 | NumRow0 = 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 | struct _CoreExport Key |
---|
222 | { |
---|
223 | Key(const OIS::KeyEvent& evt) : key((KeyCode::Enum)evt.key), text(evt.text) { } |
---|
224 | KeyCode::Enum key; |
---|
225 | unsigned int text; |
---|
226 | }; |
---|
227 | |
---|
228 | class _CoreExport KeyEvent |
---|
229 | { |
---|
230 | public: |
---|
231 | KeyEvent(KeyCode::Enum key, unsigned int text) : key(key), text(text) { } |
---|
232 | KeyEvent(const OIS::KeyEvent& evt, unsigned int mod) : key((KeyCode::Enum)evt.key), text(evt.text), modifiers(mod) { } |
---|
233 | KeyEvent(const Key& key, unsigned int mod) : key(key.key), text(key.text), modifiers(mod) { } |
---|
234 | bool isModifierDown(KeyboardModifier::Enum modifier) const { return (KeyboardModifier::Enum)modifier&modifiers; } |
---|
235 | |
---|
236 | const KeyCode::Enum key; |
---|
237 | unsigned int text; |
---|
238 | unsigned int modifiers; |
---|
239 | }; |
---|
240 | |
---|
241 | typedef OIS::MouseState MouseState; |
---|
242 | |
---|
243 | class _CoreExport JoyStickState : OIS::JoyStickState |
---|
244 | { |
---|
245 | public: |
---|
246 | JoyStickState(const OIS::JoyStickState& state, int ID) : OIS::JoyStickState(state), mJoyStickID(ID) { } |
---|
247 | JoyStickState() { clear(); } |
---|
248 | int mJoyStickID; |
---|
249 | }; |
---|
250 | |
---|
251 | /** |
---|
252 | @brief Interface class used for key input listeners. |
---|
253 | */ |
---|
254 | class _CoreExport KeyHandler |
---|
255 | { |
---|
256 | public: |
---|
257 | virtual ~KeyHandler() { } |
---|
258 | virtual bool keyPressed (const KeyEvent& evt) = 0; |
---|
259 | virtual bool keyReleased(const KeyEvent& evt) = 0; |
---|
260 | virtual bool keyHeld (const KeyEvent& evt) = 0; |
---|
261 | }; |
---|
262 | |
---|
263 | /** |
---|
264 | @brief Interface class used for mouse input listeners. |
---|
265 | */ |
---|
266 | class _CoreExport MouseHandler |
---|
267 | { |
---|
268 | public: |
---|
269 | virtual ~MouseHandler() { } |
---|
270 | virtual bool mouseButtonPressed (const MouseState& state, MouseButton::Enum id) = 0; |
---|
271 | virtual bool mouseButtonReleased(const MouseState& state, MouseButton::Enum id) = 0; |
---|
272 | virtual bool mouseButtonHeld (const MouseState& state, MouseButton::Enum id) = 0; |
---|
273 | virtual bool mouseMoved (const MouseState& state) = 0; |
---|
274 | virtual bool mouseScrolled (const MouseState& state) = 0; |
---|
275 | }; |
---|
276 | |
---|
277 | |
---|
278 | /** |
---|
279 | @brief Interface class used for joy stick input listeners. |
---|
280 | */ |
---|
281 | class _CoreExport JoyStickHandler |
---|
282 | { |
---|
283 | public: |
---|
284 | virtual ~JoyStickHandler() { } |
---|
285 | virtual bool joyStickButtonPressed (const JoyStickState& state, int button) = 0; |
---|
286 | virtual bool joyStickButtonReleased(const JoyStickState& state, int button) = 0; |
---|
287 | virtual bool joyStickButtonHeld (const JoyStickState& state, int button) = 0; |
---|
288 | virtual bool joyStickAxisMoved (const JoyStickState& state, int axis) = 0; |
---|
289 | virtual bool joyStickSliderMoved (const JoyStickState& state, int index) {return true;} |
---|
290 | virtual bool joyStickPovMoved (const JoyStickState& state, int index) {return true;} |
---|
291 | virtual bool joyStickVector3Moved (const JoyStickState& state, int index) {return true;} |
---|
292 | }; |
---|
293 | |
---|
294 | } |
---|
295 | |
---|
296 | #endif /* _InputInterfaces_H__ */ |
---|