Clutter Engine 0.0.1
Loading...
Searching...
No Matches
clt::Input Class Reference

Class managing input actions and their states. More...

#include <Input.h>

Classes

struct  Action
 Struct representing an action mapped to a key. More...
 
struct  AxisMapping
 Struct representing a mapping between two keys for an axis. More...
 
struct  MouseAxisMapping
 Struct representing a mapping between two mouse buttons for an axis. More...
 
struct  VectMapping
 Struct representing a mapping for a 2D vector using four keys. More...
 

Public Member Functions

 Input (const Input &)=delete
 Deleted copy constructor.
 
Inputoperator= (const Input &)=delete
 Deleted copy assignment operator.
 
void SetShowMouseCursor (bool show)
 Sets whether the mouse cursor should be shown.
 
void LockMouseCursor (bool lock)
 Locks or unlocks the mouse cursor.
 
Vector2 GetMousePosition () const
 Gets the current mouse position.
 
bool IsButtonPressed (EKey pKey) const
 Checks if a key is pressed.
 
bool IsButtonPressed (EMouseButton pButton) const
 Checks if a mouse button is pressed.
 
void Update ()
 Updates the state of the input manager.
 
void MapKeyToAction (EKey pKey, const std::string &pActionName, EInputState pState=EInputState::Pressed)
 Maps a key to an action.
 
void MapKeyToAction (EMouseButton pKey, const std::string &pActionName, EInputState pState=EInputState::Pressed)
 Maps a mouse button to an action.
 
void MapKeyToAction (EControllerButton pKey, const std::string &pActionName, EInputState pState=EInputState::Pressed)
 Maps a controller button to an action.
 
void RegisterActionCallback (const std::string &pActionName, std::function< void()> callback)
 Registers a callback for an action.
 
void RegisterAxisCallback (const std::string &axisName, std::function< void(float)> callback)
 Registers a callback for an axis.
 
void RegisterMouseCallback (std::function< void(Vector2)> callback)
 Registers a callback for mouse movement.
 
void RegisterScrollCallback (std::function< void(float)> callback)
 Registers a callback for mouse scroll.
 
void MapKeysToAxis (EKey positiveKey, EKey negativeKey, const std::string &axisName)
 Maps two keys to an axis.
 
void MapKeysToAxis (EMouseButton positiveKey, EMouseButton negativeKey, const std::string &axisName)
 Maps two mouse buttons to an axis.
 
void MapKeysToAxis (EControllerAxis axis, const std::string &axisName, float pDeadzone=-1.0f)
 Maps a controller axis to an axis name.
 
bool RegisterVectCallback (const std::string &VectName, std::function< void(Vector2)> callback)
 Registers a callback for a vector input.
 
void MapKeysToVect (EKey XPositiveKey, EKey XNegativeKey, EKey YPositiveKey, EKey YNegativeKey, const std::string &VectName)
 Maps four keys to a 2D vector input.
 

Static Public Member Functions

static InputGet ()
 Gets the singleton instance of the InputManager.
 

Detailed Description

Class managing input actions and their states.

Member Function Documentation

◆ Get()

static Input & clt::Input::Get ( )
inlinestatic

Gets the singleton instance of the InputManager.

Returns
Reference to the singleton instance.

◆ GetMousePosition()

Vector2 clt::Input::GetMousePosition ( ) const
inline

Gets the current mouse position.

Returns
The last recorded mouse position.

◆ IsButtonPressed() [1/2]

bool Input::IsButtonPressed ( EKey pKey) const

Checks if a key is pressed.

Parameters
pKeyThe key to check.
Returns
True if the key is pressed, false otherwise.

◆ IsButtonPressed() [2/2]

bool Input::IsButtonPressed ( EMouseButton pButton) const

Checks if a mouse button is pressed.

Parameters
pButtonThe mouse button to check.
Returns
True if the button is pressed, false otherwise.

◆ LockMouseCursor()

