Gamedev Framework (gf)  0.16.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 
71 
97  struct GF_API Event {
101  struct KeyEvent {
105  };
106 
110  struct TextEvent {
112  };
113 
120  };
121 
127  };
128 
134  };
135 
142  };
143 
150  int16_t value;
151  };
152 
158  };
159 
165  };
166 
168 
169  union {
180  };
181 
182  };
183 
184 #ifndef DOXYGEN_SHOULD_SKIP_THIS
185 }
186 #endif
187 }
188 
189 #endif // GL_EVENT_H
GamepadId id
Id of the gamepad.
Definition: Event.h:148
Rune rune
The rune.
Definition: Event.h:111
GamepadButtonEvent gamepadButton
Gamepad button event parameters (EventType::GamepadButtonPressed, EventType::GamepadButtonReleased) ...
Definition: Event.h:176
MouseButtonEvent mouseButton
Mouse button event parameters (EventType::MouseButtonPressed, EventType::MouseButtonReleased) ...
Definition: Event.h:173
GamepadButton
The gamepad buttons.
Definition: Gamepad.h:43
Gamepad axis event parameters (EventType::GamepadAxisMoved)
Definition: Event.h:147
MouseCursorEvent mouseCursor
Mouse cursor move event parameters (EventType::MouseMoved)
Definition: Event.h:174
The mouse wheel was scrolled (data in event.mouseWheel)
Gamepad disconnection event parameters (EventType::GamepadDisconnected)
Definition: Event.h:163
The mouse cursor left the window (no data)
Vector2i coords
Position of the mouse cursor.
Definition: Event.h:126
A key was repeated (data in event.key)
MouseWheelEvent mouseWheel
Mouse wheel event parameters (EventType::MouseWheelScrolled)
Definition: Event.h:175
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:132
The window requested to be closed (no data)
GamepadAxis axis
Axis of the gamepad.
Definition: Event.h:149
TextEvent text
Text event parameters (EventType::TextEntered)
Definition: Event.h:172
Text event parameters (EventType::TextEntered)
Definition: Event.h:110
A gamepad axis was moved (data in event.gamepadAxis)
int16_t value
Value of the axis.
Definition: Event.h:150
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:140
Scancode
Scancodes.
Definition: Keyboard.h:51
A gamepad button was released (data in event.gamepadButton)
Scancode scancode
Scancode of the key.
Definition: Event.h:103
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:101
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:118
The mouse cursor moved (data in event.mouseCursor)
Mouse cursor move event parameters (EventType::MouseMoved)
Definition: Event.h:125
GamepadHwId id
Hardware id of the gamepad.
Definition: Event.h:157
Gamepad button event parameters (EventType::GamepadButtonPressed, EventType::GamepadButtonReleased) ...
Definition: Event.h:139
A mouse button was pressed (data in event.mouseButton)
GamepadId id
Id of the gamepad.
Definition: Event.h:164
GamepadButton button
Button of the gamepad.
Definition: Event.h:141
The window gained focus (no data)
GamepadDisconnection gamepadDisconnection
Gamepad disconnection event parameters (EventType::GamepadDisconnected)
Definition: Event.h:179
Keycode keycode
Keycode of the key.
Definition: Event.h:102
A key was released (data in event.key)
The window lost focus (no data)
EventType type
Type of the event.
Definition: Event.h:167
Gamepad connection event parameters (EventType::GamepadConnected)
Definition: Event.h:156
Vector2i coords
Position of the mouse cursor.
Definition: Event.h:119
Vector2i offset
Offset of the mouse wheel.
Definition: Event.h:133
Mouse button event parameters (EventType::MouseButtonPressed, EventType::MouseButtonReleased) ...
Definition: Event.h:117
KeyEvent key
Key event parameters (EventType::KeyPressed, EventType::KeyReleased, EventType::KeyRepeated) ...
Definition: Event.h:171
GamepadConnection gamepadConnection
Gamepad connection event parameters (EventType::GamepadConnected)
Definition: Event.h:178
MouseButton
Mouse buttons.
Definition: Mouse.h:36
Defines a system event and its parameters.
Definition: Event.h:97
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:170
GamepadAxisEvent gamepadAxis
Gamepad axis event parameters (EventType::GamepadAxisMoved)
Definition: Event.h:177
Keycode
Keycodes.
Definition: Keyboard.h:280
Flags< Mod > modifiers
Modifiers that are pressed.
Definition: Event.h:104