FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
fge::Event Class Reference

This class is a wrapper for SDL events. More...

#include <C_event.hpp>

Public Member Functions

 Event (fge::Vector2i const &windowSize, fge::Vector2i const &windowPosition)
 Constructor to apply to size of the window and the position.
 
 Event (fge::vulkan::SurfaceWindow const &surfaceWindow)
 Constructor to apply window data.
 
 Event (fge::RenderWindow const &renderWindow)
 
void clear ()
 Clear all the events.
 
void start ()
 Start the event loop.
 
void process (SDL_Event const &evt)
 Process an SDL event.
 
void process (unsigned int maxEventCount=20)
 Process automatically SDL events.
 
void pushType (SDL_EventType type)
 
void popType (SDL_EventType type)
 TODO: add comments.
 
bool isKeyPressed (uint32_t keycode) const
 Check if a key is pressed.
 
uint32_t getKeyUnicode () const
 Get the unicode of the last key pressed.
 
fge::Vector2i const & getWindowSize () const
 Get the window size.
 
fge::Vector2i const & getWindowPos () const
 Get the window position.
 
bool isEventType (uint32_t type) const
 Check if the specified SDL event is active.
 
fge::Vector2i const & getMousePixelPos () const
 Get the mouse pixel position.
 
bool isMouseButtonPressed (uint8_t mouseButton) const
 Check if the specified mouse button is pressed.
 
int getMouseWheelHorizontalDelta () const
 Get the horizontal mouse wheel delta.
 
int getMouseWheelVerticalDelta () const
 Get the vertical mouse wheel delta.
 
fge::net::Packetpack (fge::net::Packet &pck)
 Pack events data into a network packet.
 
fge::net::Packetunpack (fge::net::Packet &pck)
 Unpack events data from a network packet.
 
std::string getBinaryKeysString () const
 Get a binary representation of all keys into a string.
 
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.
 

Public Attributes

fge::CallbackHandler< fge::Event const &, SDL_QuitEvent const & > _onQuit
 
fge::CallbackHandler< fge::Event const &, SDL_CommonEvent const & > _onAppTerminating
 
fge::CallbackHandler< fge::Event const &, SDL_CommonEvent const & > _onAppLowMemory
 
fge::CallbackHandler< fge::Event const &, SDL_CommonEvent const & > _onAppWillEnterBackground
 
fge::CallbackHandler< fge::Event const &, SDL_CommonEvent const & > _onAppDidEnterBackground
 
fge::CallbackHandler< fge::Event const &, SDL_CommonEvent const & > _onAppWillEnterForeground
 
fge::CallbackHandler< fge::Event const &, SDL_CommonEvent const & > _onAppDidEnterForeground
 
fge::CallbackHandler< fge::Event const &, SDL_WindowEvent const & > _onWindowEvent
 
fge::CallbackHandler< fge::Event const &, SDL_SysWMEvent const & > _onSyswmEvent
 
fge::CallbackHandler< fge::Event const &, SDL_KeyboardEvent const & > _onKeyDown
 
fge::CallbackHandler< fge::Event const &, SDL_KeyboardEvent const & > _onKeyUp
 
fge::CallbackHandler< fge::Event const &, SDL_TextEditingEvent const & > _onTextEditing
 
fge::CallbackHandler< fge::Event const &, SDL_TextInputEvent const & > _onTextInput
 
fge::CallbackHandler< fge::Event const &, SDL_CommonEvent const & > _onKeymapChanged
 
fge::CallbackHandler< fge::Event const &, SDL_MouseMotionEvent const & > _onMouseMotion
 
fge::CallbackHandler< fge::Event const &, SDL_MouseButtonEvent const & > _onMouseButtonDown
 
fge::CallbackHandler< fge::Event const &, SDL_MouseButtonEvent const & > _onMouseButtonUp
 
fge::CallbackHandler< fge::Event const &, SDL_MouseWheelEvent const & > _onMouseWheel
 
fge::CallbackHandler< fge::Event const &, SDL_JoyAxisEvent const & > _onJoyAxisMotion
 
fge::CallbackHandler< fge::Event const &, SDL_JoyBallEvent const & > _onJoyBallMotion
 
fge::CallbackHandler< fge::Event const &, SDL_JoyHatEvent const & > _onJoyHatMotion
 
fge::CallbackHandler< fge::Event const &, SDL_JoyButtonEvent const & > _onJoyButtonDown
 
fge::CallbackHandler< fge::Event const &, SDL_JoyButtonEvent const & > _onJoyButtonUp
 
fge::CallbackHandler< fge::Event const &, SDL_JoyDeviceEvent const & > _onJoyDeviceAdded
 
fge::CallbackHandler< fge::Event const &, SDL_JoyDeviceEvent const & > _onJoyDeviceRemoved
 
fge::CallbackHandler< fge::Event const &, SDL_ControllerAxisEvent const & > _onControllerAxisMotion
 
fge::CallbackHandler< fge::Event const &, SDL_ControllerButtonEvent const & > _onControllerButtonDown
 
fge::CallbackHandler< fge::Event const &, SDL_ControllerButtonEvent const & > _onControllerButtonUp
 
fge::CallbackHandler< fge::Event const &, SDL_ControllerDeviceEvent const & > _onControllerDeviceAdded
 
fge::CallbackHandler< fge::Event const &, SDL_ControllerDeviceEvent const & > _onControllerDeviceRemoved
 
fge::CallbackHandler< fge::Event const &, SDL_ControllerDeviceEvent const & > _onControllerDeviceRemapped
 
fge::CallbackHandler< fge::Event const &, SDL_TouchFingerEvent const & > _onFingerDown
 
