Aegis2D
Modular C++26 2D game engine for networked games
Loading...
Searching...
No Matches
latched_action.hpp
Go to the documentation of this file.
1
3#pragma once
4
7#include <aegis2d/platform/export.hpp>
10
11#include <string_view>
12
13namespace aegis2d::platform {
14
28class AEGIS2D_PLATFORM_EXPORT LatchedAction {
29public:
33 explicit LatchedAction(ActionId action, bool enabled = false) noexcept;
34
37 [[nodiscard]] ActionId action() const noexcept;
38
41 void set_enabled(bool enabled) noexcept;
42
45 [[nodiscard]] bool enabled() const noexcept;
46
55 bool update(const ActionMap& actions, const Keyboard& keyboard);
56
65 bool update(const ActionMap& actions, const Keyboard& keyboard, const Gamepad& gamepad);
66
69 [[nodiscard]] bool held() const noexcept;
70
72 void release() noexcept;
73
77 void save(core::Config& settings, std::string_view path) const;
78
84 void load(const core::Config& settings, std::string_view path);
85
86private:
87 ActionId action_;
88 bool enabled_;
89 bool held_ = false;
90};
91
92} // namespace aegis2d::platform
Named actions (move, fire...) bound to keys and gamepad buttons, so gameplay never reads raw input.
Actions of the game and the keys and gamepad buttons that trigger them.
Definition actions.hpp:38
Buttons held down, and those pressed or released since the start of the frame, with the position of t...
Definition gamepad.hpp:139
Keys held down, and those pressed or released since the start of the frame.
Definition keyboard.hpp:150
An action the player can hold without holding a key, such as fire.
Definition latched_action.hpp:28
LatchedAction(ActionId action, bool enabled=false) noexcept
Follows an action of an ActionMap.
JSON configuration with dotted-path lookups, which can be changed and saved.
Gamepad buttons, sticks and triggers, with no SDL type.
Keyboard keys, their names, and the state of the keyboard during a frame.
Window and input on top of SDL3, independent of the graphics API (client only).
Definition actions.hpp:19
std::size_t ActionId
Identifier of an action in its ActionMap, given by ActionMap::add().
Definition actions.hpp:22
Definition endpoint.hpp:85