light/modules/input/public/events/event.hpp

57 lines
907 B
C++
Raw Normal View History

2025-07-05 13:28:41 +03:30
#pragma once
2025-07-11 00:05:48 +03:30
namespace lt {
2025-07-05 13:28:41 +03:30
enum class EventType : uint8_t
2025-07-05 13:28:41 +03:30
{
None = 0,
// input
MouseMoved,
WheelScrolled,
ButtonPressed,
ButtonReleased,
KeyPressed,
KeyRepeated,
KeyReleased,
SetChar,
// window
WindowMoved,
WindowResized,
WindowClosed,
WindowLostFocus,
WindowGainFocus,
};
enum EventCategory : uint8_t
2025-07-05 13:28:41 +03:30
{
None = 0,
WindowEventCategory = bit(0),
InputEventCategory = bit(1),
KeyboardEventCategory = bit(2),
MouseEventCategory = bit(3),
2025-07-05 13:28:41 +03:30
};
class Event
{
public:
2025-07-06 14:02:50 +03:30
Event() = default;
virtual ~Event() = default;
2025-07-06 16:52:50 +03:30
[[nodiscard]] virtual auto get_event_type() const -> EventType = 0;
2025-07-06 14:02:50 +03:30
2025-07-06 16:52:50 +03:30
[[nodiscard]] virtual auto get_info_lt_log() const -> std::string = 0;
2025-07-06 14:02:50 +03:30
2025-07-06 16:52:50 +03:30
[[nodiscard]] virtual auto has_category(EventCategory category) const -> bool = 0;
2025-07-05 13:28:41 +03:30
2025-07-06 14:02:50 +03:30
friend auto operator<<(std::ostream &os, const Event &e) -> std::ostream &
2025-07-05 13:28:41 +03:30
{
return os << e.get_info_lt_log();
2025-07-05 13:28:41 +03:30
}
};
2025-07-11 00:05:48 +03:30
} // namespace lt