diff options
Diffstat (limited to '3rdparty/bgfx/examples/common/entry/entry_osx.mm')
-rw-r--r-- | 3rdparty/bgfx/examples/common/entry/entry_osx.mm | 58 |
1 files changed, 54 insertions, 4 deletions
diff --git a/3rdparty/bgfx/examples/common/entry/entry_osx.mm b/3rdparty/bgfx/examples/common/entry/entry_osx.mm index 89e7c4814d1..5b59fe06c84 100644 --- a/3rdparty/bgfx/examples/common/entry/entry_osx.mm +++ b/3rdparty/bgfx/examples/common/entry/entry_osx.mm @@ -9,7 +9,7 @@ #import <Cocoa/Cocoa.h> -#include <bgfxplatform.h> +#include <bgfx/bgfxplatform.h> #include <bx/uint32_t.h> #include <bx/thread.h> @@ -39,6 +39,8 @@ - (void)windowWillClose:(NSNotification*)notification; - (BOOL)windowShouldClose:(NSWindow*)window; - (void)windowDidResize:(NSNotification*)notification; +- (void)windowDidBecomeKey:(NSNotification *)notification; +- (void)windowDidResignKey:(NSNotification *)notification; @end @@ -86,8 +88,8 @@ namespace entry , m_fullscreen(false) { s_translateKey[27] = Key::Esc; - s_translateKey[13] = Key::Return; - s_translateKey[9] = Key::Tab; + s_translateKey[uint8_t('\n')] = Key::Return; + s_translateKey[uint8_t('\t')] = Key::Tab; s_translateKey[127] = Key::Backspace; s_translateKey[uint8_t(' ')] = Key::Space; @@ -96,6 +98,28 @@ namespace entry s_translateKey[uint8_t('_')] = s_translateKey[uint8_t('-')] = Key::Minus; + s_translateKey[uint8_t('~')] = + s_translateKey[uint8_t('`')] = Key::Tilde; + + s_translateKey[uint8_t(':')] = + s_translateKey[uint8_t(';')] = Key::Semicolon; + s_translateKey[uint8_t('"')] = + s_translateKey[uint8_t('\'')] = Key::Quote; + + s_translateKey[uint8_t('{')] = + s_translateKey[uint8_t('[')] = Key::LeftBracket; + s_translateKey[uint8_t('}')] = + s_translateKey[uint8_t(']')] = Key::RightBracket; + + s_translateKey[uint8_t('<')] = + s_translateKey[uint8_t(',')] = Key::Comma; + s_translateKey[uint8_t('>')] = + s_translateKey[uint8_t('.')] = Key::Period; + s_translateKey[uint8_t('?')] = + s_translateKey[uint8_t('/')] = Key::Slash; + s_translateKey[uint8_t('|')] = + s_translateKey[uint8_t('\\')] = Key::Backslash; + s_translateKey[uint8_t('0')] = Key::Key0; s_translateKey[uint8_t('1')] = Key::Key1; s_translateKey[uint8_t('2')] = Key::Key2; @@ -249,7 +273,7 @@ namespace entry { // TODO: remove! // Command + Left Mouse Button acts as middle! This just a temporary solution! - // This is becase the average OSX user doesn't have middle mouse click. + // This is because the average OSX user doesn't have middle mouse click. MouseButton::Enum mb = ([event modifierFlags] & NSCommandKeyMask) ? MouseButton::Middle : MouseButton::Left; m_eventQueue.postMouseEvent(s_defaultWindow, m_mx, m_my, m_scroll, mb, true); break; @@ -362,6 +386,18 @@ namespace entry m_eventQueue.postMouseEvent(s_defaultWindow, m_mx, m_my, m_scroll, MouseButton::Right, false); } + void windowDidBecomeKey() + { + m_eventQueue.postSuspendEvent(s_defaultWindow, Suspend::WillResume); + m_eventQueue.postSuspendEvent(s_defaultWindow, Suspend::DidResume); + } + + void windowDidResignKey() + { + m_eventQueue.postSuspendEvent(s_defaultWindow, Suspend::WillSuspend); + m_eventQueue.postSuspendEvent(s_defaultWindow, Suspend::DidSuspend); + } + int32_t run(int _argc, char** _argv) { [NSApplication sharedApplication]; @@ -701,6 +737,20 @@ namespace entry s_ctx.windowDidResize(); } +- (void)windowDidBecomeKey:(NSNotification*)notification +{ + BX_UNUSED(notification); + using namespace entry; + s_ctx.windowDidBecomeKey(); +} + +- (void)windowDidResignKey:(NSNotification*)notification +{ + BX_UNUSED(notification); + using namespace entry; + s_ctx.windowDidResignKey(); +} + @end int main(int _argc, char** _argv) |