CSFML 3.0.0
Loading...
Searching...
No Matches
Event.h
Go to the documentation of this file.
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2026 Laurent Gomila (laurent@sfml-dev.org)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages 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 freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
25#pragma once
26
28// Headers
30#include <CSFML/Window/Export.h>
31
32#include <CSFML/Window/Joystick.h>
33#include <CSFML/Window/Keyboard.h>
34#include <CSFML/Window/Mouse.h>
35#include <CSFML/Window/Sensor.h>
36
37
42 typedef enum
43{
44 sfEvtClosed,
45 sfEvtResized,
46 sfEvtFocusLost,
47 sfEvtFocusGained,
48 sfEvtTextEntered,
49 sfEvtKeyPressed,
50 sfEvtKeyReleased,
51 sfEvtMouseWheelScrolled,
52 sfEvtMouseButtonPressed,
53 sfEvtMouseButtonReleased,
54 sfEvtMouseMoved,
55 sfEvtMouseMovedRaw,
56 sfEvtMouseEntered,
57 sfEvtMouseLeft,
58 sfEvtJoystickButtonPressed,
59 sfEvtJoystickButtonReleased,
60 sfEvtJoystickMoved,
61 sfEvtJoystickConnected,
62 sfEvtJoystickDisconnected,
63 sfEvtTouchBegan,
64 sfEvtTouchMoved,
65 sfEvtTouchEnded,
66 sfEvtSensorChanged,
67
68 sfEvtCount
69} sfEventType;
70
71
76 typedef struct
77{
78 sfEventType type;
79 sfKeyCode code;
80 sfScancode scancode;
81 bool alt;
82 bool control;
83 bool shift;
84 bool system;
85} sfKeyEvent;
86
91 typedef struct
92{
93 sfEventType type;
94 uint32_t unicode;
95} sfTextEvent;
96
101 typedef struct
102{
103 sfEventType type;
104 sfVector2i position;
105} sfMouseMoveEvent;
106
111 typedef struct
112{
113 sfEventType type;
114 sfVector2i delta;
115} sfMouseMoveRawEvent;
116
121 typedef struct
122{
123 sfEventType type;
124 sfMouseButton button;
125 sfVector2i position;
126} sfMouseButtonEvent;
127
132 typedef struct
133{
134 sfEventType type;
135 sfMouseWheel wheel;
136 float delta;
137 sfVector2i position;
138} sfMouseWheelScrollEvent;
139
144 typedef struct
145{
146 sfEventType type;
147 unsigned int joystickId;
148 sfJoystickAxis axis;
149 float position;
150} sfJoystickMoveEvent;
151
156 typedef struct
157{
158 sfEventType type;
159 unsigned int joystickId;
160 unsigned int button;
161} sfJoystickButtonEvent;
162
167 typedef struct
168{
169 sfEventType type;
170 unsigned int joystickId;
171} sfJoystickConnectEvent;
172
177 typedef struct
178{
179 sfEventType type;
180 sfVector2u size;
181} sfSizeEvent;
182
187 typedef struct
188{
189 sfEventType type;
190 unsigned int finger;
191 sfVector2i position;
192} sfTouchEvent;
193
198 typedef struct
199{
200 sfEventType type;
201 sfSensorType sensorType;
202 sfVector3f value;
203} sfSensorEvent;
204
209 typedef union
210{
211 sfEventType type;
212 sfSizeEvent size;
213 sfKeyEvent key;
214 sfTextEvent text;
215 sfMouseMoveEvent mouseMove;
216 sfMouseMoveRawEvent mouseMoveRaw;
217 sfMouseButtonEvent mouseButton;
218 sfMouseWheelScrollEvent mouseWheelScroll;
219 sfJoystickMoveEvent joystickMove;
220 sfJoystickButtonEvent joystickButton;
221 sfJoystickConnectEvent joystickConnect;
222 sfTouchEvent touch;
223 sfSensorEvent sensor;
224} sfEvent;
sfEventType
sfEventType
Definition of all the event types.
Definition Event.h:43
sfEvtCount
@ sfEvtCount
Keep last – the total number of event types.
Definition Event.h:68
sfEvtKeyPressed
@ sfEvtKeyPressed
A key was pressed (data in event.key).
Definition Event.h:49
sfEvtClosed
@ sfEvtClosed
The window requested to be closed (no data).
Definition Event.h:44
sfEvtJoystickButtonReleased
@ sfEvtJoystickButtonReleased
A joystick button was released (data in event.joystickButton).
Definition Event.h:59
sfEvtMouseMovedRaw
@ sfEvtMouseMovedRaw
The mouse cursor moved (data in event.mouseMove).
Definition Event.h:55
sfEvtJoystickConnected
@ sfEvtJoystickConnected
A joystick was connected (data in event.joystickConnect).
Definition Event.h:61
sfEvtSensorChanged
@ sfEvtSensorChanged
A sensor value changed (data in event.sensor).
Definition Event.h:66
sfEvtJoystickDisconnected
@ sfEvtJoystickDisconnected
A joystick was disconnected (data in event.joystickConnect).
Definition Event.h:62
sfEvtTextEntered
@ sfEvtTextEntered
A character was entered (data in event.text).
Definition Event.h:48
sfEvtMouseWheelScrolled
@ sfEvtMouseWheelScrolled
The mouse wheel was scrolled (data in event.mouseWheelScroll).
Definition Event.h:51
sfEvtJoystickMoved
@ sfEvtJoystickMoved
The joystick moved along an axis (data in event.joystickMove).
Definition Event.h:60
sfEvtMouseLeft
@ sfEvtMouseLeft
The mouse cursor left the area of the window (no data).
Definition Event.h:57
sfEvtFocusGained
@ sfEvtFocusGained
The window gained the focus (no data).
Definition Event.h:47
sfEvtMouseEntered
@ sfEvtMouseEntered
The mouse cursor entered the area of the window (no data).
Definition Event.h:56
sfEvtMouseButtonPressed
@ sfEvtMouseButtonPressed
A mouse button was pressed (data in event.mouseButton).
Definition Event.h:52
sfEvtMouseButtonReleased
@ sfEvtMouseButtonReleased
A mouse button was released (data in event.mouseButton).
Definition Event.h:53
sfEvtMouseMoved
@ sfEvtMouseMoved
The mouse cursor moved (data in event.mouseMove).
Definition Event.h:54
sfEvtKeyReleased
@ sfEvtKeyReleased
A key was released (data in event.key).
Definition Event.h:50
sfEvtResized
@ sfEvtResized
The window was resized (data in event.size).
Definition Event.h:45
sfEvtTouchEnded
@ sfEvtTouchEnded
A touch event ended (data in event.touch).
Definition Event.h:65
sfEvtTouchBegan
@ sfEvtTouchBegan
A touch event began (data in event.touch).
Definition Event.h:63
sfEvtFocusLost
@ sfEvtFocusLost
The window lost the focus (no data).
Definition Event.h:46
sfEvtTouchMoved
@ sfEvtTouchMoved
A touch moved (data in event.touch).
Definition Event.h:64
sfEvtJoystickButtonPressed
@ sfEvtJoystickButtonPressed
A joystick button was pressed (data in event.joystickButton).
Definition Event.h:58
Joystick.h
sfJoystickAxis
sfJoystickAxis
Axes supported by SFML joysticks.
Definition Joystick.h:52
Keyboard.h
sfScancode
sfScancode
Scancodes.
Definition Keyboard.h:161
sfKeyCode
sfKeyCode
Key codes.
Definition Keyboard.h:42
Mouse.h
sfMouseWheel
sfMouseWheel
Mouse wheels.
Definition Mouse.h:59
sfMouseButton
sfMouseButton
Mouse buttons.
Definition Mouse.h:41
Sensor.h
sfSensorType
sfSensorType
Sensor Types.
Definition Sensor.h:41
Export.h
sfJoystickButtonEvent
Joystick buttons events parameters.
Definition Event.h:157
sfJoystickButtonEvent::type
sfEventType type
Definition Event.h:158
sfJoystickButtonEvent::joystickId
unsigned int joystickId
Definition Event.h:159
sfJoystickButtonEvent::button
unsigned int button
Definition Event.h:160
sfJoystickConnectEvent
Joystick connection/disconnection event parameters.
Definition Event.h:168
sfJoystickConnectEvent::joystickId
unsigned int joystickId
Definition Event.h:170
sfJoystickConnectEvent::type
sfEventType type
Definition Event.h:169
sfJoystickMoveEvent
Joystick axis move event parameters.
Definition Event.h:145
sfJoystickMoveEvent::axis
sfJoystickAxis axis
Definition Event.h:148
sfJoystickMoveEvent::position
float position
Definition Event.h:149
sfJoystickMoveEvent::type
sfEventType type
Definition Event.h:146
sfJoystickMoveEvent::joystickId
unsigned int joystickId
Definition Event.h:147
sfKeyEvent
Keyboard event parameters.
Definition Event.h:77
sfKeyEvent::alt
bool alt
Definition Event.h:81
sfKeyEvent::system
bool system
Definition Event.h:84
sfKeyEvent::shift
bool shift
Definition Event.h:83
sfKeyEvent::control
bool control
Definition Event.h:82
sfKeyEvent::type
sfEventType type
Definition Event.h:78
sfKeyEvent::scancode
sfScancode scancode
Definition Event.h:80
sfKeyEvent::code
sfKeyCode code
Definition Event.h:79
sfMouseButtonEvent
Mouse buttons events parameters.
Definition Event.h:122
sfMouseButtonEvent::position
sfVector2i position
Definition Event.h:125
sfMouseButtonEvent::type
sfEventType type
Definition Event.h:123
sfMouseButtonEvent::button
sfMouseButton button
Definition Event.h:124
sfMouseMoveEvent
Mouse move event parameters.
Definition Event.h:102
sfMouseMoveEvent::type
sfEventType type
Definition Event.h:103
sfMouseMoveEvent::position
sfVector2i position
Definition Event.h:104
sfMouseMoveRawEvent
Mouse move raw event parameters.
Definition Event.h:112
sfMouseMoveRawEvent::delta
sfVector2i delta
Definition Event.h:114
sfMouseMoveRawEvent::type
sfEventType type
Definition Event.h:113
sfMouseWheelScrollEvent
Mouse wheel events parameters.
Definition Event.h:133
sfMouseWheelScrollEvent::position
sfVector2i position
Definition Event.h:137
sfMouseWheelScrollEvent::delta
float delta
Definition Event.h:136
sfMouseWheelScrollEvent::wheel
sfMouseWheel wheel
Definition Event.h:135
sfMouseWheelScrollEvent::type
sfEventType type
Definition Event.h:134
sfSensorEvent
Sensor event parameters.
Definition Event.h:199
sfSensorEvent::value
sfVector3f value
Definition Event.h:202
sfSensorEvent::sensorType
sfSensorType sensorType
Definition Event.h:201
sfSensorEvent::type
sfEventType type
Definition Event.h:200
sfSizeEvent
Size events parameters.
Definition Event.h:178
sfSizeEvent::type
sfEventType type
Definition Event.h:179
sfSizeEvent::size
sfVector2u size
Definition Event.h:180
sfTextEvent
Text event parameters.
Definition Event.h:92
sfTextEvent::type
sfEventType type
Definition Event.h:93
sfTextEvent::unicode
uint32_t unicode
Definition Event.h:94
sfTouchEvent
Touch events parameters.
Definition Event.h:188
sfTouchEvent::type
sfEventType type
Definition Event.h:189
sfTouchEvent::finger
unsigned int finger
Definition Event.h:190
sfTouchEvent::position
sfVector2i position
Definition Event.h:191
sfVector2i
2-component vector of integers
Definition Vector2.h:38
sfVector2u
2-component vector of unsigned integers
Definition Vector2.h:49
sfVector3f
3-component vector of floats
Definition Vector3.h:38
sfEvent
sfEvent defines a system event and its parameters
Definition Event.h:210
sfEvent::joystickConnect
sfJoystickConnectEvent joystickConnect
Joystick (dis)connect event parameters.
Definition Event.h:221
sfEvent::key
sfKeyEvent key
Key event parameters.
Definition Event.h:213
sfEvent::mouseMove
sfMouseMoveEvent mouseMove
Mouse move event parameters.
Definition Event.h:215
sfEvent::touch
sfTouchEvent touch
Touch events parameters.
Definition Event.h:222
sfEvent::size
sfSizeEvent size
Size event parameters.
Definition Event.h:212
sfEvent::joystickButton
sfJoystickButtonEvent joystickButton
Joystick button event parameters.
Definition Event.h:220
sfEvent::mouseMoveRaw
sfMouseMoveRawEvent mouseMoveRaw
Mouse move raw event parameters.
Definition Event.h:216
sfEvent::sensor
sfSensorEvent sensor
Sensor event parameters.
Definition Event.h:223
sfEvent::joystickMove
sfJoystickMoveEvent joystickMove
Joystick move event parameters.
Definition Event.h:219
sfEvent::mouseButton
sfMouseButtonEvent mouseButton
Mouse button event parameters.
Definition Event.h:217
sfEvent::type
sfEventType type
Type of the event.
Definition Event.h:211
sfEvent::mouseWheelScroll
sfMouseWheelScrollEvent mouseWheelScroll
Mouse wheel event parameters.
Definition Event.h:218
sfEvent::text
sfTextEvent text
Text event parameters.
Definition Event.h:214