19 explicit constexpr Chord(
Entry const& match) : m_match(match) {}
21 [[nodiscard]]
constexpr auto is_engaged(
Entry const& entry)
const ->
bool {
return entry == m_match; }
31 explicit constexpr KeyChord(
int const key,
int const action = GLFW_PRESS,
int const mods = 0)
32 :
Chord(
Entry{.actor = key, .action = action, .mods = mods}) {}
43 explicit constexpr MouseButtonChord(
int const button,
int const action = GLFW_PRESS,
int const mods = 0)
44 :
Chord(
Entry{.actor = button, .action = action, .mods = mods}) {}
55 explicit constexpr Trigger(
int const actor) : m_actor(actor) {}
57 constexpr auto on_action(
int const actor,
int const action) ->
bool {
58 if (actor != m_actor) {
return false; }
60 case GLFW_PRESS: m_engaged =
true;
return true;
61 case GLFW_RELEASE: m_engaged =
false;
return true;
62 default:
return false;
66 [[nodiscard]]
constexpr auto is_engaged() const ->
bool {
return m_engaged; }
96 explicit constexpr DigitalAxis(
int lo,
int hi) : m_lo(lo), m_hi(hi) {}
98 constexpr auto on_action(
int const actor,
int const action) ->
bool {
99 if (actor != m_lo && actor != m_hi) {
return false; }
101 case GLFW_PRESS: on_press(actor);
return true;
102 case GLFW_RELEASE: on_release(actor);
return true;
103 default:
return false;
107 [[nodiscard]]
constexpr auto value() const ->
float {
109 if (m_held.test(0)) { ret -= 1.0f; }
110 if (m_held.test(1)) { ret += 1.0f; }
117 constexpr void on_press(
int const signal) {
118 if (signal == m_lo) {
120 }
else if (signal == m_hi) {
125 constexpr void on_release(
int const signal) {
126 if (signal == m_lo) {
128 }
else if (signal == m_hi) {
136 std::bitset<2> m_held{};
Definition controls.hpp:9
int actor
Definition controls.hpp:10
auto operator==(Entry const &) const -> bool=default
int mods
Definition controls.hpp:12
int action
Definition controls.hpp:11