InputManager Class
InputManager providing access to various input states. More...
Declaration
Public Constructors Index
| InputManager (std::unique_ptr< helios::engine::input::InputAdapter > input) | |
|
Creates a new InputManager with the specified InputAdapter. More... | |
Public Member Functions Index
| void | poll (float deltaTime) noexcept |
|
Sets the window this InputManager will observe for input. More... | |
| bool | isKeyPressed (const helios::engine::input::types::Key &key) const noexcept |
|
Returns true if the specified key is currently pressed, otherwise false. More... | |
| bool | isKeyReleased (const helios::engine::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::engine::input::gamepad::GamepadState & | gamepadState (const helios::engine::input::types::Gamepad gamepadId) const noexcept |
|
Returns a const reference to the GamepadState for the specified gamepadId. More... | |
| bool | isConnected (helios::engine::input::types::Gamepad gamepadId) const noexcept |
|
Returns true if the specified gamepad is connected, otherwise false. More... | |
| const helios::engine::input::InputAdapter & | inputAdapter () const noexcept |
|
Retrieves the InputAdapter associated with this InputManager. More... | |
| helios::engine::input::InputAdapter & | inputAdapter () noexcept |
|
Retrieves the InputAdapter associated with this InputManager. More... | |
Private Member Attributes Index
| std::unique_ptr< helios::engine::input::InputAdapter > | input_ |
|
A pointer to the currently observed window, which might be nullptr. 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::engine::util::log::Logger & | logger_ = helios::engine::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 41 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 74 of file InputManager.ixx.
Public Member Functions
gamepadState()
| inline 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 213 of file InputManager.ixx.
Reference helios::registerComponents.
inputAdapter()
| inline noexcept |
Retrieves the InputAdapter associated with this InputManager.
- Returns
A reference to the InputAdapter associated with this InputManager.
Definition at line 234 of file InputManager.ixx.
inputAdapter()
| inline 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 246 of file InputManager.ixx.
isConnected()
| inline 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 224 of file InputManager.ixx.
Reference helios::registerComponents.
isKeyPressed()
| inline 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 136 of file InputManager.ixx.
isKeyReleased()
| inline 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 157 of file InputManager.ixx.
poll()
| 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.
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.
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 115 of file InputManager.ixx.
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 178 of file InputManager.ixx.
References logger_, helios::registerComponents and helios::engine::util::log::Logger::warn.
Private Member Attributes
gamepadMask_
|
A bitmask used for registering the gamepads that should be polled for inputs.
Definition at line 57 of file InputManager.ixx.
input_
|
A pointer to the currently observed window, which might be nullptr.
The InputAdapter owned by this InputManager.
Definition at line 52 of file InputManager.ixx.
Protected Static Attributes
logger_
| protected static |
Shared logger instance for all InputManager objects.
Definition at line 63 of file InputManager.ixx.
Referenced by registerGamepads.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.