libdonut 2.3.6
Application framework for cross-platform game development in C++20
Loading...
Searching...
No Matches
InputManager.hpp
Go to the documentation of this file.
1#ifndef DONUT_EVENTS_INPUT_MANAGER_HPP
2#define DONUT_EVENTS_INPUT_MANAGER_HPP
3
7#include <donut/math.hpp>
8
9#include <array> // std::array
10#include <bitset> // std::bitset
11#include <cstddef> // std::size_t
12#include <optional> // std::optional
13#include <type_traits> // std::is_same_v, std::is_enum_v, std::underlying_type_t
14#include <unordered_map> // std::unordered_map
15#include <vector> // std::vector
16
17namespace donut::events {
18
32 float mouseSensitivity = 0.00038397243543875251f;
33
41
49
59
69
79
89
97
106};
107
130public:
135 static constexpr std::size_t OUTPUT_COUNT = 64;
136
143 using Outputs = std::bitset<OUTPUT_COUNT>;
144
153
163 InputManager(const InputManagerOptions& options = {});
164
167
169 InputManager(const InputManager&) = delete;
170
173
176
179
194
207 void handleEvent(const Event& event);
208
222 void bind(Input input, Outputs outputs);
223
237 void addBinding(Input input, Outputs outputs);
238
250 void unbind(Input input);
251
261 void unbindAll() noexcept;
262
280 void press(Input input, i32 offset = 32767) noexcept;
281
299 void release(Input input, i32 offset = -32767) noexcept;
300
318 void move(Input input, i32 offset) noexcept;
319
335 void set(Input input, i32 value) noexcept;
336
349 void resetAllInputs() noexcept;
350
358 void setMouseSensitivity(float sensitivity) noexcept;
359
367 void setControllerLeftStickSensitivity(float sensitivity) noexcept;
368
376 void setControllerRightStickSensitivity(float sensitivity) noexcept;
377
385 void setControllerLeftStickDeadzone(float deadzone) noexcept;
386
394 void setControllerRightStickDeadzone(float deadzone) noexcept;
395
403 void setControllerLeftTriggerDeadzone(float deadzone) noexcept;
404
412 void setControllerRightTriggerDeadzone(float deadzone) noexcept;
413
421 void setTouchMotionSensitivity(float sensitivity) noexcept;
422
430 void setTouchPressureDeadzone(float deadzone) noexcept;
431
438 [[nodiscard]] bool hasAnyBindings() const noexcept;
439
451 [[nodiscard]] std::vector<Binding> getBindings() const;
452
463 [[nodiscard]] std::optional<Outputs> findBinding(Input input) const noexcept;
464
480 [[nodiscard]] std::optional<vec2> getMousePosition() const noexcept;
481
496 [[nodiscard]] bool mouseJustMoved() const noexcept;
497
513 [[nodiscard]] bool mouseWheelJustScrolledHorizontally() const noexcept;
514
530 [[nodiscard]] bool mouseWheelJustScrolledVertically() const noexcept;
531
537 [[nodiscard]] bool isControllerConnected() const noexcept;
538
556 [[nodiscard]] std::optional<vec2> getControllerLeftStickPosition() const noexcept;
557
575 [[nodiscard]] std::optional<vec2> getControllerRightStickPosition() const noexcept;
576
594 [[nodiscard]] std::optional<float> getControllerLeftTriggerPosition() const noexcept;
595
613 [[nodiscard]] std::optional<float> getControllerRightTriggerPosition() const noexcept;
614
631 [[nodiscard]] bool controllerLeftStickJustMoved() const noexcept;
632
649 [[nodiscard]] bool controllerRightStickJustMoved() const noexcept;
650
666 [[nodiscard]] bool controllerLeftTriggerJustMoved() const noexcept;
667
683 [[nodiscard]] bool controllerRightTriggerJustMoved() const noexcept;
684
703 [[nodiscard]] std::optional<vec2> getTouchPosition() const noexcept;
704
722 [[nodiscard]] std::optional<float> getTouchPressure() const noexcept;
723
740 [[nodiscard]] bool touchJustMoved() const noexcept;
741
758 [[nodiscard]] bool touchJustChangedPressure() const noexcept;
759
771 [[nodiscard]] Outputs getCurrentOutputs() const noexcept;
772
783 [[nodiscard]] Outputs getPreviousOutputs() const noexcept;
784
798 [[nodiscard]] Outputs getJustPressedOutputs() const noexcept;
799
813 [[nodiscard]] Outputs getJustReleasedOutputs() const noexcept;
814
831 [[nodiscard]] bool isPressed(std::size_t output) const noexcept;
832
850 [[nodiscard]] bool justPressed(std::size_t output) const noexcept;
851
869 [[nodiscard]] bool justReleased(std::size_t output) const noexcept;
870
892 [[nodiscard]] i32 getAbsoluteState(std::size_t output) const noexcept;
893
914 [[nodiscard]] i32 getRelativeState(std::size_t output) const noexcept;
915
934 [[nodiscard]] float getAbsoluteValue(std::size_t outputPositive) const noexcept;
935
954 [[nodiscard]] float getRelativeValue(std::size_t outputPositive) const noexcept;
955
977 [[nodiscard]] float getAbsoluteValue(std::size_t outputNegative, std::size_t outputPositive) const noexcept;
978
1000 [[nodiscard]] float getRelativeValue(std::size_t outputNegative, std::size_t outputPositive) const noexcept;
1001
1037 [[nodiscard]] vec2 getAbsoluteValue(std::size_t outputNegativeX, std::size_t outputPositiveX, std::size_t outputNegativeY, std::size_t outputPositiveY) const noexcept;
1038
1066 [[nodiscard]] vec2 getRelativeValue(std::size_t outputNegativeX, std::size_t outputPositiveX, std::size_t outputNegativeY, std::size_t outputPositiveY) const noexcept;
1067
1110 [[nodiscard]] vec3 getAbsoluteValue(std::size_t outputNegativeX, std::size_t outputPositiveX, std::size_t outputNegativeY, std::size_t outputPositiveY,
1111 std::size_t outputNegativeZ, std::size_t outputPositiveZ) const noexcept;
1112
1146 [[nodiscard]] vec3 getRelativeValue(std::size_t outputNegativeX, std::size_t outputPositiveX, std::size_t outputNegativeY, std::size_t outputPositiveY,
1147 std::size_t outputNegativeZ, std::size_t outputPositiveZ) const noexcept;
1148
1166 [[nodiscard]] bool isPressed(Input input) const noexcept;
1167
1187 [[nodiscard]] bool justPressed(Input input) const noexcept;
1188
1208 [[nodiscard]] bool justReleased(Input input) const noexcept;
1209
1217 template <typename... Actions>
1218 void bind(Input input, Actions... actions) requires((std::is_enum_v<Actions> && !std::is_same_v<Actions, Input>) && ...) {
1219 Outputs outputs{};
1220 (outputs.set(static_cast<std::size_t>(static_cast<std::underlying_type_t<Actions>>(actions))), ...);
1221 bind(input, outputs);
1222 }
1223
1231 template <typename... Actions>
1232 void addBinding(Input input, Actions... actions) requires((std::is_enum_v<Actions> && !std::is_same_v<Actions, Input>) && ...) {
1233 Outputs outputs{};
1234 (outputs.set(static_cast<std::size_t>(static_cast<std::underlying_type_t<Actions>>(actions))), ...);
1235 addBinding(input, outputs);
1236 }
1237
1245 template <typename Action>
1246 [[nodiscard]] bool isPressed(Action action) const noexcept requires(std::is_enum_v<Action> && !std::is_same_v<Action, Input>) {
1247 return isPressed(static_cast<std::size_t>(static_cast<std::underlying_type_t<Action>>(action)));
1248 }
1249
1257 template <typename Action>
1258 [[nodiscard]] bool justPressed(Action action) const noexcept requires(std::is_enum_v<Action> && !std::is_same_v<Action, Input>) {
1259 return justPressed(static_cast<std::size_t>(static_cast<std::underlying_type_t<Action>>(action)));
1260 }
1261
1269 template <typename Action>
1270 [[nodiscard]] bool justReleased(Action action) const noexcept requires(std::is_enum_v<Action> && !std::is_same_v<Action, Input>) {
1271 return justReleased(static_cast<std::size_t>(static_cast<std::underlying_type_t<Action>>(action)));
1272 }
1273
1281 template <typename Action>
1282 [[nodiscard]] i32 getAbsoluteState(Action action) const noexcept requires(std::is_enum_v<Action> && !std::is_same_v<Action, Input>) {
1283 return getAbsoluteState(static_cast<std::size_t>(static_cast<std::underlying_type_t<Action>>(action)));
1284 }
1285
1293 template <typename Action>
1294 [[nodiscard]] i32 getRelativeState(Action action) const noexcept requires(std::is_enum_v<Action> && !std::is_same_v<Action, Input>) {
1295 return getRelativeState(static_cast<std::size_t>(static_cast<std::underlying_type_t<Action>>(action)));
1296 }
1297
1305 template <typename Action>
1306 [[nodiscard]] float getAbsoluteValue(Action actionPositive) const noexcept requires(std::is_enum_v<Action> && !std::is_same_v<Action, Input>) {
1307 return getAbsoluteValue(static_cast<std::size_t>(static_cast<std::underlying_type_t<Action>>(actionPositive)));
1308 }
1309
1317 template <typename Action>
1318 [[nodiscard]] float getRelativeValue(Action actionPositive) const noexcept requires(std::is_enum_v<Action> && !std::is_same_v<Action, Input>) {
1319 return getRelativeValue(static_cast<std::size_t>(static_cast<std::underlying_type_t<Action>>(actionPositive)));
1320 }
1321
1329 template <typename Action>
1330 [[nodiscard]] float getAbsoluteValue(Action actionNegative, Action actionPositive) const noexcept requires(std::is_enum_v<Action> && !std::is_same_v<Action, Input>) {
1331 return getAbsoluteValue(static_cast<std::size_t>(static_cast<std::underlying_type_t<Action>>(actionNegative)),
1332 static_cast<std::size_t>(static_cast<std::underlying_type_t<Action>>(actionPositive)));
1333 }
1334
1342 template <typename Action>
1343 [[nodiscard]] float getRelativeValue(Action actionNegative, Action actionPositive) const noexcept requires(std::is_enum_v<Action> && !std::is_same_v<Action, Input>) {
1344 return getRelativeValue(static_cast<std::size_t>(static_cast<std::underlying_type_t<Action>>(actionNegative)),
1345 static_cast<std::size_t>(static_cast<std::underlying_type_t<Action>>(actionPositive)));
1346 }
1347
1357 template <typename Action>
1358 [[nodiscard]] vec2 getAbsoluteValue(Action actionNegativeX, Action actionPositiveX, Action actionNegativeY, Action actionPositiveY) const noexcept
1359 requires(std::is_enum_v<Action> && !std::is_same_v<Action, Input>) {
1360 return getAbsoluteValue(static_cast<std::size_t>(static_cast<std::underlying_type_t<Action>>(actionNegativeX)),
1361 static_cast<std::size_t>(static_cast<std::underlying_type_t<Action>>(actionPositiveX)),
1362 static_cast<std::size_t>(static_cast<std::underlying_type_t<Action>>(actionNegativeY)),
1363 static_cast<std::size_t>(static_cast<std::underlying_type_t<Action>>(actionPositiveY)));
1364 }
1365
1375 template <typename Action>
1376 [[nodiscard]] vec2 getRelativeValue(Action actionNegativeX, Action actionPositiveX, Action actionNegativeY, Action actionPositiveY) const noexcept
1377 requires(std::is_enum_v<Action> && !std::is_same_v<Action, Input>) {
1378 return getRelativeValue(static_cast<std::size_t>(static_cast<std::underlying_type_t<Action>>(actionNegativeX)),
1379 static_cast<std::size_t>(static_cast<std::underlying_type_t<Action>>(actionPositiveX)),
1380 static_cast<std::size_t>(static_cast<std::underlying_type_t<Action>>(actionNegativeY)),
1381 static_cast<std::size_t>(static_cast<std::underlying_type_t<Action>>(actionPositiveY)));
1382 }
1383
1393 template <typename Action>
1394 [[nodiscard]] vec3 getAbsoluteValue(Action actionNegativeX, Action actionPositiveX, Action actionNegativeY, Action actionPositiveY, Action actionNegativeZ,
1395 Action actionPositiveZ) const noexcept requires(std::is_enum_v<Action> && !std::is_same_v<Action, Input>) {
1396 return getAbsoluteValue(static_cast<std::size_t>(static_cast<std::underlying_type_t<Action>>(actionNegativeX)),
1397 static_cast<std::size_t>(static_cast<std::underlying_type_t<Action>>(actionPositiveX)),
1398 static_cast<std::size_t>(static_cast<std::underlying_type_t<Action>>(actionNegativeY)),
1399 static_cast<std::size_t>(static_cast<std::underlying_type_t<Action>>(actionPositiveY)),
1400 static_cast<std::size_t>(static_cast<std::underlying_type_t<Action>>(actionNegativeZ)),
1401 static_cast<std::size_t>(static_cast<std::underlying_type_t<Action>>(actionPositiveZ)));
1402 }
1403
1413 template <typename Action>
1414 [[nodiscard]] vec3 getRelativeValue(Action actionNegativeX, Action actionPositiveX, Action actionNegativeY, Action actionPositiveY, Action actionNegativeZ,
1415 Action actionPositiveZ) const noexcept requires(std::is_enum_v<Action> && !std::is_same_v<Action, Input>) {
1416 return getRelativeValue(static_cast<std::size_t>(static_cast<std::underlying_type_t<Action>>(actionNegativeX)),
1417 static_cast<std::size_t>(static_cast<std::underlying_type_t<Action>>(actionPositiveX)),
1418 static_cast<std::size_t>(static_cast<std::underlying_type_t<Action>>(actionNegativeY)),
1419 static_cast<std::size_t>(static_cast<std::underlying_type_t<Action>>(actionPositiveY)),
1420 static_cast<std::size_t>(static_cast<std::underlying_type_t<Action>>(actionNegativeZ)),
1421 static_cast<std::size_t>(static_cast<std::underlying_type_t<Action>>(actionPositiveZ)));
1422 }
1423
1424private:
1425 struct ControllerDeleter {
1426 void operator()(void* handle) const noexcept;
1427 };
1428
1429 using Controller = UniqueHandle<void*, ControllerDeleter>;
1430
1431 void setMousePosition(vec2 position, vec2 relativeMotion) noexcept;
1432 void scrollMouseWheelHorizontally(float offset) noexcept;
1433 void scrollMouseWheelVertically(float offset) noexcept;
1434
1435 void setControllerLeftStickPosition(vec2 position) noexcept;
1436 void setControllerRightStickPosition(vec2 position) noexcept;
1437 void setControllerLeftTriggerPosition(float position) noexcept;
1438 void setControllerRightTriggerPosition(float position) noexcept;
1439
1440 void setTouchPosition(vec2 position) noexcept;
1441 void setTouchPressure(float pressure) noexcept;
1442
1443 InputManagerOptions options;
1444 std::unordered_map<Input, Outputs> bindings{};
1445 std::optional<vec2> mousePosition{};
1446 Controller controller{};
1447 std::optional<vec2> controllerLeftStickPosition{};
1448 std::optional<vec2> controllerRightStickPosition{};
1449 std::optional<float> controllerLeftTriggerPosition{};
1450 std::optional<float> controllerRightTriggerPosition{};
1451 std::optional<vec2> touchPosition{};
1452 std::optional<float> touchPressure{};
1453 Outputs currentPersistentOutputs{};
1454 Outputs previousPersistentOutputs{};
1455 Outputs transientOutputPresses{};
1456 Outputs transientOutputReleases{};
1457 std::array<i32, OUTPUT_COUNT> outputAbsoluteStates{};
1458 std::array<i32, OUTPUT_COUNT> outputRelativeStates{};
1459 std::array<u8, OUTPUT_COUNT> outputPersistentPresses{};
1460 std::bitset<INPUT_COUNT> currentPersistentInputs{};
1461 std::bitset<INPUT_COUNT> previousPersistentInputs{};
1462 std::bitset<INPUT_COUNT> transientInputPresses{};
1463 std::bitset<INPUT_COUNT> transientInputReleases{};
1464 bool mouseTransientMotion = false;
1465 bool mouseWheelHorizontalTransientMotion = false;
1466 bool mouseWheelVerticalTransientMotion = false;
1467 bool controllerLeftStickTransientMotion = false;
1468 bool controllerRightStickTransientMotion = false;
1469 bool controllerLeftTriggerTransientMotion = false;
1470 bool controllerRightTriggerTransientMotion = false;
1471 bool touchTransientMotion = false;
1472 bool touchTransientPressure = false;
1473};
1474
1475} // namespace donut::events
1476
1477#endif
Generic nullable RAII resource handle with exclusive ownership of a resource that is automatically de...
Definition UniqueHandle.hpp:21
Persistent system for mapping physical Input controls to abstract output numbers and processing input...
Definition InputManager.hpp:129
Outputs getPreviousOutputs() const noexcept
Get all output numbers for which at least one bound input was in pressed state on the previous frame.
void handleEvent(const Event &event)
Handle an event from an EventPump, which may cause updates to the internal input/output state of the ...
InputManager & operator=(InputManager &&)=delete
Moving an input manager is not allowed, since it manages global state.
bool hasAnyBindings() const noexcept
Check if this input manager has any active bindings for any input.
void addBinding(Input input, Outputs outputs)
Bind a physical input to a set of abstract output numbers, adding to the previous binding if one alre...
std::bitset< OUTPUT_COUNT > Outputs
Set of up to OUTPUT_COUNT unique abstract output numbers.
Definition InputManager.hpp:143
bool isPressed(std::size_t output) const noexcept
Check if a specific output has any bound inputs which are currently in a pressed state.
Outputs getJustReleasedOutputs() const noexcept
Get all output numbers for which a release was triggered on the current frame.
static constexpr std::size_t OUTPUT_COUNT
The maximum supported number of separate outputs that the input manager can keep track of.
Definition InputManager.hpp:135
InputManager & operator=(const InputManager &)=delete
Copying an input manager is not allowed, since it manages global state.
bool isControllerConnected() const noexcept
Check if a controller is currently connected as an active input device.
void setControllerLeftStickDeadzone(float deadzone) noexcept
Set the controller left analog stick deadzone fraction.
std::optional< vec2 > getControllerRightStickPosition() const noexcept
Get the latest known position of the right analog stick of the connected controller,...
bool mouseWheelJustScrolledVertically() const noexcept
Check if the mouse wheel was just scrolled vertically on the current frame.
std::vector< Binding > getBindings() const
Get all active bindings of this input manager.
float getRelativeValue(Action actionNegative, Action actionPositive) const noexcept
Like getRelativeValue(std::size_t, std::size_t) const, but accepts "actions" of any enum type,...
Definition InputManager.hpp:1343
bool mouseJustMoved() const noexcept
Check if the mouse just moved on the current frame.
void prepareForEvents()
Update the internal state to prepare for the input events of the current frame to be handled.
vec3 getRelativeValue(Action actionNegativeX, Action actionPositiveX, Action actionNegativeY, Action actionPositiveY, Action actionNegativeZ, Action actionPositiveZ) const noexcept
Like getRelativeValue(std::size_t, std::size_t, std::size_t, std::size_t, std::size_t,...
Definition InputManager.hpp:1414
void setControllerRightTriggerDeadzone(float deadzone) noexcept
Set the controller right trigger deadzone fraction.
void setControllerLeftStickSensitivity(float sensitivity) noexcept
Set the controller left analog stick sensitivity coefficient.
void resetAllInputs() noexcept
Reset the internal state of all inputs and outputs for both the current and previous frame.
bool justReleased(std::size_t output) const noexcept
Check if a specific output had a release triggered on the current frame.
void setControllerLeftTriggerDeadzone(float deadzone) noexcept
Set the controller left trigger deadzone fraction.
i32 getAbsoluteState(Action action) const noexcept
Like getAbsoluteState(std::size_t) const, but accepts an "action" of any enum type,...
Definition InputManager.hpp:1282
Outputs getJustPressedOutputs() const noexcept
Get all output numbers for which a press was triggered on the current frame.
std::optional< vec2 > getControllerLeftStickPosition() const noexcept
Get the latest known position of the left analog stick of the connected controller,...
std::optional< vec2 > getTouchPosition() const noexcept
Get the latest known touch finger position processed by the input manager.
bool justPressed(Action action) const noexcept
Like justPressed(std::size_t) const, but accepts an "action" of any enum type, which is interpreted a...
Definition InputManager.hpp:1258
void setControllerRightStickDeadzone(float deadzone) noexcept
Set the controller right analog stick deadzone fraction.
float getAbsoluteValue(Action actionPositive) const noexcept
Like getAbsoluteValue(std::size_t) const, but accepts an "action" of any enum type,...
Definition InputManager.hpp:1306
i32 getRelativeState(std::size_t output) const noexcept
Get the current raw total relative value of a specific output, which consists of the accumulated cont...
bool isPressed(Action action) const noexcept
Like isPressed(std::size_t) const, but accepts an "action" of any enum type, which is interpreted as ...
Definition InputManager.hpp:1246
bool controllerLeftStickJustMoved() const noexcept
Check if the controller left analog stick just moved on the current frame.
bool mouseWheelJustScrolledHorizontally() const noexcept
Check if the mouse wheel was just scrolled horizontally on the current frame.
InputManager(InputManager &&)=delete
Moving an input manager is not allowed, since it manages global state.
void bind(Input input, Outputs outputs)
Bind a physical input to a set of abstract output numbers, overriding the previous binding if one alr...
void setMouseSensitivity(float sensitivity) noexcept
Set the mouse sensitivity coefficient.
vec2 getAbsoluteValue(Action actionNegativeX, Action actionPositiveX, Action actionNegativeY, Action actionPositiveY) const noexcept
Like getAbsoluteValue(std::size_t, std::size_t, std::size_t, std::size_t) const, but accepts "actions...
Definition InputManager.hpp:1358
i32 getAbsoluteState(std::size_t output) const noexcept
Get the current raw total absolute value of a specific output, which consists of the accumulated cont...
void unbind(Input input)
Remove all outputs from a specific input.
bool touchJustMoved() const noexcept
Check if the touch finger just moved on the current frame.
void move(Input input, i32 offset) noexcept
Trigger a transient press and release of an input that only lasts for the current frame and apply a r...
float getRelativeValue(std::size_t outputPositive) const noexcept
Get the current scaled relative value of a specific output in a single direction, which consists of t...
Outputs getCurrentOutputs() const noexcept
Get all output numbers for which at least one bound input is currently in a pressed state.
bool controllerRightStickJustMoved() const noexcept
Check if the controller right analog stick just moved on the current frame.
bool controllerRightTriggerJustMoved() const noexcept
Check if the controller right trigger just moved on the current frame.
vec2 getRelativeValue(Action actionNegativeX, Action actionPositiveX, Action actionNegativeY, Action actionPositiveY) const noexcept
Like getRelativeValue(std::size_t, std::size_t, std::size_t, std::size_t) const, but accepts "actions...
Definition InputManager.hpp:1376
std::optional< float > getControllerLeftTriggerPosition() const noexcept
Get the latest known position of the left trigger of the connected controller, if there is one.
bool justPressed(std::size_t output) const noexcept
Check if a specific output had a press triggered on the current frame.
void addBinding(Input input, Actions... actions)
Like addBinding(Input, Outputs), but accepts a pack of "actions" of any enum type,...
Definition InputManager.hpp:1232
InputManager(const InputManager &)=delete
Copying an input manager is not allowed, since it manages global state.
void press(Input input, i32 offset=32767) noexcept
Add to an input and apply an offset to all of its bound outputs.
float getAbsoluteValue(std::size_t outputPositive) const noexcept
Get the current scaled absolute value of a specific output in a single direction, which consists of t...
void setTouchPressureDeadzone(float deadzone) noexcept
Set the touch finger pressure deadzone fraction.
std::optional< Outputs > findBinding(Input input) const noexcept
Get the set of outputs that a specific input is currently bound to.
void setControllerRightStickSensitivity(float sensitivity) noexcept
Set the controller right analog stick sensitivity coefficient.
std::optional< float > getControllerRightTriggerPosition() const noexcept
Get the latest known position of the right trigger of the connected controller, if there is one.
bool touchJustChangedPressure() const noexcept
Check if the touch finger just changed pressure on the current frame.
vec3 getAbsoluteValue(Action actionNegativeX, Action actionPositiveX, Action actionNegativeY, Action actionPositiveY, Action actionNegativeZ, Action actionPositiveZ) const noexcept
Like getAbsoluteValue(std::size_t, std::size_t, std::size_t, std::size_t, std::size_t,...
Definition InputManager.hpp:1394
std::optional< float > getTouchPressure() const noexcept
Get the latest known touch finger pressure processed by the input manager.
std::optional< vec2 > getMousePosition() const noexcept
Get the latest known mouse position processed by the input manager.
i32 getRelativeState(Action action) const noexcept
Like getRelativeState(std::size_t) const, but accepts an "action" of any enum type,...
Definition InputManager.hpp:1294
InputManager(const InputManagerOptions &options={})
Construct an input manager.
float getAbsoluteValue(Action actionNegative, Action actionPositive) const noexcept
Like getAbsoluteValue(std::size_t, std::size_t) const, but accepts "actions" of any enum type,...
Definition InputManager.hpp:1330
void release(Input input, i32 offset=-32767) noexcept
Subtract from an input and apply an offset to all of its bound outputs.
void unbindAll() noexcept
Remove all bindings from all inputs.
void setTouchMotionSensitivity(float sensitivity) noexcept
Set the touch finger motion sensitivity coefficient.
void set(Input input, i32 value) noexcept
Set the absolute value of all outputs bound to a specific input, without affecting the relative value...
float getRelativeValue(Action actionPositive) const noexcept
Like getRelativeValue(std::size_t) const, but accepts an "action" of any enum type,...
Definition InputManager.hpp:1318
bool justReleased(Action action) const noexcept
Like justReleased(std::size_t) const, but accepts an "action" of any enum type, which is interpreted ...
Definition InputManager.hpp:1270
bool controllerLeftTriggerJustMoved() const noexcept
Check if the controller left trigger just moved on the current frame.
Definition Error.hpp:7
Input
Unique identifier for a specific control on a physical input device, such as a certain keyboard key,...
Definition Input.hpp:323
Data structure containing information about an event.
Definition Event.hpp:339
Configuration options for an InputManager.
Definition InputManager.hpp:22
float controllerLeftTriggerDeadzone
Controller left trigger deadzone fraction.
Definition InputManager.hpp:78
float controllerLeftStickSensitivity
Controller left analog stick sensitivity coefficient.
Definition InputManager.hpp:40
float controllerRightTriggerDeadzone
Controller right trigger deadzone fraction.
Definition InputManager.hpp:88
float controllerLeftStickDeadzone
Controller left analog stick deadzone fraction.
Definition InputManager.hpp:58
float touchMotionSensitivity
Touch finger motion sensitivity coefficient.
Definition InputManager.hpp:96
float touchPressureDeadzone
Touch finger pressure deadzone fraction.
Definition InputManager.hpp:105
float controllerRightStickDeadzone
Controller right analog stick deadzone fraction.
Definition InputManager.hpp:68
float mouseSensitivity
Mouse sensitivity coefficient.
Definition InputManager.hpp:32
float controllerRightStickSensitivity
Controller right analog stick sensitivity coefficient.
Definition InputManager.hpp:48
A single configured binding from a physical input to a set of abstract output numbers.
Definition InputManager.hpp:149
Input input
Definition InputManager.hpp:150
Outputs outputs
Definition InputManager.hpp:151