[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34346] branches/merwin-tablet-2/intern/ ghost/intern: sync with summer work on Windows tablet & mouse
Mike Erwin
significant.bit at gmail.com
Sun Jan 16 07:00:58 CET 2011
Revision: 34346
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=34346
Author: merwin
Date: 2011-01-16 06:00:55 +0000 (Sun, 16 Jan 2011)
Log Message:
-----------
sync with summer work on Windows tablet & mouse
Modified Paths:
--------------
branches/merwin-tablet-2/intern/ghost/intern/GHOST_SystemWin32.cpp
branches/merwin-tablet-2/intern/ghost/intern/GHOST_SystemWin32.h
branches/merwin-tablet-2/intern/ghost/intern/GHOST_WindowWin32.cpp
branches/merwin-tablet-2/intern/ghost/intern/GHOST_WindowWin32.h
Modified: branches/merwin-tablet-2/intern/ghost/intern/GHOST_SystemWin32.cpp
===================================================================
--- branches/merwin-tablet-2/intern/ghost/intern/GHOST_SystemWin32.cpp 2011-01-16 04:57:51 UTC (rev 34345)
+++ branches/merwin-tablet-2/intern/ghost/intern/GHOST_SystemWin32.cpp 2011-01-16 06:00:55 UTC (rev 34346)
@@ -39,108 +39,74 @@
#include "GHOST_SystemWin32.h"
#include "GHOST_EventDragnDrop.h"
-#define WIN32_LEAN_AND_MEAN
-#ifdef _WIN32_IE
-#undef _WIN32_IE
-#endif
-#define _WIN32_IE 0x0501
-#include <windows.h>
+#include <stdio.h> // for debug [mce]
+
+#define _WIN32_IE 0x501 /* shipped before XP, so doesn't impose additional requirements */
#include <shlobj.h>
// win64 doesn't define GWL_USERDATA
#ifdef WIN32
-#ifndef GWL_USERDATA
-#define GWL_USERDATA GWLP_USERDATA
-#define GWL_WNDPROC GWLP_WNDPROC
+ #ifndef GWL_USERDATA
+ #define GWL_USERDATA GWLP_USERDATA
+ #define GWL_WNDPROC GWLP_WNDPROC
+ #endif
#endif
-#endif
-/*
- * According to the docs the mouse wheel message is supported from windows 98
- * upwards. Leaving WINVER at default value, the WM_MOUSEWHEEL message and the
- * wheel detent value are undefined.
- */
-#ifndef WM_MOUSEWHEEL
-#define WM_MOUSEWHEEL 0x020A
-#endif // WM_MOUSEWHEEL
-#ifndef WHEEL_DELTA
-#define WHEEL_DELTA 120 /* Value for rolling one detent, (old convention! MS changed it) */
-#endif // WHEEL_DELTA
-
-/*
- * Defines for mouse buttons 4 and 5 aka xbutton1 and xbutton2.
- * MSDN: Declared in Winuser.h, include Windows.h
- * This does not seem to work with MinGW so we define our own here.
- */
-#ifndef XBUTTON1
-#define XBUTTON1 0x0001
-#endif // XBUTTON1
-#ifndef XBUTTON2
-#define XBUTTON2 0x0002
-#endif // XBUTTON2
-#ifndef WM_XBUTTONUP
-#define WM_XBUTTONUP 524
-#endif // WM_XBUTTONUP
-#ifndef WM_XBUTTONDOWN
-#define WM_XBUTTONDOWN 523
-#endif // WM_XBUTTONDOWN
-
#include "GHOST_Debug.h"
#include "GHOST_DisplayManagerWin32.h"
#include "GHOST_EventButton.h"
#include "GHOST_EventCursor.h"
#include "GHOST_EventKey.h"
#include "GHOST_EventWheel.h"
-#include "GHOST_EventNDOF.h"
#include "GHOST_TimerTask.h"
#include "GHOST_TimerManager.h"
#include "GHOST_WindowManager.h"
#include "GHOST_WindowWin32.h"
-#include "GHOST_NDOFManager.h"
+#include "GHOST_TabletManagerWin32.h"
// Key code values not found in winuser.h
#ifndef VK_MINUS
-#define VK_MINUS 0xBD
-#endif // VK_MINUS
+ #define VK_MINUS 0xBD
+#endif
#ifndef VK_SEMICOLON
-#define VK_SEMICOLON 0xBA
-#endif // VK_SEMICOLON
+ #define VK_SEMICOLON 0xBA
+#endif
#ifndef VK_PERIOD
-#define VK_PERIOD 0xBE
-#endif // VK_PERIOD
+ #define VK_PERIOD 0xBE
+#endif
#ifndef VK_COMMA
-#define VK_COMMA 0xBC
-#endif // VK_COMMA
+ #define VK_COMMA 0xBC
+#endif
#ifndef VK_QUOTE
-#define VK_QUOTE 0xDE
-#endif // VK_QUOTE
+ #define VK_QUOTE 0xDE
+#endif
#ifndef VK_BACK_QUOTE
-#define VK_BACK_QUOTE 0xC0
-#endif // VK_BACK_QUOTE
+ #define VK_BACK_QUOTE 0xC0
+#endif
#ifndef VK_SLASH
-#define VK_SLASH 0xBF
-#endif // VK_SLASH
+ #define VK_SLASH 0xBF
+#endif
#ifndef VK_BACK_SLASH
-#define VK_BACK_SLASH 0xDC
-#endif // VK_BACK_SLASH
+ #define VK_BACK_SLASH 0xDC
+#endif
#ifndef VK_EQUALS
-#define VK_EQUALS 0xBB
-#endif // VK_EQUALS
+ #define VK_EQUALS 0xBB
+#endif
#ifndef VK_OPEN_BRACKET
-#define VK_OPEN_BRACKET 0xDB
-#endif // VK_OPEN_BRACKET
+ #define VK_OPEN_BRACKET 0xDB
+#endif
#ifndef VK_CLOSE_BRACKET
-#define VK_CLOSE_BRACKET 0xDD
-#endif // VK_CLOSE_BRACKET
+ #define VK_CLOSE_BRACKET 0xDD
+#endif
#ifndef VK_GR_LESS
-#define VK_GR_LESS 0xE2
-#endif // VK_GR_LESS
+ #define VK_GR_LESS 0xE2
+#endif
GHOST_SystemWin32::GHOST_SystemWin32()
: m_hasPerformanceCounter(false), m_freq(0), m_start(0)
{
- m_displayManager = new GHOST_DisplayManagerWin32 ();
+ m_displayManager = new GHOST_DisplayManagerWin32;
GHOST_ASSERT(m_displayManager, "GHOST_SystemWin32::GHOST_SystemWin32(): m_displayManager==0\n");
m_displayManager->initialize();
@@ -154,12 +120,16 @@
{
// Shutdown COM
OleUninitialize();
+
+ delete m_tabletManager;
}
GHOST_TUns64 GHOST_SystemWin32::getMilliSeconds() const
{
- // Hardware does not support high resolution timers. We will use GetTickCount instead then.
+ // If hardware does not support high resolution timers,
+ // we will use GetTickCount instead.
+
if (!m_hasPerformanceCounter) {
return ::GetTickCount();
}
@@ -172,7 +142,7 @@
__int64 delta = 1000*(count-m_start);
GHOST_TUns64 t = (GHOST_TUns64)(delta/m_freq);
- return t;
+ return t;
}
@@ -193,33 +163,34 @@
GHOST_IWindow* GHOST_SystemWin32::createWindow(
- const STR_String& title,
+ const STR_String& title,
GHOST_TInt32 left, GHOST_TInt32 top, GHOST_TUns32 width, GHOST_TUns32 height,
GHOST_TWindowState state, GHOST_TDrawingContextType type,
bool stereoVisual, const GHOST_TUns16 numOfAASamples, const GHOST_TEmbedderWindowID parentWindow )
{
- GHOST_Window* window = 0;
- window = new GHOST_WindowWin32 (this, title, left, top, width, height, state, type, stereoVisual, numOfAASamples);
+ GHOST_WindowWin32* window =
+ new GHOST_WindowWin32 (this, title, left, top, width, height, state, type, stereoVisual, numOfAASamples);
+
if (window) {
if (window->getValid()) {
- // Store the pointer to the window
-// if (state != GHOST_kWindowStateFullScreen) {
- m_windowManager->addWindow(window);
-// }
+ m_windowManager->addWindow(window);
+ m_windowManager->setActiveWindow(window);
+ if (m_tabletManager->available())
+ window->becomeTabletAware(m_tabletManager);
}
else {
// An invalid window could be one that was used to test for AA
- window = ((GHOST_WindowWin32*)window)->getNextWindow();
-
+ GHOST_WindowWin32* other_window = (GHOST_WindowWin32*) window->getNextWindow();
+
+ delete window;
+ window = 0;
+
// If another window is found, let the wm know about that one, but not the old one
- if (window->getValid()) {
- m_windowManager->addWindow(window);
+ if (other_window)
+ {
+ m_windowManager->addWindow(other_window);
+ window = other_window;
}
- else {
- delete window;
- window = 0;
- }
-
}
}
return window;
@@ -240,7 +211,7 @@
#else
GHOST_TUns64 next = timerMgr->nextFireTime();
GHOST_TInt64 maxSleep = next - getMilliSeconds();
-
+
if (next == GHOST_kFireTimeNever) {
::WaitMessage();
} else if(maxSleep >= 0.0) {
@@ -263,6 +234,13 @@
}
} while (waitForEvent && !anyProcessed);
+// Handle tablet input either here (polling)
+// or after WT_PACKET messages (event driven)
+// -- not both!
+
+// if (m_tabletManager->processPackets())
+// anyProcessed = true;
+
return anyProcessed;
}
@@ -342,6 +320,8 @@
m_curKeyStatus[i] = false;
}
+ m_tabletManager = new GHOST_TabletManagerWin32;
+
/* Disable scaling on high DPI displays on Vista */
HMODULE user32 = ::LoadLibraryA("user32.dll");
typedef BOOL (WINAPI * LPFNSETPROCESSDPIAWARE)();
@@ -368,8 +348,8 @@
wc.cbClsExtra= 0;
wc.cbWndExtra= 0;
wc.hInstance= ::GetModuleHandle(0);
- wc.hIcon = ::LoadIcon(wc.hInstance, "APPICON");
-
+ wc.hIcon = ::LoadIcon(wc.hInstance, "APPICON");
+
if (!wc.hIcon) {
::LoadIcon(NULL, IDI_APPLICATION);
}
@@ -632,17 +612,27 @@
GHOST_EventButton* GHOST_SystemWin32::processButtonEvent(GHOST_TEventType type, GHOST_IWindow *window, GHOST_TButtonMask mask)
{
+ if (eventIsFromTablet())
+ return NULL;
+
+ static GHOST_Buttons buttons;
+ if (type == GHOST_kEventButtonUp && !buttons.get(mask))
+ // discard rogue button up events (probably from tablet)
+ return NULL;
+ buttons.set(mask, type == GHOST_kEventButtonDown);
+
+ printf("system button %d %s\n", mask, (type == GHOST_kEventButtonDown) ? "down" : (type == GHOST_kEventButtonUp) ? "up" : "???");
+
return new GHOST_EventButton (getSystem()->getMilliSeconds(), type, window, mask);
}
-GHOST_EventCursor* GHOST_SystemWin32::processCursorEvent(GHOST_TEventType type, GHOST_IWindow *Iwindow)
+GHOST_EventCursor* GHOST_SystemWin32::processCursorEvent(GHOST_TEventType type, GHOST_IWindow *Iwindow, int x_screen, int y_screen)
{
- GHOST_TInt32 x_screen, y_screen;
+ printf("system cursor (%d,%d)\n", x_screen, y_screen);
+
GHOST_SystemWin32 * system = ((GHOST_SystemWin32 * ) getSystem());
GHOST_WindowWin32 * window = ( GHOST_WindowWin32 * ) Iwindow;
-
- system->getCursorPosition(x_screen, y_screen);
if(window->getCursorGrabMode() != GHOST_kGrabDisable && window->getCursorGrabMode() != GHOST_kGrabNormal)
{
@@ -669,7 +659,7 @@
window->setCursorGrabAccum(x_accum + (x_screen - x_new), y_accum + (y_screen - y_new));
}else{
return new GHOST_EventCursor(system->getMilliSeconds(),
- GHOST_kEventCursorMove,
+ type,
window,
x_screen + x_accum,
y_screen + y_accum
@@ -679,7 +669,7 @@
}
else {
return new GHOST_EventCursor(system->getMilliSeconds(),
- GHOST_kEventCursorMove,
+ type,
window,
x_screen,
y_screen
@@ -693,7 +683,7 @@
{
// short fwKeys = LOWORD(wParam); // key flags
int zDelta = (short) HIWORD(wParam); // wheel rotation
-
+
// zDelta /= WHEEL_DELTA;
// temporary fix below: microsoft now has added more precision, making the above division not work
if (zDelta <= 0 ) zDelta= -1; else zDelta= 1;
@@ -715,7 +705,6 @@
/* Eat any character related messages */
if (::PeekMessage(&keyMsg, NULL, WM_CHAR, WM_SYSDEADCHAR, PM_REMOVE)) {
ascii = (char) keyMsg.wParam;
-
}
event = new GHOST_EventKey(getSystem()->getMilliSeconds(), keyDown ? GHOST_kEventKeyDown: GHOST_kEventKeyUp, window, key, ascii);
@@ -729,7 +718,15 @@
GHOST_Event* GHOST_SystemWin32::processWindowEvent(GHOST_TEventType type, GHOST_IWindow* window)
{
- return new GHOST_Event(getSystem()->getMilliSeconds(), type, window);
+ GHOST_System* system = (GHOST_System*)getSystem();
+
+ if (type == GHOST_kEventWindowActivate)
+ {
+ puts("activating window");
+ system->getWindowManager()->setActiveWindow(window);
+ }
+
+ return new GHOST_Event(system->getMilliSeconds(), type, window);
}
GHOST_TSuccess GHOST_SystemWin32::pushDragDropEvent(GHOST_TEventType eventType,
@@ -801,337 +798,35 @@
LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- GHOST_Event* event = 0;
LRESULT lResult = 0;
GHOST_SystemWin32* system = ((GHOST_SystemWin32*)getSystem());
GHOST_ASSERT(system, "GHOST_SystemWin32::s_wndProc(): system not initialized")
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list