Skip to main content

InputAdapter Class

Abstract interface for platform-specific input adapters. More...

Declaration

class helios::input::InputAdapter { ... }

Derived Classes

classGLFWInputAdapter

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

boolisKeyPressed (helios::input::types::Key key, const helios::window::Window &win) const noexcept=0

Returns true if the key is pressed, otherwise false. More...

boolisKeyReleased (helios::input::types::Key key, const helios::window::Window &win) const noexcept=0

Returns true if the key is released, otherwise false. More...

boolisConnected (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...

voidupdateGamepadState (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()

helios::input::InputAdapter::InputAdapter (std::unique_ptr< helios::input::gamepad::DeadzoneStrategy > deadzoneStrategy)
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.

78 explicit InputAdapter(std::unique_ptr<helios::input::gamepad::DeadzoneStrategy> deadzoneStrategy) :
79 deadzoneStrategy_(std::move(deadzoneStrategy))
80 {}

Reference deadzoneStrategy_.

Referenced by helios::ext::glfw::input::GLFWInputAdapter::GLFWInputAdapter.

Public Destructor

~InputAdapter()

virtual helios::input::InputAdapter::~InputAdapter ()
virtual default

Virtual destructor for proper polymorphic cleanup.

Definition at line 70 of file InputAdapter.ixx.

Public Member Functions

gamepadSettings()

helios::input::gamepad::GamepadSettings & helios::input::InputAdapter::gamepadSettings (helios::input::types::Gamepad gamepadId)
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.

171 const auto id = static_cast<unsigned int>(gamepadId);
172 const auto idx = std::countr_zero(id);
173
174 return gamepadSettings_[idx];
175 }

Reference gamepadSettings_.

Referenced by helios::ext::glfw::input::GLFWInputAdapter::updateGamepadState.

gamepadState()

virtual const helios::input::gamepad::GamepadState & helios::input::InputAdapter::gamepadState (helios::input::types::Gamepad gamepadId)
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

updateGamepadState

See Also

isConnected

Definition at line 152 of file InputAdapter.ixx.

isConnected()

virtual bool helios::input::InputAdapter::isConnected (helios::input::types::Gamepad gamepadId)
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()

virtual bool helios::input::InputAdapter::isKeyPressed (helios::input::types::Key key, const helios::window::Window & win)
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()

virtual bool helios::input::InputAdapter::isKeyReleased (helios::input::types::Key key, const helios::window::Window & win)
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()

virtual void helios::input::InputAdapter::updateGamepadState (unsigned int gamepadMask)
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_

std::unique_ptr<helios::input::gamepad::DeadzoneStrategy> helios::input::InputAdapter::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.

54 std::unique_ptr<helios::input::gamepad::DeadzoneStrategy> deadzoneStrategy_;

Referenced by InputAdapter and helios::ext::glfw::input::GLFWInputAdapter::updateGamepadState.

gamepadSettings_

std::array<helios::input::gamepad::GamepadSettings, std::to_underlying(helios::input::types::Gamepad::size_)> helios::input::InputAdapter::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.

62 std::array<helios::input::gamepad::GamepadSettings, std::to_underlying(helios::input::types::Gamepad::size_)> gamepadSettings_ = {};

Referenced by gamepadSettings.

Protected Static Attributes

logger_

const helios::util::log::Logger& helios::input::InputAdapter::logger_ = helios::util::log::LogManager::loggerForScope(HELIOS_LOG_SCOPE)
protected static

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.