Class Engine::Controller¶
ClassList > Engine > Controller
Controller implementation polling Raylib keyboard, mouse, and gamepad inputs.
#include <Controller.hpp>
Inherits the following classes: Engine::IController
Public Types inherited from Engine::IController¶
| Type | Name |
|---|---|
| typedef std::unordered_map< Action, ActionBinding > | Kmap |
Public Attributes inherited from Engine::IController¶
| Type | Name |
|---|---|
| std::set< Action > | _activeActions Active actions triggered during this tick/frame. |
| std::set< Action > | _networkedActions Subset of _activeActions whose action is marked networked. |
| std::set< Action > | _pressedActions Actions that were pressed (edge-triggered) this tick/frame. |
| Kmap | m_keymap Mapping of action names to their shortcuts and network flag. |
Public Functions¶
| Type | Name |
|---|---|
| Controller (int gamepadId=0) Constructs a Controller . |
|
| virtual void | Update () override Evaluates all registered keybinds and updates the list of active actions. |
| virtual void | addKeybind (const Action & action, const Keybind & kb, bool networked=false) override Binds a physical button/key to an action name. |
| virtual const std::set< Action > & | getActiveActions () override const Retrieves all active actions for this frame. |
| virtual const std::set< Action > & | getNetworkedActiveActions () override const Returns all actions currently active in this frame that should be send to the server. |
| virtual bool | isActionActive (const std::string & action) override const Checks if a specific action is active this frame. |
| virtual bool | isActionPressed (const std::string & action) override const Checks if a specific action was pressed (edge-triggered) this frame. |
| void | setGamepadId (const int gamepadId) Sets the gamepad ID for this controller. |
| ~Controller () override |
Public Functions inherited from Engine::IController¶
| Type | Name |
|---|---|
| virtual void | Update () = 0 Updates the active action list for this frame based on hardware input. |
| virtual void | addKeybind (const Action & action, const Keybind & kb, bool networked=false) = 0 Binds a key/button to an abstract action name. |
| virtual const std::set< Action > & | getActiveActions () const = 0 Returns all actions currently active in this frame. |
| virtual const std::set< Action > & | getNetworkedActiveActions () const = 0 Returns all actions currently active in this frame that should be send to the server. |
| virtual bool | isActionActive (const std::string & action) const = 0 Checks if an action is currently active in this frame. |
| virtual bool | isActionPressed (const std::string & action) const = 0 Checks if an action was triggered (pressed) this frame (edge-triggered). |
| virtual | ~IController () = default |
Public Functions Documentation¶
function Controller¶
Constructs a Controller .
Parameters:
gamepadIdGamepad index (default 0).
function Update¶
Evaluates all registered keybinds and updates the list of active actions.
Implements Engine::IController::Update
function addKeybind¶
Binds a physical button/key to an action name.
virtual void Engine::Controller::addKeybind (
const Action & action,
const Keybind & kb,
bool networked=false
) override
Parameters:
actionthe action to addkbthe specific keybindnetworkedWhen true, marks the action as sent to the server in player_input.
Implements Engine::IController::addKeybind
function getActiveActions¶
Retrieves all active actions for this frame.
Implements Engine::IController::getActiveActions
function getNetworkedActiveActions¶
Returns all actions currently active in this frame that should be send to the server.
Returns:
Const reference to active actions list that should be sent to the server
Implements Engine::IController::getNetworkedActiveActions
function isActionActive¶
Checks if a specific action is active this frame.
Implements Engine::IController::isActionActive
function isActionPressed¶
Checks if a specific action was pressed (edge-triggered) this frame.
Implements Engine::IController::isActionPressed
function setGamepadId¶
Sets the gamepad ID for this controller.
function ~Controller¶
The documentation for this class was generated from the following file /home/runner/work/r-type/r-type/Engine/include/Inputs/Controller.hpp