InputAdapter Class
Abstract interface for platform-specific input adapters. More...
Declaration
Derived Classes
| class | GLFWInputAdapter |
|
InputAdapter implementation for a GLFWWindow. More... | |
Public Constructors Index
| InputAdapter (std::unique_ptr< helios::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::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::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::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::input::gamepad::GamepadState & | gamepadState (helios::input::types::Gamepad gamepadId) const noexcept=0 |
|
Returns a const ref to the GamepadState-object for the specified gamepadId. More... | |
| helios::input::gamepad::GamepadSettings & | gamepadSettings (helios::input::types::Gamepad gamepadId) noexcept |
|
Returns the configuration settings for the specified gamepad. More... | |
Protected Member Attributes Index
| std::unique_ptr< helios::input::gamepad::DeadzoneStrategy > | deadzoneStrategy_ |
|
Strategy used to normalize analog stick input within deadzones. More... | |
| std::array< helios::input::gamepad::GamepadSettings, std::to_underlying(helios::input::types::Gamepad::size_)> | gamepadSettings_ = {} |
|
Per-gamepad configuration settings. More... | |
Protected Static Attributes Index
| static const helios::util::log::Logger & | logger_ = helios::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 40 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 78 of file InputAdapter.ixx.
Reference deadzoneStrategy_.
Referenced by helios::ext::glfw::input::GLFWInputAdapter::GLFWInputAdapter.
Public Destructor
~InputAdapter()
| virtual default |
Virtual destructor for proper polymorphic cleanup.
Definition at line 70 of file InputAdapter.ixx.
Public Member Functions
gamepadSettings()
| inline nodiscard 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 170 of file InputAdapter.ixx.
Reference gamepadSettings_.
Referenced by helios::ext::glfw::input::GLFWInputAdapter::updateGamepadState.
gamepadState()
| nodiscard 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 152 of file InputAdapter.ixx.
isConnected()
| nodiscard 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 115 of file InputAdapter.ixx.
isKeyPressed()
| nodiscard 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 90 of file InputAdapter.ixx.
isKeyReleased()
| nodiscard 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 102 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 131 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 54 of file InputAdapter.ixx.
Referenced by InputAdapter and helios::ext::glfw::input::GLFWInputAdapter::updateGamepadState.
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 62 of file InputAdapter.ixx.
Referenced by gamepadSettings.
Protected Static Attributes
logger_
| protected static |
Shared logger instance for all InputAdapter objects.
Definition at line 46 of file InputAdapter.ixx.
Referenced by helios::ext::glfw::input::GLFWInputAdapter::isKeyPressed and helios::ext::glfw::input::GLFWInputAdapter::isKeyReleased.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.