void clt::Input::LockMouseCursor ( bool lock)
inline

Locks or unlocks the mouse cursor.

Parameters
lockTrue to lock the cursor, false to unlock.

◆ MapKeysToAxis() [1/3]

void Input::MapKeysToAxis ( EControllerAxis axis,
const std::string & axisName,
float pDeadzone = -1.0f )

Maps a controller axis to an axis name.

Parameters
axisController axis.
axisNameName of the axis.
pDeadzoneDeadzone for the axis (optional).

◆ MapKeysToAxis() [2/3]

void Input::MapKeysToAxis ( EKey positiveKey,
EKey negativeKey,
const std::string & axisName )

Maps two keys to an axis.

Parameters
positiveKeyKey for positive direction.
negativeKeyKey for negative direction.
axisNameName of the axis.

◆ MapKeysToAxis() [3/3]

void Input::MapKeysToAxis ( EMouseButton positiveKey,
EMouseButton negativeKey,
const std::string & axisName )

Maps two mouse buttons to an axis.

Parameters
positiveKeyMouse button for positive direction.
negativeKeyMouse button for negative direction.
axisNameName of the axis.

◆ MapKeysToVect()

void Input::MapKeysToVect ( EKey XPositiveKey,
EKey XNegativeKey,
EKey YPositiveKey,
EKey YNegativeKey,
const std::string & VectName )

Maps four keys to a 2D vector input.

Parameters
XPositiveKeyKey for positive X direction.
XNegativeKeyKey for negative X direction.
YPositiveKeyKey for positive Y direction.
YNegativeKeyKey for negative Y direction.
VectNameName of the vector input.

◆ MapKeyToAction() [1/3]

void Input::MapKeyToAction ( EControllerButton pKey,
const std::string & pActionName,
EInputState pState = EInputState::Pressed )

Maps a controller button to an action.

Parameters
pKeyController button code.
pActionNameName of the action.
pStateState of the input.

◆ MapKeyToAction() [2/3]

void Input::MapKeyToAction ( EKey pKey,
const std::string & pActionName,
EInputState pState = EInputState::Pressed )

Maps a key to an action.

Parameters
pKeyKey code.
pActionNameName of the action.
pStateState of the input.

◆ MapKeyToAction() [3/3]

void Input::MapKeyToAction ( EMouseButton pKey,
const std::string & pActionName,
EInputState pState = EInputState::Pressed )

Maps a mouse button to an action.

Parameters
pKeyMouse button code.
pActionNameName of the action.
pStateState of the input.

◆ RegisterActionCallback()

void Input::RegisterActionCallback ( const std::string & pActionName,
std::function< void()> callback )

Registers a callback for an action.

Parameters
pActionNameName of the action.
callbackFunction to be called when the action is triggered.

◆ RegisterAxisCallback()

void Input::RegisterAxisCallback ( const std::string & axisName,
std::function< void(float)> callback )

Registers a callback for an axis.

Parameters
axisNameName of the axis.
callbackFunction to be called with the axis value.

◆ RegisterMouseCallback()

void Input::RegisterMouseCallback ( std::function< void(Vector2)> callback)

Registers a callback for mouse movement.

Parameters
callbackFunction to be called with the mouse delta.

◆ RegisterScrollCallback()

void Input::RegisterScrollCallback ( std::function< void(float)> callback)

Registers a callback for mouse scroll.

Parameters
callbackFunction to be called with the scroll value.

◆ RegisterVectCallback()

bool Input::RegisterVectCallback ( const std::string & VectName,
std::function< void(Vector2)> callback )

Registers a callback for a vector input.

Parameters
VectNameName of the vector input.
callbackFunction to be called with the vector value.
Returns
True if registration was successful, false otherwise.

◆ SetShowMouseCursor()

void clt::Input::SetShowMouseCursor ( bool show)
inline

Sets whether the mouse cursor should be shown.

Parameters
showTrue to show the cursor, false to hide.

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