[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38164] branches/merwin-spacenav: various fixes to enable MSVC build, removed crusty old Win32 ndof code

Mike Erwin significant.bit at gmail.com
Wed Jul 6 20:50:59 CEST 2011


Revision: 38164
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38164
Author:   merwin
Date:     2011-07-06 18:50:59 +0000 (Wed, 06 Jul 2011)
Log Message:
-----------
various fixes to enable MSVC build, removed crusty old Win32 ndof code

Modified Paths:
--------------
    branches/merwin-spacenav/intern/ghost/intern/GHOST_DropTargetWin32.cpp
    branches/merwin-spacenav/intern/ghost/intern/GHOST_NDOFManager.h
    branches/merwin-spacenav/intern/ghost/intern/GHOST_SystemWin32.cpp
    branches/merwin-spacenav/intern/ghost/intern/GHOST_SystemWin32.h
    branches/merwin-spacenav/source/blender/editors/space_view3d/view3d_edit.c

Modified: branches/merwin-spacenav/intern/ghost/intern/GHOST_DropTargetWin32.cpp
===================================================================
--- branches/merwin-spacenav/intern/ghost/intern/GHOST_DropTargetWin32.cpp	2011-07-06 18:34:01 UTC (rev 38163)
+++ branches/merwin-spacenav/intern/ghost/intern/GHOST_DropTargetWin32.cpp	2011-07-06 18:50:59 UTC (rev 38164)
@@ -33,6 +33,7 @@
  
 #include "GHOST_Debug.h"
 #include "GHOST_DropTargetWin32.h"
+#include <ShellApi.h>
 
 #ifdef GHOST_DEBUG
 // utility

Modified: branches/merwin-spacenav/intern/ghost/intern/GHOST_NDOFManager.h
===================================================================
--- branches/merwin-spacenav/intern/ghost/intern/GHOST_NDOFManager.h	2011-07-06 18:34:01 UTC (rev 38163)
+++ branches/merwin-spacenav/intern/ghost/intern/GHOST_NDOFManager.h	2011-07-06 18:50:59 UTC (rev 38164)
@@ -29,7 +29,7 @@
 
 // --- the following type definitions will find a home somewhere else once finished ---
 
-#define DEBUG_NDOF_MOTION
+//#define DEBUG_NDOF_MOTION
 #define DEBUG_NDOF_BUTTONS
 
 typedef enum { NDOF_UnknownDevice, NDOF_SpaceNavigator, NDOF_SpaceExplorer, NDOF_SpacePilotPro } NDOF_DeviceT;

Modified: branches/merwin-spacenav/intern/ghost/intern/GHOST_SystemWin32.cpp
===================================================================
--- branches/merwin-spacenav/intern/ghost/intern/GHOST_SystemWin32.cpp	2011-07-06 18:34:01 UTC (rev 38163)
+++ branches/merwin-spacenav/intern/ghost/intern/GHOST_SystemWin32.cpp	2011-07-06 18:50:59 UTC (rev 38164)
@@ -59,46 +59,12 @@
 #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 
- * 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
-
-#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_TimerTask.h"
 #include "GHOST_TimerManager.h"
 #include "GHOST_WindowManager.h"
@@ -156,27 +122,12 @@
 #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
