Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Erwin <significant.bit@gmail.com>2011-08-04 07:14:00 +0400
committerMike Erwin <significant.bit@gmail.com>2011-08-04 07:14:00 +0400
commita6fed14da4569380cecac3154482d0e6e54d1433 (patch)
treefd34b536492cd3910a3b2e6d8bc45003bdef1f89 /intern/ghost
parente5e6f91856efe3d78eab747c25be4e1d0a5988ef (diff)
stricter guards for disabling NDOF code (will test in 3.. 2.. 1..)
Diffstat (limited to 'intern/ghost')
-rw-r--r--intern/ghost/intern/GHOST_NDOFManagerWin32.cpp6
-rw-r--r--intern/ghost/intern/GHOST_NDOFManagerWin32.h8
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.cpp43
3 files changed, 35 insertions, 22 deletions
diff --git a/intern/ghost/intern/GHOST_NDOFManagerWin32.cpp b/intern/ghost/intern/GHOST_NDOFManagerWin32.cpp
index 57d84ec14d4..fd62e845f7d 100644
--- a/intern/ghost/intern/GHOST_NDOFManagerWin32.cpp
+++ b/intern/ghost/intern/GHOST_NDOFManagerWin32.cpp
@@ -22,7 +22,9 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
-
+
+#ifdef WITH_INPUT_NDOF // use contents of this file
+
#include "GHOST_NDOFManagerWin32.h"
@@ -39,3 +41,5 @@ bool GHOST_NDOFManagerWin32::available()
// always available since RawInput is built into Windows
return true;
}
+
+#endif // WITH_INPUT_NDOF
diff --git a/intern/ghost/intern/GHOST_NDOFManagerWin32.h b/intern/ghost/intern/GHOST_NDOFManagerWin32.h
index 31f7e074cd6..9f3eddeb3c8 100644
--- a/intern/ghost/intern/GHOST_NDOFManagerWin32.h
+++ b/intern/ghost/intern/GHOST_NDOFManagerWin32.h
@@ -22,10 +22,13 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
-
+
+
#ifndef _GHOST_NDOFMANAGERWIN32_H_
#define _GHOST_NDOFMANAGERWIN32_H_
+#ifdef WITH_INPUT_NDOF
+
#include "GHOST_NDOFManager.h"
@@ -37,4 +40,5 @@ public:
};
-#endif
+#endif // WITH_INPUT_NDOF
+#endif // #include guard
diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index bbf8efeaee3..38f3985b139 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -62,7 +62,6 @@
#endif
#endif
-#include "GHOST_Debug.h"
#include "GHOST_DisplayManagerWin32.h"
#include "GHOST_EventButton.h"
#include "GHOST_EventCursor.h"
@@ -72,7 +71,10 @@
#include "GHOST_TimerManager.h"
#include "GHOST_WindowManager.h"
#include "GHOST_WindowWin32.h"
+
+#ifdef WITH_INPUT_NDOF
#include "GHOST_NDOFManagerWin32.h"
+#endif
// Key code values not found in winuser.h
#ifndef VK_MINUS
@@ -127,22 +129,32 @@
static void initRawInput()
{
- RAWINPUTDEVICE devices[2];
- memset(devices, 0, 2 * sizeof(RAWINPUTDEVICE));
+#ifdef WITH_INPUT_NDOF
+#define DEVICE_COUNT 2
+#else
+#define DEVICE_COUNT 1
+#endif
- // multi-axis mouse (SpaceNavigator, etc.)
- devices[0].usUsagePage = 0x01;
- devices[0].usUsage = 0x08;
+ RAWINPUTDEVICE devices[DEVICE_COUNT];
+ memset(devices, 0, DEVICE_COUNT * sizeof(RAWINPUTDEVICE));
// Initiates WM_INPUT messages from keyboard
// That way GHOST can retrieve true keys
+ devices[0].usUsagePage = 0x01;
+ devices[0].usUsage = 0x06; /* http://msdn.microsoft.com/en-us/windows/hardware/gg487473.aspx */
+
+#ifdef WITH_INPUT_NDOF
+ // multi-axis mouse (SpaceNavigator, etc.)
devices[1].usUsagePage = 0x01;
- devices[1].usUsage = 0x06; /* http://msdn.microsoft.com/en-us/windows/hardware/gg487473.aspx */
+ devices[1].usUsage = 0x08;
+#endif
- if (RegisterRawInputDevices(devices, 2, sizeof(RAWINPUTDEVICE)))
- puts("registered for RawInput (spacenav & keyboard)");
+ if (RegisterRawInputDevices(devices, DEVICE_COUNT, sizeof(RAWINPUTDEVICE)))
+ ; // yay!
else
printf("could not register for RawInput: %d\n", (int)GetLastError());
+
+#undef DEVICE_COUNT
}
GHOST_SystemWin32::GHOST_SystemWin32()
@@ -808,6 +820,7 @@ bool GHOST_SystemWin32::processNDOF(RAWINPUT const& raw)
case 1: // translation
{
short* axis = (short*)(data + 1);
+ // massage into blender view coords (same goes for rotation)
short t[3] = {axis[0], -axis[2], axis[1]};
m_ndofManager->updateTranslation(t, now);
@@ -830,14 +843,6 @@ bool GHOST_SystemWin32::processNDOF(RAWINPUT const& raw)
}
case 3: // buttons
{
-#if 0
- // I'm getting garbage bits -- examine whole report:
- printf("ndof: HID report for buttons [");
- for (int i = 0; i < raw.data.hid.dwSizeHid; ++i)
- printf(" %02X", data[i]);
- printf(" ]\n");
-#endif
-
int button_bits;
memcpy(&button_bits, data + 1, sizeof(button_bits));
m_ndofManager->updateButtons(button_bits, now);
@@ -892,12 +897,12 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
GHOST_PRINT(" key ignored\n")
}
break;
- case RIM_TYPEHID:
#ifdef WITH_INPUT_NDOF
+ case RIM_TYPEHID:
if (system->processNDOF(raw))
eventHandled = true;
-#endif
break;
+#endif
}
break;
}