void MediaPluginCEF::unicodeInput(const std::string &utf8str, LLCEFLib::EKeyboardModifier modifiers, LLSD native_key_data = LLSD::emptyMap()) { #if LL_DARWIN //mLLCEFLib->keyPress(utf8str[0], true); //mLLCEFLib->keyboardEvent(LLCEFLib::KE_KEY_DOWN, (uint32_t)(utf8str[0]), 0, LLCEFLib::KM_MODIFIER_NONE, 0, 0, 0); if (!native_key_data.has("event_chars") || !native_key_data.has("event_umodchars") || !native_key_data.has("event_keycode") || !native_key_data.has("event_modifiers")) return; uint32_t unicodeChar = native_key_data["event_chars"].asInteger(); uint32_t unmodifiedChar = native_key_data["event_umodchars"].asInteger(); uint32_t keyCode = native_key_data["event_keycode"].asInteger(); uint32_t rawmodifiers = native_key_data["event_modifiers"].asInteger(); mLLCEFLib->injectUnicodeText(unicodeChar, unmodifiedChar, keyCode, rawmodifiers); #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); #elif LL_LINUX uint32_t native_scan_code = 0; uint32_t native_virtual_key = 0; uint32_t native_modifiers = 0; deserializeKeyboardData(native_key_data, native_scan_code, native_virtual_key, native_modifiers); mLLCEFLib->nativeKeyboardEvent(LLCEFLib::KE_KEY_DOWN, native_scan_code, native_virtual_key, native_modifiers); mLLCEFLib->nativeKeyboardEvent(LLCEFLib::KE_KEY_UP, native_scan_code, native_virtual_key, native_modifiers); #endif };
void keyEvent(LLQtWebKit::EKeyEvent key_event, int key, LLQtWebKit::EKeyboardModifier modifiers, LLSD native_key_data = LLSD::emptyMap()) { // The incoming values for 'key' will be the ones from indra_constants.h std::string utf8_text; if(key < KEY_SPECIAL) { // Low-ascii characters need to get passed through. utf8_text = (char)key; } // Any special-case handling we want to do for particular keys... switch((KEY)key) { // ASCII codes for some standard keys case LLQtWebKit::KEY_BACKSPACE: utf8_text = (char)8; break; case LLQtWebKit::KEY_TAB: utf8_text = (char)9; break; case LLQtWebKit::KEY_RETURN: utf8_text = (char)13; break; case LLQtWebKit::KEY_PAD_RETURN: utf8_text = (char)13; break; case LLQtWebKit::KEY_ESCAPE: utf8_text = (char)27; break; default: break; } // std::cerr << "key event " << (int)key_event << ", native_key_data = " << native_key_data << std::endl; uint32_t native_scan_code = 0; uint32_t native_virtual_key = 0; uint32_t native_modifiers = 0; deserializeKeyboardData( native_key_data, native_scan_code, native_virtual_key, native_modifiers ); LLQtWebKit::getInstance()->keyboardEvent( mBrowserWindowId, key_event, (uint32_t)key, utf8_text.c_str(), modifiers, native_scan_code, native_virtual_key, native_modifiers); checkEditState(); };
void unicodeInput( const std::string &utf8str, LLQtWebKit::EKeyboardModifier modifiers, LLSD native_key_data = LLSD::emptyMap()) { uint32_t key = LLQtWebKit::KEY_NONE; // std::cerr << "unicode input, native_key_data = " << native_key_data << std::endl; if(utf8str.size() == 1) { // The only way a utf8 string can be one byte long is if it's actually a single 7-bit ascii character. // In this case, use it as the key value. key = utf8str[0]; } uint32_t native_scan_code = 0; uint32_t native_virtual_key = 0; uint32_t native_modifiers = 0; deserializeKeyboardData( native_key_data, native_scan_code, native_virtual_key, native_modifiers ); LLQtWebKit::getInstance()->keyboardEvent( mBrowserWindowId, LLQtWebKit::KE_KEY_DOWN, (uint32_t)key, utf8str.c_str(), modifiers, native_scan_code, native_virtual_key, native_modifiers); LLQtWebKit::getInstance()->keyboardEvent( mBrowserWindowId, LLQtWebKit::KE_KEY_UP, (uint32_t)key, utf8str.c_str(), modifiers, native_scan_code, native_virtual_key, native_modifiers); checkEditState(); };
void MediaPluginCEF::keyEvent(LLCEFLib::EKeyEvent key_event, int key, LLCEFLib::EKeyboardModifier modifiers_x, LLSD native_key_data = LLSD::emptyMap()) { #if LL_DARWIN if (!native_key_data.has("event_type") || !native_key_data.has("event_modifiers") || !native_key_data.has("event_keycode") || !native_key_data.has("event_isrepeat")) return; uint32_t eventType = native_key_data["event_type"].asInteger(); if (!eventType) return; uint32_t eventModifiers = native_key_data["event_modifiers"].asInteger(); uint32_t eventKeycode = native_key_data["event_keycode"].asInteger(); char eventChars = static_cast<char>(native_key_data["event_chars"].isUndefined() ? 0 : native_key_data["event_chars"].asInteger()); char eventUChars = static_cast<char>(native_key_data["event_umodchars"].isUndefined() ? 0 : native_key_data["event_umodchars"].asInteger()); bool eventIsRepeat = native_key_data["event_isrepeat"].asBoolean(); mLLCEFLib->keyboardEventOSX(eventType, eventModifiers, (eventChars) ? &eventChars : NULL, (eventUChars) ? &eventUChars : NULL, eventIsRepeat, eventKeycode); #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); #elif LL_LINUX uint32_t native_scan_code = 0; uint32_t native_virtual_key = 0; uint32_t native_modifiers = 0; deserializeKeyboardData(native_key_data, native_scan_code, native_virtual_key, native_modifiers); mLLCEFLib->nativeKeyboardEvent(key_event, native_scan_code, native_virtual_key, native_modifiers); #endif }