GLFWInputAdapter Class
InputAdapter implementation for a GLFWWindow. More...
Declaration
Base class
| class | InputAdapter |
|
Abstract interface for platform-specific input adapters. More... | |
Public Constructors Index
| GLFWInputAdapter (std::unique_ptr< helios::input::gamepad::DeadzoneStrategy > deadzoneStrategy) | |
|
Constructs a GLFWInputAdapter with the specified deadzone strategy. More... | |
Public Member Functions Index
| bool | isKeyPressed (helios::input::types::Key key, const helios::window::Window &win) const noexcept override |
|
Checks if a specific key is currently pressed for the given window. If the specified window is not of type GLFWWindow, this method always returns false. More... | |
| bool | isKeyReleased (helios::input::types::Key key, const helios::window::Window &win) const noexcept override |
|
Checks if a specific key is currently released for the given window. More... | |
| bool | isKeyPressed (helios::input::types::Key key, const helios::ext::glfw::window::GLFWWindow &win) const noexcept |
|
Checks if a specific key is currently pressed for the given GLFWWindow. More... | |
| bool | isKeyReleased (helios::input::types::Key key, const helios::ext::glfw::window::GLFWWindow &win) const noexcept |
|
Checks if a specific key is currently released for the given GLFWWindow. More... | |
| const helios::input::gamepad::GamepadState & | gamepadState (helios::input::types::Gamepad gamepadId) const noexcept override |
|
Returns a const ref to the GamepadState-object for the specified gamepadId. More... | |
| void | updateGamepadState (unsigned int gamepadMask) noexcept override |
|
Updates the GamepadState objects with the values queried from the underlying Gamepad identified by the specified mask. More... | |
| bool | isConnected (helios::input::types::Gamepad gamepadId) const noexcept override |
|
Returns a boolean value indicating the availability (i.e., connect state) of the gamepad identified by the specified gamepadId. More... | |
Private Member Attributes Index
| std::array< helios::input::gamepad::GamepadState, std::to_underlying(helios::input::types::Gamepad::size_)> | gamepadStates_ = {} |
|
Array storing the current state of each connected gamepad. More... | |
Description
InputAdapter implementation for a GLFWWindow.
This class translates generic input queries into GLFW-specific API calls. Input queries are always executed against a GLFWWindow instance, which is to be specified by the caller.
The adapter applies the configured `DeadzoneStrategy` and `GamepadSettings` during gamepad state updates to normalize analog stick input and handle axis inversion.
- See Also
InputAdapter for the abstract interface.
- See Also
GamepadSettings for per-controller configuration.
- See Also
DeadzoneStrategy for input normalization strategies.
Definition at line 46 of file GLFWInputAdapter.ixx.
Public Constructors
GLFWInputAdapter()
| inline |
Constructs a GLFWInputAdapter with the specified deadzone strategy.
- Parameters
-
deadzoneStrategy The strategy used for analog stick normalization. Ownership is transferred to the base InputAdapter.
Definition at line 67 of file GLFWInputAdapter.ixx.
Reference helios::input::InputAdapter::InputAdapter.
Public Member Functions
gamepadState()
| inline nodiscard noexcept virtual |
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 143 of file GLFWInputAdapter.ixx.
Reference helios::ext::glfw::input::GLFWGamepadLookup::toArrayIndex.
isConnected()
| inline nodiscard noexcept virtual |
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 238 of file GLFWInputAdapter.ixx.
Reference helios::ext::glfw::input::GLFWGamepadLookup::from.
isKeyPressed()
| inline nodiscard noexcept virtual |
Checks if a specific key is currently pressed for the given window. If the specified window is not of type GLFWWindow, this method always returns false.
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 77 of file GLFWInputAdapter.ixx.
References isKeyPressed and helios::input::InputAdapter::logger_.
Referenced by isKeyPressed.
isKeyPressed()
| inline nodiscard noexcept |
Checks if a specific key is currently pressed for the given GLFWWindow.
- Parameters
-
key The helios key to check.
win The `GLFWWindow` instance to query for the key-press.
- Returns
true if the key is pressed, otherwise false.
Definition at line 116 of file GLFWInputAdapter.ixx.
isKeyReleased()
| inline nodiscard noexcept virtual |
Checks if a specific key is currently released for the given window.
If the specified window is not of type GLFWWindow, this method always returns false.
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 96 of file GLFWInputAdapter.ixx.
References isKeyReleased and helios::input::InputAdapter::logger_.
Referenced by isKeyReleased.
isKeyReleased()
| inline nodiscard noexcept |
Checks if a specific key is currently released for the given GLFWWindow.
- Parameters
-
key The helios key to check.
win The `GLFWWindow` instance to query for the key-release.
- Returns
true if the key is released, otherwise false.
Definition at line 132 of file GLFWInputAdapter.ixx.
updateGamepadState()
| inline noexcept virtual |
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 153 of file GLFWInputAdapter.ixx.
References helios::input::InputAdapter::deadzoneStrategy_, helios::ext::glfw::input::GLFWGamepadLookup::from and helios::input::InputAdapter::gamepadSettings.
Private Member Attributes
gamepadStates_
|
Array storing the current state of each connected gamepad.
Indexed by gamepad ID, each entry holds the most recently polled button and axis states for that controller.
Definition at line 57 of file GLFWInputAdapter.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.