From fae9c8fe864278b20dfdb7caae3fbc50c779947b Mon Sep 17 00:00:00 2001 From: Monroe Linden Date: Mon, 18 Jan 2010 17:58:12 -0800 Subject: Added getNativeKeyData() function to LLWindow and LLWindowMacOSX. Added an LLSD argument to LLPluginClassMedia::keyEvent() and LLPluginClassMedia::textInput() which contains the native key data. Made LLViewerMediaImpl retrieve the native key data and pass it to keyEvent and textInput. Added a native_key_data parameter to the text_event and key_event messages. Made the webkit plugin extract the native_key_data parameter and pass it to the internal keyEvent() and unicodeInput() functions. Fixed LLMediaPluginTest to match function signature change to LLPluginClassMedia::keyEvent(). --- indra/media_plugins/webkit/media_plugin_webkit.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'indra/media_plugins') diff --git a/indra/media_plugins/webkit/media_plugin_webkit.cpp b/indra/media_plugins/webkit/media_plugin_webkit.cpp index 084cdd9561..3248f1dab5 100644 --- a/indra/media_plugins/webkit/media_plugin_webkit.cpp +++ b/indra/media_plugins/webkit/media_plugin_webkit.cpp @@ -464,7 +464,7 @@ private: //////////////////////////////////////////////////////////////////////////////// // - void keyEvent(LLQtWebKit::EKeyEvent key_event, int key, LLQtWebKit::EKeyboardModifier modifiers) + void keyEvent(LLQtWebKit::EKeyEvent key_event, int key, LLQtWebKit::EKeyboardModifier modifiers, LLSD native_key_data = LLSD::emptyMap()) { int llqt_key; @@ -515,6 +515,8 @@ private: } // std::cerr << "keypress, original code = 0x" << std::hex << key << ", converted code = 0x" << std::hex << llqt_key << std::dec << std::endl; + + std::cerr << "key event " << (int)key_event << ", native_key_data = " << native_key_data << std::endl; if(llqt_key != 0) { @@ -526,10 +528,12 @@ private: //////////////////////////////////////////////////////////////////////////////// // - void unicodeInput( const std::string &utf8str, LLQtWebKit::EKeyboardModifier modifiers) + void unicodeInput( const std::string &utf8str, LLQtWebKit::EKeyboardModifier modifiers, LLSD native_key_data = LLSD::emptyMap()) { LLWString wstr = utf8str_to_wstring(utf8str); + std::cerr << "unicode input, native_key_data = " << native_key_data << std::endl; + unsigned int i; for(i=0; i < wstr.size(); i++) { @@ -843,6 +847,7 @@ void MediaPluginWebKit::receiveMessage(const char *message_string) std::string event = message_in.getValue("event"); S32 key = message_in.getValueS32("key"); std::string modifiers = message_in.getValue("modifiers"); + LLSD native_key_data = message_in.getValueLLSD("native_key_data"); // Treat unknown events as key-up for safety. LLQtWebKit::EKeyEvent key_event = LLQtWebKit::KE_KEY_UP; @@ -855,14 +860,15 @@ void MediaPluginWebKit::receiveMessage(const char *message_string) key_event = LLQtWebKit::KE_KEY_REPEAT; } - keyEvent(key_event, key, decodeModifiers(modifiers)); + keyEvent(key_event, key, decodeModifiers(modifiers), native_key_data); } else if(message_name == "text_event") { std::string text = message_in.getValue("text"); std::string modifiers = message_in.getValue("modifiers"); + LLSD native_key_data = message_in.getValueLLSD("native_key_data"); - unicodeInput(text, decodeModifiers(modifiers)); + unicodeInput(text, decodeModifiers(modifiers), native_key_data); } if(message_name == "edit_cut") { -- cgit v1.2.3 From 572b8fc518ee45cdf5403f58b18e0000868696cb Mon Sep 17 00:00:00 2001 From: Monroe Linden Date: Tue, 19 Jan 2010 21:55:51 -0800 Subject: Changes to llqtwebkit keyboard event api. Reference to new mac build of llqtwebkit (from revision 5e61bf24915f in https://hg.lindenlab.com/monroe/llqtwebkit-4.6). --- indra/media_plugins/webkit/media_plugin_webkit.cpp | 109 +++++++++------------ 1 file changed, 47 insertions(+), 62 deletions(-) (limited to 'indra/media_plugins') diff --git a/indra/media_plugins/webkit/media_plugin_webkit.cpp b/indra/media_plugins/webkit/media_plugin_webkit.cpp index 3248f1dab5..e95e9e3b34 100644 --- a/indra/media_plugins/webkit/media_plugin_webkit.cpp +++ b/indra/media_plugins/webkit/media_plugin_webkit.cpp @@ -466,62 +466,43 @@ private: // void keyEvent(LLQtWebKit::EKeyEvent key_event, int key, LLQtWebKit::EKeyboardModifier modifiers, LLSD native_key_data = LLSD::emptyMap()) { - int llqt_key; - // The incoming values for 'key' will be the ones from indra_constants.h - // the outgoing values are the ones from llqtwebkit.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) { - // This is the list that the llqtwebkit implementation actually maps into Qt keys. -// case KEY_XXX: llqt_key = LL_DOM_VK_CANCEL; break; -// case KEY_XXX: llqt_key = LL_DOM_VK_HELP; break; - case KEY_BACKSPACE: llqt_key = LL_DOM_VK_BACK_SPACE; break; - case KEY_TAB: llqt_key = LL_DOM_VK_TAB; break; -// case KEY_XXX: llqt_key = LL_DOM_VK_CLEAR; break; - case KEY_RETURN: llqt_key = LL_DOM_VK_RETURN; break; - case KEY_PAD_RETURN: llqt_key = LL_DOM_VK_ENTER; break; - case KEY_SHIFT: llqt_key = LL_DOM_VK_SHIFT; break; - case KEY_CONTROL: llqt_key = LL_DOM_VK_CONTROL; break; - case KEY_ALT: llqt_key = LL_DOM_VK_ALT; break; -// case KEY_XXX: llqt_key = LL_DOM_VK_PAUSE; break; - case KEY_CAPSLOCK: llqt_key = LL_DOM_VK_CAPS_LOCK; break; - case KEY_ESCAPE: llqt_key = LL_DOM_VK_ESCAPE; break; - case KEY_PAGE_UP: llqt_key = LL_DOM_VK_PAGE_UP; break; - case KEY_PAGE_DOWN: llqt_key = LL_DOM_VK_PAGE_DOWN; break; - case KEY_END: llqt_key = LL_DOM_VK_END; break; - case KEY_HOME: llqt_key = LL_DOM_VK_HOME; break; - case KEY_LEFT: llqt_key = LL_DOM_VK_LEFT; break; - case KEY_UP: llqt_key = LL_DOM_VK_UP; break; - case KEY_RIGHT: llqt_key = LL_DOM_VK_RIGHT; break; - case KEY_DOWN: llqt_key = LL_DOM_VK_DOWN; break; -// case KEY_XXX: llqt_key = LL_DOM_VK_PRINTSCREEN; break; - case KEY_INSERT: llqt_key = LL_DOM_VK_INSERT; break; - case KEY_DELETE: llqt_key = LL_DOM_VK_DELETE; break; -// case KEY_XXX: llqt_key = LL_DOM_VK_CONTEXT_MENU; break; + // 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: - if(key < KEY_SPECIAL) - { - // Pass the incoming key through -- it should be regular ASCII, which should be correct for webkit. - llqt_key = key; - } - else - { - // Don't pass through untranslated special keys -- they'll be all wrong. - llqt_key = 0; - } + default: break; } -// std::cerr << "keypress, original code = 0x" << std::hex << key << ", converted code = 0x" << std::hex << llqt_key << std::dec << std::endl; - - std::cerr << "key event " << (int)key_event << ", native_key_data = " << native_key_data << std::endl; +// 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; - if(llqt_key != 0) + if(native_key_data.isMap()) { - LLQtWebKit::getInstance()->keyEvent( mBrowserWindowId, key_event, llqt_key, modifiers); + native_scan_code = (uint32_t)(native_key_data["key_code"].asInteger()); + native_virtual_key = (uint32_t)(native_key_data["char_code"].asInteger()); + native_modifiers = (uint32_t)(native_key_data["modifiers"].asInteger()); } + + LLQtWebKit::getInstance()->keyboardEvent( mBrowserWindowId, key_event, (uint32_t)key, utf8_text.c_str(), modifiers, native_scan_code, native_virtual_key, native_modifiers); checkEditState(); }; @@ -529,27 +510,31 @@ private: //////////////////////////////////////////////////////////////////////////////// // void unicodeInput( const std::string &utf8str, LLQtWebKit::EKeyboardModifier modifiers, LLSD native_key_data = LLSD::emptyMap()) - { - LLWString wstr = utf8str_to_wstring(utf8str); + { + uint32_t key = LLQtWebKit::KEY_NONE; - std::cerr << "unicode input, native_key_data = " << native_key_data << std::endl; +// std::cerr << "unicode input, native_key_data = " << native_key_data << std::endl; - unsigned int i; - for(i=0; i < wstr.size(); i++) + if(utf8str.size() == 1) { -// std::cerr << "unicode input, code = 0x" << std::hex << (unsigned long)(wstr[i]) << std::dec << std::endl; - - if(wstr[i] == 32) - { - // For some reason, the webkit plugin really wants the space bar to come in through the key-event path, not the unicode path. - LLQtWebKit::getInstance()->keyEvent( mBrowserWindowId, LLQtWebKit::KE_KEY_DOWN, 32, modifiers); - LLQtWebKit::getInstance()->keyEvent( mBrowserWindowId, LLQtWebKit::KE_KEY_UP, 32, modifiers); - } - else - { - LLQtWebKit::getInstance()->unicodeInput(mBrowserWindowId, wstr[i], modifiers); - } + // 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; + + if(native_key_data.isMap()) + { + native_scan_code = (uint32_t)(native_key_data["key_code"].asInteger()); + native_virtual_key = (uint32_t)(native_key_data["char_code"].asInteger()); + native_modifiers = (uint32_t)(native_key_data["modifiers"].asInteger()); } + + 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(); }; -- cgit v1.2.3 From 80139d95adbcb2258c5541a4e0ace32f32b78ba5 Mon Sep 17 00:00:00 2001 From: Callum Prentice Date: Thu, 4 Feb 2010 16:30:21 -0800 Subject: added code to grab raw key codes from Win32 WPARAM and LPARAM and send to plugin factored out keyboard message deserialization for media_plugin_webkit new version of llqtwebkit with Girish's changes to keyboard and cursor handling code --- indra/media_plugins/webkit/media_plugin_webkit.cpp | 37 ++++++++++++++-------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'indra/media_plugins') diff --git a/indra/media_plugins/webkit/media_plugin_webkit.cpp b/indra/media_plugins/webkit/media_plugin_webkit.cpp index e95e9e3b34..89ea1b0537 100644 --- a/indra/media_plugins/webkit/media_plugin_webkit.cpp +++ b/indra/media_plugins/webkit/media_plugin_webkit.cpp @@ -461,6 +461,27 @@ private: return (LLQtWebKit::EKeyboardModifier)result; } + //////////////////////////////////////////////////////////////////////////////// + // + void deserializeKeyboardData( LLSD native_key_data, uint32_t& native_scan_code, uint32_t& native_virtual_key, uint32_t& native_modifiers ) + { + if( native_key_data.isMap() ) + { + // these LLSD names are a little confusing here but they + // make more sense on the Mac specific version and that was done first + native_scan_code = (uint32_t)(native_key_data["key_code"].asInteger()); + native_virtual_key = (uint32_t)(native_key_data["char_code"].asInteger()); + native_modifiers = (uint32_t)(native_key_data["modifiers"].asInteger()); + + // would like to use LLQtWebKit::KM_MODIFIER_SHIFT but don't want + // make the client depend on llQtWebKit so pass over as an int + // (not bool so we can to modifier list later) + if ( native_modifiers == 1 ) + native_modifiers = LLQtWebKit::KM_MODIFIER_SHIFT; + else + native_modifiers = LLQtWebKit::KM_MODIFIER_NONE; + }; + }; //////////////////////////////////////////////////////////////////////////////// // @@ -494,13 +515,7 @@ private: uint32_t native_scan_code = 0; uint32_t native_virtual_key = 0; uint32_t native_modifiers = 0; - - if(native_key_data.isMap()) - { - native_scan_code = (uint32_t)(native_key_data["key_code"].asInteger()); - native_virtual_key = (uint32_t)(native_key_data["char_code"].asInteger()); - native_modifiers = (uint32_t)(native_key_data["modifiers"].asInteger()); - } + 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); @@ -525,13 +540,7 @@ private: uint32_t native_scan_code = 0; uint32_t native_virtual_key = 0; uint32_t native_modifiers = 0; - - if(native_key_data.isMap()) - { - native_scan_code = (uint32_t)(native_key_data["key_code"].asInteger()); - native_virtual_key = (uint32_t)(native_key_data["char_code"].asInteger()); - native_modifiers = (uint32_t)(native_key_data["modifiers"].asInteger()); - } + 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); -- cgit v1.2.3 From 8b0ae67e73a82940d3e7004eb17081a8ca4b8594 Mon Sep 17 00:00:00 2001 From: Monroe Linden Date: Fri, 5 Feb 2010 18:23:16 -0800 Subject: Changed LLWindowWin32::getNativeKeyData() to use platform-specific names in the key data. Changed MediaPluginWebkit::deserializeKeyboardData() to use platform-specific names when extracting the key data. Also fixed a mac-specific issue where the arguments were reversed, which was causing flash apps to get bad keycode data. Just pass 0 for the "native modifiers" param on windows, since it doesn't seem to actually have a native notion of a "modifier keys mask". The Qt (non-native) modifiers should be good enough. --- indra/media_plugins/webkit/media_plugin_webkit.cpp | 26 ++++++++++++---------- 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'indra/media_plugins') diff --git a/indra/media_plugins/webkit/media_plugin_webkit.cpp b/indra/media_plugins/webkit/media_plugin_webkit.cpp index 56b9250393..b147b1d96a 100644 --- a/indra/media_plugins/webkit/media_plugin_webkit.cpp +++ b/indra/media_plugins/webkit/media_plugin_webkit.cpp @@ -474,21 +474,23 @@ private: // void deserializeKeyboardData( LLSD native_key_data, uint32_t& native_scan_code, uint32_t& native_virtual_key, uint32_t& native_modifiers ) { + native_scan_code = 0; + native_virtual_key = 0; + native_modifiers = 0; + if( native_key_data.isMap() ) { - // these LLSD names are a little confusing here but they - // make more sense on the Mac specific version and that was done first - native_scan_code = (uint32_t)(native_key_data["key_code"].asInteger()); - native_virtual_key = (uint32_t)(native_key_data["char_code"].asInteger()); +#if LL_DARWIN + native_scan_code = (uint32_t)(native_key_data["char_code"].asInteger()); + native_virtual_key = (uint32_t)(native_key_data["key_code"].asInteger()); native_modifiers = (uint32_t)(native_key_data["modifiers"].asInteger()); - - // would like to use LLQtWebKit::KM_MODIFIER_SHIFT but don't want - // make the client depend on llQtWebKit so pass over as an int - // (not bool so we can to modifier list later) - if ( native_modifiers == 1 ) - native_modifiers = LLQtWebKit::KM_MODIFIER_SHIFT; - else - native_modifiers = LLQtWebKit::KM_MODIFIER_NONE; +#elif LL_WINDOWS + native_scan_code = (uint32_t)(native_key_data["scan_code"].asInteger()); + native_virtual_key = (uint32_t)(native_key_data["virtual_key"].asInteger()); + // TODO: I don't think we need to do anything with native modifiers here -- please verify +#else + // Add other platforms here as needed +#endif }; }; -- cgit v1.2.3