Aegis2D
Modular C++26 2D game engine for networked games
Loading...
Searching...
No Matches
controls.hpp
Go to the documentation of this file.
1
3#pragma once
4
6#include <aegis2d/platform/export.hpp>
8
9#include <functional>
10#include <map>
11#include <string>
12#include <string_view>
13#include <vector>
14
15namespace aegis2d::platform {
16
21 std::string action;
23 std::string keys;
24};
25
27using ActionLabels = std::map<std::string, std::string, std::less<>>;
28
33[[nodiscard]] AEGIS2D_PLATFORM_EXPORT std::string action_label(std::string_view name);
34
41[[nodiscard]] AEGIS2D_PLATFORM_EXPORT std::string keys_label(const ActionMap& actions,
42 ActionId action);
43
51[[nodiscard]] AEGIS2D_PLATFORM_EXPORT std::string
52buttons_label(const ActionMap& actions, ActionId action, GamepadStyle style);
53
60[[nodiscard]] AEGIS2D_PLATFORM_EXPORT std::vector<ControlLine>
61control_lines(const ActionMap& actions, const ActionLabels& labels = {});
62
69[[nodiscard]] AEGIS2D_PLATFORM_EXPORT std::vector<ControlLine>
70control_lines(const ActionMap& actions, GamepadStyle style, const ActionLabels& labels = {});
71
72} // 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
Gamepad buttons, sticks and triggers, with no SDL type.
Window and input on top of SDL3, independent of the graphics API (client only).
Definition actions.hpp:19
std::string keys_label(const ActionMap &actions, ActionId action)
The keys of an action as shown to the player.
std::string_view name() noexcept
Name of the module, used to check that it is linked.
std::string action_label(std::string_view name)
Default label of an action name.
std::vector< ControlLine > control_lines(const ActionMap &actions, const ActionLabels &labels={})
Every action with the keys that trigger it now, in the order they were declared.
std::string buttons_label(const ActionMap &actions, ActionId action, GamepadStyle style)
The gamepad buttons of an action as printed on the player's pad.
std::map< std::string, std::string, std::less<> > ActionLabels
Display labels of actions, by action name: {"up", "Move up"}.
Definition controls.hpp:27
std::size_t ActionId
Identifier of an action in its ActionMap, given by ActionMap::add().
Definition actions.hpp:22
GamepadStyle
Family of a gamepad, which sets the labels printed on its buttons.
Definition gamepad.hpp:101
One line of a controls reminder: an action and the keys (or gamepad buttons) that trigger it now.
Definition controls.hpp:19
std::string keys
Its current keys, such as "Space / Enter", or buttons, such as "A / RT".
Definition controls.hpp:23
std::string action
What the action does, such as "Fire".
Definition controls.hpp:21