Gamedev Framework (gf)  0.17.0
A C++14 framework for 2D games
Event.h
1 /*
2  * Gamedev Framework (gf)
3  * Copyright (C) 2016-2019 Julien Bernard
4  *
5  * This software is provided 'as-is', without any express or implied
6  * warranty. In no event will the authors be held liable for any damages
7  * arising from the use of this software.
8  *
9  * Permission is granted to anyone to use this software for any purpose,
10  * including commercial applications, and to alter it and redistribute it
11  * freely, subject to the following restrictions:
12  *
13  * 1. The origin of this software must not be misrepresented; you must not
14  * claim that you wrote the original software. If you use this software
15  * in a product, an acknowledgment in the product documentation would be
16  * appreciated but is not required.
17  * 2. Altered source versions must be plainly marked as such, and must not be
18  * misrepresented as being the original software.
19  * 3. This notice may not be removed or altered from any source distribution.
20  *
21  * Part of this file comes from SFML, with the same license:
22  * Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
23  */
24 #ifndef GF_EVENT_H
25 #define GF_EVENT_H
26 
27 #include "Gamepad.h"
28 #include "Keyboard.h"
29 #include "Mouse.h"
30 #include "Portability.h"
31 #include "Rune.h"
32 #include "Vector.h"
33 
34 namespace gf {
35 #ifndef DOXYGEN_SHOULD_SKIP_THIS
36 inline namespace v1 {
37 #endif
38 
43  enum class EventType {
44  // window events
45  Resized,
46  Closed,
47  FocusGained,
48  FocusLost,
49 
50  // inputs events
51  KeyPressed,
52  KeyRepeated,
53  KeyReleased,
54 
58  MouseMoved,
59  MouseEntered,
60  MouseLeft,
61 
67 
68  TextEntered,
69 
70  TouchBegan,
71  TouchMoved,
72  TouchEnded,
73  };
74 
75 
101  struct GF_API Event {
105  struct KeyEvent {
109  };
110 
114  struct TextEvent {
116  };
117 
124  };
125 
131  };
132 
138  };
139 
146  };
147 
154  int16_t value;
155  };
156 
162  };
163 
169  };
170 
174  struct TouchEvent {
175  int64_t finger;
177  };
178 
180 
181  union {
193  };
194 
195  };
196 
197 #ifndef DOXYGEN_SHOULD_SKIP_THIS
198 }
199 #endif
200 }
201 
202 #endif // GL_EVENT_H
GamepadId id
Id of the gamepad.
Definition: Event.h:152
Rune rune
The rune.
Definition: Event.h:115
GamepadButtonEvent gamepadButton
Gamepad button event parameters (EventType::GamepadButtonPressed, EventType::GamepadButtonReleased) ...
Definition: Event.h:188
MouseButtonEvent mouseButton
Mouse button event parameters (EventType::MouseButtonPressed, EventType::MouseButtonReleased) ...
Definition: Event.h:185
GamepadButton
The gamepad buttons.
Definition: Gamepad.h:43
Gamepad axis event parameters (EventType::GamepadAxisMoved)
Definition: Event.h:151
MouseCursorEvent mouseCursor
Mouse cursor move event parameters (EventType::MouseMoved)
Definition: Event.h:186
The mouse wheel was scrolled (data in event.mouseWheel)
Gamepad disconnection event parameters (EventType::GamepadDisconnected)
Definition: Event.h:167
The mouse cursor left the window (no data)
Vector2i coords
Position of the mouse cursor.
Definition: Event.h:130
A key was repeated (data in event.key)
MouseWheelEvent mouseWheel
Mouse wheel event parameters (EventType::MouseWheelScrolled)
Definition: Event.h:187
A gamepad button was pressed (data in event.gamepadButton)
Vector2i coords
Position of the touch.
Definition: Event.h:176
A key was pressed (data in event.key)
Mouse wheel event parameters (EventType::MouseWheelScrolled)
Definition: Event.h:136
The window requested to be closed (no data)
GamepadAxis axis
Axis of the gamepad.
Definition: Event.h:153
TextEvent text
Text event parameters (EventType::TextEntered)
Definition: Event.h:184
Text event parameters (EventType::TextEntered)
Definition: Event.h:114
A gamepad axis was moved (data in event.gamepadAxis)
int16_t value
Value of the axis.
Definition: Event.h:154
A gamepad was connected (data in event.gamepadConnection)
GamepadHwId
A gamepad hardware identifier.
Definition: Gamepad.h:104
GamepadId id
Id of the gamepad.
Definition: Event.h:144
Scancode
Scancodes.
Definition: Keyboard.h:51
TouchEvent touch
Touch event parameters (EventType::TouchBegan, EventType::Moved, EventType::Ended) ...
Definition: Event.h:192
A gamepad button was released (data in event.gamepadButton)
Scancode scancode
Scancode of the key.
Definition: Event.h:107
The window was resized (data in event.size)
GamepadAxis
The gamepad axis.
Definition: Gamepad.h:71
A text was entered (data in event.text)
The namespace for gf classes.
Definition: Action.h:35
Keyboard event parameters (EventType::KeyPressed, EventType::KeyReleased, EventType::KeyRepeated) ...
Definition: Event.h:105
EventType
Enumeration of the different types of events.
Definition: Event.h:43
The mouse cursor entered the window (no data)
A character encoded in UTF-8.
Definition: Rune.h:37
GamepadId
A gamepad identifier.
Definition: Gamepad.h:121
MouseButton button
Code of the button that has been pressed.
Definition: Event.h:122
The mouse cursor moved (data in event.mouseCursor)
int64_t finger
Finger that touched.
Definition: Event.h:175
Mouse cursor move event parameters (EventType::MouseMoved)
Definition: Event.h:129
GamepadHwId id
Hardware id of the gamepad.
Definition: Event.h:161
Gamepad button event parameters (EventType::GamepadButtonPressed, EventType::GamepadButtonReleased) ...
Definition: Event.h:143
A mouse button was pressed (data in event.mouseButton)
GamepadId id
Id of the gamepad.
Definition: Event.h:168
Touch event parameters (EventType::TouchBegan, EventType::TouchMoved, EventType::TouchEnded) ...
Definition: Event.h:174
GamepadButton button
Button of the gamepad.
Definition: Event.h:145
The window gained focus (no data)
GamepadDisconnection gamepadDisconnection
Gamepad disconnection event parameters (EventType::GamepadDisconnected)
Definition: Event.h:191
Keycode keycode
Keycode of the key.
Definition: Event.h:106
A key was released (data in event.key)
The window lost focus (no data)
EventType type
Type of the event.
Definition: Event.h:179
Gamepad connection event parameters (EventType::GamepadConnected)
Definition: Event.h:160
Vector2i coords
Position of the mouse cursor.
Definition: Event.h:123
Vector2i offset
Offset of the mouse wheel.
Definition: Event.h:137
Mouse button event parameters (EventType::MouseButtonPressed, EventType::MouseButtonReleased) ...
Definition: Event.h:121
KeyEvent key
Key event parameters (EventType::KeyPressed, EventType::KeyReleased, EventType::KeyRepeated) ...
Definition: Event.h:183
GamepadConnection gamepadConnection
Gamepad connection event parameters (EventType::GamepadConnected)
Definition: Event.h:190
MouseButton
Mouse buttons.
Definition: Mouse.h:36
Defines a system event and its parameters.
Definition: Event.h:101
A gamepad was disconnected (data in event.gamepadDisconnection)
A mouse button was released (data in event.mouseButton)
Vector2i size
Size event parameters (EventType::Resized)
Definition: Event.h:182
GamepadAxisEvent gamepadAxis
Gamepad axis event parameters (EventType::GamepadAxisMoved)
Definition: Event.h:189
Keycode
Keycodes.
Definition: Keyboard.h:280
Flags< Mod > modifiers
Modifiers that are pressed.
Definition: Event.h:108