6#include <klib/base_types.hpp>
26 [[nodiscard]] virtual auto
get_value() const -> action::Value = 0;
31template <
typename Type>
32concept ValueTypeT = std::same_as<Type, bool> || std::same_as<Type, float> || std::same_as<Type, glm::vec2>;
39 explicit(
false)
Value(
bool const digital) : m_value(digital ? 1.0f : 0.0f, 0.0f) {}
40 explicit(
false)
Value(
float const axis_1d) : m_value(axis_1d, 0.0f) {}
41 explicit(
false)
Value(glm::vec2
const axis_2d) : m_value(axis_2d) {}
44 template <ValueTypeT Type>
45 [[nodiscard]]
auto get() const -> Type {
46 if constexpr (std::same_as<Type, bool>) {
47 return m_value[0] != 0.0f;
48 }
else if constexpr (std::same_as<Type, float>) {
60template <std::
size_t Count>
61using Bits = std::bitset<Count>;
69 explicit IDigital(
int const match) : match(match) {}
78 void disengage() final;
79 [[nodiscard]] auto should_dispatch() const ->
bool final;
80 [[nodiscard]] auto get_value() const -> action::
Value final {
return m_state[0]; }
83 mutable bool m_changed{};
105 void disengage() final;
106 [[nodiscard]] auto should_dispatch() const ->
bool final {
return true; }
107 [[nodiscard]]
auto get_value() const -> action::
Value final;
120 explicit IBinaryAxis2D(glm::ivec2
const horz, glm::ivec2
const vert) : horz(horz), vert(vert) {}
131 void disengage() final;
132 [[nodiscard]] auto should_dispatch() const ->
bool final {
return true; }
133 [[nodiscard]]
auto get_value() const -> action::
Value final;
140 static constexpr auto dead_zone_v = 0.05f;
147 float dead_zone{dead_zone_v};
156 void on_cursor_pos(event::CursorPos
const& )
final {}
157 [[nodiscard]]
auto should_dispatch() const ->
bool final {
return true; }
158 [[nodiscard]]
auto get_gamepad_binding() const -> std::optional<Gamepad::Binding> final {
return binding; }
162template <std::derived_from<IAction> BaseT>
172 void update_gamepad(
Gamepad const& )
final {}
173 [[nodiscard]]
auto get_gamepad_binding()
const -> std::optional<Gamepad::Binding>
final {
return {}; }
177template <std::derived_from<IAction> BaseT>
187 void update_gamepad(
Gamepad const& )
final {}
188 [[nodiscard]]
auto get_gamepad_binding()
const -> std::optional<Gamepad::Binding>
final {
return {}; }
194 enum class Dim : std::int8_t { One, Two };
203 void update_gamepad(Gamepad
const& )
final {}
204 void disengage() final { m_value = {}; }
205 [[nodiscard]]
auto should_dispatch() const ->
bool final;
206 [[nodiscard]] auto get_gamepad_binding() const -> std::optional<Gamepad::Binding> final {
return {}; }
207 [[nodiscard]]
auto get_value() const -> action::Value final;
210 mutable glm::vec2 m_value{};
int action
Definition event.hpp:41
int key
Definition event.hpp:40