17#ifndef _FGE_C_EVENT_HPP_INCLUDED
18#define _FGE_C_EVENT_HPP_INCLUDED
20#include "FastEngine/fge_extern.hpp"
21#include "C_vector.hpp"
22#include "FastEngine/C_callback.hpp"
23#include "SDL_events.h"
25#define FGE_EVENT_KEYCODES_SIZE 12
26#define FGE_EVENT_DEFAULT_MAXEVENTCOUNT 20
68 explicit Event(fge::Vector2i
const& windowSize, fge::Vector2i
const& windowPosition) :
69 g_windowSize(windowSize),
70 g_windowPosition(windowPosition)
100#ifndef FGE_DEF_SERVER
119 void process(
unsigned int maxEventCount = FGE_EVENT_DEFAULT_MAXEVENTCOUNT);
122 void pushType(SDL_EventType type);
282 static uint64_t EventTypeToBitMask(uint32_t type);
283 static std::size_t KeycodeToBitIndex(uint32_t keyCode);
284 static uint32_t UTF8ToUTF32(
char const* utf8);
287 uint64_t g_types = 0;
290 uint32_t g_keyCodes[FGE_EVENT_KEYCODES_SIZE] = {0};
291 uint32_t g_keyUnicode = 0;
294 fge::Vector2i g_mouseRelativeMotion = {0, 0};
295 fge::Vector2i g_mousePixelPosition = {0, 0};
296 uint8_t g_mouseButtons = 0;
298 int g_mouseWheelHorizontalDelta = 0;
299 int g_mouseWheelVerticalDelta = 0;
302 fge::Vector2i g_windowSize;
303 fge::Vector2i g_windowPosition;
This class is used to handle callbacks in a safe way.
Definition C_callback.hpp:189
This class is a wrapper for SDL events.
Definition C_event.hpp:59
std::string getBinaryTypesString() const
Get a binary representation of all SDL event types into a string.
std::string getBinaryMouseButtonsString() const
Get a binary representation of all mouse buttons into a string.
bool isKeyPressed(uint32_t keycode) const
Check if a key is pressed.
bool isMouseButtonPressed(uint8_t mouseButton) const
Check if the specified mouse button is pressed.
std::string getBinaryKeysString() const
Get a binary representation of all keys into a string.
bool isEventType(uint32_t type) const
Check if the specified SDL event is active.
void clear()
Clear all the events.
void popType(SDL_EventType type)
TODO: add comments.
void start()
Start the event loop.
fge::Vector2i const & getWindowPos() const
Get the window position.
fge::Vector2i const & getMousePixelPos() const
Get the mouse pixel position.
uint32_t getKeyUnicode() const
Get the unicode of the last key pressed.
Event(fge::Vector2i const &windowSize, fge::Vector2i const &windowPosition)
Constructor to apply to size of the window and the position.
Definition C_event.hpp:68
fge::Vector2i const & getWindowSize() const
Get the window size.
int getMouseWheelHorizontalDelta() const
Get the horizontal mouse wheel delta.
fge::net::Packet & unpack(fge::net::Packet &pck)
Unpack events data from a network packet.
fge::net::Packet & pack(fge::net::Packet &pck)
Pack events data into a network packet.
void process(unsigned int maxEventCount=20)
Process automatically SDL events.
Event(fge::vulkan::SurfaceWindow const &surfaceWindow)
Constructor to apply window data.
void process(SDL_Event const &evt)
Process an SDL event.
int getMouseWheelVerticalDelta() const
Get the vertical mouse wheel delta.
Definition C_renderWindow.hpp:51
Definition C_packet.hpp:70
Vulkan OS window surface.
Definition vulkan/C_surface.hpp:97