R-Type  2
Doom but in better
Loading...
Searching...
No Matches
Key.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2024
3** rtype (Workspace)
4** File description:
5** Key.hpp
6*/
7
15#pragma once
16#include <any>
17#include <optional>
18#include <unordered_map>
19#include <SFML/Window/Event.hpp>
20
21#include "Log.hpp"
22#include "LogMacros.hpp"
23#include "Utilities.hpp"
24#include "Constants.hpp"
26
27namespace GUI
28{
29 namespace ECS
30 {
31 namespace Systems
32 {
33 enum class Key {
34 Unknown = -1,
35 A = 0,
36 B,
37 C,
38 D,
39 E,
40 F,
41 G,
42 H,
43 I,
44 J,
45 K,
46 L,
47 M,
48 N,
49 O,
50 P,
51 Q,
52 R,
53 S,
54 T,
55 U,
56 V,
57 W,
58 X,
59 Y,
60 Z,
61 Up,
62 F1,
63 F2,
64 F3,
65 F4,
66 F5,
67 F6,
68 F7,
69 F8,
70 F9,
71 F10,
72 F11,
73 F12,
74 F13,
75 F14,
76 F15,
77 F16,
78 F17,
79 F18,
80 F19,
81 F20,
82 F21,
83 F22,
84 F23,
85 F24,
86 Tab,
87 End,
88 Add,
89 Cut,
90 Num0,
91 Num1,
92 Num2,
93 Num3,
94 Num4,
95 Num5,
96 Num6,
97 Num7,
98 Num8,
99 Num9,
100 LAlt,
101 RAlt,
102 Menu,
103 Home,
104 Down,
105 Left,
106 Copy,
107 Redo,
108 Undo,
109 Help,
110 Back,
111 Stop,
112 Comma,
113 Enter,
114 Slash,
115 Grave,
116 Equal,
117 Space,
118 Right,
119 Pause,
120 Paste,
121 LShift,
122 RShift,
123 Escape,
124 Period,
125 Hyphen,
126 PageUp,
127 Insert,
128 Delete,
129 Divide,
130 Search,
131 Select,
132 Forward,
133 Refresh,
134 Execute,
135 LSystem,
136 RSystem,
137 Numpad0,
138 Numpad1,
139 Numpad2,
140 Numpad3,
141 Numpad4,
142 Numpad5,
143 Numpad6,
144 Numpad7,
145 Numpad8,
146 Numpad9,
147 PageDown,
148 LControl,
149 RControl,
150 LBracket,
151 RBracket,
152 Subtract,
153 Multiply,
154 CapsLock,
155 HomePage,
156 VolumeUp,
157 Semicolon,
158 Backslash,
159 Backspace,
160 Favorites,
161 MediaStop,
178 };
179
180 extern const std::unordered_map<Key, std::string> keyCodeEquivalence;
182 public:
183 KeyMapper(const std::uint32_t EntityId = 0);
192 const Key mapKey(const std::any &sfmlKey) const;
193
202 const std::string stringKey(const std::any &keyCode) const;
209 const std::string stringKey(const GUI::ECS::Systems::Key &keyCode) const;
218 const std::string getInfo(const unsigned int indent = 0) const;
219
220 private:
221 std::unordered_map<sf::Keyboard::Key, Key> _sfmlKeyToCustom;
222 std::unordered_map<sf::Keyboard::Scancode, Key> _sfmlScanCodeToCustom;
223 };
224
233 std::ostream &operator<<(std::ostream &os, const KeyMapper &item);
234
243 std::ostream &operator<<(std::ostream &os, const Key &item);
244
245 }
246 }
247}
This is the file in charge of containing the constants that are meant to be used throughout the progr...
This is the file that links the EntityNode children.
Macro definitions for logging messages with varying levels of detail and formatting.
This is the file in charge of containing the Log class (the one in charge of outputing info only when...
KeyMapper(const std::uint32_t EntityId=0)
Definition Key.cpp:163
const std::string stringKey(const std::any &keyCode) const
This is the function that wan take either an sf::Keyboard::Key or a sf::Keyboard::Scancode and return...
Definition Key.cpp:440
const Key mapKey(const std::any &sfmlKey) const
This is the function in charge of returning the internal key code equivalent for an sf::Keyboard::Sca...
Definition Key.cpp:416
const std::string getInfo(const unsigned int indent=0) const
This is a function meant for debugging purposes It will dump the current state of the variables upon ...
Definition Key.cpp:454
std::ostream & operator<<(std::ostream &os, const Clock &item)
Outputs the clock's info to a stream.
Definition Clock.cpp:73
const std::unordered_map< Key, std::string > keyCodeEquivalence
An unordered map to track the equivalence between the Key and the string representation.
Definition Key.cpp:16