Gamedev Framework (gf)  0.7.0
A C++14 framework for 2D games
Event.h
1 /*
2  * Gamedev Framework (gf)
3  * Copyright (C) 2016-2018 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 
71 
118  struct GF_API Event {
122  struct KeyEvent {
126  };
127 
131  struct TextEvent {
133  };
134 
141  };
142 
148  };
149 
155  };
156 
163  };
164 
171  int16_t value;
172  };
173 
179  };
180 
186  };
187 
189 
190  union {
201  };
202 
203  };
204 
205 #ifndef DOXYGEN_SHOULD_SKIP_THIS
206 }
207 #endif
208 }
209 
210 #endif // GL_EVENT_H
GamepadId id
Id of the gamepad.
Definition: Event.h:169
Rune rune
The rune.
Definition: Event.h:132
GamepadButtonEvent gamepadButton
Gamepad button event parameters (EventType::GamepadButtonPressed, EventType::GamepadButtonReleased) ...
Definition: Event.h:197
MouseButtonEvent mouseButton
Mouse button event parameters (EventType::MouseButtonPressed, EventType::MouseButtonReleased) ...
Definition: Event.h:194
GamepadButton
The gamepad buttons.
Definition: Gamepad.h:42
Gamepad axis event parameters (EventType::GamepadAxisMoved)
Definition: Event.h:168
MouseCursorEvent mouseCursor
Mouse cursor move event parameters (EventType::MouseMoved)
Definition: Event.h:195
The mouse wheel was scrolled (data in event.mouseWheel)
Gamepad disconnection event parameters (EventType::GamepadDisconnected)
Definition: Event.h:184
The mouse cursor left the window (no data)
Vector2i coords
Position of the mouse cursor.
Definition: Event.h:147
A key was repeated (data in event.key)
MouseWheelEvent mouseWheel
Mouse wheel event parameters (EventType::MouseWheelScrolled)
Definition: Event.h:196
A gamepad button was pressed (data in event.gamepadButton)
A key was pressed (data in event.key)
Mouse wheel event parameters (EventType::MouseWheelScrolled)
Definition: Event.h:153
The window requested to be closed (no data)
GamepadAxis axis
Axis of the gamepad.
Definition: Event.h:170
TextEvent text
Text event parameters (EventType::TextEntered)
Definition: Event.h:193
Text event parameters (EventType::TextEntered)
Definition: Event.h:131
A gamepad axis was moved (data in event.gamepadAxis)
int16_t value
Value of the axis.
Definition: Event.h:171
Modifiers modifiers
Modifiers that are pressed.
Definition: Event.h:125
A gamepad was connected (data in event.gamepadConnection)
GamepadHwId
A gamepad hardware identifier.
Definition: Gamepad.h:103
GamepadId id
Id of the gamepad.
Definition: Event.h:161
Scancode
Scancodes.
Definition: Keyboard.h:59
A gamepad button was released (data in event.gamepadButton)
Scancode scancode
Scancode of the key.
Definition: Event.h:124
The window was resized (data in event.size)
GamepadAxis
The gamepad axis.
Definition: Gamepad.h:70
A text was entered (data in event.text)
The namespace for gf classes.
Definition: Action.h:34
Keyboard event parameters (EventType::KeyPressed, EventType::KeyReleased, EventType::KeyRepeated) ...
Definition: Event.h:122
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:120
MouseButton button
Code of the button that has been pressed.
Definition: Event.h:139
The mouse cursor moved (data in event.mouseCursor)
Mouse cursor move event parameters (EventType::MouseMoved)
Definition: Event.h:146
GamepadHwId id
Hardware id of the gamepad.
Definition: Event.h:178
Gamepad button event parameters (EventType::GamepadButtonPressed, EventType::GamepadButtonReleased) ...
Definition: Event.h:160
A mouse button was pressed (data in event.mouseButton)
GamepadId id
Id of the gamepad.
Definition: Event.h:185
GamepadButton button
Button of the gamepad.
Definition: Event.h:162
The window gained focus (no data)
GamepadDisconnection gamepadDisconnection
Gamepad disconnection event parameters (EventType::GamepadDisconnected)
Definition: Event.h:200
Keycode keycode
Keycode of the key.
Definition: Event.h:123
A key was released (data in event.key)
The window lost focus (no data)
EventType type
Type of the event.
Definition: Event.h:188
Gamepad connection event parameters (EventType::GamepadConnected)
Definition: Event.h:177
Vector2i coords
Position of the mouse cursor.
Definition: Event.h:140
Vector2i offset
Offset of the mouse wheel.
Definition: Event.h:154
Mouse button event parameters (EventType::MouseButtonPressed, EventType::MouseButtonReleased) ...
Definition: Event.h:138
KeyEvent key
Key event parameters (EventType::KeyPressed, EventType::KeyReleased, EventType::KeyRepeated) ...
Definition: Event.h:192
GamepadConnection gamepadConnection
Gamepad connection event parameters (EventType::GamepadConnected)
Definition: Event.h:199
MouseButton
Mouse buttons.
Definition: Mouse.h:36
Defines a system event and its parameters.
Definition: Event.h:118
A gamepad was disconnected (data in event.gamepadDisconnection)
Vector2u size
Size event parameters (EventType::Resized)
Definition: Event.h:191
A mouse button was released (data in event.mouseButton)
GamepadAxisEvent gamepadAxis
Gamepad axis event parameters (EventType::GamepadAxisMoved)
Definition: Event.h:198
Keycode
Keycodes.
Definition: Keyboard.h:288