mirror of
https://github.com/Kiritow/MiniEngine.git
synced 2024-03-22 13:11:22 +08:00
60 lines
1.1 KiB
C++
60 lines
1.1 KiB
C++
#pragma once
|
|
#include "MiniEngine.h"
|
|
|
|
namespace MiniEngine
|
|
{
|
|
|
|
namespace EventSystem
|
|
{
|
|
|
|
class EventBase
|
|
{
|
|
public:
|
|
EventBase()=default;
|
|
EventBase(SDL_Event);
|
|
protected:
|
|
SDL_Event e;
|
|
virtual void update(const EventBase&);
|
|
friend class EventHandlerBase;
|
|
};
|
|
|
|
class MouseMotionEvent : public EventBase
|
|
{
|
|
public:
|
|
int x,y;
|
|
void update(const EventBase&);
|
|
};
|
|
|
|
enum class MouseButton { Left, Middle, Right, X1, X2 };
|
|
|
|
class MouseButtonEvent : public EventBase
|
|
{
|
|
public:
|
|
int x,y;
|
|
MouseButton button;
|
|
void update(const EventBase&);
|
|
};
|
|
|
|
class KeyEvent : public EventBase
|
|
{
|
|
public:
|
|
int key;
|
|
void update(const EventBase&);
|
|
};
|
|
|
|
class EventHandlerBase
|
|
{
|
|
public:
|
|
virtual bool event(const EventBase&);
|
|
protected:
|
|
virtual bool onMouseDown(const MouseButtonEvent&);
|
|
virtual bool onMouseUp(const MouseButtonEvent&);
|
|
virtual bool onMouseMotion(const MouseMotionEvent&);
|
|
virtual bool onKeyDown(const KeyEvent&);
|
|
virtual bool onKeyUp(const KeyEvent&);
|
|
};
|
|
|
|
}/// End of namespace MiniEngine::EventSystem
|
|
|
|
}/// End of namespace MiniEngine
|