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 | Declarations of various interface classes for the input management. |
---|
33 | */ |
---|
34 | |
---|
35 | #ifndef _InputInterfaces_H__ |
---|
36 | #define _InputInterfaces_H__ |
---|
37 | |
---|
38 | #include "core/CorePrereqs.h" |
---|
39 | |
---|
40 | #include "ois/OISKeyboard.h" |
---|
41 | #include "ois/OISMouse.h" |
---|
42 | #include "ois/OISJoyStick.h" |
---|
43 | #include "util/Math.h" |
---|
44 | |
---|
45 | namespace orxonox |
---|
46 | { |
---|
47 | namespace KeyCode |
---|
48 | { |
---|
49 | const unsigned int numberOfKeys = 0xEE; // 238 |
---|
50 | |
---|
51 | // note: KeyCode comments were directly copied from OISKeyboard.h |
---|
52 | enum ByEnum |
---|
53 | { |
---|
54 | Unassigned = OIS::KC_UNASSIGNED, |
---|
55 | Escape = OIS::KC_ESCAPE, |
---|
56 | NumRow1 = OIS::KC_1, |
---|
57 | NumRow2 = OIS::KC_2, |
---|
58 | NumRow3 = OIS::KC_3, |
---|
59 | NumRow4 = OIS::KC_4, |
---|
60 | NumRow5 = OIS::KC_5, |
---|
61 | NumRow6 = OIS::KC_6, |
---|
62 | NumRow7 = OIS::KC_7, |
---|
63 | NumRow8 = OIS::KC_8, |
---|
64 | NumRow9 = OIS::KC_9, |
---|
65 | NumRow0 = OIS::KC_0, |
---|
66 | Minus = OIS::KC_MINUS, // - on main keyboard |
---|
67 | Equals = OIS::KC_EQUALS, |
---|
68 | Back = OIS::KC_BACK, // backspace |
---|
69 | Tab = OIS::KC_TAB, |
---|
70 | Q = OIS::KC_Q, |
---|
71 | W = OIS::KC_W, |
---|
72 | E = OIS::KC_E, |
---|
73 | R = OIS::KC_R, |
---|
74 | T = OIS::KC_T, |
---|
75 | Y = OIS::KC_Y, |
---|
76 | U = OIS::KC_U, |
---|
77 | I = OIS::KC_I, |
---|
78 | O = OIS::KC_O, |
---|
79 | P = OIS::KC_P, |
---|
80 | LeftBracket = OIS::KC_LBRACKET, |
---|
81 | RightBracket = OIS::KC_RBRACKET, |
---|
82 | Return = OIS::KC_RETURN, // Enter on main keyboard |
---|
83 | LeftControl = OIS::KC_LCONTROL, |
---|
84 | A = OIS::KC_A, |
---|
85 | S = OIS::KC_S, |
---|
86 | D = OIS::KC_D, |
---|
87 | F = OIS::KC_F, |
---|
88 | G = OIS::KC_G, |
---|
89 | H = OIS::KC_H, |
---|
90 | J = OIS::KC_J, |
---|
91 | K = OIS::KC_K, |
---|
92 | L = OIS::KC_L, |
---|
93 | Semicolon = OIS::KC_SEMICOLON, |
---|
94 | Apostrophe = OIS::KC_APOSTROPHE, |
---|
95 | Grave = OIS::KC_GRAVE, // accent |
---|
96 | LeftShift = OIS::KC_LSHIFT, |
---|
97 | Backslash = OIS::KC_BACKSLASH, |
---|
98 | Z = OIS::KC_Z, |
---|
99 | X = OIS::KC_X, |
---|
100 | C = OIS::KC_C, |
---|
101 | V = OIS::KC_V, |
---|
102 | B = OIS::KC_B, |
---|
103 | N = OIS::KC_N, |
---|
104 | M = OIS::KC_M, |
---|
105 | Comma = OIS::KC_COMMA, |
---|
106 | Period = OIS::KC_PERIOD, // . on main keyboard |
---|
107 | Slash = OIS::KC_SLASH, // / on main keyboard |
---|
108 | RightShift = OIS::KC_RSHIFT, |
---|
109 | Multiply = OIS::KC_MULTIPLY, // * on numeric keypad |
---|
110 | LeftAlt = OIS::KC_LMENU, // left Alt |
---|
111 | Space = OIS::KC_SPACE, |
---|
112 | CapsLock = OIS::KC_CAPITAL, |
---|
113 | F1 = OIS::KC_F1, |
---|
114 | F2 = OIS::KC_F2, |
---|
115 | F3 = OIS::KC_F3, |
---|
116 | F4 = OIS::KC_F4, |
---|
117 | F5 = OIS::KC_F5, |
---|
118 | F6 = OIS::KC_F6, |
---|
119 | F7 = OIS::KC_F7, |
---|
120 | F8 = OIS::KC_F8, |
---|
121 | F9 = OIS::KC_F9, |
---|
122 | F10 = OIS::KC_F10, |
---|
123 | NumLock = OIS::KC_NUMLOCK, |
---|
124 | ScrollLock = OIS::KC_SCROLL, // Scroll Lock |
---|
125 | Numpad7 = OIS::KC_NUMPAD7, |
---|
126 | Numpad8 = OIS::KC_NUMPAD8, |
---|
127 | Numpad9 = OIS::KC_NUMPAD9, |
---|
128 | NumpadSubtract= OIS::KC_SUBTRACT, // - on numeric keypad |
---|
129 | Numpad4 = OIS::KC_NUMPAD4, |
---|
130 | Numpad5 = OIS::KC_NUMPAD5, |
---|
131 | Numpad6 = OIS::KC_NUMPAD6, |
---|
132 | NumpadAdd = OIS::KC_ADD, // + on numeric keypad |
---|
133 | Numpad1 = OIS::KC_NUMPAD1, |
---|
134 | Numpad2 = OIS::KC_NUMPAD2, |
---|
135 | Numpad3 = OIS::KC_NUMPAD3, |
---|
136 | Numpad0 = OIS::KC_NUMPAD0, |
---|
137 | NumpadPeriod = OIS::KC_DECIMAL, // . on numeric keypad |
---|
138 | LessThan = OIS::KC_OEM_102, // < > | on UK/Germany keyboards |
---|
139 | F11 = OIS::KC_F11, |
---|
140 | F12 = OIS::KC_F12, |
---|
141 | F13 = OIS::KC_F13, // (NEC PC98) |
---|
142 | F14 = OIS::KC_F14, // (NEC PC98) |
---|
143 | F15 = OIS::KC_F15, // (NEC PC98) |
---|
144 | Kana = OIS::KC_KANA, // (Japanese keyboard) |
---|
145 | ABNT_C1 = OIS::KC_ABNT_C1, // / ? on Portugese (Brazilian) keyboards |
---|
146 | Convert = OIS::KC_CONVERT, // (Japanese keyboard) |
---|
147 | NoConvert = OIS::KC_NOCONVERT, // (Japanese keyboard) |
---|
148 | Yen = OIS::KC_YEN, // (Japanese keyboard) |
---|
149 | ABNT_C2 = OIS::KC_ABNT_C2, // Numpad . on Portugese (Brazilian) keyboards |
---|
150 | NumpadEquals = OIS::KC_NUMPADEQUALS, // = on numeric keypad (NEC PC98) |
---|
151 | PreviousTrack = OIS::KC_PREVTRACK, // Previous Track (KC_CIRCUMFLEX on Japanese keyboard) |
---|
152 | AT = OIS::KC_AT, // (NEC PC98) |
---|
153 | Colon = OIS::KC_COLON, // (NEC PC98) |
---|
154 | Underline = OIS::KC_UNDERLINE, // (NEC PC98) |
---|
155 | Kanji = OIS::KC_KANJI, // (Japanese keyboard) |
---|
156 | Stop = OIS::KC_STOP, // (NEC PC98) |
---|
157 | AX = OIS::KC_AX, // (Japan AX) |
---|
158 | Unlabeled = OIS::KC_UNLABELED, // (J3100) |
---|
159 | NextTrack = OIS::KC_NEXTTRACK, // Next Track |
---|
160 | NumpadEnter = OIS::KC_NUMPADENTER, // Enter on numeric keypad |
---|
161 | RightControl = OIS::KC_RCONTROL, |
---|
162 | Mute = OIS::KC_MUTE, // Mute |
---|
163 | Calculator = OIS::KC_CALCULATOR, // Calculator |
---|
164 | PlayPause = OIS::KC_PLAYPAUSE, // Play / Pause |
---|
165 | MediaStop = OIS::KC_MEDIASTOP, // Media Stop |
---|
166 | VolumeDown = OIS::KC_VOLUMEDOWN, // Volume - |
---|
167 | VolumeUp = OIS::KC_VOLUMEUP, // Volume + |
---|
168 | WebHome = OIS::KC_WEBHOME, // Web home |
---|
169 | NumpadComma = OIS::KC_NUMPADCOMMA, // , on numeric keypad (NEC PC98) |
---|
170 | Divide = OIS::KC_DIVIDE, // / on numeric keypad |
---|
171 | SystemRequest = OIS::KC_SYSRQ, |
---|
172 | RightAlt = OIS::KC_RMENU, // right Alt |
---|
173 | Pause = OIS::KC_PAUSE, // Pause |
---|
174 | Home = OIS::KC_HOME, // Home on arrow keypad |
---|
175 | Up = OIS::KC_UP, // UpArrow on arrow keypad |
---|
176 | PageUp = OIS::KC_PGUP, // PgUp on arrow keypad |
---|
177 | Left = OIS::KC_LEFT, // LeftArrow on arrow keypad |
---|
178 | Right = OIS::KC_RIGHT, // RightArrow on arrow keypad |
---|
179 | End = OIS::KC_END, // End on arrow keypad |
---|
180 | Down = OIS::KC_DOWN, // DownArrow on arrow keypad |
---|
181 | PageDown = OIS::KC_PGDOWN, // PgDn on arrow keypad |
---|
182 | Insert = OIS::KC_INSERT, // Insert on arrow keypad |
---|
183 | Delete = OIS::KC_DELETE, // Delete on arrow keypad |
---|
184 | LeftWindows = OIS::KC_LWIN, // Left Windows key |
---|
185 | RightWindows = OIS::KC_RWIN, // Right Windows key |
---|
186 | Apps = OIS::KC_APPS, // AppMenu key |
---|
187 | Power = OIS::KC_POWER, // System Power |
---|
188 | Sleep = OIS::KC_SLEEP, // System Sleep |
---|
189 | Wake = OIS::KC_WAKE, // System Wake |
---|
190 | WebSearch = OIS::KC_WEBSEARCH, // Web Search |
---|
191 | WebFavorites = OIS::KC_WEBFAVORITES, // Web Favorites |
---|
192 | WebRefresh = OIS::KC_WEBREFRESH, // Web Refresh |
---|
193 | WebStop = OIS::KC_WEBSTOP, // Web Stop |
---|
194 | WebForward = OIS::KC_WEBFORWARD, // Web Forward |
---|
195 | WebBack = OIS::KC_WEBBACK, // Web Back |
---|
196 | MyComputer = OIS::KC_MYCOMPUTER, // My Computer |
---|
197 | Mail = OIS::KC_MAIL, // Mail |
---|
198 | MediaSelect = OIS::KC_MEDIASELECT // Media Select |
---|
199 | }; |
---|
200 | |
---|
201 | // Names as string. Has no real linkage! |
---|
202 | const char* const ByString[] = |
---|
203 | { |
---|
204 | "Unassigned", |
---|
205 | "Escape", |
---|
206 | "NumRow1", "NumRow2", "NumRow3", "NumRow4", "NumRow5", |
---|
207 | "NumRow6", "NumRow7", "NumRow8", "NumRow9", "NumRow0", |
---|
208 | "Minus", "Equals", "Back", "Tab", |
---|
209 | "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", |
---|
210 | "LeftBracket", "RightBracket", |
---|
211 | "Return", "LeftControl", |
---|
212 | "A", "S", "D", "F", "G", "H", "J", "K", "L", |
---|
213 | "Semicolon", "Apostrophe", "Grave", |
---|
214 | "LeftShift", "Backslash", |
---|
215 | "Z", "X", "C", "V", "B", "N", "M", |
---|
216 | "Comma", "Period", "Slash", |
---|
217 | "RightShift", |
---|
218 | "Multiply", |
---|
219 | "LeftAlt", |
---|
220 | "Space", |
---|
221 | "CapsLock", |
---|
222 | "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", |
---|
223 | "NumLock", "ScrollLock", |
---|
224 | "Numpad7", "Numpad8", "Numpad9", |
---|
225 | "NumpadSubtract", |
---|
226 | "Numpad4", "Numpad5", "Numpad6", |
---|
227 | "NumpadAdd", |
---|
228 | "Numpad1", "Numpad2", "Numpad3", "Numpad0", |
---|
229 | "NumpadPeriod", |
---|
230 | "","", |
---|
231 | "LessThan", |
---|
232 | "F11", "F12", |
---|
233 | "","","","","","","","","","","", |
---|
234 | "F13", "F14", "F15", |
---|
235 | "","","","","","","","","","", |
---|
236 | "Kana", |
---|
237 | "","", |
---|
238 | "ABNT_C1", |
---|
239 | "","","","","", |
---|
240 | "Convert", |
---|
241 | "", |
---|
242 | "NoConvert", |
---|
243 | "", |
---|
244 | "Yen", |
---|
245 | "ABNT_C2", |
---|
246 | "","","","","","","","","","","","","","", |
---|
247 | "NumpadEquals", |
---|
248 | "","", |
---|
249 | "PreviousTrack", |
---|
250 | "AT", |
---|
251 | "Colon", "Underline", |
---|
252 | "Kanji", |
---|
253 | "Stop", |
---|
254 | "AX", |
---|
255 | "Unlabeled", |
---|
256 | "NextTrack", |
---|
257 | "","", |
---|
258 | "NumpadEnter", |
---|
259 | "RightControl", |
---|
260 | "","", |
---|
261 | "Mute", |
---|
262 | "Calculator", |
---|
263 | "PlayPause", |
---|
264 | "", |
---|
265 | "MediaStop", |
---|
266 | "","","","","","","","","", |
---|
267 | "VolumeDown", |
---|
268 | "", |
---|
269 | "VolumeUp", |
---|
270 | "", |
---|
271 | "WebHome", |
---|
272 | "NumpadComma", |
---|
273 | "", |
---|
274 | "Divide", |
---|
275 | "", |
---|
276 | "SystemRequest", |
---|
277 | "RightAlt", |
---|
278 | "","","","","","","","","","","","", |
---|
279 | "Pause", |
---|
280 | "", |
---|
281 | "Home", |
---|
282 | "UP", |
---|
283 | "PageUp", |
---|
284 | "", |
---|
285 | "Left", |
---|
286 | "", |
---|
287 | "Right", |
---|
288 | "", |
---|
289 | "End", "Down", "PageDown", "Insert", "Delete", |
---|
290 | "","","","","","","", |
---|
291 | "LeftWindows", "RightWindows", "Apps", |
---|
292 | "Power", "Sleep", |
---|
293 | "","","", |
---|
294 | "Wake", |
---|
295 | "", |
---|
296 | "WebSearch", "WebFavorites", "WebRefresh", "WebStop", "WebForward", "WebBack", |
---|
297 | "MyComputer", "Mail", "MediaSelect" |
---|
298 | }; |
---|
299 | } |
---|
300 | |
---|
301 | namespace MouseButtonCode |
---|
302 | { |
---|
303 | const unsigned int numberOfButtons = 8; |
---|
304 | |
---|
305 | enum ByEnum |
---|
306 | { |
---|
307 | Left = OIS::MB_Left, |
---|
308 | Right = OIS::MB_Right, |
---|
309 | Middle = OIS::MB_Middle, |
---|
310 | Button3 = OIS::MB_Button3, |
---|
311 | Button4 = OIS::MB_Button4, |
---|
312 | Button5 = OIS::MB_Button5, |
---|
313 | Button6 = OIS::MB_Button6, |
---|
314 | Button7 = OIS::MB_Button7, |
---|
315 | }; |
---|
316 | |
---|
317 | // Names as string. Has no real linkage! |
---|
318 | const char* const ByString[] = |
---|
319 | { |
---|
320 | "Left", |
---|
321 | "Right", |
---|
322 | "Middle", |
---|
323 | "Button3", |
---|
324 | "Button4", |
---|
325 | "Button5", |
---|
326 | "Button6", |
---|
327 | "Button7", |
---|
328 | }; |
---|
329 | } |
---|
330 | |
---|
331 | namespace MouseAxisCode |
---|
332 | { |
---|
333 | const unsigned int numberOfAxes = 2; |
---|
334 | |
---|
335 | enum ByEnum |
---|
336 | { |
---|
337 | X, |
---|
338 | Y |
---|
339 | }; |
---|
340 | |
---|
341 | // Names as string. Has no real linkage! |
---|
342 | const char* const ByString[] = |
---|
343 | { |
---|
344 | "X", |
---|
345 | "Y" |
---|
346 | }; |
---|
347 | } |
---|
348 | |
---|
349 | namespace JoyStickButtonCode |
---|
350 | { |
---|
351 | const unsigned int numberOfButtons = 64; |
---|
352 | |
---|
353 | enum ByEnum |
---|
354 | { |
---|
355 | Button0 = 0, Button1 = 1, Button2 = 2, Button3 = 3, |
---|
356 | Button4 = 4, Button5 = 5, Button6 = 6, Button7 = 7, |
---|
357 | Button8 = 8, Button9 = 9, Button10 = 10, Button11 = 11, |
---|
358 | Button12 = 12, Button13 = 13, Button14 = 14, Button15 = 15, |
---|
359 | Button16 = 16, Button17 = 17, Button18 = 18, Button19 = 19, |
---|
360 | Button20 = 20, Button21 = 21, Button22 = 22, Button23 = 23, |
---|
361 | Button24 = 24, Button25 = 25, Button26 = 26, Button27 = 27, |
---|
362 | Button28 = 28, Button29 = 29, Button30 = 30, Button31 = 31, |
---|
363 | |
---|
364 | POV0North = 32, POV0South = 33, POV0East = 34, POV0West = 35, |
---|
365 | POV0NorthEast = 36, POV0SouthEast = 37, POV0NorthWest = 38, POV0SouthWest = 39, |
---|
366 | |
---|
367 | POV1North = 40, POV1South = 41, POV1East = 42, POV1West = 43, |
---|
368 | POV1NorthEast = 44, POV1SouthEast = 45, POV1NorthWest = 46, POV1SouthWest = 47, |
---|
369 | |
---|
370 | POV2North = 48, POV2South = 49, POV2East = 50, POV2West = 51, |
---|
371 | POV2NorthEast = 52, POV2SouthEast = 53, POV2NorthWest = 54, POV2SouthWest = 55, |
---|
372 | |
---|
373 | POV3North = 56, POV3South = 57, POV3East = 58, POV3West = 59, |
---|
374 | POV3NorthEast = 60, POV3SouthEast = 61, POV3NorthWest = 62, POV3SouthWest = 63, |
---|
375 | }; |
---|
376 | |
---|
377 | // Names as string. Has no real linkage! |
---|
378 | const char* const ByString[] = |
---|
379 | { |
---|
380 | "Button00", "Button01", "Button02", "Button03", |
---|
381 | "Button04", "Button05", "Button06", "Button07", |
---|
382 | "Button08", "Button09", "Button10", "Button11", |
---|
383 | "Button12", "Button13", "Button14", "Button15", |
---|
384 | "Button16", "Button17", "Button18", "Button19", |
---|
385 | "Button20", "Button21", "Button22", "Button23", |
---|
386 | "Button24", "Button25", "Button26", "Button27", |
---|
387 | "Button28", "Button29", "Button30", "Button31", |
---|
388 | "POV0North", "POV0South", "POV0East", "POV0West", |
---|
389 | "POV0NorthEast", "POV0SouthEast", "POV0NorthWest", "POV0SouthWest", |
---|
390 | "POV1North", "POV1South", "POV1East", "POV1West", |
---|
391 | "POV1NorthEast", "POV1SouthEast", "POV1NorthWest", "POV1SouthWest", |
---|
392 | "POV2North", "POV2South", "POV2East", "POV2West", |
---|
393 | "POV2NorthEast", "POV2SouthEast", "POV2NorthWest", "POV2SouthWest", |
---|
394 | "POV3North", "POV3South", "POV3East", "POV3West", |
---|
395 | "POV3NorthEast", "POV3SouthEast", "POV3NorthWest", "POV3SouthWest" |
---|
396 | }; |
---|
397 | } |
---|
398 | |
---|
399 | namespace JoyStickAxisCode |
---|
400 | { |
---|
401 | const unsigned int numberOfAxes = 24; |
---|
402 | |
---|
403 | enum ByEnum |
---|
404 | { |
---|
405 | Slider0 = 0, Slider1 = 1, Slider2 = 2, Slider3 = 3, |
---|
406 | Slider4 = 4, Slider5 = 5, Slider6 = 6, Slider7 = 7, |
---|
407 | Axis0 = 8, Axis1 = 9, Axis2 = 10, Axis3 = 11, |
---|
408 | Axis4 = 12, Axis5 = 13, Axis6 = 14, Axis7 = 15, |
---|
409 | Axis8 = 16, Axis9 = 17, Axis10 = 18, Axis11 = 19, |
---|
410 | Axis12 = 20, Axis13 = 21, Axis14 = 22, Axis15 = 23 |
---|
411 | }; |
---|
412 | |
---|
413 | // Names as string. Has no real linkage! |
---|
414 | const char* const ByString[] = |
---|
415 | { |
---|
416 | "Slider0", "Slider1", "Slider2", "Slider3", |
---|
417 | "Slider4", "Slider5", "Slider6", "Slider7", |
---|
418 | "Axis00", "Axis01", "Axis02", "Axis03", |
---|
419 | "Axis04", "Axis05", "Axis06", "Axis07", |
---|
420 | "Axis08", "Axis09", "Axis10", "Axis11", |
---|
421 | "Axis12", "Axis13", "Axis14", "Axis15" |
---|
422 | }; |
---|
423 | } |
---|
424 | |
---|
425 | namespace KeyboardModifier |
---|
426 | { |
---|
427 | enum Enum |
---|
428 | { |
---|
429 | Shift = 0x0000001, |
---|
430 | Ctrl = 0x0000010, |
---|
431 | Alt = 0x0000100 |
---|
432 | }; |
---|
433 | } |
---|
434 | |
---|
435 | namespace InputDevice |
---|
436 | { |
---|
437 | enum Enum |
---|
438 | { |
---|
439 | Keyboard, |
---|
440 | Mouse, |
---|
441 | JoyStick0, |
---|
442 | JoyStick1, |
---|
443 | JoyStick2, |
---|
444 | JoyStick3 |
---|
445 | // note: No problem if there are more joy sticks. This enum is just for convenience. |
---|
446 | }; |
---|
447 | } |
---|
448 | |
---|
449 | struct _CoreExport Key |
---|
450 | { |
---|
451 | Key(const OIS::KeyEvent& evt) : key((KeyCode::ByEnum)evt.key), text(evt.text) { } |
---|
452 | KeyCode::ByEnum key; |
---|
453 | unsigned int text; |
---|
454 | }; |
---|
455 | |
---|
456 | class _CoreExport KeyEvent |
---|
457 | { |
---|
458 | public: |
---|
459 | KeyEvent(KeyCode::ByEnum key, unsigned int text) : key(key), text(text) { } |
---|
460 | KeyEvent(const OIS::KeyEvent& evt, unsigned int mod) |
---|
461 | : key((KeyCode::ByEnum)evt.key), text(evt.text), modifiers(mod) { } |
---|
462 | KeyEvent(const Key& key, unsigned int mod) : key(key.key), text(key.text), modifiers(mod) { } |
---|
463 | bool isModifierDown(KeyboardModifier::Enum modifier) const |
---|
464 | { return (KeyboardModifier::Enum)modifier&modifiers; } |
---|
465 | |
---|
466 | const KeyCode::ByEnum key; |
---|
467 | unsigned int text; |
---|
468 | unsigned int modifiers; |
---|
469 | }; |
---|
470 | |
---|
471 | |
---|
472 | class _CoreExport InputHandler |
---|
473 | { |
---|
474 | public: |
---|
475 | virtual ~InputHandler() { } |
---|
476 | virtual void updateInput(float dt) = 0; |
---|
477 | }; |
---|
478 | |
---|
479 | /** |
---|
480 | @brief |
---|
481 | Interface class used for key input listeners. |
---|
482 | */ |
---|
483 | class _CoreExport KeyHandler : virtual public InputHandler |
---|
484 | { |
---|
485 | public: |
---|
486 | virtual ~KeyHandler() { } |
---|
487 | virtual void keyPressed (const KeyEvent& evt) = 0; |
---|
488 | virtual void keyReleased(const KeyEvent& evt) = 0; |
---|
489 | virtual void keyHeld (const KeyEvent& evt) = 0; |
---|
490 | virtual void updateKey (float dt) = 0; |
---|
491 | }; |
---|
492 | |
---|
493 | /** |
---|
494 | @brief |
---|
495 | Interface class used for mouse input listeners. |
---|
496 | */ |
---|
497 | class _CoreExport MouseHandler : virtual public InputHandler |
---|
498 | { |
---|
499 | public: |
---|
500 | virtual ~MouseHandler() { } |
---|
501 | virtual void mouseButtonPressed (MouseButtonCode::ByEnum id) = 0; |
---|
502 | virtual void mouseButtonReleased(MouseButtonCode::ByEnum id) = 0; |
---|
503 | virtual void mouseButtonHeld (MouseButtonCode::ByEnum id) = 0; |
---|
504 | virtual void mouseMoved (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) = 0; |
---|
505 | virtual void mouseScrolled (int abs, int rel) = 0; |
---|
506 | virtual void updateMouse (float dt) = 0; |
---|
507 | }; |
---|
508 | |
---|
509 | |
---|
510 | /** |
---|
511 | @brief |
---|
512 | Interface class used for joy stick input listeners. |
---|
513 | */ |
---|
514 | class _CoreExport JoyStickHandler : virtual public InputHandler |
---|
515 | { |
---|
516 | public: |
---|
517 | virtual ~JoyStickHandler() { } |
---|
518 | virtual void joyStickButtonPressed (unsigned int joyStickID, JoyStickButtonCode::ByEnum id) = 0; |
---|
519 | virtual void joyStickButtonReleased(unsigned int joyStickID, JoyStickButtonCode::ByEnum id) = 0; |
---|
520 | virtual void joyStickButtonHeld (unsigned int joyStickID, JoyStickButtonCode::ByEnum id) = 0; |
---|
521 | virtual void joyStickAxisMoved (unsigned int joyStickID, unsigned int axis, float value) = 0; |
---|
522 | virtual void updateJoyStick (float dt, unsigned int joyStick) = 0; |
---|
523 | }; |
---|
524 | |
---|
525 | class _CoreExport EmptyHandler : public KeyHandler, public MouseHandler, public JoyStickHandler |
---|
526 | { |
---|
527 | friend class InputManager; |
---|
528 | private: |
---|
529 | EmptyHandler() { } |
---|
530 | EmptyHandler(EmptyHandler&); |
---|
531 | virtual ~EmptyHandler() { } |
---|
532 | |
---|
533 | void updateInput(float dt) { } |
---|
534 | void updateJoyStick(float dt, unsigned int joyStick) { } |
---|
535 | void updateMouse(float dt) { } |
---|
536 | void updateKey(float dt) { } |
---|
537 | |
---|
538 | void keyPressed (const KeyEvent& evt) { } |
---|
539 | void keyReleased(const KeyEvent& evt) { } |
---|
540 | void keyHeld (const KeyEvent& evt) { } |
---|
541 | |
---|
542 | void mouseButtonPressed (MouseButtonCode::ByEnum id) { } |
---|
543 | void mouseButtonReleased(MouseButtonCode::ByEnum id) { } |
---|
544 | void mouseButtonHeld (MouseButtonCode::ByEnum id) { } |
---|
545 | void mouseMoved (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) { } |
---|
546 | void mouseScrolled (int abs, int rel) { } |
---|
547 | |
---|
548 | void joyStickButtonPressed (unsigned int joyStickID, JoyStickButtonCode::ByEnum id) { } |
---|
549 | void joyStickButtonReleased(unsigned int joyStickID, JoyStickButtonCode::ByEnum id) { } |
---|
550 | void joyStickButtonHeld (unsigned int joyStickID, JoyStickButtonCode::ByEnum id) { } |
---|
551 | void joyStickAxisMoved (unsigned int joyStickID, unsigned int axis, float value) { } |
---|
552 | }; |
---|
553 | |
---|
554 | } |
---|
555 | |
---|
556 | #endif /* _InputInterfaces_H__ */ |
---|