Toast Engine
Toggle main menu visibility
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
18
namespace
input {
19
23
class
TOAST_API Bind {
24
public
:
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
64
private
:
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
}
input::Bind::evaluate
auto evaluate(const InputSample &sample, const EvalContext &ctx) -> Result
Evaluates every trigger and applies per-bind modifiers.
Definition
bind.cpp:35
input::Bind::keycode
auto keycode() const noexcept -> const KeyCode &
Definition
bind.hpp:54
input::Bind::fromToml
static auto fromToml(const toml::table &table, ValueType vt) -> Bind
Builds a bind from a [[bind]] TOML table.
Definition
bind.cpp:7
input::Bind::keycodeString
auto keycodeString() const noexcept -> std::string_view
Definition
bind.hpp:60
trigger.hpp
Triggers turn a raw input sample into an action value and discrete events.
keycodes.hpp
modifier.hpp
Modifiers post-process a value in place before it reaches the action.
input::Bind::Result
Outcome of evaluating a bind for one frame.
Definition
bind.hpp:30
input::EvalContext
Per-frame context passed down to triggers and modifiers during evaluation.
Definition
value.hpp:140
input::InputSample
One frame of raw input for a single keycode.
Definition
value.hpp:130
input::KeyCode
A parsed keycode resolved to a device, kind and numeric code.
Definition
keycodes.hpp:63
input::SignalList
Fixed-capacity buffer of discrete events fired in a single frame.
Definition
value.hpp:90
input::Value
A tagged value that may represent a bool, a float or a glm::vec2.
Definition
value.hpp:31
value.hpp
Value type shared by triggers, modifiers and actionsg.
input::ValueType
ValueType
Value domain of an action or an input sample.
Definition
value.hpp:22
engine
src
toast
input
bind.hpp
Generated by
1.17.0