diff options
-rw-r--r-- | indra/llwindow/llopenglview-objc.mm | 24 | ||||
-rwxr-xr-x | indra/llwindow/llwindowmacosx.cpp | 1 | ||||
-rw-r--r-- | indra/media_plugins/cef/media_plugin_cef.cpp | 41 |
3 files changed, 48 insertions, 18 deletions
diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm index 7bb20240d2..81e90accb7 100644 --- a/indra/llwindow/llopenglview-objc.mm +++ b/indra/llwindow/llopenglview-objc.mm @@ -28,6 +28,18 @@ #include "llwindowmacosx-objc.h" #import "llappdelegate-objc.h" + + +//--------------------------- +// Coppied from indra_constants.h +//#include "indra_constats.h" +const uint32_t MASK_CONTROL = 0x0001; // Mapped to cmd on Macs +const uint32_t MASK_ALT = 0x0002; +const uint32_t MASK_SHIFT = 0x0004; +//const uint32_t MASK_MAC_CONTROL = 0x0008; // Un-mapped Ctrl key on Macs, not used on Windows + +//--------------------------- + @implementation NSScreen (PointConversion) + (NSScreen *)currentScreenForMouseLocation @@ -70,7 +82,17 @@ void extractKeyDataFromEvent (NSEvent *theEvent, NativeKeyEventData * eventData) } eventData->mKeyEvent = NativeKeyEventData::KEYUNKNOWN; eventData->mKeyCode = [theEvent keyCode]; - eventData->mKeyModifiers = [theEvent modifierFlags]; + + unsigned int modifiers = [theEvent modifierFlags]; + + if (modifiers & (NSAlphaShiftKeyMask | NSShiftKeyMask)) + modifiers |= MASK_SHIFT; + if (modifiers & NSAlternateKeyMask) + modifiers |= MASK_ALT; + if (modifiers & NSControlKeyMask) + modifiers |= MASK_CONTROL; + + eventData->mKeyModifiers = modifiers; eventData->mScanCode = [theEvent keyCode ]; eventData->mKeyboardType = 0; } diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp index 2a104c1877..7bc5d263e4 100755 --- a/indra/llwindow/llwindowmacosx.cpp +++ b/indra/llwindow/llwindowmacosx.cpp @@ -1733,6 +1733,7 @@ LLSD LLWindowMacOSX::getNativeKeyData() result["modifiers"] = (S32)(mRawKeyEvent->mKeyModifiers); result["keyboard_type"] = (S32)(mRawKeyEvent->mKeyboardType); + #if 0 // This causes trouble for control characters -- apparently character codes less than 32 (escape, control-A, etc) // cause llsd serialization to create XML that the llsd deserializer won't parse! diff --git a/indra/media_plugins/cef/media_plugin_cef.cpp b/indra/media_plugins/cef/media_plugin_cef.cpp index 75e1055d2d..7d60c1a5ed 100644 --- a/indra/media_plugins/cef/media_plugin_cef.cpp +++ b/indra/media_plugins/cef/media_plugin_cef.cpp @@ -128,7 +128,7 @@ MediaPluginBase(host_send_func, host_user_data) // MediaPluginCEF::~MediaPluginCEF() { - mLLCEFLib->requestExit(); + mLLCEFLib->reset(); } //////////////////////////////////////////////////////////////////////////////// @@ -532,12 +532,11 @@ void MediaPluginCEF::receiveMessage(const char* message_string) } else if (message_name == "scroll_event") { - S32 x = message_in.getValueS32("y"); S32 y = message_in.getValueS32("y"); const int scaling_factor = 40; y *= -scaling_factor; - mLLCEFLib->mouseWheel(x, y); + mLLCEFLib->mouseWheel(y); } else if (message_name == "text_event") { @@ -577,9 +576,9 @@ void MediaPluginCEF::receiveMessage(const char* message_string) { key_event = LLCEFLib::KE_KEY_REPEAT; } - + keyEvent(key_event, key, LLCEFLib::KM_MODIFIER_NONE, native_key_data); - + #endif #elif LL_WINDOWS std::string event = message_in.getValue("event"); @@ -721,7 +720,7 @@ void MediaPluginCEF::deserializeKeyboardData(LLSD native_key_data, uint32_t& nat //////////////////////////////////////////////////////////////////////////////// // -void MediaPluginCEF::keyEvent(LLCEFLib::EKeyEvent key_event, int key, LLCEFLib::EKeyboardModifier modifiers, LLSD native_key_data = LLSD::emptyMap()) +void MediaPluginCEF::keyEvent(LLCEFLib::EKeyEvent key_event, int key, LLCEFLib::EKeyboardModifier modifiers_x, LLSD native_key_data = LLSD::emptyMap()) { #if LL_DARWIN std::string utf8_text; @@ -730,16 +729,25 @@ void MediaPluginCEF::keyEvent(LLCEFLib::EKeyEvent key_event, int key, LLCEFLib:: uint32_t native_scan_code = native_key_data["scan_code"].asInteger(); uint32_t native_virtual_key = native_key_data["key_code"].asInteger(); uint32_t native_modifiers = native_key_data["modifiers"].asInteger(); - - - + if (key < 128) { utf8_text = (char)native_virtual_key; } - + + unsigned int modifers = LLCEFLib::KM_MODIFIER_NONE; + + if (native_modifiers & (MASK_CONTROL | MASK_MAC_CONTROL)) + modifers |= LLCEFLib::KM_MODIFIER_CONTROL; + if (native_modifiers & MASK_SHIFT) + modifers |= LLCEFLib::KM_MODIFIER_SHIFT; + if (native_modifiers & MASK_ALT) + modifers |= LLCEFLib::KM_MODIFIER_ALT; + + //modifers |= LLCEFLib::KM_MODIFIER_META; + switch ((KEY)key) - + { case KEY_BACKSPACE: utf8_text = (char)8; break; case KEY_TAB: utf8_text = (char)9; break; @@ -751,16 +759,15 @@ void MediaPluginCEF::keyEvent(LLCEFLib::EKeyEvent key_event, int key, LLCEFLib:: break; } - mLLCEFLib->keyboardEvent(key_event, native_char_code, - utf8_text.c_str(), modifiers, - native_scan_code, native_virtual_key, - native_modifiers); - + mLLCEFLib->keyboardEvent(key_event, native_char_code, utf8_text.c_str(), + static_cast<LLCEFLib::EKeyboardModifier>(modifers), + native_scan_code, native_virtual_key, native_modifiers); + #elif LL_WINDOWS U32 msg = ll_U32_from_sd(native_key_data["msg"]); U32 wparam = ll_U32_from_sd(native_key_data["w_param"]); U64 lparam = ll_U32_from_sd(native_key_data["l_param"]); - + mLLCEFLib->nativeKeyboardEvent(msg, wparam, lparam); #endif }; |