Finality Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
KeyPrintScript.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <
Finality.h
>
4
#include <string>
5
6
namespace
FINALITY
7
{
9
class
KeyPrintScript
:
public
FINALITY::ScriptableComponent
10
{
11
public
:
12
KeyPrintScript
() =
default
;
13
14
private
:
15
void
Start()
override
16
{
17
FI_CLIENT_INFO
(
"KeyPrintScript initialized! Press any key to see its name."
);
18
}
19
20
void
Update(
float
dt)
override
21
{
22
for
(
unsigned
int
i = 32; i < 349; ++i)
23
{
24
if
(
Input::IsKeyDown
(i))
25
{
26
FI_CLIENT_INFO
(
"Key Pressed: {}"
, GetKeyName(i));
27
}
28
}
29
}
30
31
void
OnDestroy()
override
32
{
33
FI_CLIENT_INFO
(
"KeyPrintScript destroyed."
);
34
}
35
36
std::string GetKeyName(
KeyCode
key)
37
{
38
if
(key >=
Key::A
&& key <=
Key::Z
)
39
{
40
return
std::string(1,
static_cast<
char
>
(key));
41
}
42
if
(key >=
Key::D0
&& key <=
Key::D9
)
43
{
44
return
std::string(1,
static_cast<
char
>
(key));
45
}
46
47
switch
(key)
48
{
49
case
Key::Space
:
return
"SPACE"
;
50
case
Key::Apostrophe
:
return
"APOSTROPHE"
;
51
case
Key::Comma
:
return
"COMMA"
;
52
case
Key::Minus
:
return
"MINUS"
;
53
case
Key::Period
:
return
"PERIOD"
;
54
case
Key::Slash
:
return
"SLASH"
;
55
case
Key::Semicolon
:
return
"SEMICOLON"
;
56
case
Key::Equal
:
return
"EQUAL"
;
57
case
Key::LeftBracket
:
return
"LEFT BRACKET"
;
58
case
Key::Backslash
:
return
"BACKSLASH"
;
59
case
Key::RightBracket
:
return
"RIGHT BRACKET"
;
60
case
Key::GraveAccent
:
return
"GRAVE ACCENT"
;
61
case
Key::World1
:
return
"WORLD 1"
;
62
case
Key::World2
:
return
"WORLD 2"
;
63
case
Key::Escape
:
return
"ESCAPE"
;
64
case
Key::Enter
:
return
"ENTER"
;
65
case
Key::Tab
:
return
"TAB"
;
66
case
Key::Backspace
:
return
"BACKSPACE"
;
67
case
Key::Insert
:
return
"INSERT"
;
68
case
Key::Delete
:
return
"DELETE"
;
69
case
Key::Right
:
return
"RIGHT ARROW"
;
70
case
Key::Left
:
return
"LEFT ARROW"
;
71
case
Key::Down
:
return
"DOWN ARROW"
;
72
case
Key::Up
:
return
"UP ARROW"
;
73
case
Key::PageUp
:
return
"PAGE UP"
;
74
case
Key::PageDown
:
return
"PAGE DOWN"
;
75
case
Key::Home
:
return
"HOME"
;
76
case
Key::End
:
return
"END"
;
77
case
Key::CapsLock
:
return
"CAPS LOCK"
;
78
case
Key::ScrollLock
:
return
"SCROLL LOCK"
;
79
case
Key::NumLock
:
return
"NUM LOCK"
;
80
case
Key::PrintScreen
:
return
"PRINT SCREEN"
;
81
case
Key::Pause
:
return
"PAUSE"
;
82
case
Key::F1
:
return
"F1"
;
case
Key::F2
:
return
"F2"
;
case
Key::F3
:
return
"F3"
;
83
case
Key::F4
:
return
"F4"
;
case
Key::F5
:
return
"F5"
;
case
Key::F6
:
return
"F6"
;
84
case
Key::F7
:
return
"F7"
;
case
Key::F8
:
return
"F8"
;
case
Key::F9
:
return
"F9"
;
85
case
Key::F10
:
return
"F10"
;
case
Key::F11
:
return
"F11"
;
case
Key::F12
:
return
"F12"
;
86
case
Key::KP0
:
return
"NUMPAD 0"
;
case
Key::KP1
:
return
"NUMPAD 1"
;
87
case
Key::KP2
:
return
"NUMPAD 2"
;
case
Key::KP3
:
return
"NUMPAD 3"
;
88
case
Key::KP4
:
return
"NUMPAD 4"
;
case
Key::KP5
:
return
"NUMPAD 5"
;
89
case
Key::KP6
:
return
"NUMPAD 6"
;
case
Key::KP7
:
return
"NUMPAD 7"
;
90
case
Key::KP8
:
return
"NUMPAD 8"
;
case
Key::KP9
:
return
"NUMPAD 9"
;
91
case
Key::KPDecimal
:
return
"NUMPAD DECIMAL"
;
92
case
Key::KPDivide
:
return
"NUMPAD DIVIDE"
;
93
case
Key::KPMultiply
:
return
"NUMPAD MULTIPLY"
;
94
case
Key::KPSubtract
:
return
"NUMPAD SUBTRACT"
;
95
case
Key::KPAdd
:
return
"NUMPAD ADD"
;
96
case
Key::KPEnter
:
return
"NUMPAD ENTER"
;
97
case
Key::KPEqual
:
return
"NUMPAD EQUAL"
;
98
case
Key::LeftShift
:
return
"LEFT SHIFT"
;
99
case
Key::LeftControl
:
return
"LEFT CONTROL"
;
100
case
Key::LeftAlt
:
return
"LEFT ALT"
;
101
case
Key::LeftSuper
:
return
"LEFT SUPER"
;
102
case
Key::RightShift
:
return
"RIGHT SHIFT"
;
103
case
Key::RightControl
:
return
"RIGHT CONTROL"
;
104
case
Key::RightAlt
:
return
"RIGHT ALT"
;
105
case
Key::RightSuper
:
return
"RIGHT SUPER"
;
106
case
Key::Menu
:
return
"MENU"
;
107
default
:
return
"UNKNOWN_KEY_"
+ std::to_string(key);
108
}
109
}
110
};
111
}
Finality.h
FI_CLIENT_INFO
#define FI_CLIENT_INFO(...)
Definition
Finality.h:55
FINALITY::Input::IsKeyDown
static bool IsKeyDown(KeyCode key)
FINALITY::KeyPrintScript::KeyPrintScript
KeyPrintScript()=default
FINALITY::ScriptableComponent
Definition
ScriptableComponent.h:96
FINALITY::Key::NumLock
@ NumLock
Definition
KeyCodes.h:87
FINALITY::Key::LeftAlt
@ LeftAlt
Definition
KeyCodes.h:137
FINALITY::Key::Left
@ Left
Definition
KeyCodes.h:78
FINALITY::Key::KP5
@ KP5
Definition
KeyCodes.h:122
FINALITY::Key::PrintScreen
@ PrintScreen
Definition
KeyCodes.h:88
FINALITY::Key::F1
@ F1
Definition
KeyCodes.h:91
FINALITY::Key::PageUp
@ PageUp
Definition
KeyCodes.h:81
FINALITY::Key::Home
@ Home
Definition
KeyCodes.h:83
FINALITY::Key::Minus
@ Minus
Definition
KeyCodes.h:18
FINALITY::Key::A
@ A
Definition
KeyCodes.h:36
FINALITY::Key::KP9
@ KP9
Definition
KeyCodes.h:126
FINALITY::Key::Tab
@ Tab
Definition
KeyCodes.h:73
FINALITY::Key::Backslash
@ Backslash
Definition
KeyCodes.h:64
FINALITY::Key::F11
@ F11
Definition
KeyCodes.h:101
FINALITY::Key::KP3
@ KP3
Definition
KeyCodes.h:120
FINALITY::Key::LeftSuper
@ LeftSuper
Definition
KeyCodes.h:138
FINALITY::Key::KP0
@ KP0
Definition
KeyCodes.h:117
FINALITY::Key::RightShift
@ RightShift
Definition
KeyCodes.h:139
FINALITY::Key::D0
@ D0
Definition
KeyCodes.h:22
FINALITY::Key::Delete
@ Delete
Definition
KeyCodes.h:76
FINALITY::Key::F10
@ F10
Definition
KeyCodes.h:100
FINALITY::Key::Comma
@ Comma
Definition
KeyCodes.h:17
FINALITY::Key::KPEnter
@ KPEnter
Definition
KeyCodes.h:132
FINALITY::Key::Equal
@ Equal
Definition
KeyCodes.h:34
FINALITY::Key::GraveAccent
@ GraveAccent
Definition
KeyCodes.h:66
FINALITY::Key::RightBracket
@ RightBracket
Definition
KeyCodes.h:65
FINALITY::Key::KPDecimal
@ KPDecimal
Definition
KeyCodes.h:127
FINALITY::Key::RightAlt
@ RightAlt
Definition
KeyCodes.h:141
FINALITY::Key::Down
@ Down
Definition
KeyCodes.h:79
FINALITY::Key::ScrollLock
@ ScrollLock
Definition
KeyCodes.h:86
FINALITY::Key::KP7
@ KP7
Definition
KeyCodes.h:124
FINALITY::Key::F5
@ F5
Definition
KeyCodes.h:95
FINALITY::Key::Backspace
@ Backspace
Definition
KeyCodes.h:74
FINALITY::Key::Up
@ Up
Definition
KeyCodes.h:80
FINALITY::Key::KPAdd
@ KPAdd
Definition
KeyCodes.h:131
FINALITY::Key::F7
@ F7
Definition
KeyCodes.h:97
FINALITY::Key::F8
@ F8
Definition
KeyCodes.h:98
FINALITY::Key::F9
@ F9
Definition
KeyCodes.h:99
FINALITY::Key::CapsLock
@ CapsLock
Definition
KeyCodes.h:85
FINALITY::Key::World1
@ World1
Definition
KeyCodes.h:67
FINALITY::Key::Right
@ Right
Definition
KeyCodes.h:77
FINALITY::Key::F6
@ F6
Definition
KeyCodes.h:96
FINALITY::Key::KP1
@ KP1
Definition
KeyCodes.h:118
FINALITY::Key::KP6
@ KP6
Definition
KeyCodes.h:123
FINALITY::Key::Z
@ Z
Definition
KeyCodes.h:61
FINALITY::Key::Enter
@ Enter
Definition
KeyCodes.h:72
FINALITY::Key::End
@ End
Definition
KeyCodes.h:84
FINALITY::Key::Space
@ Space
Definition
KeyCodes.h:15
FINALITY::Key::D9
@ D9
Definition
KeyCodes.h:31
FINALITY::Key::KP2
@ KP2
Definition
KeyCodes.h:119
FINALITY::Key::Slash
@ Slash
Definition
KeyCodes.h:20
FINALITY::Key::RightSuper
@ RightSuper
Definition
KeyCodes.h:142
FINALITY::Key::KP4
@ KP4
Definition
KeyCodes.h:121
FINALITY::Key::Escape
@ Escape
Definition
KeyCodes.h:71
FINALITY::Key::F2
@ F2
Definition
KeyCodes.h:92
FINALITY::Key::LeftBracket
@ LeftBracket
Definition
KeyCodes.h:63
FINALITY::Key::PageDown
@ PageDown
Definition
KeyCodes.h:82
FINALITY::Key::Menu
@ Menu
Definition
KeyCodes.h:143
FINALITY::Key::Pause
@ Pause
Definition
KeyCodes.h:89
FINALITY::Key::KPDivide
@ KPDivide
Definition
KeyCodes.h:128
FINALITY::Key::F4
@ F4
Definition
KeyCodes.h:94
FINALITY::Key::KPMultiply
@ KPMultiply
Definition
KeyCodes.h:129
FINALITY::Key::Insert
@ Insert
Definition
KeyCodes.h:75
FINALITY::Key::LeftShift
@ LeftShift
Definition
KeyCodes.h:135
FINALITY::Key::KPEqual
@ KPEqual
Definition
KeyCodes.h:133
FINALITY::Key::F12
@ F12
Definition
KeyCodes.h:102
FINALITY::Key::KP8
@ KP8
Definition
KeyCodes.h:125
FINALITY::Key::Semicolon
@ Semicolon
Definition
KeyCodes.h:33
FINALITY::Key::F3
@ F3
Definition
KeyCodes.h:93
FINALITY::Key::Period
@ Period
Definition
KeyCodes.h:19
FINALITY::Key::Apostrophe
@ Apostrophe
Definition
KeyCodes.h:16
FINALITY::Key::LeftControl
@ LeftControl
Definition
KeyCodes.h:136
FINALITY::Key::World2
@ World2
Definition
KeyCodes.h:68
FINALITY::Key::KPSubtract
@ KPSubtract
Definition
KeyCodes.h:130
FINALITY::Key::RightControl
@ RightControl
Definition
KeyCodes.h:140
FINALITY
Definition
Asset.h:12
FINALITY::KeyCode
unsigned int KeyCode
Definition
KeyCodes.h:11
Sandbox
src
scripts
KeyPrintScript.h
Generated by
1.18.0