CoriEngine
Loading...
Searching...
No Matches
MouseEvent.hpp
Go to the documentation of this file.
1#pragma once
2#include "Event.hpp"
4
5namespace Cori {
6 namespace Core {
7 class MouseMovedEvent final : public Event {
8 public:
9 MouseMovedEvent(const int32_t x, const int32_t y)
10 : m_MouseX(x), m_MouseY(y) {
11 }
12
13 [[nodiscard]] int32_t GetX() const { return m_MouseX; }
14 [[nodiscard]] int32_t GetY() const { return m_MouseY; }
15
16 [[nodiscard]] std::string ToString() const override {
17 return std::string("MouseMovedEvent: (") + std::to_string(m_MouseX) + std::string(", ") + std::to_string(m_MouseY) + std::string(")");
18 }
19
22 private:
23 int32_t m_MouseX{ 0 };
24 int32_t m_MouseY{ 0 };
25 };
26
27 class MouseScrolledEvent final : public Event {
28 public:
29 MouseScrolledEvent(const int16_t xDirection, const int16_t yDirection)
30 : m_xDirection(xDirection), m_yDirection(yDirection) {}
31
32 int16_t GetXOffset() const { return m_xDirection; }
33 int16_t GetYOffset() const { return m_yDirection; }
34
35 std::string ToString() const override {
36 return std::string("MouseScrolledEvent: (") + std::to_string(m_xDirection) + std::string(", ") + std::to_string(m_yDirection) + std::string(")");
37 }
40 private:
41 int16_t m_xDirection{ 0 };
42 int16_t m_yDirection{ 0 };
43 };
44
55
57 public:
59 : MouseButtonEvent(button) {}
60
61 std::string ToString() const override {
62 return std::string("MouseButtonPressedEvent: ") + CoriGetKeyName(m_Button);
63 }
65 };
66
68 public:
70 : MouseButtonEvent(button) {}
71
72 std::string ToString() const override {
73 return std::string("MouseButtonReleasedEvent: ") + CoriGetKeyName(m_Button);
74
75 }
77 };
78 }
79}
#define EVENT_CLASS_TYPE(type)
Assigns an EventType to the custom event type derived from the Event class. Use it in the public fiel...
Definition Event.hpp:124
#define EVENT_CLASS_CATEGORY(category)
Assigns an EventCategory to the custom event type derived from the Event class. Use it in the public ...
Definition Event.hpp:132
An abstract class that is ment to be used as a template for defining events.
Definition Event.hpp:18
MouseButtonEvent(const CoriMouseKeycode button)
CoriMouseKeycode GetMouseButton() const
std::string ToString() const override
Returns the name of the Event.
MouseButtonPressedEvent(const CoriMouseKeycode button)
std::string ToString() const override
Returns the name of the Event.
MouseButtonReleasedEvent(const CoriMouseKeycode button)
std::string ToString() const override
Returns the name of the Event.
MouseMovedEvent(const int32_t x, const int32_t y)
Definition MouseEvent.hpp:9
std::string ToString() const override
Returns the name of the Event.
MouseScrolledEvent(const int16_t xDirection, const int16_t yDirection)
Core systems of the engine are here.
static std::string CoriGetKeyName(const CoriKeycode code)
@ EventCategoryMouse
Definition Event.hpp:11
@ EventCategoryInput
Definition Event.hpp:9
@ EventCategoryMouseButton
Definition Event.hpp:12
enum Cori::Core::CoriMouseCode CoriMouseKeycode
An enum of all available mouse buttons.
Global engine namespace.