light/modules/input/events.cppm

42 lines
704 B
Text
Raw Normal View History

export module input.events;
2025-09-18 19:16:54 +03:30
import input.codes;
import math.vec2;
import std;
2025-09-18 19:16:54 +03:30
namespace lt::input {
export class AnalogEvent
2025-09-18 19:16:54 +03:30
{
public:
AnalogEvent(Key key, math::uvec2 pointer_position)
: m_key(key)
2025-09-18 19:16:54 +03:30
, m_pointer_position(pointer_position)
{
}
[[nodiscard]] auto get_key() const -> Key
2025-09-18 19:16:54 +03:30
{
return m_key;
2025-09-18 19:16:54 +03:30
};
[[nodiscard]] auto get_pointer_position() const -> math::uvec2
{
return m_pointer_position;
}
[[nodiscard]] auto to_string() const -> std::string
{
const auto &[x, y] = m_pointer_position;
return std::format("input::AnalogEvent: {} @ {}, {}", std::to_underlying(m_key), x, y);
2025-09-18 19:16:54 +03:30
}
private:
Key m_key;
2025-09-18 19:16:54 +03:30
math::uvec2 m_pointer_position;
};
} // namespace lt::input