InputAdapter Class
Abstract interface for platform-specific input adapters. More...
Declaration
Public Constructors Index
| InputAdapter (std::unique_ptr< helios::engine::input::gamepad::DeadzoneStrategy > deadzoneStrategy) | |
|
Constructs an InputAdapter with the specified deadzone strategy. More... | |
Public Destructor Index
| ~InputAdapter ()=default | |
|
Virtual destructor for proper polymorphic cleanup. More... | |
Public Member Functions Index
| bool | isKeyPressed (helios::engine::input::types::Key key, const helios::window::Window win) const noexcept=0 |
|
Returns true if the key is pressed, otherwise false. More... | |
| bool | isKeyReleased (helios::engine::input::types::Key key, const helios::window::Window win) const noexcept=0 |
|
Returns true if the key is released, otherwise false. More... | |
| bool | isConnected (helios::engine::input::types::Gamepad gamepadId) const noexcept=0 |
|
Returns a boolean value indicating the availability (i.e., connect state) of the gamepad identified by the specified gamepadId. More... | |
| void | updateGamepadState (unsigned int gamepadMask) noexcept=0 |
|
Updates the GamepadState objects with the values queried from the underlying Gamepad identified by the specified mask. More... | |
| const helios::engine::input::gamepad::GamepadState & | gamepadState (helios::engine::input::types::Gamepad gamepadId) const noexcept=0 |
|
Returns a const ref to the GamepadState-object for the specified gamepadId. More... | |
| helios::engine::input::gamepad::GamepadSettings & | gamepadSettings (helios::engine::input::types::Gamepad gamepadId) noexcept |
|
Returns the configuration settings for the specified gamepad. More... | |
Protected Member Attributes Index
| std::unique_ptr< helios::engine::input::gamepad::DeadzoneStrategy > | deadzoneStrategy_ |
|
Strategy used to normalize analog stick input within deadzones. More... | |
| std::array< helios::engine::input::gamepad::GamepadSettings, std::to_underlying(helios::engine::input::types::Gamepad::size_)> | gamepadSettings_ = {} |
|
Per-gamepad configuration settings. More... | |
Protected Static Attributes Index
| static const helios::engine::util::log::Logger & | logger_ = helios::engine::util::log::LogManager::loggerForScope(HELIOS_LOG_SCOPE) |
|
Shared logger instance for all InputAdapter objects. More... | |
Description
Abstract interface for platform-specific input adapters.
Provides a unified interface for querying input device states across different platforms. Concrete implementations translate generic input queries into platform-specific API calls.
The adapter manages per-gamepad configuration through GamepadSettings and applies input normalization via a configurable DeadzoneStrategy.
- See Also
GLFWInputAdapter for a GLFW-based implementation.
- See Also
GamepadSettings for per-controller configuration options.
- See Also
DeadzoneStrategy for input normalization strategies.
Definition at line 46 of file InputAdapter.ixx.
Public Constructors
InputAdapter()
| inline explicit |
Constructs an InputAdapter with the specified deadzone strategy.
- Parameters
-
deadzoneStrategy The strategy used for analog stick normalization. Ownership is transferred to this adapter.
Definition at line 84 of file InputAdapter.ixx.
Public Destructor
~InputAdapter()
| virtual default |
Virtual destructor for proper polymorphic cleanup.
Definition at line 76 of file InputAdapter.ixx.
Public Member Functions
gamepadSettings()
| inline noexcept |
Returns the configuration settings for the specified gamepad.
Provides access to the mutable settings object for the given gamepad, allowing runtime configuration of deadzone thresholds and axis inversion. Changes to the returned settings are applied during subsequent calls to updateGamepadState().
- Parameters
-
gamepadId The gamepad to retrieve settings for.
- Returns
Reference to the mutable GamepadSettings for the specified gamepad.
- See Also
GamepadSettings for available configuration options.
Definition at line 174 of file InputAdapter.ixx.
References gamepadSettings_ and helios::registerComponents.
gamepadState()
| noexcept |
Returns a const ref to the GamepadState-object for the specified gamepadId.
Implementing APIs can call this method in each frame to retrieve the current state for the gamepad, as computed by updateGamepadState(). This method guarantees that for a given gamepadId, a single GamepadState object is reused across calls, avoiding re-instantiation overhead.
- Parameters
-
gamepadId The id of the gamepad to query
- Returns
Returns a const ref to the GamepadState. If the GamepadState was never queried before, or if a recent call to updateGamepadState did not succeed, the values of the GamepadState will not hold representative values. Implementing APIs should verify the availability of the Gamepad by calling isConnected()
- See Also
- See Also
Definition at line 156 of file InputAdapter.ixx.
isConnected()
| noexcept |
Returns a boolean value indicating the availability (i.e., connect state) of the gamepad identified by the specified gamepadId.
- Parameters
-
gamepadId The gamepadId to query for availability.
- Returns
true if the Gamepad identified by gamepadId is connected, otherwise false.
Definition at line 119 of file InputAdapter.ixx.
isKeyPressed()
| noexcept |
Returns true if the key is pressed, otherwise false.
- Parameters
-
key The key to query for the pressed state.
win The window instance from which the state should be queried.
- Returns
True if the key is pressed, otherwise false.
Definition at line 96 of file InputAdapter.ixx.
isKeyReleased()
| noexcept |
Returns true if the key is released, otherwise false.
- Parameters
-
key The key to query for the released state.
win The window instance from which the state should be queried.
- Returns
True if the key is released, otherwise false.
Definition at line 106 of file InputAdapter.ixx.
updateGamepadState()
| noexcept |
Updates the GamepadState objects with the values queried from the underlying Gamepad identified by the specified mask.
Updates the GamepadState objects with the current values of the underlying hardware. If querying the underlying hardware fails, this method will update the GamepadState values to a valid initial state (no movement or interaction). Implementations should use isConnected() to check whether the current values of a GamepadState object can be trusted.
- Parameters
-
gamepadMask A bitmask representing all GamepadState objects to update, e.g. Gamepad::ONE | Gamepad::TWO...
Definition at line 135 of file InputAdapter.ixx.
Protected Member Attributes
deadzoneStrategy_
| protected |
Strategy used to normalize analog stick input within deadzones.
Ownership is held by the adapter. Applied during gamepad state updates to filter out hardware drift and rescale input values.
Definition at line 60 of file InputAdapter.ixx.
gamepadSettings_
| protected |
Per-gamepad configuration settings.
Array indexed by gamepad ID, storing deadzone thresholds and axis inversion flags for each connected controller.
Definition at line 68 of file InputAdapter.ixx.
Referenced by gamepadSettings.
Protected Static Attributes
logger_
| protected static |
Shared logger instance for all InputAdapter objects.
Definition at line 52 of file InputAdapter.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.