fge::CallbackHandler< fge::Event const &, SDL_TouchFingerEvent const & > _onFingerUp
 
fge::CallbackHandler< fge::Event const &, SDL_TouchFingerEvent const & > _onFingerMotion
 
fge::CallbackHandler< fge::Event const &, SDL_DollarGestureEvent const & > _onDollarGesture
 
fge::CallbackHandler< fge::Event const &, SDL_DollarGestureEvent const & > _onDollarRecord
 
fge::CallbackHandler< fge::Event const &, SDL_MultiGestureEvent const & > _onMultiGesture
 
fge::CallbackHandler< fge::Event const &, SDL_CommonEvent const & > _onClipboardUpdate
 
fge::CallbackHandler< fge::Event const &, SDL_DropEvent const & > _onDropFile
 
fge::CallbackHandler< fge::Event const &, SDL_DropEvent const & > _onDropText
 
fge::CallbackHandler< fge::Event const &, SDL_DropEvent const & > _onDropBegin
 
fge::CallbackHandler< fge::Event const &, SDL_DropEvent const & > _onDropComplete
 
fge::CallbackHandler< fge::Event const &, SDL_AudioDeviceEvent const & > _onAudioDeviceAdded
 
fge::CallbackHandler< fge::Event const &, SDL_AudioDeviceEvent const & > _onAudioDeviceRemoved
 
fge::CallbackHandler< fge::Event const &, SDL_CommonEvent const & > _onRenderTargetReset
 
fge::CallbackHandler< fge::Event const &, SDL_CommonEvent const & > _onRenderDeviceReset
 

Detailed Description

This class is a wrapper for SDL events.

This class regroups all the SDL events in a single class. It also provides a way to send events to the server. All events can be monitored with callbacks.

See also
CallbackHandler

Constructor & Destructor Documentation

◆ Event() [1/2]

fge::Event::Event ( fge::Vector2i const & windowSize,
fge::Vector2i const & windowPosition )
inlineexplicit

Constructor to apply to size of the window and the position.

Parameters
windowSizeThe size of the window
windowPositionThe position of the window

◆ Event() [2/2]

fge::Event::Event ( fge::vulkan::SurfaceWindow const & surfaceWindow)
explicit

Constructor to apply window data.

Parameters
surfaceWindowThe surface window

Member Function Documentation

◆ clear()

void fge::Event::clear ( )

Clear all the events.

◆ getBinaryKeysString()

std::string fge::Event::getBinaryKeysString ( ) const

Get a binary representation of all keys into a string.

Returns
The string

◆ getBinaryMouseButtonsString()

std::string fge::Event::getBinaryMouseButtonsString ( ) const

Get a binary representation of all mouse buttons into a string.

Returns
The string

◆ getBinaryTypesString()

std::string fge::Event::getBinaryTypesString ( ) const

Get a binary representation of all SDL event types into a string.

Returns
The string

◆ getKeyUnicode()

uint32_t fge::Event::getKeyUnicode ( ) const

Get the unicode of the last key pressed.

Returns
The unicode character

◆ getMousePixelPos()

fge::Vector2i const & fge::Event::getMousePixelPos ( ) const

Get the mouse pixel position.

Returns
The mouse pixel position

◆ getMouseWheelHorizontalDelta()

int fge::Event::getMouseWheelHorizontalDelta ( ) const

Get the horizontal mouse wheel delta.

Returns
The horizontal mouse wheel delta

◆ getMouseWheelVerticalDelta()

int fge::Event::getMouseWheelVerticalDelta ( ) const

Get the vertical mouse wheel delta.

Returns
The vertical mouse wheel delta

◆ getWindowPos()

fge::Vector2i const & fge::Event::getWindowPos ( ) const

Get the window position.

Returns
The window position

◆ getWindowSize()

fge::Vector2i const & fge::Event::getWindowSize ( ) const

Get the window size.

Returns
The window size

◆ isEventType()

bool fge::Event::isEventType ( uint32_t type) const

Check if the specified SDL event is active.

Parameters
typeThe SDL event type
Returns
true if the event is active, false otherwise

◆ isKeyPressed()

bool fge::Event::isKeyPressed ( uint32_t keycode) const

Check if a key is pressed.

Parameters
keycodeThe SDL key code
Returns
true if the key is pressed, false otherwise

◆ isMouseButtonPressed()

bool fge::Event::isMouseButtonPressed ( uint8_t mouseButton) const

Check if the specified mouse button is pressed.

Parameters
mouseButtonThe SDL mouse button
Returns
true if the button is pressed, false otherwise

◆ pack()

fge::net::Packet & fge::Event::pack ( fge::net::Packet & pck)

Pack events data into a network packet.

Parameters
pckThe packet
Returns
The packet

◆ popType()

void fge::Event::popType ( SDL_EventType type)

TODO: add comments.

◆ process() [1/2]

void fge::Event::process ( SDL_Event const & evt)

Process an SDL event.

Before any attempt to call this function, you should call start.

See also
start
Parameters
evtThe SDL event

◆ process() [2/2]

void fge::Event::process ( unsigned int maxEventCount = 20)

Process automatically SDL events.

This function loop through all available events and call process. The start function is called by this function.

Parameters
maxEventCountThe maximum number of processed events par call

◆ start()

void fge::Event::start ( )

Start the event loop.

This function should be called every time you want to process events. It clear some dynamic events like :

  • Mouse wheel delta
  • Unicode key text
  • Event types
See also
process

◆ unpack()

fge::net::Packet & fge::Event::unpack ( fge::net::Packet & pck)

Unpack events data from a network packet.

Parameters
pckThe packet
Returns
The packet

The documentation for this class was generated from the following file: