60 lines
1012 B
C++
60 lines
1012 B
C++
#pragma once
|
|
#ifndef EVENT_H_
|
|
#define EVENT_H_
|
|
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
|
|
enum class EventType : unsigned int {
|
|
// ----- INPUT -----
|
|
INPUT = 1 << 0,
|
|
// Mouse
|
|
MOUSE = 1 << 1,
|
|
MOUSE_MOVED = 1 << 2,
|
|
};
|
|
|
|
constexpr EventType operator|(EventType a, EventType b) {
|
|
return static_cast<EventType>(
|
|
static_cast<unsigned int>(a) |
|
|
static_cast<unsigned int>(b)
|
|
);
|
|
}
|
|
|
|
constexpr EventType operator&(EventType a, EventType b) {
|
|
return static_cast<EventType>(
|
|
static_cast<unsigned int>(a) &
|
|
static_cast<unsigned int>(b)
|
|
);
|
|
}
|
|
|
|
constexpr EventType operator~(EventType a) {
|
|
return static_cast<EventType>(
|
|
~static_cast<unsigned int>(a)
|
|
);
|
|
}
|
|
|
|
struct Event {
|
|
public:
|
|
Event();
|
|
virtual ~Event() = default;
|
|
|
|
public:
|
|
virtual EventType GetType() const = 0;
|
|
|
|
public:
|
|
void Handle();
|
|
size_t Id() const;
|
|
|
|
public:
|
|
bool IsHandled() const;
|
|
|
|
private:
|
|
bool m_handled;
|
|
size_t m_id;
|
|
|
|
private:
|
|
static size_t s_id_counter;
|
|
};
|
|
|
|
#endif // EVENT_H_
|