R-Type 0.1
Loading...
Searching...
No Matches
rtk::ecs::concepts::Event Class Reference

Input query interface filled by the window backend. More...

#include <systems/RenderConcept.hpp>

Public Member Functions

bool isKeyPressed (Key key) const
 Tells whether a key is held.
 
bool isKeyReleased (Key key) const
 Tells whether a key was released this frame.
 
bool isMouseButtonPressed (MouseButton button) const
 Tells whether a mouse button is held.
 
bool isMouseButtonReleased (MouseButton button) const
 Tells whether a mouse button was released this frame.
 
int getMouseX () const
 Returns the cursor x position.
 
int getMouseY () const
 Returns the cursor y position.
 
bool isGamepadButtonPressed (int joystickId, GamepadButton button) const
 Tells whether a gamepad button is held.
 
bool isGamepadButtonReleased (int joystickId, GamepadButton button) const
 Tells whether a gamepad button was released this frame.
 
float getGamepadAxis (int joystickId, GamepadAxis axis) const
 Returns the position of a gamepad axis.
 
bool isGamepadConnected (int joystickId) const
 Tells whether a gamepad is plugged in.
 

Public Attributes

void * userData {nullptr}
 Backend context passed to every function.
 
bool(* _isKeyPressed )(void *, Key)
 Backend key press query.
 
bool(* _isKeyReleased )(void *, Key)
 Backend key release query.
 
bool(* _isMouseButtonPressed )(void *, MouseButton)
 Backend mouse press query.
 
bool(* _isMouseButtonReleased )(void *, MouseButton)
 Backend mouse release query.
 
int(* _getMouseX )(void *)
 Backend mouse x query.
 
int(* _getMouseY )(void *)
 Backend mouse y query.
 
bool(* _isGamepadButtonPressed )(void *, int, GamepadButton)
 Backend gamepad press query.
 
bool(* _isGamepadButtonReleased )(void *, int, GamepadButton)
 Backend gamepad release query.
 
float(* _getGamepadAxis )(void *, int, GamepadAxis)
 Backend gamepad axis query.
 
bool(* _isGamepadConnected )(void *, int)
 Backend gamepad presence query.
 

Detailed Description

Input query interface filled by the window backend.

The backend stores a context pointer and plain function pointers, so the engine can query inputs without depending on the backend types. Every query returns a neutral value when its function pointer is not set.

Member Function Documentation

◆ isKeyPressed()

bool rtk::ecs::concepts::Event::isKeyPressed ( Key key) const
inlinenodiscard

Tells whether a key is held.

Parameters
keyKey to test.
Returns
True while the key is down.

◆ isKeyReleased()

bool rtk::ecs::concepts::Event::isKeyReleased ( Key key) const
inlinenodiscard

Tells whether a key was released this frame.

Parameters
keyKey to test.
Returns
True on the frame the key goes up.

◆ isMouseButtonPressed()

bool rtk::ecs::concepts::Event::isMouseButtonPressed ( MouseButton button) const
inlinenodiscard

Tells whether a mouse button is held.

Parameters
buttonButton to test.
Returns
True while the button is down.

◆ isMouseButtonReleased()

bool rtk::ecs::concepts::Event::isMouseButtonReleased ( MouseButton button) const
inlinenodiscard

Tells whether a mouse button was released this frame.

Parameters
buttonButton to test.
Returns
True on the frame the button goes up.

◆ getMouseX()

int rtk::ecs::concepts::Event::getMouseX ( ) const
inlinenodiscard

Returns the cursor x position.

Returns
X in window pixels.

◆ getMouseY()

int rtk::ecs::concepts::Event::getMouseY ( ) const
inlinenodiscard

Returns the cursor y position.

Returns
Y in window pixels.

◆ isGamepadButtonPressed()

bool rtk::ecs::concepts::Event::isGamepadButtonPressed ( int joystickId,
GamepadButton button ) const
inlinenodiscard

Tells whether a gamepad button is held.

Parameters
joystickIdGamepad index.
buttonButton to test.
Returns
True while the button is down.

◆ isGamepadButtonReleased()

bool rtk::ecs::concepts::Event::isGamepadButtonReleased ( int joystickId,
GamepadButton button ) const
inlinenodiscard

Tells whether a gamepad button was released this frame.

Parameters
joystickIdGamepad index.
buttonButton to test.
Returns
True on the frame the button goes up.

◆ getGamepadAxis()

float rtk::ecs::concepts::Event::getGamepadAxis ( int joystickId,
GamepadAxis axis ) const
inlinenodiscard

Returns the position of a gamepad axis.

Parameters
joystickIdGamepad index.
axisAxis to read.
Returns
A value between -1 and 1.

◆ isGamepadConnected()

bool rtk::ecs::concepts::Event::isGamepadConnected ( int joystickId) const
inlinenodiscard

Tells whether a gamepad is plugged in.

Parameters
joystickIdGamepad index.
Returns
True if the gamepad is connected.