Clutter Engine 0.0.1
|
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. | |
Input & | operator= (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 Input & | Get () |
Gets the singleton instance of the InputManager. | |
Class managing input actions and their states.
|
inlinestatic |
Gets the singleton instance of the InputManager.
|
inline |
Gets the current mouse position.
bool Input::IsButtonPressed | ( | EKey | pKey | ) | const |
Checks if a key is pressed.
pKey | The key to check. |
bool Input::IsButtonPressed | ( | EMouseButton | pButton | ) | const |
Checks if a mouse button is pressed.
pButton | The mouse button to check. |
|
inline |
Locks or unlocks the mouse cursor.
lock | True to lock the cursor, false to unlock. |
void Input::MapKeysToAxis | ( | EControllerAxis | axis, |
const std::string & | axisName, | ||
float | pDeadzone = -1.0f ) |
Maps a controller axis to an axis name.
axis | Controller axis. |
axisName | Name of the axis. |
pDeadzone | Deadzone for the axis (optional). |
void Input::MapKeysToAxis | ( | EKey | positiveKey, |
EKey | negativeKey, | ||
const std::string & | axisName ) |
Maps two keys to an axis.
positiveKey | Key for positive direction. |
negativeKey | Key for negative direction. |
axisName | Name of the axis. |
void Input::MapKeysToAxis | ( | EMouseButton | positiveKey, |
EMouseButton | negativeKey, | ||
const std::string & | axisName ) |
Maps two mouse buttons to an axis.
positiveKey | Mouse button for positive direction. |
negativeKey | Mouse button for negative direction. |
axisName | Name of the axis. |
void Input::MapKeysToVect | ( | EKey | XPositiveKey, |
EKey | XNegativeKey, | ||
EKey | YPositiveKey, | ||
EKey | YNegativeKey, | ||
const std::string & | VectName ) |
Maps four keys to a 2D vector input.
XPositiveKey | Key for positive X direction. |
XNegativeKey | Key for negative X direction. |
YPositiveKey | Key for positive Y direction. |
YNegativeKey | Key for negative Y direction. |
VectName | Name of the vector input. |
void Input::MapKeyToAction | ( | EControllerButton | pKey, |
const std::string & | pActionName, | ||
EInputState | pState = EInputState::Pressed ) |
Maps a controller button to an action.
pKey | Controller button code. |
pActionName | Name of the action. |
pState | State of the input. |
void Input::MapKeyToAction | ( | EKey | pKey, |
const std::string & | pActionName, | ||
EInputState | pState = EInputState::Pressed ) |
Maps a key to an action.
pKey | Key code. |
pActionName | Name of the action. |
pState | State of the input. |
void Input::MapKeyToAction | ( | EMouseButton | pKey, |
const std::string & | pActionName, | ||
EInputState | pState = EInputState::Pressed ) |
Maps a mouse button to an action.
pKey | Mouse button code. |
pActionName | Name of the action. |
pState | State of the input. |
void Input::RegisterActionCallback | ( | const std::string & | pActionName, |
std::function< void()> | callback ) |
Registers a callback for an action.
pActionName | Name of the action. |
callback | Function to be called when the action is triggered. |
void Input::RegisterAxisCallback | ( | const std::string & | axisName, |
std::function< void(float)> | callback ) |
Registers a callback for an axis.
axisName | Name of the axis. |
callback | Function to be called with the axis value. |
void Input::RegisterMouseCallback | ( | std::function< void(Vector2)> | callback | ) |
Registers a callback for mouse movement.
callback | Function to be called with the mouse delta. |
void Input::RegisterScrollCallback | ( | std::function< void(float)> | callback | ) |
Registers a callback for mouse scroll.
callback | Function to be called with the scroll value. |
bool Input::RegisterVectCallback | ( | const std::string & | VectName, |
std::function< void(Vector2)> | callback ) |
Registers a callback for a vector input.
VectName | Name of the vector input. |
callback | Function to be called with the vector value. |
|
inline |
Sets whether the mouse cursor should be shown.
show | True to show the cursor, false to hide. |