-*/
-GHOST_TInt32 GHOST_SystemWin32::initKeyboardRawInput(void)
-{
-	RAWINPUTDEVICE device = {0};
-	device.usUsagePage	= 0x01; /* usUsagePage & usUsage for keyboard*/
-	device.usUsage		= 0x06; /* http://msdn.microsoft.com/en-us/windows/hardware/gg487473.aspx */
-
-	return RegisterRawInputDevices(&device, 1, sizeof(device));
-};
-#endif
-
 static void initRawInput()
 {
 	RAWINPUTDEVICE devices[2];
 	memset(devices, 0, 2 * sizeof(RAWINPUTDEVICE));
 
-	// multi-axis mouse (SpaceNavigator)
+	// multi-axis mouse (SpaceNavigator, etc.)
 	devices[0].usUsagePage = 0x01;
 	devices[0].usUsage = 0x08;
 
@@ -414,15 +365,7 @@
 		(LPFNSETPROCESSDPIAWARE)GetProcAddress(user32, "SetProcessDPIAware");
 	if (SetProcessDPIAware)
 		SetProcessDPIAware();
-//	#ifdef NEED_RAW_PROC
-//		pRegisterRawInputDevices = (LPFNDLLRRID)GetProcAddress(user32, "RegisterRawInputDevices");
-//		pGetRawInputData = (LPFNDLLGRID)GetProcAddress(user32, "GetRawInputData");
-//	#else
-		FreeLibrary(user32);
-//	#endif
-
-	/* 	Initiates WM_INPUT messages from keyboard */
-//	initKeyboardRawInput();
+	FreeLibrary(user32);
 	initRawInput();
 
 	// Determine whether this system has a high frequency performance counter. */
@@ -464,17 +407,11 @@
 
 GHOST_TSuccess GHOST_SystemWin32::exit()
 {
-//	#ifdef NEED_RAW_PROC
-//	FreeLibrary(user32);
-//	#endif
-
 	return GHOST_System::exit();
 }
 
 GHOST_TKey GHOST_SystemWin32::hardKey(GHOST_IWindow *window, RAWINPUT const& raw, int * keyDown, char * vk)
 {
-//	unsigned int size = 0;
-//	char * data;
 	GHOST_TKey key = GHOST_kKeyUnknown;
 
 
@@ -757,7 +694,6 @@
 	char vk;
 	GHOST_SystemWin32 * system = (GHOST_SystemWin32 *)getSystem();
 	GHOST_TKey key = system->hardKey(window, raw, &keyDown, &vk);
-//	GHOST_TKey key = system->hardKey(window, wParam, lParam, &keyDown, &vk);
 	GHOST_EventKey* event;
 	if (key != GHOST_kKeyUnknown) {
 		char ascii = '\0';
@@ -832,11 +768,9 @@
 
 		GetRawInputDeviceInfo(raw.header.hDevice, RIDI_DEVICEINFO, &info, &infoSize);
 		if (info.dwType == RIM_TYPEHID)
-			{
-			// printf("hardware ID = %04X:%04X\n", info.hid.dwVendorId, info.hid.dwProductId);
 			m_ndofManager->setDevice(info.hid.dwVendorId, info.hid.dwProductId);
-			}
-		else puts("<!> not a HID device... mouse/kb perhaps?");
+		else
+            puts("<!> not a HID device... mouse/kb perhaps?");
 
 		firstEvent = false;
 		}
@@ -845,13 +779,25 @@
 	// send motion. Mark as 'sent' so motion will always get dispatched.
 	eventSent = true;
 
+#ifdef _MSC_VER
+    // using Microsoft compiler & header files
+    // they invented the RawInput API, so this version is (probably) correct
+	BYTE const* data = raw.data.hid.bRawData;
+	// struct RAWHID {
+  	// DWORD dwSizeHid;
+  	// DWORD dwCount;
+  	// BYTE  bRawData[1];
+	// };
+#else
+	// MinGW's definition (below) doesn't agree, so we need a slight
+	// workaround until it's fixed
 	BYTE const* data = &raw.data.hid.bRawData;
-	// MinGW's definition (below) doesn't agree with MSDN reference for bRawData:
-	// typedef struct tagRAWHID {
-	// 	DWORD dwSizeHid;
-	// 	DWORD dwCount;
-	// 	BYTE bRawData; // <== isn't this s'posed to be a BYTE*?
-	// } RAWHID,*PRAWHID,*LPRAWHID;
+	// struct RAWHID {
+	// DWORD dwSizeHid;
+	// DWORD dwCount;
+	// BYTE bRawData; // <== isn't this s'posed to be a BYTE*?
+	// };
+#endif
 
 	BYTE packetType = data[0];
 	switch (packetType)
@@ -1241,30 +1187,6 @@
 					 * In GHOST, we let DefWindowProc call the timer callback.
 					 */
 					break;
-#if 0 // old NDOF code
-				case WM_BLND_NDOF_AXIS:
-					{
-						GHOST_TEventNDOFData ndofdata;
-						system->m_ndofManager->GHOST_NDOFGetDatas(ndofdata);
-						system->m_eventManager->
-							pushEvent(new GHOST_EventNDOF(
-								system->getMilliSeconds(), 
-								GHOST_kEventNDOFMotion, 
-								window, ndofdata));
-					}
-					break;
-				case WM_BLND_NDOF_BTN:
-					{
-						GHOST_TEventNDOFData ndofdata;
-						system->m_ndofManager->GHOST_NDOFGetDatas(ndofdata);
-						system->m_eventManager->
-							pushEvent(new GHOST_EventNDOF(
-								system->getMilliSeconds(), 
-								GHOST_kEventNDOFButton, 
-								window, ndofdata));
-					}
-					break;
-#endif // old NDOF code
 			}
 		}
 		else {
@@ -1284,13 +1206,6 @@
 		GHOST_PRINT("GHOST_SystemWin32::wndProc: event without window\n")
 	}
 
