2022-03-08 21:19:19 +03:30
|
|
|
#pragma once
|
|
|
|
|
2025-07-10 13:29:03 +03:30
|
|
|
#include <input/events/event.hpp>
|
2025-07-17 10:44:00 +03:30
|
|
|
#include <math/vec2.hpp>
|
2022-03-08 21:19:19 +03:30
|
|
|
#include <sstream>
|
|
|
|
|
2025-07-11 00:05:48 +03:30
|
|
|
namespace lt {
|
2022-03-08 21:19:19 +03:30
|
|
|
|
|
|
|
class MouseMovedEvent: public Event
|
|
|
|
{
|
|
|
|
public:
|
2025-07-05 14:23:01 +03:30
|
|
|
MouseMovedEvent(float x, float y): m_position(x, y)
|
2022-03-08 21:19:19 +03:30
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2025-07-17 10:44:00 +03:30
|
|
|
[[nodiscard]] auto get_position() const -> const math::vec2 &
|
2025-07-05 13:28:41 +03:30
|
|
|
{
|
2025-07-05 14:23:01 +03:30
|
|
|
return m_position;
|
2025-07-05 13:28:41 +03:30
|
|
|
}
|
2022-03-08 21:19:19 +03:30
|
|
|
|
2025-07-06 16:52:50 +03:30
|
|
|
[[nodiscard]] auto get_x() const -> float
|
2025-07-05 13:28:41 +03:30
|
|
|
{
|
2025-07-05 14:23:01 +03:30
|
|
|
return m_position.x;
|
2025-07-05 13:28:41 +03:30
|
|
|
}
|
2025-07-06 14:02:50 +03:30
|
|
|
|
2025-07-06 16:52:50 +03:30
|
|
|
[[nodiscard]] auto get_y() const -> float
|
2025-07-05 13:28:41 +03:30
|
|
|
{
|
2025-07-05 14:23:01 +03:30
|
|
|
return m_position.y;
|
2025-07-05 13:28:41 +03:30
|
|
|
}
|
2022-03-08 21:19:19 +03:30
|
|
|
|
2025-07-06 16:52:50 +03:30
|
|
|
[[nodiscard]] auto get_info_lt_log() const -> std::string override
|
2022-03-08 21:19:19 +03:30
|
|
|
{
|
|
|
|
std::stringstream ss;
|
2025-07-05 14:23:01 +03:30
|
|
|
ss << "MouseMoved: " << m_position.x << ", " << m_position.y;
|
2022-03-08 21:19:19 +03:30
|
|
|
return ss.str();
|
|
|
|
}
|
2025-07-06 14:02:50 +03:30
|
|
|
|
2025-07-14 08:45:09 +00:00
|
|
|
[[nodiscard]] auto get_event_type() const -> EventType override
|
|
|
|
{
|
|
|
|
return ::lt::EventType::MouseMoved;
|
|
|
|
}
|
2025-07-06 14:02:50 +03:30
|
|
|
|
2025-07-14 08:45:09 +00:00
|
|
|
[[nodiscard]] auto has_category(EventCategory category) const -> bool override
|
|
|
|
{
|
|
|
|
return static_cast<uint8_t>(InputEventCategory | MouseEventCategory) & category;
|
|
|
|
}
|
2025-07-05 16:07:51 +03:30
|
|
|
|
|
|
|
private:
|
2025-07-17 10:44:00 +03:30
|
|
|
const math::vec2 m_position;
|
2022-03-08 21:19:19 +03:30
|
|
|
};
|
|
|
|
|
|
|
|
class WheelScrolledEvent: public Event
|
|
|
|
{
|
|
|
|
public:
|
2025-07-05 14:23:01 +03:30
|
|
|
WheelScrolledEvent(float offset): m_offset(offset)
|
2022-03-08 21:19:19 +03:30
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2025-07-06 16:52:50 +03:30
|
|
|
[[nodiscard]] auto get_offset() const -> float
|
2025-07-05 13:28:41 +03:30
|
|
|
{
|
2025-07-05 14:23:01 +03:30
|
|
|
return m_offset;
|
2025-07-05 13:28:41 +03:30
|
|
|
}
|
2022-03-08 21:19:19 +03:30
|
|
|
|
2025-07-06 16:52:50 +03:30
|
|
|
[[nodiscard]] auto get_info_lt_log() const -> std::string override
|
2022-03-08 21:19:19 +03:30
|
|
|
{
|
|
|
|
std::stringstream ss;
|
2025-07-05 14:23:01 +03:30
|
|
|
ss << "WheelScrolled: " << m_offset;
|
2022-03-08 21:19:19 +03:30
|
|
|
return ss.str();
|
|
|
|
}
|
2025-07-06 14:02:50 +03:30
|
|
|
|
2025-07-14 08:45:09 +00:00
|
|
|
[[nodiscard]] auto get_event_type() const -> EventType override
|
|
|
|
{
|
|
|
|
return ::lt::EventType::WheelScrolled;
|
|
|
|
}
|
2025-07-06 14:02:50 +03:30
|
|
|
|
2025-07-14 08:45:09 +00:00
|
|
|
[[nodiscard]] auto has_category(EventCategory category) const -> bool override
|
|
|
|
{
|
|
|
|
return static_cast<uint8_t>(InputEventCategory | MouseEventCategory) & category;
|
|
|
|
}
|
2025-07-05 16:07:51 +03:30
|
|
|
|
|
|
|
private:
|
|
|
|
const float m_offset;
|
2022-03-08 21:19:19 +03:30
|
|
|
};
|
|
|
|
|
|
|
|
class ButtonPressedEvent: public Event
|
|
|
|
{
|
|
|
|
public:
|
2025-07-05 14:23:01 +03:30
|
|
|
ButtonPressedEvent(int button): m_button(button)
|
2022-03-08 21:19:19 +03:30
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2025-07-06 16:52:50 +03:30
|
|
|
[[nodiscard]] auto get_button() const -> int
|
2025-07-05 13:28:41 +03:30
|
|
|
{
|
2025-07-05 14:23:01 +03:30
|
|
|
return m_button;
|
2025-07-05 13:28:41 +03:30
|
|
|
}
|
2022-03-08 21:19:19 +03:30
|
|
|
|
2025-07-06 16:52:50 +03:30
|
|
|
[[nodiscard]] auto get_info_lt_log() const -> std::string override
|
2022-03-08 21:19:19 +03:30
|
|
|
{
|
|
|
|
std::stringstream ss;
|
2025-07-05 14:23:01 +03:30
|
|
|
ss << "ButtonPressed: " << m_button;
|
2022-03-08 21:19:19 +03:30
|
|
|
return ss.str();
|
|
|
|
}
|
2025-07-06 14:02:50 +03:30
|
|
|
|
2025-07-14 08:45:09 +00:00
|
|
|
[[nodiscard]] auto get_event_type() const -> EventType override
|
|
|
|
{
|
|
|
|
return ::lt::EventType::ButtonPressed;
|
|
|
|
}
|
2025-07-06 14:02:50 +03:30
|
|
|
|
2025-07-14 08:45:09 +00:00
|
|
|
[[nodiscard]] auto has_category(EventCategory category) const -> bool override
|
|
|
|
{
|
|
|
|
return static_cast<uint8_t>(InputEventCategory | MouseEventCategory) & category;
|
|
|
|
}
|
2022-03-08 21:19:19 +03:30
|
|
|
|
|
|
|
private:
|
2025-07-05 14:23:01 +03:30
|
|
|
const int m_button;
|
2025-07-05 16:07:51 +03:30
|
|
|
};
|
2022-03-08 21:19:19 +03:30
|
|
|
|
2025-07-05 16:07:51 +03:30
|
|
|
class ButtonReleasedEvent: public Event
|
|
|
|
{
|
2022-03-08 21:19:19 +03:30
|
|
|
public:
|
2025-07-05 14:23:01 +03:30
|
|
|
ButtonReleasedEvent(int button): m_button(button)
|
2022-03-08 21:19:19 +03:30
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2025-07-06 16:52:50 +03:30
|
|
|
[[nodiscard]] auto get_button() const -> int
|
2025-07-05 13:28:41 +03:30
|
|
|
{
|
2025-07-05 14:23:01 +03:30
|
|
|
return m_button;
|
2025-07-05 13:28:41 +03:30
|
|
|
}
|
2022-03-08 21:19:19 +03:30
|
|
|
|
2025-07-06 16:52:50 +03:30
|
|
|
[[nodiscard]] auto get_info_lt_log() const -> std::string override
|
2022-03-08 21:19:19 +03:30
|
|
|
{
|
|
|
|
std::stringstream ss;
|
2025-07-05 14:23:01 +03:30
|
|
|
ss << "ButtonReleased: " << m_button;
|
2022-03-08 21:19:19 +03:30
|
|
|
return ss.str();
|
|
|
|
}
|
2025-07-05 16:07:51 +03:30
|
|
|
|
2025-07-14 08:45:09 +00:00
|
|
|
[[nodiscard]] auto get_event_type() const -> EventType override
|
|
|
|
{
|
|
|
|
return ::lt::EventType::ButtonReleased;
|
|
|
|
}
|
2025-07-06 14:02:50 +03:30
|
|
|
|
2025-07-14 08:45:09 +00:00
|
|
|
[[nodiscard]] auto has_category(EventCategory category) const -> bool override
|
|
|
|
{
|
|
|
|
return static_cast<uint8_t>(InputEventCategory | MouseEventCategory) & category;
|
|
|
|
}
|
2025-07-05 16:07:51 +03:30
|
|
|
|
|
|
|
private:
|
|
|
|
const int m_button;
|
2022-03-08 21:19:19 +03:30
|
|
|
};
|
|
|
|
|
2025-07-11 00:05:48 +03:30
|
|
|
} // namespace lt
|