diff options
-rw-r--r-- | intern/ghost/intern/GHOST_NDOFManagerWin32.cpp | 6 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_NDOFManagerWin32.h | 8 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemWin32.cpp | 43 |
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; } |