1 /*
2  * Input.h
3  *
4  *  Created on: 05.12.2015
5  *      Author: pavel
6  */
7 
8 #ifndef SAMPLES_COMMON_INCLUDE_INPUT_H_
9 #define SAMPLES_COMMON_INCLUDE_INPUT_H_
10 
11 #include "OgreBitesPrerequisites.h"
12 
13 namespace Ogre {
14     struct FrameEvent;
15 }
16 
17 /** \addtogroup Optional
18 *  @{
19 */
20 /** \addtogroup Bites
21 *  @{
22 */
23 namespace OgreBites {
24 
25 enum ButtonType {
26     BUTTON_LEFT = 1,
27     BUTTON_MIDDLE,
28     BUTTON_RIGHT,
29 };
30 
31 enum EventType {
32     KEYDOWN = 1,
33     KEYUP,
34     MOUSEBUTTONDOWN,
35     MOUSEBUTTONUP,
36     MOUSEWHEEL,
37     MOUSEMOTION,
38     FINGERDOWN,
39     FINGERUP,
40     FINGERMOTION,
41 };
42 
43 typedef int Keycode;
44 
45 struct Keysym {
46     Keycode sym;
47     unsigned short mod;
48 };
49 
50 struct KeyboardEvent {
51     int type;
52     Keysym keysym;
53     unsigned char repeat;
54 };
55 struct MouseMotionEvent {
56     int type;
57     int x, y;
58     int xrel, yrel;
59     int windowID;
60 };
61 struct MouseButtonEvent {
62     int type;
63     int x, y;
64     unsigned char button;
65     unsigned char clicks;
66 };
67 struct MouseWheelEvent {
68     int type;
69     int y;
70 };
71 struct TouchFingerEvent {
72     int type;
73     int fingerId;
74     float x, y;
75     float dx, dy;
76 };
77 
78 union Event
79 {
80     int type;
81     KeyboardEvent key;
82     MouseButtonEvent button;
83     MouseWheelEvent wheel;
84     MouseMotionEvent motion;
85     TouchFingerEvent tfinger;
86 };
87 
88 // SDL compat
89 enum {
90     SDLK_RETURN = int('\r'),
91     SDLK_ESCAPE = int('\033'),
92     SDLK_SPACE = int(' '),
93     SDLK_F1 = (1 << 30) | 58,
94     SDLK_F2,
95     SDLK_F3,
96     SDLK_F4,
97     SDLK_F5,
98     SDLK_F6,
99     SDLK_F7,
100     SDLK_F8,
101     SDLK_F9,
102     SDLK_F10,
103     SDLK_F11,
104     SDLK_F12,
105     SDLK_PAGEUP = (1 << 30) | 75,
106     SDLK_PAGEDOWN = (1 << 30) | 78,
107     SDLK_RIGHT = (1 << 30) | 79,
108     SDLK_LEFT,
109     SDLK_DOWN,
110     SDLK_UP,
111     SDLK_KP_MINUS = (1 << 30) | 86,
112     SDLK_KP_PLUS,
113     SDLK_LSHIFT = (1 << 30) | 225,
114     KMOD_CTRL = 0x0040 | 0x0080,
115 };
116 
117 /**
118 the return values of the callbacks are ignored by ApplicationContext
119 however they can be used to control event propagation in a hierarchy
120 */
121 struct _OgreBitesExport InputListener {
~InputListenerInputListener122     virtual ~InputListener() {}
frameRenderedInputListener123     virtual void frameRendered(const Ogre::FrameEvent& evt) { }
keyPressedInputListener124     virtual bool keyPressed(const KeyboardEvent& evt) { return true;}
keyReleasedInputListener125     virtual bool keyReleased(const KeyboardEvent& evt) { return true; }
touchMovedInputListener126     virtual bool touchMoved(const TouchFingerEvent& evt) { return true; }
touchPressedInputListener127     virtual bool touchPressed(const TouchFingerEvent& evt) { return true; }
touchReleasedInputListener128     virtual bool touchReleased(const TouchFingerEvent& evt) { return true; }
mouseMovedInputListener129     virtual bool mouseMoved(const MouseMotionEvent& evt) { return true; }
mouseWheelRolledInputListener130     virtual bool mouseWheelRolled(const MouseWheelEvent& evt) { return true; }
mousePressedInputListener131     virtual bool mousePressed(const MouseButtonEvent& evt) { return true; }
mouseReleasedInputListener132     virtual bool mouseReleased(const MouseButtonEvent& evt) { return true; }
133 };
134 }
135 /** @} */
136 /** @} */
137 
138 #endif /* SAMPLES_COMMON_INCLUDE_INPUT_H_ */
139