[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36542] trunk/blender/intern/ghost/intern: Patch [#26799] embedded blenderplayer not receiving keyboard input by Sebastian Korczak
Dalai Felinto
dfelinto at gmail.com
Sun May 8 00:28:57 CEST 2011
Revision: 36542
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36542
Author: dfelinto
Date: 2011-05-07 22:28:56 +0000 (Sat, 07 May 2011)
Log Message:
-----------
Patch [#26799] embedded blenderplayer not receiving keyboard input by Sebastian Korczak
(patch co-reviewed by Nathan Letwory)
Overview: GHOST using rawinput for keyboard input. GHOST window receives WM_INPUT only when it is the active window. Child window cannot be active, so when embedding blenderplayer, WM_INPUT is consumed by top level parent window (for Burster it is the web browser window). Patch register raw input device as 'inputsink' - it makes GHOST window receives all keyboard messages. Window procedure check if GHOST window is active or focused.
::TranslateMessage(&msg) generates WM_CHAR etc. messages from WM_KEYDOWN, WM_KEYUP etc. Because of using RawInput only WM_INPUT messages are processed, so we doesn't need WM_CHAR, WM_KEYDOWN etc. [this is why ::TranslateMessage is no longer getting called].
Note: It's responsibility of the parent window (aka the wrapper) to send WM_SETFOCUS to child window (embedded blenderplayer).
However some parent windows (e.g. webbrowsers) will not send WM_SETFOCUS to the child window when someone clicks on it.
In those cases the blenderplayer needs to be patched to call setFocus(&msg); in the event of WM_LBUTTONDOWN (see GHOST_SystemWin32.cpp)
Modified Paths:
--------------
trunk/blender/intern/ghost/intern/GHOST_SystemWin32.cpp
trunk/blender/intern/ghost/intern/GHOST_WindowWin32.cpp
Modified: trunk/blender/intern/ghost/intern/GHOST_SystemWin32.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemWin32.cpp 2011-05-07 20:53:49 UTC (rev 36541)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemWin32.cpp 2011-05-07 22:28:56 UTC (rev 36542)
@@ -304,7 +304,6 @@
// Process all the events waiting for us
while (::PeekMessage(&msg, 0, 0, 0, PM_REMOVE) != 0) {
- ::TranslateMessage(&msg);
::DispatchMessage(&msg);
anyProcessed = true;
}
@@ -819,6 +818,11 @@
// Keyboard events, processed
////////////////////////////////////////////////////////////////////////
case WM_INPUT:
+ // check WM_INPUT from input sink when ghost window is not in the foreground
+ if (wParam == RIM_INPUTSINK) {
+ if (GetFocus() != hwnd) // WM_INPUT message not for this window
+ return 0;
+ } //else wPAram == RIM_INPUT
event = processKeyEvent(window, wParam, lParam);
if (!event) {
GHOST_PRINT("GHOST_SystemWin32::wndProc: key event ")
Modified: trunk/blender/intern/ghost/intern/GHOST_WindowWin32.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_WindowWin32.cpp 2011-05-07 20:53:49 UTC (rev 36541)
+++ trunk/blender/intern/ghost/intern/GHOST_WindowWin32.cpp 2011-05-07 22:28:56 UTC (rev 36542)
@@ -307,6 +307,15 @@
}
}
+ if (parentwindowhwnd != 0) {
+ RAWINPUTDEVICE device = {0};
+ device.usUsagePage = 0x01; /* usUsagePage & usUsage for keyboard*/
+ device.usUsage = 0x06; /* http://msdn.microsoft.com/en-us/windows/hardware/gg487473.aspx */
+ device.dwFlags |= RIDEV_INPUTSINK; // makes WM_INPUT is visible for ghost when has parent window
+ device.hwndTarget = m_hWnd;
+ RegisterRawInputDevices(&device, 1, sizeof(device));
+ }
+
m_wintab = ::LoadLibrary("Wintab32.dll");
if (m_wintab) {
GHOST_WIN32_WTInfo fpWTInfo = ( GHOST_WIN32_WTInfo ) ::GetProcAddress( m_wintab, "WTInfoA" );
More information about the Bf-blender-cvs
mailing list