-//	if (event) {
-//		system->pushEvent(event);
-//	}
-//	else {
-//		lResult = ::DefWindowProc(hwnd, msg, wParam, lParam);
-//	}
-
 	if (event) {
 		system->pushEvent(event);
 		eventHandled = true;

Modified: branches/merwin-spacenav/intern/ghost/intern/GHOST_SystemWin32.h
===================================================================
--- branches/merwin-spacenav/intern/ghost/intern/GHOST_SystemWin32.h	2011-07-06 18:34:01 UTC (rev 38163)
+++ branches/merwin-spacenav/intern/ghost/intern/GHOST_SystemWin32.h	2011-07-06 18:50:59 UTC (rev 38164)
@@ -38,7 +38,6 @@
 #error WIN32 only!
 #endif // WIN32
 
-//#undef _WIN32_WINNT
 #define _WIN32_WINNT 0x501 // require Windows XP or newer
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
@@ -50,96 +49,6 @@
 #	define __int64 long long
 #endif
 
-/* RawInput definitions should not be needed, due to WinXP requirement
-
-#ifndef WM_INPUT
-#define WM_INPUT 0x00FF
-#endif 
-#ifndef RID_INPUT
-#define RID_INPUT 0x10000003
-#endif
-#ifndef RIM_INPUTSINK
-#define RIM_INPUTSINK 0x1
-#endif
-#ifndef RI_KEY_BREAK
-#define RI_KEY_BREAK 0x1
-#endif
-#ifndef RI_KEY_E0
-#define RI_KEY_E0 0x2
-#endif
-#ifndef RI_KEY_E1
-#define RI_KEY_E1 0x4
-#endif
-#ifndef RIM_TYPEMOUSE
-#define RIM_TYPEMOUSE		0x0
-#define RIM_TYPEKEYBOARD	0x1
-#define RIM_TYPEHID			0x2
-
-typedef struct tagRAWINPUTDEVICE {
-	USHORT usUsagePage;
-	USHORT usUsage;
-	DWORD dwFlags;
-	HWND hwndTarget;
-} RAWINPUTDEVICE;
-
-typedef struct tagRAWINPUTHEADER {
-	DWORD dwType;
-	DWORD dwSize;
-	HANDLE hDevice;
-	WPARAM wParam;
-} RAWINPUTHEADER;
-
-typedef struct tagRAWMOUSE {
-	USHORT usFlags;
-	union {
-		ULONG ulButtons;
-		struct	{
-			USHORT	usButtonFlags;
-			USHORT	usButtonData;
-		};
-	};
-	ULONG	ulRawButtons;
-	LONG	lLastX;
-	LONG	lLastY;
-	ULONG	ulExtraInformation;
-} RAWMOUSE;
-
-typedef struct tagRAWKEYBOARD {
-	USHORT	MakeCode;
-	USHORT	Flags;
-	USHORT	Reserved;
-	USHORT	VKey;
-	UINT	Message;
-	ULONG	ExtraInformation;
-} RAWKEYBOARD;
-
-typedef struct tagRAWHID {
-	DWORD	dwSizeHid;
-	DWORD	dwCount;
-	BYTE	bRawData[1];
-} RAWHID;
-
-typedef struct tagRAWINPUT {
-	RAWINPUTHEADER header;
-	union {
-		RAWMOUSE	mouse;
-		RAWKEYBOARD keyboard;
-		RAWHID      hid;
-	} data;
-} RAWINPUT;
-
-DECLARE_HANDLE(HRAWINPUT);
-#endif
-
-#ifdef FREE_WINDOWS
-#define NEED_RAW_PROC
-typedef BOOL (WINAPI * LPFNDLLRRID)(RAWINPUTDEVICE*,UINT, UINT);
-
-typedef UINT (WINAPI * LPFNDLLGRID)(HRAWINPUT, UINT, LPVOID, PUINT, UINT);
-#define GetRawInputData(hRawInput, uiCommand, pData, pcbSize, cbSizeHeader) ((pGetRawInputData)?pGetRawInputData(hRawInput, uiCommand, pData, pcbSize, cbSizeHeader):(UINT)-1)
-#endif
-*/
-
 class GHOST_EventButton;
 class GHOST_EventCursor;
 class GHOST_EventKey;
@@ -426,11 +335,6 @@
 	static LRESULT WINAPI s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
 
 	/**
-	 * Initiates WM_INPUT messages from keyboard 
-	 */
-//	GHOST_TInt32 initKeyboardRawInput(void);
-
-	/**
  * Toggles console
  * @action	0 - Hides
  *			1 - Shows
@@ -458,15 +362,6 @@
 
 	/** Console status */
 	int m_consoleStatus;
-
-	/** handle for user32.dll*/
-//	HMODULE user32;
-//	#ifdef NEED_RAW_PROC
-//	/* pointer to RegisterRawInputDevices function */
-//	LPFNDLLRRID pRegisterRawInputDevices;
-//	/* pointer to GetRawInputData function */

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list