Finality Engine
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
6namespace FINALITY
7{
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}
#define FI_CLIENT_INFO(...)
Definition Finality.h:55
static bool IsKeyDown(KeyCode key)
unsigned int KeyCode
Definition KeyCodes.h:11