R-Type  2
Doom but in better
Loading...
Searching...
No Matches
Key.cpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2024
3** rtype (Workspace)
4** File description:
5** key.cpp
6*/
7
15
16const std::unordered_map<GUI::ECS::Systems::Key, std::string> GUI::ECS::Systems::keyCodeEquivalence = {
153 {GUI::ECS::Systems::Key::NumpadDecimal, "NumpadDecimal"},
154 {GUI::ECS::Systems::Key::NonUsBackslash, "NonUsBackslash"},
155 {GUI::ECS::Systems::Key::MediaPlayPause, "MediaPlayPause"},
156 {GUI::ECS::Systems::Key::MediaNextTrack, "MediaNextTrack"},
157 {GUI::ECS::Systems::Key::LaunchMediaSelect, "LaunchMediaSelect"},
158 {GUI::ECS::Systems::Key::LaunchApplication1, "LaunchApplication1"},
159 {GUI::ECS::Systems::Key::LaunchApplication2, "LaunchApplication2"},
160 {GUI::ECS::Systems::Key::MediaPreviousTrack, "MediaPreviousTrack"}
161};
162
163GUI::ECS::Systems::KeyMapper::KeyMapper(const std::uint32_t EntityId)
164 : EntityNode(EntityId)
165{
166 _sfmlKeyToCustom[sf::Keyboard::Key::Unknown] = Key::Unknown;
167 _sfmlKeyToCustom[sf::Keyboard::Key::A] = Key::A;
168 _sfmlKeyToCustom[sf::Keyboard::Key::B] = Key::B;
169 _sfmlKeyToCustom[sf::Keyboard::Key::C] = Key::C;
170 _sfmlKeyToCustom[sf::Keyboard::Key::D] = Key::D;
171 _sfmlKeyToCustom[sf::Keyboard::Key::E] = Key::E;
172 _sfmlKeyToCustom[sf::Keyboard::Key::F] = Key::F;
173 _sfmlKeyToCustom[sf::Keyboard::Key::G] = Key::G;
174 _sfmlKeyToCustom[sf::Keyboard::Key::H] = Key::H;
175 _sfmlKeyToCustom[sf::Keyboard::Key::I] = Key::I;
176 _sfmlKeyToCustom[sf::Keyboard::Key::J] = Key::J;
177 _sfmlKeyToCustom[sf::Keyboard::Key::K] = Key::K;
178 _sfmlKeyToCustom[sf::Keyboard::Key::L] = Key::L;
179 _sfmlKeyToCustom[sf::Keyboard::Key::M] = Key::M;
180 _sfmlKeyToCustom[sf::Keyboard::Key::N] = Key::N;
181 _sfmlKeyToCustom[sf::Keyboard::Key::O] = Key::O;
182 _sfmlKeyToCustom[sf::Keyboard::Key::P] = Key::P;
183 _sfmlKeyToCustom[sf::Keyboard::Key::Q] = Key::Q;
184 _sfmlKeyToCustom[sf::Keyboard::Key::R] = Key::R;
185 _sfmlKeyToCustom[sf::Keyboard::Key::S] = Key::S;
186 _sfmlKeyToCustom[sf::Keyboard::Key::T] = Key::T;
187 _sfmlKeyToCustom[sf::Keyboard::Key::U] = Key::U;
188 _sfmlKeyToCustom[sf::Keyboard::Key::V] = Key::V;
189 _sfmlKeyToCustom[sf::Keyboard::Key::W] = Key::W;
190 _sfmlKeyToCustom[sf::Keyboard::Key::X] = Key::X;
191 _sfmlKeyToCustom[sf::Keyboard::Key::Y] = Key::Y;
192 _sfmlKeyToCustom[sf::Keyboard::Key::Z] = Key::Z;
193 _sfmlKeyToCustom[sf::Keyboard::Key::Up] = Key::Up;
194 _sfmlKeyToCustom[sf::Keyboard::Key::F1] = Key::F1;
195 _sfmlKeyToCustom[sf::Keyboard::Key::F2] = Key::F2;
196 _sfmlKeyToCustom[sf::Keyboard::Key::F3] = Key::F3;
197 _sfmlKeyToCustom[sf::Keyboard::Key::F4] = Key::F4;
198 _sfmlKeyToCustom[sf::Keyboard::Key::F5] = Key::F5;
199 _sfmlKeyToCustom[sf::Keyboard::Key::F6] = Key::F6;
200 _sfmlKeyToCustom[sf::Keyboard::Key::F7] = Key::F7;
201 _sfmlKeyToCustom[sf::Keyboard::Key::F8] = Key::F8;
202 _sfmlKeyToCustom[sf::Keyboard::Key::F9] = Key::F9;
203 _sfmlKeyToCustom[sf::Keyboard::Key::F10] = Key::F10;
204 _sfmlKeyToCustom[sf::Keyboard::Key::F11] = Key::F11;
205 _sfmlKeyToCustom[sf::Keyboard::Key::F12] = Key::F12;
206 _sfmlKeyToCustom[sf::Keyboard::Key::F13] = Key::F13;
207 _sfmlKeyToCustom[sf::Keyboard::Key::F14] = Key::F14;
208 _sfmlKeyToCustom[sf::Keyboard::Key::F15] = Key::F15;
209 _sfmlKeyToCustom[sf::Keyboard::Key::Tab] = Key::Tab;
210 _sfmlKeyToCustom[sf::Keyboard::Key::End] = Key::End;
211 _sfmlKeyToCustom[sf::Keyboard::Key::Add] = Key::Add;
212 _sfmlKeyToCustom[sf::Keyboard::Key::Num0] = Key::Num0;
213 _sfmlKeyToCustom[sf::Keyboard::Key::Num1] = Key::Num1;
214 _sfmlKeyToCustom[sf::Keyboard::Key::Num2] = Key::Num2;
215 _sfmlKeyToCustom[sf::Keyboard::Key::Num3] = Key::Num3;
216 _sfmlKeyToCustom[sf::Keyboard::Key::Num4] = Key::Num4;
217 _sfmlKeyToCustom[sf::Keyboard::Key::Num5] = Key::Num5;
218 _sfmlKeyToCustom[sf::Keyboard::Key::Num6] = Key::Num6;
219 _sfmlKeyToCustom[sf::Keyboard::Key::Num7] = Key::Num7;
220 _sfmlKeyToCustom[sf::Keyboard::Key::Num8] = Key::Num8;
221 _sfmlKeyToCustom[sf::Keyboard::Key::Num9] = Key::Num9;
222 _sfmlKeyToCustom[sf::Keyboard::Key::LAlt] = Key::LAlt;
223 _sfmlKeyToCustom[sf::Keyboard::Key::RAlt] = Key::RAlt;
224 _sfmlKeyToCustom[sf::Keyboard::Key::Menu] = Key::Menu;
225 _sfmlKeyToCustom[sf::Keyboard::Key::Home] = Key::Home;
226 _sfmlKeyToCustom[sf::Keyboard::Key::Down] = Key::Down;
227 _sfmlKeyToCustom[sf::Keyboard::Key::Left] = Key::Left;
228 _sfmlKeyToCustom[sf::Keyboard::Key::Comma] = Key::Comma;
229 _sfmlKeyToCustom[sf::Keyboard::Key::Enter] = Key::Enter;
230 _sfmlKeyToCustom[sf::Keyboard::Key::Slash] = Key::Slash;
231 _sfmlKeyToCustom[sf::Keyboard::Key::Grave] = Key::Grave;
232 _sfmlKeyToCustom[sf::Keyboard::Key::Equal] = Key::Equal;
233 _sfmlKeyToCustom[sf::Keyboard::Key::Space] = Key::Space;
234 _sfmlKeyToCustom[sf::Keyboard::Key::Right] = Key::Right;
235 _sfmlKeyToCustom[sf::Keyboard::Key::Pause] = Key::Pause;
236 _sfmlKeyToCustom[sf::Keyboard::Key::LShift] = Key::LShift;
237 _sfmlKeyToCustom[sf::Keyboard::Key::RShift] = Key::RShift;
238 _sfmlKeyToCustom[sf::Keyboard::Key::Escape] = Key::Escape;
239 _sfmlKeyToCustom[sf::Keyboard::Key::Period] = Key::Period;
240 _sfmlKeyToCustom[sf::Keyboard::Key::Hyphen] = Key::Hyphen;
241 _sfmlKeyToCustom[sf::Keyboard::Key::PageUp] = Key::PageUp;
242 _sfmlKeyToCustom[sf::Keyboard::Key::Insert] = Key::Insert;
243 _sfmlKeyToCustom[sf::Keyboard::Key::Delete] = Key::Delete;
244 _sfmlKeyToCustom[sf::Keyboard::Key::Divide] = Key::Divide;
245 _sfmlKeyToCustom[sf::Keyboard::Key::LSystem] = Key::LSystem;
246 _sfmlKeyToCustom[sf::Keyboard::Key::RSystem] = Key::RSystem;
247 _sfmlKeyToCustom[sf::Keyboard::Key::Numpad0] = Key::Numpad0;
248 _sfmlKeyToCustom[sf::Keyboard::Key::Numpad1] = Key::Numpad1;
249 _sfmlKeyToCustom[sf::Keyboard::Key::Numpad2] = Key::Numpad2;
250 _sfmlKeyToCustom[sf::Keyboard::Key::Numpad3] = Key::Numpad3;
251 _sfmlKeyToCustom[sf::Keyboard::Key::Numpad4] = Key::Numpad4;
252 _sfmlKeyToCustom[sf::Keyboard::Key::Numpad5] = Key::Numpad5;
253 _sfmlKeyToCustom[sf::Keyboard::Key::Numpad6] = Key::Numpad6;
254 _sfmlKeyToCustom[sf::Keyboard::Key::Numpad7] = Key::Numpad7;
255 _sfmlKeyToCustom[sf::Keyboard::Key::Numpad8] = Key::Numpad8;
256 _sfmlKeyToCustom[sf::Keyboard::Key::Numpad9] = Key::Numpad9;
257 _sfmlKeyToCustom[sf::Keyboard::Key::PageDown] = Key::PageDown;
258 _sfmlKeyToCustom[sf::Keyboard::Key::LControl] = Key::LControl;
259 _sfmlKeyToCustom[sf::Keyboard::Key::RControl] = Key::RControl;
260 _sfmlKeyToCustom[sf::Keyboard::Key::LBracket] = Key::LBracket;
261 _sfmlKeyToCustom[sf::Keyboard::Key::RBracket] = Key::RBracket;
262 _sfmlKeyToCustom[sf::Keyboard::Key::Subtract] = Key::Subtract;
263 _sfmlKeyToCustom[sf::Keyboard::Key::Multiply] = Key::Multiply;
264 _sfmlKeyToCustom[sf::Keyboard::Key::Semicolon] = Key::Semicolon;
265 _sfmlKeyToCustom[sf::Keyboard::Key::Backslash] = Key::Backslash;
266 _sfmlKeyToCustom[sf::Keyboard::Key::Backspace] = Key::Backspace;
267 _sfmlKeyToCustom[sf::Keyboard::Key::Apostrophe] = Key::Apostrophe;
268
269
270 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Unknown] = Key::Unknown;
271 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::A] = Key::A;
272 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::B] = Key::B;
273 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::C] = Key::C;
274 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::D] = Key::D;
275 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::E] = Key::E;
276 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::F] = Key::F;
277 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::G] = Key::G;
278 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::H] = Key::H;
279 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::I] = Key::I;
280 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::J] = Key::J;
281 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::K] = Key::K;
282 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::L] = Key::L;
283 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::M] = Key::M;
284 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::N] = Key::N;
285 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::O] = Key::O;
286 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::P] = Key::P;
287 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Q] = Key::Q;
288 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::R] = Key::R;
289 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::S] = Key::S;
290 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::T] = Key::T;
291 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::U] = Key::U;
292 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::V] = Key::V;
293 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::W] = Key::W;
294 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::X] = Key::X;
295 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Y] = Key::Y;
296 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Z] = Key::Z;
297 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Up] = Key::Up;
298 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::F1] = Key::F1;
299 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::F2] = Key::F2;
300 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::F3] = Key::F3;
301 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::F4] = Key::F4;
302 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::F5] = Key::F5;
303 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::F6] = Key::F6;
304 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::F7] = Key::F7;
305 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::F8] = Key::F8;
306 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::F9] = Key::F9;
307 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::F10] = Key::F10;
308 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::F11] = Key::F11;
309 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::F12] = Key::F12;
310 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::F13] = Key::F13;
311 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::F14] = Key::F14;
312 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::F15] = Key::F15;
313 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::F16] = Key::F16;
314 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::F17] = Key::F17;
315 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::F18] = Key::F18;
316 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::F19] = Key::F19;
317 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::F20] = Key::F20;
318 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::F21] = Key::F21;
319 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::F22] = Key::F22;
320 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::F23] = Key::F23;
321 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::F24] = Key::F24;
322 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Tab] = Key::Tab;
323 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::End] = Key::End;
324 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Cut] = Key::Cut;
325 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Num0] = Key::Num0;
326 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Num1] = Key::Num1;
327 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Num2] = Key::Num2;
328 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Num3] = Key::Num3;
329 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Num4] = Key::Num4;
330 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Num5] = Key::Num5;
331 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Num6] = Key::Num6;
332 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Num7] = Key::Num7;
333 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Num8] = Key::Num8;
334 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Num9] = Key::Num9;
335 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::LAlt] = Key::LAlt;
336 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::RAlt] = Key::RAlt;
337 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Menu] = Key::Menu;
338 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Home] = Key::Home;
339 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Down] = Key::Down;
340 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Copy] = Key::Copy;
341 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Redo] = Key::Redo;
342 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Undo] = Key::Undo;
343 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Help] = Key::Help;
344 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Back] = Key::Back;
345 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Stop] = Key::Stop;
346 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Left] = Key::Left;
347 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Comma] = Key::Comma;
348 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Enter] = Key::Enter;
349 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Slash] = Key::Slash;
350 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Grave] = Key::Grave;
351 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Equal] = Key::Equal;
352 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Space] = Key::Space;
353 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Right] = Key::Right;
354 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Pause] = Key::Pause;
355 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Paste] = Key::Paste;
356 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::LShift] = Key::LShift;
357 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::RShift] = Key::RShift;
358 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Escape] = Key::Escape;
359 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Period] = Key::Period;
360 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Hyphen] = Key::Hyphen;
361 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::PageUp] = Key::PageUp;
362 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Insert] = Key::Insert;
363 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Delete] = Key::Delete;
364 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Search] = Key::Search;
365 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Select] = Key::Select;
366 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::NumpadPlus] = Key::Add;
367 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::LSystem] = Key::LSystem;
368 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::RSystem] = Key::RSystem;
369 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Numpad0] = Key::Numpad0;
370 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Numpad1] = Key::Numpad1;
371 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Numpad2] = Key::Numpad2;
372 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Numpad3] = Key::Numpad3;
373 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Numpad4] = Key::Numpad4;
374 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Numpad5] = Key::Numpad5;
375 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Numpad6] = Key::Numpad6;
376 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Numpad7] = Key::Numpad7;
377 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Numpad8] = Key::Numpad8;
378 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Numpad9] = Key::Numpad9;
379 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Forward] = Key::Forward;
380 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Refresh] = Key::Refresh;
381 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Execute] = Key::Execute;
382 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::HomePage] = Key::HomePage;
383 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::VolumeUp] = Key::VolumeUp;
384 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::PageDown] = Key::PageDown;
385 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::LControl] = Key::LControl;
386 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::RControl] = Key::RControl;
387 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::LBracket] = Key::LBracket;
388 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::RBracket] = Key::RBracket;
389 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::CapsLock] = Key::CapsLock;
390 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::NumpadDivide] = Key::Divide;
391 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Semicolon] = Key::Semicolon;
392 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Backslash] = Key::Backslash;
393 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Backspace] = Key::Backspace;
394 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Favorites] = Key::Favorites;
395 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::MediaStop] = Key::MediaStop;
396 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::NumpadMinus] = Key::Subtract;
397 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::LaunchMail] = Key::LaunchMail;
398 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::VolumeDown] = Key::VolumeDown;
399 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::ModeChange] = Key::ModeChange;
400 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::VolumeMute] = Key::VolumeMute;
401 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Apostrophe] = Key::Apostrophe;
402 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::NumpadEqual] = Key::NumpadEqual;
403 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::NumpadEnter] = Key::NumpadEnter;
404 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::Application] = Key::Application;
405 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::NumpadMultiply] = Key::Multiply;
406 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::NumpadDecimal] = Key::NumpadDecimal;
407 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::NonUsBackslash] = Key::NonUsBackslash;
408 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::MediaPlayPause] = Key::MediaPlayPause;
409 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::MediaNextTrack] = Key::MediaNextTrack;
410 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::LaunchMediaSelect] = Key::LaunchMediaSelect;
411 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::LaunchApplication1] = Key::LaunchApplication1;
412 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::LaunchApplication2] = Key::LaunchApplication2;
413 _sfmlScanCodeToCustom[sf::Keyboard::Scancode::MediaPreviousTrack] = Key::MediaPreviousTrack;
414};
415
417{
418
419 std::optional<sf::Keyboard::Key> sfKey = Utilities::unCast<sf::Keyboard::Key>(sfmlKey, false);
420 std::optional<sf::Keyboard::Scancode> sfCode = Utilities::unCast<sf::Keyboard::Scancode>(sfmlKey, false);
421
422 if (sfKey.has_value()) {
423 auto it = _sfmlKeyToCustom.find(sfKey.value());
424 if (it != _sfmlKeyToCustom.end()) {
425 return it->second;
426 }
427 return Key::Unknown;
428 } else if (sfCode.has_value()) {
429 auto it = _sfmlScanCodeToCustom.find(sfCode.value());
430 if (it != _sfmlScanCodeToCustom.end()) {
431 return it->second;
432 }
433 return Key::Unknown;
434 } else {
435 return Key::Unknown;
436 }
437
438}
439
440const std::string GUI::ECS::Systems::KeyMapper::stringKey(const std::any &keyCode) const
441{
442 return stringKey(mapKey(keyCode));
443}
444
446{
447 std::unordered_map<Key, std::string>::const_iterator it = keyCodeEquivalence.find(key);
448 if (it != keyCodeEquivalence.end()) {
449 return it->second;
450 }
451 return "Unknown";
452}
453
454const std::string GUI::ECS::Systems::KeyMapper::getInfo(const unsigned int indent) const
455{
456
457 std::string indentation = "";
458 for (unsigned int i = 0; i < indent; ++i) {
459 indentation += "\t";
460 }
461 std::string result = indentation + "KeyMapper:\n";
462 result += indentation + "- Entity Id: " + Recoded::myToString(getEntityNodeId()) + "\n";
463 result += indentation + "- Sfml Key to Custom Key Mapping: {\n";
464 if (SHOWKEYS) {
465 for (const auto &it : _sfmlKeyToCustom) {
466 result += indentation + "\t- " + stringKey(it.first) + " -> " + stringKey(it.second) + "\n";
467 }
468 } else {
469 result += indentation + "\t- List dump hidden by SHOWKEYS toggle\n";
470 }
471 result += indentation + "}\n";
472 result += indentation + "- Sfml Scan Code to Custom Key Mapping: {\n";
473 if (SHOWKEYS) {
474 for (const auto &it : _sfmlScanCodeToCustom) {
475 result += indentation + "\t- " + stringKey(it.first) + " -> " + stringKey(it.second) + "\n";
476 }
477 } else {
478 result += indentation + "\t- List dump hidden by SHOWKEYS toggle\n";
479 }
480 result += indentation + "}\n";
481 result += indentation + "- Key code Equivalence: {\n";
482 if (SHOWKEYS) {
483 for (const std::pair<GUI::ECS::Systems::Key, std::string> &it : keyCodeEquivalence) {
484 result += indentation + "\t- " + stringKey(it.first) + " -> " + it.second + "\n";
485 }
486 } else {
487 result += indentation + "\t- List dump hidden by SHOWKEYS toggle\n";
488 }
489 result += indentation + "}\n";
490 return result;
491}
492
493std::ostream &GUI::ECS::Systems::operator<<(std::ostream &os, const GUI::ECS::Systems::KeyMapper &item)
494{
495 os << item.getInfo();
496 return os;
497}
498
499std::ostream &GUI::ECS::Systems::operator<<(std::ostream &os, const Key &item)
500{
501 std::unordered_map<Key, std::string>::const_iterator it = keyCodeEquivalence.find(item);
502 if (it != keyCodeEquivalence.end()) {
503 os << "'" << it->second << "'";
504 } else {
505 os << "'Unknown Key'";
506 }
507 return os;
508}
509
File in charge of containing code to provide an abstraction layer between the SFML keys and the inter...
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
const std::string myToString(const Rect< RectType > &rectangle)
Converts a Rect<T> object to its string representation.
Definition Rect.hpp:223
std::optional< T > unCast(const std::any &classNode, const bool raiseOnError=true, const std::string customErrorMessage="")
Casts the content of a std::any back to its original type.
Definition UnCast.hpp:65