[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37355] branches/merwin-spacenav/intern/ ghost/intern: Made WinXP or later required, SpaceNav (almost) working on Windows
Mike Erwin
significant.bit at gmail.com
Fri Jun 10 03:34:55 CEST 2011
Revision: 37355
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37355
Author: merwin
Date: 2011-06-10 01:34:53 +0000 (Fri, 10 Jun 2011)
Log Message:
-----------
Made WinXP or later required, SpaceNav (almost) working on Windows
Modified Paths:
--------------
branches/merwin-spacenav/intern/ghost/intern/GHOST_DisplayManagerWin32.cpp
branches/merwin-spacenav/intern/ghost/intern/GHOST_DropTargetWin32.h
branches/merwin-spacenav/intern/ghost/intern/GHOST_SystemPathsWin32.cpp
branches/merwin-spacenav/intern/ghost/intern/GHOST_SystemPathsWin32.h
branches/merwin-spacenav/intern/ghost/intern/GHOST_SystemWin32.cpp
branches/merwin-spacenav/intern/ghost/intern/GHOST_SystemWin32.h
branches/merwin-spacenav/intern/ghost/intern/GHOST_TaskbarWin32.h
branches/merwin-spacenav/intern/ghost/intern/GHOST_WindowWin32.h
Modified: branches/merwin-spacenav/intern/ghost/intern/GHOST_DisplayManagerWin32.cpp
===================================================================
--- branches/merwin-spacenav/intern/ghost/intern/GHOST_DisplayManagerWin32.cpp 2011-06-10 00:57:27 UTC (rev 37354)
+++ branches/merwin-spacenav/intern/ghost/intern/GHOST_DisplayManagerWin32.cpp 2011-06-10 01:34:53 UTC (rev 37355)
@@ -35,8 +35,11 @@
#include "GHOST_DisplayManagerWin32.h"
#include "GHOST_Debug.h"
+#define _WIN32_WINNT 0x501 // require Windows XP or newer
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
// We do not support multiple monitors at the moment
-#include <windows.h>
#define COMPILE_MULTIMON_STUBS
#ifndef FREE_WINDOWS
#include <multimon.h>
Modified: branches/merwin-spacenav/intern/ghost/intern/GHOST_DropTargetWin32.h
===================================================================
--- branches/merwin-spacenav/intern/ghost/intern/GHOST_DropTargetWin32.h 2011-06-10 00:57:27 UTC (rev 37354)
+++ branches/merwin-spacenav/intern/ghost/intern/GHOST_DropTargetWin32.h 2011-06-10 01:34:53 UTC (rev 37355)
@@ -33,7 +33,6 @@
#ifndef _GHOST_DROP_TARGET_WIN32_H_
#define _GHOST_DROP_TARGET_WIN32_H_
-#include <windows.h>
#include <string.h>
#include <GHOST_Types.h>
#include "GHOST_WindowWin32.h"
Modified: branches/merwin-spacenav/intern/ghost/intern/GHOST_SystemPathsWin32.cpp
===================================================================
--- branches/merwin-spacenav/intern/ghost/intern/GHOST_SystemPathsWin32.cpp 2011-06-10 00:57:27 UTC (rev 37354)
+++ branches/merwin-spacenav/intern/ghost/intern/GHOST_SystemPathsWin32.cpp 2011-06-10 01:34:53 UTC (rev 37355)
@@ -32,12 +32,7 @@
#include "GHOST_SystemPathsWin32.h"
-#define WIN32_LEAN_AND_MEAN
-#ifdef _WIN32_IE
-#undef _WIN32_IE
-#endif
#define _WIN32_IE 0x0501
-#include <windows.h>
#include <shlobj.h>
#if defined(__MINGW32__) || defined(__CYGWIN__)
Modified: branches/merwin-spacenav/intern/ghost/intern/GHOST_SystemPathsWin32.h
===================================================================
--- branches/merwin-spacenav/intern/ghost/intern/GHOST_SystemPathsWin32.h 2011-06-10 00:57:27 UTC (rev 37354)
+++ branches/merwin-spacenav/intern/ghost/intern/GHOST_SystemPathsWin32.h 2011-06-10 01:34:53 UTC (rev 37355)
@@ -38,6 +38,8 @@
#error WIN32 only!
#endif // WIN32
+#define _WIN32_WINNT 0x501 // require Windows XP or newer
+#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "GHOST_SystemPaths.h"
Modified: branches/merwin-spacenav/intern/ghost/intern/GHOST_SystemWin32.cpp
===================================================================
--- branches/merwin-spacenav/intern/ghost/intern/GHOST_SystemWin32.cpp 2011-06-10 00:57:27 UTC (rev 37354)
+++ branches/merwin-spacenav/intern/ghost/intern/GHOST_SystemWin32.cpp 2011-06-10 01:34:53 UTC (rev 37355)
@@ -39,21 +39,16 @@
* @date May 7, 2001
*/
+#ifdef BF_GHOST_DEBUG
#include <iostream>
-
-#ifdef FREE_WINDOWS
-# define WINVER 0x0501 /* GetConsoleWindow() for MinGW */
#endif
+#include <stdio.h> // [mce] temporary debug, remove soon!
+
#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>
+#define _WIN32_IE 0x0501 /* shipped before XP, so doesn't impose additional requirements */
#include <shlobj.h>
// win64 doesn't define GWL_USERDATA
@@ -64,6 +59,7 @@
#endif
#endif
+#if 0 // shouldn't be needed...
/*
* 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
@@ -94,18 +90,20 @@
#define WM_XBUTTONDOWN 523
#endif // WM_XBUTTONDOWN
+#endif // ^^^ removed code
+
#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_EventNDOF.h"
#include "GHOST_TimerTask.h"
#include "GHOST_TimerManager.h"
#include "GHOST_WindowManager.h"
#include "GHOST_WindowWin32.h"
-#include "GHOST_NDOFManager.h"
+#include "GHOST_NDOFManagerWin32.h"
// Key code values not found in winuser.h
#ifndef VK_MINUS
@@ -158,6 +156,7 @@
#define VK_MEDIA_PLAY_PAUSE 0xB3
#endif // VK_MEDIA_PLAY_PAUSE
+#if 0
/*
Initiates WM_INPUT messages from keyboard
That way GHOST can retrieve true keys
@@ -170,7 +169,28 @@
return RegisterRawInputDevices(&device, 1, sizeof(device));
};
+#endif
+static void initRawInput()
+{
+ RAWINPUTDEVICE devices[2];
+ memset(devices, 0, 2 * sizeof(RAWINPUTDEVICE));
+
+ // multi-axis mouse (SpaceNavigator)
+ devices[0].usUsagePage = 0x01;
+ devices[0].usUsage = 0x08;
+
+ // Initiates WM_INPUT messages from keyboard
+ // That way GHOST can retrieve true keys
+ devices[1].usUsagePage = 0x01;
+ devices[1].usUsage = 0x06; /* http://msdn.microsoft.com/en-us/windows/hardware/gg487473.aspx */
+
+ if (RegisterRawInputDevices(devices, 2, sizeof(RAWINPUTDEVICE)))
+ puts("registered for RawInput (spacenav & keyboard)");
+ else
+ printf("could not register for RawInput: %d\n", (int)GetLastError());
+}
+
GHOST_SystemWin32::GHOST_SystemWin32()
: m_hasPerformanceCounter(false), m_freq(0), m_start(0)
{
@@ -186,6 +206,8 @@
this->handleKeyboardChange();
// Require COM for GHOST_DropTargetWin32 created in GHOST_WindowWin32.
OleInitialize(0);
+
+ m_ndofManager = new GHOST_NDOFManagerWin32(*this);
}
GHOST_SystemWin32::~GHOST_SystemWin32()
@@ -193,6 +215,7 @@
// Shutdown COM
OleUninitialize();
toggleConsole(1);
+ delete m_ndofManager;
}
@@ -384,23 +407,24 @@
GHOST_TSuccess success = GHOST_System::init();
/* Disable scaling on high DPI displays on Vista */
+ HMODULE
user32 = ::LoadLibraryA("user32.dll");
typedef BOOL (WINAPI * LPFNSETPROCESSDPIAWARE)();
LPFNSETPROCESSDPIAWARE SetProcessDPIAware =
(LPFNSETPROCESSDPIAWARE)GetProcAddress(user32, "SetProcessDPIAware");
if (SetProcessDPIAware)
SetProcessDPIAware();
- #ifdef NEED_RAW_PROC
- pRegisterRawInputDevices = (LPFNDLLRRID)GetProcAddress(user32, "RegisterRawInputDevices");
- pGetRawInputData = (LPFNDLLGRID)GetProcAddress(user32, "GetRawInputData");
- #else
+// #ifdef NEED_RAW_PROC
+// pRegisterRawInputDevices = (LPFNDLLRRID)GetProcAddress(user32, "RegisterRawInputDevices");
+// pGetRawInputData = (LPFNDLLGRID)GetProcAddress(user32, "GetRawInputData");
+// #else
FreeLibrary(user32);
- #endif
+// #endif
/* Initiates WM_INPUT messages from keyboard */
- initKeyboardRawInput();
+// initKeyboardRawInput();
+ initRawInput();
-
// Determine whether this system has a high frequency performance counter. */
m_hasPerformanceCounter = ::QueryPerformanceFrequency((LARGE_INTEGER*)&m_freq) == TRUE;
if (m_hasPerformanceCounter) {
@@ -440,104 +464,90 @@
GHOST_TSuccess GHOST_SystemWin32::exit()
{
- #ifdef NEED_RAW_PROC
- FreeLibrary(user32);
- #endif
+// #ifdef NEED_RAW_PROC
+// FreeLibrary(user32);
+// #endif
return GHOST_System::exit();
}
-GHOST_TKey GHOST_SystemWin32::hardKey(GHOST_IWindow *window, WPARAM wParam, LPARAM lParam, int * keyDown, char * vk)
+GHOST_TKey GHOST_SystemWin32::hardKey(GHOST_IWindow *window, RAWINPUT const& raw, int * keyDown, char * vk)
{
- unsigned int size = 0;
- char * data;
+// unsigned int size = 0;
+// char * data;
GHOST_TKey key = GHOST_kKeyUnknown;
if(!keyDown)
return GHOST_kKeyUnknown;
- GetRawInputData((HRAWINPUT)lParam, RID_INPUT, 0, &size, sizeof(RAWINPUTHEADER));
+ GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem();
- if((data = (char*)malloc(size)) &&
- GetRawInputData((HRAWINPUT)lParam, RID_INPUT, data, &size, sizeof(RAWINPUTHEADER)))
+ GHOST_ModifierKeys modifiers;
+ system->retrieveModifierKeys(modifiers);
+
+ *keyDown = !(raw.data.keyboard.Flags & RI_KEY_BREAK);
+ key = this->convertKey(window, raw.data.keyboard.VKey, raw.data.keyboard.MakeCode, (raw.data.keyboard.Flags&(RI_KEY_E1|RI_KEY_E0)));
+
+ // extra handling of modifier keys: don't send repeats out from GHOST
+ if(key >= GHOST_kKeyLeftShift && key <= GHOST_kKeyRightAlt)
{
- RAWINPUT ri;
- memcpy(&ri,data,(size < sizeof(ri)) ? size : sizeof(ri));
-
- if (ri.header.dwType == RIM_TYPEKEYBOARD)
- {
- GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem();
-
- GHOST_ModifierKeys modifiers;
- system->retrieveModifierKeys(modifiers);
-
- *keyDown = !(ri.data.keyboard.Flags & RI_KEY_BREAK);
- key = this->convertKey(window, ri.data.keyboard.VKey, ri.data.keyboard.MakeCode, (ri.data.keyboard.Flags&(RI_KEY_E1|RI_KEY_E0)));
-
- // extra handling of modifier keys: don't send repeats out from GHOST
- if(key >= GHOST_kKeyLeftShift && key <= GHOST_kKeyRightAlt)
- {
- bool changed = false;
- GHOST_TModifierKeyMask modifier;
- switch(key) {
- case GHOST_kKeyLeftShift:
- {
- changed = (modifiers.get(GHOST_kModifierKeyLeftShift) != (bool)*keyDown);
- modifier = GHOST_kModifierKeyLeftShift;
- }
- break;
- case GHOST_kKeyRightShift:
- {
- changed = (modifiers.get(GHOST_kModifierKeyRightShift) != (bool)*keyDown);
- modifier = GHOST_kModifierKeyRightShift;
- }
- break;
- case GHOST_kKeyLeftControl:
- {
- changed = (modifiers.get(GHOST_kModifierKeyLeftControl) != (bool)*keyDown);
- modifier = GHOST_kModifierKeyLeftControl;
- }
- break;
- case GHOST_kKeyRightControl:
- {
- changed = (modifiers.get(GHOST_kModifierKeyRightControl) != (bool)*keyDown);
- modifier = GHOST_kModifierKeyRightControl;
- }
- break;
- case GHOST_kKeyLeftAlt:
- {
- changed = (modifiers.get(GHOST_kModifierKeyLeftAlt) != (bool)*keyDown);
- modifier = GHOST_kModifierKeyLeftAlt;
- }
- break;
- case GHOST_kKeyRightAlt:
- {
- changed = (modifiers.get(GHOST_kModifierKeyRightAlt) != (bool)*keyDown);
- modifier = GHOST_kModifierKeyRightAlt;
- }
- break;
- default: break;
+ bool changed = false;
+ GHOST_TModifierKeyMask modifier;
+ switch(key) {
+ case GHOST_kKeyLeftShift:
+ {
+ changed = (modifiers.get(GHOST_kModifierKeyLeftShift) != (bool)*keyDown);
+ modifier = GHOST_kModifierKeyLeftShift;
}
-
- if(changed)
+ break;
+ case GHOST_kKeyRightShift:
{
- modifiers.set(modifier, (bool)*keyDown);
- system->storeModifierKeys(modifiers);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list