GlistEngine
Loading...
Searching...
No Matches
gWindowEvents.h
Go to the documentation of this file.
1/*
2* gEvent.h
3*
4* Created on: June 24, 2023
5* Author: Metehan Gezer
6*/
7
8#ifndef GWINDOWEVENTS_H_
9#define GWINDOWEVENTS_H_
10
11#include "gEvent.h"
12#include "gUtils.h"
13
20
21class gKeyEvent : public gEvent {
22public:
23 int getKeyCode() const { return keycode; }
24
26protected:
27 gKeyEvent(const int keycode)
28 : keycode(keycode) {}
29
31};
32
33class gCharTypedEvent : public gEvent {
34public:
35 gCharTypedEvent(const unsigned int keycode)
36 : keycode(keycode) {}
37
38 unsigned int getCharacter() const { return keycode; }
39
42private:
43 unsigned int keycode;
44};
45
47public:
48 gKeyPressedEvent(const int keycode, bool isrepeat = false)
50 isrepeat(isrepeat) {}
51
52 bool isRepeat() const { return isrepeat; }
53
55private:
56 bool isrepeat;
57};
58
66
67
68class gMouseMovedEvent : public gEvent {
69public:
70 gMouseMovedEvent(float x, float y, gCursorMode cursormode)
71 : mousex(x),
72 mousey(y),
73 cursormode(cursormode) {}
74
75 float getX() const { return mousex; }
76 float getY() const { return mousey; }
77 gCursorMode getCursorMode() const { return cursormode; }
78
81private:
82 float mousex, mousey;
83 gCursorMode cursormode;
84};
85
87public:
88 gMouseScrolledEvent(const int offsetx, const int offsety)
89 : offsetx(offsetx),
90 offsety(offsety) {}
91
92 int getOffsetX() const { return offsetx; }
93 int getOffsetY() const { return offsety; }
94
95
98private:
99 int offsetx, offsety;
100};
101
102class gMouseButtonEvent : public gEvent {
103public:
104 int getMouseButton() const { return button; }
105 int getX() const { return x; }
106 int getY() const { return y; }
107
109protected:
110 gMouseButtonEvent(const int button, const int x, const int y)
111 : button(button), x(x), y(y) {}
112
114 int x, y;
115};
116
118public:
119 gMouseButtonPressedEvent(const int button, const int x, const int y)
121
123};
124
132
134public:
135 gWindowResizeEvent(int width, int height)
136 : width(width), height(height) {}
137
138 int getWidth() const { return width; }
139 int getHeight() const { return height; }
140
143private:
144 int width, height;
145};
146
148public:
149 gWindowScaleChangedEvent(int width, int height, float scalex, float scaley)
150 : width(width), height(height), scalex(scalex), scaley(scaley) {}
151
152 int getWidth() const { return width; }
153 int getHeight() const { return height; }
154 float getScaleX() const { return scalex; }
155 float getScaleY() const { return scaley; }
156
159private:
160 int width, height;
161 float scalex, scaley;
162};
163
171
179
187
195
197public:
198 gJoystickConnectEvent(int joystickId, bool isgamepad)
199 : joystickid(joystickId), isgamepad(isgamepad) {}
200
201 int getJoystickId() const { return joystickid; }
202 bool isGamepad() const { return isgamepad; }
203
206private:
207 int joystickid;
208 bool isgamepad;
209};
210
212public:
214 : joystickid(joystickId) {}
215
216 int getJoystickId() const { return joystickid; }
217
220private:
221 int joystickid;
222};
223
224#if GLIST_ANDROID || GLIST_IOS
225enum InputType {
226 INPUTTYPE_UNKNOWN = 0,
227 INPUTTYPE_FINGER = 1,
228 INPUTTYPE_STYLUS = 2,
229 INPUTTYPE_MOUSE = 3
230};
231
232enum ActionType {
233 ACTIONTYPE_DOWN = 0,
234 ACTIONTYPE_UP = 1,
235 ACTIONTYPE_MOVE = 2,
236 ACTIONTYPE_CANCEL = 3,
237 ACTIONTYPE_OUTSIDE = 4,
238 ACTIONTYPE_POINTER_DOWN = 5,
239 ACTIONTYPE_POINTER_UP = 6,
240 ACTIONTYPE_HOVER_MOVE = 7,
241 ACTIONTYPE_SCROLL = 8,
242 ACTIONTYPE_HOVER_ENTER = 9,
243 ACTIONTYPE_HOVER_EXIT = 10
244};
245
246struct TouchInput {
247 InputType type;
248 int fingerid;
249 int pointerindex;
250 int x, y;
251};
252
253class gTouchEvent : public gEvent {
254public:
255 gTouchEvent(int inputCount, TouchInput* inputs, int actionIndex, ActionType action) : inputs(inputs), inputcount(inputCount), action(action), actionindex(actionIndex) {}
256
257 int getInputCount() const { return inputcount; }
258 TouchInput* getInputs() const { return inputs; }
259 int getActionIndex() const { return actionindex; }
260 ActionType getAction() const { return action; }
261
262 G_EVENT_CLASS_TYPE(gTouchEvent)
264private:
265 int inputcount;
266 TouchInput* inputs;
267 int actionindex;
268 ActionType action;
269};
270
271enum DeviceOrientation {
272 DEVICEORIENTATION_UNSPECIFIED = -1,
273 DEVICEORIENTATION_LANDSCAPE = 0,
274 DEVICEORIENTATION_PORTRAIT = 1,
275 DEVICEORIENTATION_REVERSE_LANDSCAPE = 8,
276 DEVICEORIENTATION_REVERSE_PORTRAIT = 9
277};
278
279class gDeviceOrientationChangedEvent : public gEvent {
280public:
281 gDeviceOrientationChangedEvent(DeviceOrientation orientation) : orientation(orientation) {}
282
283 DeviceOrientation getOrientation() const { return orientation; }
284
285 G_EVENT_CLASS_TYPE(gDeviceOrientationChangedEvent)
287private:
288 DeviceOrientation orientation;
289};
290
291#endif
292
301
310
311#endif /* GWINDOWEVENTS_H_ */
Definition gWindowEvents.h:293
gAppPauseEvent()
Definition gWindowEvents.h:295
Definition gWindowEvents.h:302
gAppResumeEvent()
Definition gWindowEvents.h:304
Definition gWindowEvents.h:33
unsigned int getCharacter() const
Definition gWindowEvents.h:38
gCharTypedEvent(const unsigned int keycode)
Definition gWindowEvents.h:35
Definition gEvent.h:32
Definition gWindowEvents.h:196
bool isGamepad() const
Definition gWindowEvents.h:202
int getJoystickId() const
Definition gWindowEvents.h:201
gJoystickConnectEvent(int joystickId, bool isgamepad)
Definition gWindowEvents.h:198
Definition gWindowEvents.h:211
int getJoystickId() const
Definition gWindowEvents.h:216
gJoystickDisconnectEvent(int joystickId)
Definition gWindowEvents.h:213
Definition gWindowEvents.h:21
gKeyEvent(const int keycode)
Definition gWindowEvents.h:27
int getKeyCode() const
Definition gWindowEvents.h:23
int keycode
Definition gWindowEvents.h:30
Definition gWindowEvents.h:46
bool isRepeat() const
Definition gWindowEvents.h:52
gKeyPressedEvent(const int keycode, bool isrepeat=false)
Definition gWindowEvents.h:48
Definition gWindowEvents.h:59
gKeyReleasedEvent(const int keycode)
Definition gWindowEvents.h:61
Definition gWindowEvents.h:102
int button
Definition gWindowEvents.h:113
int getX() const
Definition gWindowEvents.h:105
int getMouseButton() const
Definition gWindowEvents.h:104
int x
Definition gWindowEvents.h:114
int y
Definition gWindowEvents.h:114
int getY() const
Definition gWindowEvents.h:106
gMouseButtonEvent(const int button, const int x, const int y)
Definition gWindowEvents.h:110
Definition gWindowEvents.h:117
gMouseButtonPressedEvent(const int button, const int x, const int y)
Definition gWindowEvents.h:119
Definition gWindowEvents.h:125
gMouseButtonReleasedEvent(const int button, const int x, const int y)
Definition gWindowEvents.h:127
Definition gWindowEvents.h:68
gMouseMovedEvent(float x, float y, gCursorMode cursormode)
Definition gWindowEvents.h:70
gCursorMode getCursorMode() const
Definition gWindowEvents.h:77
float getX() const
Definition gWindowEvents.h:75
float getY() const
Definition gWindowEvents.h:76
Definition gWindowEvents.h:86
int getOffsetY() const
Definition gWindowEvents.h:93
gMouseScrolledEvent(const int offsetx, const int offsety)
Definition gWindowEvents.h:88
int getOffsetX() const
Definition gWindowEvents.h:92
Definition gWindowEvents.h:164
gWindowFocusEvent()
Definition gWindowEvents.h:166
Definition gWindowEvents.h:172
gWindowLoseFocusEvent()
Definition gWindowEvents.h:174
Definition gWindowEvents.h:180
gWindowMouseEnterEvent()
Definition gWindowEvents.h:182
Definition gWindowEvents.h:188
gWindowMouseExitEvent()
Definition gWindowEvents.h:190
Definition gWindowEvents.h:133
int getHeight() const
Definition gWindowEvents.h:139
int getWidth() const
Definition gWindowEvents.h:138
gWindowResizeEvent(int width, int height)
Definition gWindowEvents.h:135
Definition gWindowEvents.h:147
int getHeight() const
Definition gWindowEvents.h:153
gWindowScaleChangedEvent(int width, int height, float scalex, float scaley)
Definition gWindowEvents.h:149
float getScaleY() const
Definition gWindowEvents.h:155
int getWidth() const
Definition gWindowEvents.h:152
float getScaleX() const
Definition gWindowEvents.h:154
#define G_EVENT_CLASS_CATEGORY(category)
Definition gEvent.h:91
@ EVENTCATEGORY_KEYBOARD
Definition gEvent.h:17
@ EVENTCATEGORY_JOYSTICK
Definition gEvent.h:20
@ EVENTCATEGORY_TOUCHSCREEN
Definition gEvent.h:21
@ EVENTCATEGORY_APP
Definition gEvent.h:15
@ EVENTCATEGORY_MOUSE
Definition gEvent.h:18
@ EVENTCATEGORY_MOUSE_BUTTON
Definition gEvent.h:19
@ EVENTCATEGORY_INPUT
Definition gEvent.h:16
#define G_EVENT_CLASS_TYPE(type)
Definition gEvent.h:86
gCursorMode
Definition gWindowEvents.h:14
@ CURSORMODE_NORMAL
Definition gWindowEvents.h:15
@ CURSORMODE_HIDDEN
Definition gWindowEvents.h:16
@ CURSORMODE_DISABLED
Definition gWindowEvents.h:17
@ CURSORMODE_RELATIVE
Definition gWindowEvents.h:18