71 lines
1.4 KiB
C++
Executable File
71 lines
1.4 KiB
C++
Executable File
#pragma once
|
|
#include "DeerRender/Events/Event.h"
|
|
#include <sstream>
|
|
|
|
namespace Deer {
|
|
|
|
class KeyEvent : public Event
|
|
{
|
|
public:
|
|
inline unsigned short getKeyCode() const { return m_KeyCode; }
|
|
|
|
EVENT_CLASS_CATEGORY(EventCategoryKeyboard | EventCategoryInput)
|
|
protected:
|
|
KeyEvent(unsigned short keycode)
|
|
: m_KeyCode(keycode) {}
|
|
|
|
unsigned short m_KeyCode;
|
|
};
|
|
|
|
class KeyPressedEvent : public KeyEvent
|
|
{
|
|
public:
|
|
KeyPressedEvent(unsigned int keycode, int repeatCount)
|
|
: KeyEvent(keycode), m_RepeatCount(repeatCount) {}
|
|
|
|
inline int getRepeatCount() const { return m_RepeatCount; }
|
|
|
|
std::string toString() const override
|
|
{
|
|
std::stringstream ss;
|
|
ss << "KeyPressedEvent: " << m_KeyCode << " (" << m_RepeatCount << " repeats)";
|
|
return ss.str();
|
|
}
|
|
|
|
EVENT_CLASS_TYPE(KeyPressed)
|
|
private:
|
|
int m_RepeatCount;
|
|
};
|
|
|
|
class KeyReleasedEvent : public KeyEvent
|
|
{
|
|
public:
|
|
KeyReleasedEvent(unsigned int keycode)
|
|
: KeyEvent(keycode) {}
|
|
|
|
std::string toString() const override
|
|
{
|
|
std::stringstream ss;
|
|
ss << "KeyReleasedEvent: " << m_KeyCode;
|
|
return ss.str();
|
|
}
|
|
|
|
EVENT_CLASS_TYPE(KeyReleased)
|
|
};
|
|
|
|
class KeyTypedEvent : public KeyEvent
|
|
{
|
|
public:
|
|
KeyTypedEvent(unsigned int keycode)
|
|
: KeyEvent(keycode) {}
|
|
|
|
std::string toString() const override
|
|
{
|
|
std::stringstream ss;
|
|
ss << "KeyTypedEvent: " << m_KeyCode;
|
|
return ss.str();
|
|
}
|
|
|
|
EVENT_CLASS_TYPE(KeyTyped)
|
|
};
|
|
} |