Elevate Engine 1
Loading...
Searching...
No Matches
KeyEvent.h
Go to the documentation of this file.
1#pragma once
2#include "Event.h"
3#include <sstream>
4
5namespace Elevate
6{
7 class EE_API KeyEvent : public Event
8 {
9 public:
10 inline int GetKeyCode() const { return m_KeyCode; }
11
12 EVENT_CLASS_CATEGORY(EventCategoryKeyboard | EventCategoryInput)
13 protected:
14 KeyEvent(int keycode)
15 : m_KeyCode(keycode) {}
16
18 };
19
21 {
22 public:
23 KeyPressedEvent(int keycode, int repeatCount)
24 : KeyEvent(keycode), m_RepeatCount(repeatCount) {}
25
26 inline int GetRepeatCount() const { return m_RepeatCount; }
27
28 std::string ToString() const override
29 {
30 std::stringstream ss;
31 ss << "KeyPressedEvent: " << m_KeyCode << " (" << m_RepeatCount << " repeats)";
32 return ss.str();
33 }
34
35 EVENT_CLASS_TYPE(KeyPressed)
36
37 private:
38 int m_RepeatCount = 0;
39 };
40
42 {
43 public:
44 KeyReleasedEvent(int keycode)
45 : KeyEvent(keycode) {}
46
47 std::string ToString() const override
48 {
49 std::stringstream ss;
50 ss << "KeyReleasedEvent: " << m_KeyCode;
51 return ss.str();
52 }
53
54 EVENT_CLASS_TYPE(KeyReleased)
55
56 private:
57 int m_RepeatCount = 0;
58 };
59
61 {
62 public:
63 KeyTypedEvent(int keycode)
64 : KeyEvent(keycode) {}
65
66 std::string ToString() const override
67 {
68 std::stringstream ss;
69 ss << "KeyTypedEvent: " << m_KeyCode;
70 return ss.str();
71 }
72
73 EVENT_CLASS_TYPE(KeyTyped)
74
75 private:
76 int m_RepeatCount = 0;
77 };
78}
#define EE_API
Definition Core.h:9
#define EVENT_CLASS_TYPE(type)
Definition Event.h:31
#define EVENT_CLASS_CATEGORY(category)
Definition Event.h:35
KeyEvent(int keycode)
Definition KeyEvent.h:14
int GetKeyCode() const
Definition KeyEvent.h:10
int GetRepeatCount() const
Definition KeyEvent.h:26
std::string ToString() const override
Definition KeyEvent.h:28
KeyPressedEvent(int keycode, int repeatCount)
Definition KeyEvent.h:23
KeyReleasedEvent(int keycode)
Definition KeyEvent.h:44
std::string ToString() const override
Definition KeyEvent.h:47
std::string ToString() const override
Definition KeyEvent.h:66
KeyTypedEvent(int keycode)
Definition KeyEvent.h:63