From 1ecbc8f95f9b2cdcaeddf7f8594b93d805aa75fa Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Tue, 10 Mar 2015 08:05:28 +0100 Subject: update 3rdparty libs --- 3rdparty/bgfx/examples/common/entry/entry.cpp | 37 +++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to '3rdparty/bgfx/examples/common/entry/entry.cpp') 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) ) -- cgit v1.2.3-70-g09d2