Toast Engine
Loading...
Searching...
No Matches
bind.hpp
Go to the documentation of this file.
1
8
9#pragma once
10
11#include "keycodes.hpp"
12#include "modifier.hpp"
13#include "trigger.hpp"
14#include "value.hpp"
15
16#include <toml++/toml.hpp>
17
18namespace input {
19
23class TOAST_API Bind {
24public:
25 Bind() = default;
26
30 struct Result {
31 bool active = false;
32 Value value;
33 SignalList signals;
34 };
35
42 static auto fromToml(const toml::table& table, ValueType vt) -> Bind;
43
50 auto evaluate(const InputSample& sample, const EvalContext& ctx) -> Result;
51
53 [[nodiscard]]
54 auto keycode() const noexcept -> const KeyCode& {
55 return m_keycode;
56 }
57
59 [[nodiscard]]
60 auto keycodeString() const noexcept -> std::string_view {
61 return m_keycode_string;
62 }
63
64private:
65 std::string m_keycode_string;
66 KeyCode m_keycode;
67 std::vector<std::shared_ptr<ITrigger>> m_triggers;
68 std::vector<std::shared_ptr<IModifier>> m_modifiers;
69};
70
71}
auto evaluate(const InputSample &sample, const EvalContext &ctx) -> Result
Evaluates every trigger and applies per-bind modifiers.
Definition bind.cpp:35
auto keycode() const noexcept -> const KeyCode &
Definition bind.hpp:54
static auto fromToml(const toml::table &table, ValueType vt) -> Bind
Builds a bind from a [[bind]] TOML table.
Definition bind.cpp:7
auto keycodeString() const noexcept -> std::string_view
Definition bind.hpp:60
Triggers turn a raw input sample into an action value and discrete events.
Modifiers post-process a value in place before it reaches the action.
Outcome of evaluating a bind for one frame.
Definition bind.hpp:30
Per-frame context passed down to triggers and modifiers during evaluation.
Definition value.hpp:140
One frame of raw input for a single keycode.
Definition value.hpp:130
A parsed keycode resolved to a device, kind and numeric code.
Definition keycodes.hpp:63
Fixed-capacity buffer of discrete events fired in a single frame.
Definition value.hpp:90
A tagged value that may represent a bool, a float or a glm::vec2.
Definition value.hpp:31
Value type shared by triggers, modifiers and actionsg.
ValueType
Value domain of an action or an input sample.
Definition value.hpp:22