Flint Engine
Modular C++20 2D game engine powered by SDL3
Loading...
Searching...
No Matches
event.h
1// SPDX-License-Identifier: MIT
2// SPDX-FileCopyrightText: 2025-2026 Manuel Osorio
3#pragma once
4#include "flint/math/types.h"
5
6#include <SDL3/SDL_keycode.h>
7
8#include <cstdint>
9
10namespace Flint {
14 enum class EventType {
15 Quit,
16 KeyDown,
17 KeyUp,
18 MouseMove,
19 MouseButtonDown,
20 MouseButtonUp,
21 GamepadAxisMove,
22 GamepadButtonPressed,
23 GamepadButtonReleased,
24 GamepadConnected,
25 GamepadDisconnected,
26 WindowResized,
27 WindowFocusLost,
28 WindowFocusGained,
29 WindowMoved,
30 WindowMinimized,
31 WindowDisplayScaleChanged,
32 Unknown
33 };
34
38 enum class GamepadAxis {
39 unknown = -1,
40 leftX,
41 leftY,
42 rightX,
43 rightY,
44 leftTrigger,
45 rightTrigger
46 };
47
54 enum class GamepadButton {
55 unknown = -1,
56 south,
57 east,
58 west,
59 north,
60 back,
61 guide,
62 start,
63 leftStick,
64 rightStick,
65 leftShoulder,
66 rightShoulder,
67 dpadUp,
68 dpadDown,
69 dpadLeft,
70 dpadRight,
71 misc1,
72 rightPaddle1,
73 leftPaddle1,
74 rightPaddle2,
75 leftPaddle2,
76 touchpad,
77 misc2,
78 misc3,
79 misc4,
80 misc5,
81 misc6,
82 };
83
90 struct AppEvent {
91 EventType type;
93 union {
95 struct {
96 GamepadAxis axis;
97 float value;
99
101 struct {
102 GamepadButton button;
104
106 struct {
107 SDL_Keycode keycode;
109
111 struct {
114
116 struct {
117 uint8_t button;
121 };
122 };
123}
uint8_t button
Definition event.h:117
Vec2f position
Definition event.h:118
GamepadAxis axis
Definition event.h:96
Vec2< float > position
Definition event.h:112
float value
Definition event.h:97
EventType type
Definition event.h:91
SDL_Keycode keycode
Definition event.h:107
GamepadButton button
Definition event.h:102
A tagged union representing a single application input or window event.
Definition event.h:90
struct Flint::AppEvent::@0::@6 mouseButton
Data for MouseButtonDown / MouseButtonUp events.
struct Flint::AppEvent::@0::@4 key
Data for KeyDown / KeyUp events.
struct Flint::AppEvent::@0::@2 gamepadAxis
Data for GamepadAxisMove events.
struct Flint::AppEvent::@0::@5 mouseMove
Data for MouseMove events.
struct Flint::AppEvent::@0::@3 gamepadButton
Data for GamepadButtonPressed / GamepadButtonReleased events.
Generic 2-D vector with arithmetic operators.
Definition types.h:16