Skip to main content

InputManager.ixx File

InputManager providing access to various input states. More...

Included Headers

#include <memory> #include <stdexcept> #include <cassert> #include <cmath> #include <helios.engine.util.log.Logger> #include <helios.engine.util.log.LogManager> #include <helios.engine.input.types.Key> #include <helios.engine.input.InputAdapter> #include <helios.engine.input.gamepad.GamepadState> #include <helios.engine.input.types.Gamepad>

Namespaces Index

namespacehelios
namespacewindow
namespaceengine
namespaceinput

Classes Index

classInputManager

InputManager providing access to various input states. More...

Macro Definitions Index

#defineHELIOS_LOG_SCOPE   "helios::engine::input::InputManager"

Description

InputManager providing access to various input states.

Macro Definitions

HELIOS_LOG_SCOPE

#define HELIOS_LOG_SCOPE   "helios::engine::input::InputManager"

Definition at line 25 of file InputManager.ixx.

25#define HELIOS_LOG_SCOPE "helios::engine::input::InputManager"

File Listing

The file content with the documentation metadata removed is:

1
5module;
6
7#include <memory>
8#include <stdexcept>
9#include <cassert>
10#include <cmath>
11
12export module helios.engine.input.InputManager;
13
14import helios.engine.input.types.Gamepad;
15import helios.engine.input.gamepad.GamepadState;
16import helios.engine.input.InputAdapter;
17import helios.engine.input.types.Key;
18import helios.engine.util.log.Logger;
19import helios.engine.util.log.LogManager;
20
21namespace helios::window {
22 class Window;
23}
24
25#define HELIOS_LOG_SCOPE "helios::engine::input::InputManager"
26export namespace helios::engine::input {
27
42
43 private:
47 //const helios::window::Window observedWin_ = nullptr;
48
52 std::unique_ptr<helios::engine::input::InputAdapter> input_;
53
57 unsigned int gamepadMask_ = 0x00;
58
59 protected:
64
65
66 public:
74 explicit InputManager(std::unique_ptr<helios::engine::input::InputAdapter> input)
75 : input_(std::move(input)) {}
76
77
85 // void observe(const helios::window::Window win) noexcept {
86// observedWin_ = &win;
87 // }
88
89
97 // [[nodiscard]] const helios::window::Window observedWindow() const {
98 // return observedWin_;
99 // }
100
101
115 void poll(float deltaTime) noexcept {
116 // if (observedWin_ != nullptr) {
117 // observedWin_->pollEvents();
118 //} else {
119 // logger_.warn("No window to observe.");
120 //}
121 input_->updateGamepadState(gamepadMask_);
122 }
123
124
136 [[nodiscard]] bool isKeyPressed(const helios::engine::input::types::Key& key) const noexcept {
137 /* if (observedWin_ == nullptr) {
138 logger_.warn("No window to observe.");
139 return false;
140 }*/
141
142 //return input_->isKeyPressed(key, observedWin_);
143 return false;
144 }
145
157 [[nodiscard]] bool isKeyReleased(const helios::engine::input::types::Key& key) const noexcept {
158 /* if (observedWin_ == nullptr) {
159 logger_.warn("No window to observe.");
160 return false;
161 }
162*/
163 return false;
164 //return input_->isKeyReleased(key, *observedWin_);
165 }
166
167
178 unsigned int registerGamepads(unsigned int mask) noexcept {
179 const unsigned int maxMask = static_cast<int>(std::pow(
180 helios::engine::input::types::Gamepad::size_,
181 2.0f
182 ) - 1);
183 assert(mask <= maxMask && "mask out of bounds");
184 if (mask > maxMask) {
185 logger_.warn("Gamepad mask out of bounds. Clamping to maximum valid value.");
186 mask = maxMask;
187 }
188
189
190 gamepadMask_ = mask;
191
192 return gamepadMask_;
193 }
194
195
214 return input_->gamepadState(gamepadId);
215 }
216
225 return input_->isConnected(gamepadId);
226 }
227
228
235 return *input_;
236 }
237
247 return *input_;
248 }
249
250 };
251
252
253
254} // namespace helios::engine::input

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.