InputManager Class
InputManager providing access to various input states. More...
Declaration
Public Constructors Index
| InputManager (std::unique_ptr< helios::input::InputAdapter > input) | |
|
Creates a new InputManager with the specified InputAdapter. More... | |
Public Member Functions Index
| void | observe (const helios::window::Window &win) noexcept |
|
Sets the window this InputManager will observe for input. More... | |
| const helios::window::Window * | observedWindow () const |
|
Returns a non-owning pointer to the currently observed window. More... | |
| void | poll (float deltaTime) noexcept |
|
Polls events from the currently observed window and registered gamepads. More... | |
| bool | isKeyPressed (const helios::input::types::Key &key) const noexcept |
|
Returns true if the specified key is currently pressed, otherwise false. More... | |
| bool | isKeyReleased (const helios::input::types::Key &key) const noexcept |
|
Returns true if the specified key is currently released, otherwise false. More... | |
| unsigned int | registerGamepads (unsigned int mask) noexcept |
|
Explicitly tells this InputManager which gamepads to poll for input states in `poll()`. More... | |
| const helios::input::gamepad::GamepadState & | gamepadState (helios::input::types::Gamepad gamepadId) const noexcept |
|
Returns a const reference to the `GamepadState` for the specified `gamepadId`. More... | |
| bool | isConnected (helios::input::types::Gamepad gamepadId) const noexcept |
|
Returns true if the specified gamepad is connected, otherwise false. More... | |
| const helios::input::InputAdapter & | inputAdapter () const noexcept |
|
Retrieves the InputAdapter associated with this InputManager. More... | |
| helios::input::InputAdapter & | inputAdapter () noexcept |
|
Retrieves the InputAdapter associated with this InputManager. More... | |
Private Member Attributes Index
| const helios::window::Window * | observedWin_ = nullptr |
|
A pointer to the currently observed window, which might be nullptr. More... | |
| std::unique_ptr< helios::input::InputAdapter > | input_ |
|
The InputAdapter owned by this InputManager. More... | |
| unsigned int | gamepadMask_ = 0x00 |
|
A bitmask used for registering the gamepads that should be polled for inputs. 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 InputManager objects. More... | |
Description
InputManager providing access to various input states.
The `InputManager` acts as an intermediary between the application and the underlying systems that provide input. Raw events are processed by InputAdapters owned by this `InputManager`.
An `InputManager` allows querying `GamepadState` objects by calling `gamepadState()`. The method accepts an id that identifies the gamepad whose input state should be returned.
Definition at line 36 of file InputManager.ixx.
Public Constructors
InputManager()
| inline explicit |
Creates a new InputManager with the specified InputAdapter.
Ownership of the InputAdapter is transferred to this InputManager.
- Parameters
-
input The InputAdapter used with this InputManager.
Definition at line 69 of file InputManager.ixx.
Public Member Functions
gamepadState()
| inline nodiscard noexcept |
Returns a const reference to the `GamepadState` for the specified `gamepadId`.
This method queries the `InputAdapter` owned by this `InputManager` for the `GamepadState` identified by the specified `gamepadId`. If no `GamepadState` exists for the given id, this method returns a `GamepadState` object initialized to its default values. To test whether a gamepad is available, use `isConnected()`.
`GamepadState` objects are updated by calling `poll()`.
- Parameters
-
gamepadId The id of the gamepad for which the `GamepadState` is queried.
- Returns
A const reference to the `GamepadState` for the specified gamepad.
- See Also
- See Also
Definition at line 206 of file InputManager.ixx.
inputAdapter()
| inline nodiscard noexcept |
Retrieves the InputAdapter associated with this InputManager.
- Returns
A reference to the InputAdapter associated with this InputManager.
Definition at line 227 of file InputManager.ixx.
inputAdapter()
| inline nodiscard noexcept |
Retrieves the InputAdapter associated with this InputManager.
This non-const overload allows modification of InputAdapter settings, such as gamepad deadzone and axis inversion configuration.
- Returns
A reference to the InputAdapter associated with this InputManager.
Definition at line 239 of file InputManager.ixx.
isConnected()
| inline nodiscard noexcept |
Returns true if the specified gamepad is connected, otherwise false.
- Parameters
-
gamepadId The id of the gamepad to test.
- Returns
True if a gamepad was found for the specified `gamepadId`, otherwise false.
Definition at line 217 of file InputManager.ixx.
isKeyPressed()
| inline nodiscard noexcept |
Returns true if the specified key is currently pressed, otherwise false.
This method delegates to the underlying `InputAdapter`.
- See Also
- Parameters
-
key The key to check for the pressed state.
- Returns
True if the key is pressed; returns false if the observed window is not set.
Definition at line 131 of file InputManager.ixx.
Reference logger_.
isKeyReleased()
| inline nodiscard noexcept |
Returns true if the specified key is currently released, otherwise false.
This method delegates to the underlying `InputAdapter`.
- See Also
- Parameters
-
key The key to check for the released state.
- Returns
True if the key is released; returns false if the observed window is not set.
Definition at line 151 of file InputManager.ixx.
Reference logger_.
observe()
| inline noexcept |
Sets the window this InputManager will observe for input.
All subsequent input queries will be performed on this window.
- Parameters
-
win A const reference to the window to observe.
Definition at line 80 of file InputManager.ixx.
observedWindow()
| inline nodiscard |
Returns a non-owning pointer to the currently observed window.
Returns `nullptr` if no window is currently observed.
- Returns
A non-owning pointer to the currently observed window, or `nullptr`.
Definition at line 92 of file InputManager.ixx.
poll()
| inline noexcept |
Polls events from the currently observed window and registered gamepads.
Calls the `pollEvents()` method of the observed window to process any pending window-related input events. This method should be called regularly, preferably once per frame. For updating `GamepadState` objects with their current input states, call `registerGamepads()` with a bitmask representing the gamepads to poll.
- See Also
Window::pollEvents
- Parameters
-
deltaTime The time elapsed since the last frame, in seconds.
Definition at line 110 of file InputManager.ixx.
Reference logger_.
registerGamepads()
| inline noexcept |
Explicitly tells this InputManager which gamepads to poll for input states in `poll()`.
- Parameters
-
gamepadMask A bitmask representing the gamepad ids that should be observed by this InputManager (e.g. `registerGamepads(Gamepad::ONE | Gamepad::THREE)`).
- Returns
The bitmask this InputManager uses for polling gamepad states. If an invalid mask is provided, the method returns a mask that represents no gamepads.
Definition at line 171 of file InputManager.ixx.
Reference logger_.
Private Member Attributes
gamepadMask_
|
A bitmask used for registering the gamepads that should be polled for inputs.
Definition at line 52 of file InputManager.ixx.
input_
|
The InputAdapter owned by this InputManager.
Definition at line 47 of file InputManager.ixx.
observedWin_
|
A pointer to the currently observed window, which might be nullptr.
Definition at line 42 of file InputManager.ixx.
Protected Static Attributes
logger_
| protected static |
Shared logger instance for all InputManager objects.
Definition at line 58 of file InputManager.ixx.
Referenced by isKeyPressed, isKeyReleased, poll and registerGamepads.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.