///////////////////////////////////////////////////////
| 635 | |
| 636 | //////////////////////////////////////////////////////////// |
| 637 | String KeyboardImpl::getDescription(Keyboard::Scancode code) |
| 638 | { |
| 639 | bool checkInput = true; |
| 640 | |
| 641 | // these scancodes actually correspond to keys with input |
| 642 | // but we want to return their description, not their behaviour |
| 643 | // clang-format off |
| 644 | if (code == Keyboard::Scan::Enter || |
| 645 | code == Keyboard::Scan::Escape || |
| 646 | code == Keyboard::Scan::Backspace || |
| 647 | code == Keyboard::Scan::Tab || |
| 648 | code == Keyboard::Scan::Space || |
| 649 | code == Keyboard::Scan::ScrollLock || |
| 650 | code == Keyboard::Scan::Pause || |
| 651 | code == Keyboard::Scan::Delete || |
| 652 | code == Keyboard::Scan::NumpadDivide || |
| 653 | code == Keyboard::Scan::NumpadMultiply || |
| 654 | code == Keyboard::Scan::NumpadMinus || |
| 655 | code == Keyboard::Scan::NumpadPlus || |
| 656 | code == Keyboard::Scan::NumpadEqual || |
| 657 | code == Keyboard::Scan::NumpadEnter || |
| 658 | code == Keyboard::Scan::NumpadDecimal) |
| 659 | // clang-format on |
| 660 | { |
| 661 | checkInput = false; |
| 662 | } |
| 663 | |
| 664 | if (checkInput) |
| 665 | { |
| 666 | const KeySym keysym = scancodeToKeySym(code); |
| 667 | const char32_t unicode = keysymToUnicode(keysym); |
| 668 | |
| 669 | if (unicode != 0) |
| 670 | return {unicode}; |
| 671 | } |
| 672 | |
| 673 | // Fallback to our best guess for the keys that are known to be independent of the layout. |
| 674 | // clang-format off |
| 675 | switch (code) |
| 676 | { |
| 677 | case Keyboard::Scan::Enter: return "Enter"; |
| 678 | case Keyboard::Scan::Escape: return "Escape"; |
| 679 | case Keyboard::Scan::Backspace: return "Backspace"; |
| 680 | case Keyboard::Scan::Tab: return "Tab"; |
| 681 | case Keyboard::Scan::Space: return "Space"; |
| 682 | |
| 683 | case Keyboard::Scan::F1: return "F1"; |
| 684 | case Keyboard::Scan::F2: return "F2"; |
| 685 | case Keyboard::Scan::F3: return "F3"; |
| 686 | case Keyboard::Scan::F4: return "F4"; |
| 687 | case Keyboard::Scan::F5: return "F5"; |
| 688 | case Keyboard::Scan::F6: return "F6"; |
| 689 | case Keyboard::Scan::F7: return "F7"; |
| 690 | case Keyboard::Scan::F8: return "F8"; |
| 691 | case Keyboard::Scan::F9: return "F9"; |
| 692 | case Keyboard::Scan::F10: return "F10"; |
| 693 | case Keyboard::Scan::F11: return "F11"; |
| 694 | case Keyboard::Scan::F12: return "F12"; |
nothing calls this directly
no test coverage detected