diff options
author | 2015-03-10 08:05:28 +0100 | |
---|---|---|
committer | 2015-03-10 08:05:28 +0100 | |
commit | 1ecbc8f95f9b2cdcaeddf7f8594b93d805aa75fa (patch) | |
tree | b8548463867f481d3f44d3ee33e927f2a8a65da8 /3rdparty/bgfx/examples/common/entry/entry.cpp | |
parent | 1c885a2014132f39b2526f66bcc2716bc666f244 (diff) |
update 3rdparty libs
Diffstat (limited to '3rdparty/bgfx/examples/common/entry/entry.cpp')
-rw-r--r-- | 3rdparty/bgfx/examples/common/entry/entry.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/3rdparty/bgfx/examples/common/entry/entry.cpp b/3rdparty/bgfx/examples/common/entry/entry.cpp index 947d4204666..1007787a0bd 100644 --- a/3rdparty/bgfx/examples/common/entry/entry.cpp +++ b/3rdparty/bgfx/examples/common/entry/entry.cpp @@ -34,6 +34,43 @@ namespace entry } #endif // ENTRY_CONFIG_IMPLEMENT_DEFAULT_ALLOCATOR + char keyToAscii(Key::Enum _key, uint8_t _modifiers) + { + const bool isAscii = (Key::Key0 <= _key && _key <= Key::KeyZ) + || (Key::Esc <= _key && _key <= Key::Minus); + if (!isAscii) + { + return '\0'; + } + + const bool isNumber = (Key::Key0 <= _key && _key <= Key::Key9); + if (isNumber) + { + return '0' + (_key - Key::Key0); + } + + const bool isChar = (Key::KeyA <= _key && _key <= Key::KeyZ); + if (isChar) + { + enum { ShiftMask = Modifier::LeftShift|Modifier::RightShift }; + + const bool shift = !!(_modifiers&ShiftMask); + return (shift ? 'A' : 'a') + (_key - Key::KeyA); + } + + switch (_key) + { + case Key::Esc: { return 0x1b; } break; + case Key::Return: { return 0x0d; } break; + case Key::Tab: { return 0x09; } break; + case Key::Space: { return 0xa0; } break; + case Key::Backspace: { return 0x08; } break; + case Key::Plus: { return 0x2b; } break; + case Key::Minus: { return 0x2d; } break; + default: { return '\0'; } break; + } + } + bool setOrToggle(uint32_t& _flags, const char* _name, uint32_t _bit, int _first, int _argc, char const* const* _argv) { if (0 == strcmp(_argv[_first], _name) ) |