light/modules/input/components.cppm

57 lines
709 B
Text
Raw Permalink Normal View History

export module input.system:components;
2026-01-20 09:58:35 +03:30
import preliminary;
import input.codes;
2025-09-18 19:16:54 +03:30
2026-01-20 09:58:35 +03:30
export namespace lt::input {
2025-09-18 19:16:54 +03:30
2026-01-20 09:58:35 +03:30
struct Trigger
2025-09-18 19:16:54 +03:30
{
Key mapped_keycode;
2025-09-18 19:16:54 +03:30
};
2026-01-20 09:58:35 +03:30
struct InputAction
2025-09-18 19:16:54 +03:30
{
2026-01-20 09:58:35 +03:30
enum class State : u8
2025-09-18 19:16:54 +03:30
{
inactive,
active,
triggered,
cancelled,
};
std::string name;
State state;
Trigger trigger;
};
2026-01-20 09:58:35 +03:30
class InputComponent
2025-09-18 19:16:54 +03:30
{
public:
InputComponent() = default;
2026-01-20 09:58:35 +03:30
auto add_action(InputAction action) -> size_t
2025-09-18 19:16:54 +03:30
{
m_actions.emplace_back(std::move(action));
return m_actions.size() - 1;
}
2026-01-20 09:58:35 +03:30
auto get_action(size_t idx) -> const InputAction &
2025-09-18 19:16:54 +03:30
{
return m_actions[idx];
}
private:
friend class System;
void push_event()
{
}
std::vector<InputAction> m_actions;
};
} // namespace lt::input