summaryrefslogtreecommitdiff
path: root/indra/llwindow
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llwindow')
-rw-r--r--indra/llwindow/llwindow.h4
-rw-r--r--indra/llwindow/llwindowmacosx.cpp69
-rw-r--r--indra/llwindow/llwindowmacosx.h5
-rw-r--r--indra/llwindow/llwindowwin32.cpp25
-rw-r--r--indra/llwindow/llwindowwin32.h6
5 files changed, 106 insertions, 3 deletions
diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h
index 127dbf45e0..55b221e716 100644
--- a/indra/llwindow/llwindow.h
+++ b/indra/llwindow/llwindow.h
@@ -37,6 +37,7 @@
#include "llcoord.h"
#include "llstring.h"
#include "llcursortypes.h"
+#include "llsd.h"
class LLSplashScreen;
class LLPreeditor;
@@ -162,6 +163,9 @@ public:
virtual void spawnWebBrowser(const std::string& escaped_url) {};
static std::vector<std::string> getDynamicFallbackFontList();
+
+ // Provide native key event data
+ virtual LLSD getNativeKeyData() { return LLSD::emptyMap(); }
protected:
LLWindow(LLWindowCallbacks* callbacks, BOOL fullscreen, U32 flags);
diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp
index 9ccd4c7f97..ad97bc45fc 100644
--- a/indra/llwindow/llwindowmacosx.cpp
+++ b/indra/llwindow/llwindowmacosx.cpp
@@ -260,6 +260,7 @@ LLWindowMacOSX::LLWindowMacOSX(LLWindowCallbacks* callbacks,
mTSMScriptCode = 0;
mTSMLangCode = 0;
mPreeditor = NULL;
+ mRawKeyEvent = NULL;
mFSAASamples = fsaa_samples;
mForceRebuild = FALSE;
@@ -2140,10 +2141,11 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e
{
UInt32 modifiers = 0;
+
// First, process the raw event.
{
- EventRef rawEvent;
-
+ EventRef rawEvent = NULL;
+
// Get the original event and extract the modifier keys, so we can ignore command-key events.
if (GetEventParameter(event, kEventParamTextInputSendKeyboardEvent, typeEventRef, NULL, sizeof(rawEvent), NULL, &rawEvent) == noErr)
{
@@ -2152,6 +2154,9 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e
// and call this function recursively to handle the raw key event.
eventHandler (myHandler, rawEvent);
+
+ // save the raw event until we're done processing the unicode input as well.
+ mRawKeyEvent = rawEvent;
}
}
@@ -2202,6 +2207,7 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e
delete[] buffer;
}
+ mRawKeyEvent = NULL;
result = err;
}
break;
@@ -2276,6 +2282,9 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e
GetEventParameter (event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode);
GetEventParameter (event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
+ // save the raw event so getNativeKeyData can use it.
+ mRawKeyEvent = event;
+
// printf("key event, key code = 0x%08x, char code = 0x%02x (%c), modifiers = 0x%08x\n", keyCode, charCode, (char)charCode, modifiers);
// fflush(stdout);
@@ -2371,6 +2380,8 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e
result = eventNotHandledErr;
break;
}
+
+ mRawKeyEvent = NULL;
}
break;
@@ -3211,6 +3222,60 @@ void LLWindowMacOSX::spawnWebBrowser(const std::string& escaped_url)
}
}
+LLSD LLWindowMacOSX::getNativeKeyData()
+{
+ LLSD result = LLSD::emptyMap();
+
+ if(mRawKeyEvent)
+ {
+ char char_code = 0;
+ UInt32 key_code = 0;
+ UInt32 modifiers = 0;
+ UInt32 keyboard_type = 0;
+
+ GetEventParameter (mRawKeyEvent, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(char), NULL, &char_code);
+ GetEventParameter (mRawKeyEvent, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &key_code);
+ GetEventParameter (mRawKeyEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
+ GetEventParameter (mRawKeyEvent, kEventParamKeyboardType, typeUInt32, NULL, sizeof(UInt32), NULL, &keyboard_type);
+
+ result["char_code"] = (S32)char_code;
+ result["key_code"] = (S32)key_code;
+ result["modifiers"] = (S32)modifiers;
+ result["keyboard_type"] = (S32)keyboard_type;
+
+#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!
+ std::string unicode;
+ OSStatus err = noErr;
+ EventParamType actualType = typeUTF8Text;
+ UInt32 actualSize = 0;
+ char *buffer = NULL;
+
+ err = GetEventParameter (mRawKeyEvent, kEventParamKeyUnicodes, typeUTF8Text, &actualType, 0, &actualSize, NULL);
+ if(err == noErr)
+ {
+ // allocate a buffer and get the actual data.
+ buffer = new char[actualSize];
+ err = GetEventParameter (mRawKeyEvent, kEventParamKeyUnicodes, typeUTF8Text, &actualType, actualSize, &actualSize, buffer);
+ if(err == noErr)
+ {
+ unicode.assign(buffer, actualSize);
+ }
+ delete[] buffer;
+ }
+
+ result["unicode"] = unicode;
+#endif
+
+ }
+
+
+ lldebugs << "native key data is: " << result << llendl;
+
+ return result;
+}
+
BOOL LLWindowMacOSX::dialogColorPicker( F32 *r, F32 *g, F32 *b)
{
diff --git a/indra/llwindow/llwindowmacosx.h b/indra/llwindow/llwindowmacosx.h
index 377f10b6d4..7c6b324029 100644
--- a/indra/llwindow/llwindowmacosx.h
+++ b/indra/llwindow/llwindowmacosx.h
@@ -120,6 +120,10 @@ public:
static std::vector<std::string> getDynamicFallbackFontList();
+ // Provide native key event data
+ /*virtual*/ LLSD getNativeKeyData();
+
+
protected:
LLWindowMacOSX(LLWindowCallbacks* callbacks,
const std::string& title, const std::string& name, int x, int y, int width, int height, U32 flags,
@@ -218,6 +222,7 @@ protected:
friend class LLWindowManager;
static WindowRef sMediaWindow;
+ EventRef mRawKeyEvent;
};
diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp
index 57a4921d92..c80392ad45 100644
--- a/indra/llwindow/llwindowwin32.cpp
+++ b/indra/llwindow/llwindowwin32.cpp
@@ -378,6 +378,9 @@ LLWindowWin32::LLWindowWin32(LLWindowCallbacks* callbacks,
mMousePositionModified = FALSE;
mInputProcessingPaused = FALSE;
mPreeditor = NULL;
+ mKeyCharCode = 0;
+ mKeyScanCode = 0;
+ mKeyVirtualKey = 0;
mhDC = NULL;
mhRC = NULL;
@@ -1872,6 +1875,10 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_
// allow system keys, such as ALT-F4 to be processed by Windows
eat_keystroke = FALSE;
case WM_KEYDOWN:
+ window_imp->mKeyCharCode = 0; // don't know until wm_char comes in next
+ window_imp->mKeyScanCode = ( l_param >> 16 ) & 0xff;
+ window_imp->mKeyVirtualKey = w_param;
+
window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_KEYDOWN");
{
if (gDebugWindowProc)
@@ -1891,6 +1898,9 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_
eat_keystroke = FALSE;
case WM_KEYUP:
{
+ window_imp->mKeyScanCode = ( l_param >> 16 ) & 0xff;
+ window_imp->mKeyVirtualKey = w_param;
+
window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_KEYUP");
LLFastTimer t2(FTM_KEYHANDLER);
@@ -1976,6 +1986,8 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_
break;
case WM_CHAR:
+ window_imp->mKeyCharCode = w_param;
+
// Should really use WM_UNICHAR eventually, but it requires a specific Windows version and I need
// to figure out how that works. - Doug
//
@@ -3051,6 +3063,19 @@ void LLWindowWin32::spawnWebBrowser(const std::string& escaped_url )
*/
}
+/*
+ Make the raw keyboard data available - used to poke through to LLQtWebKit so
+ that Qt/Webkit has access to the virtual keycodes etc. that it needs
+*/
+LLSD LLWindowWin32::getNativeKeyData()
+{
+ LLSD result = LLSD::emptyMap();
+
+ result["scan_code"] = (S32)mKeyScanCode;
+ result["virtual_key"] = (S32)mKeyVirtualKey;
+
+ return result;
+}
BOOL LLWindowWin32::dialogColorPicker( F32 *r, F32 *g, F32 *b )
{
diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h
index 6aca31b63e..9d57735772 100644
--- a/indra/llwindow/llwindowwin32.h
+++ b/indra/llwindow/llwindowwin32.h
@@ -132,7 +132,7 @@ protected:
HCURSOR loadColorCursor(LPCTSTR name);
BOOL isValid();
void moveWindow(const LLCoordScreen& position,const LLCoordScreen& size);
-
+ LLSD getNativeKeyData();
// Changes display resolution. Returns true if successful
BOOL setDisplayResolution(S32 width, S32 height, S32 bits, S32 refresh);
@@ -211,6 +211,10 @@ protected:
LLDragDropWin32* mDragDrop;
+ U32 mKeyCharCode;
+ U32 mKeyScanCode;
+ U32 mKeyVirtualKey;
+
friend class LLWindowManager;
};