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