light/modules/input/components.cppm

56 lines
734 B
Text
Raw Normal View History

export module input.system:components;
import input.codes;
import std;
2025-09-18 19:16:54 +03:30
namespace lt::input {
export struct Trigger
2025-09-18 19:16:54 +03:30
{
Key mapped_keycode;
2025-09-18 19:16:54 +03:30
};
export struct InputAction
2025-09-18 19:16:54 +03:30
{
enum class State : std::uint8_t
2025-09-18 19:16:54 +03:30
{
inactive,
active,
triggered,
cancelled,
};
std::string name;
State state;
Trigger trigger;
};
export class InputComponent
2025-09-18 19:16:54 +03:30
{
public:
InputComponent() = default;
auto add_action(InputAction action) -> std::size_t
2025-09-18 19:16:54 +03:30
{
m_actions.emplace_back(std::move(action));
return m_actions.size() - 1;
}
auto get_action(std::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