From b10d0058d72da3051895481ae5830a7b668b7d80 Mon Sep 17 00:00:00 2001 From: Mike Erwin Date: Thu, 18 Aug 2016 00:21:55 -0400 Subject: NDOF: compile 3D mouse code only if WITH_INPUT_NDOF When WITH_INPUT_NDOF is disabled, 3D mouse handling code is removed from: - GHOST (was mostly done, finished the job) - window manager - various editors - RNA - keymaps The input tab of user prefs does not show 3D mouse settings. Key map editor does not show NDOF mappings. DNA does not change. On my Mac the compiled binary is 42KB smaller after this change. It runs fine WITH_INPUT_NDOF on or off. --- intern/ghost/GHOST_C-api.h | 2 ++ intern/ghost/GHOST_ISystem.h | 2 ++ intern/ghost/GHOST_Types.h | 4 ++++ intern/ghost/intern/GHOST_C-api.cpp | 3 ++- intern/ghost/intern/GHOST_EventNDOF.h | 5 ++++- intern/ghost/intern/GHOST_NDOFManager.h | 4 ++++ intern/ghost/intern/GHOST_NDOFManagerCocoa.h | 4 ---- intern/ghost/intern/GHOST_NDOFManagerUnix.cpp | 4 ---- intern/ghost/intern/GHOST_NDOFManagerUnix.h | 3 --- intern/ghost/intern/GHOST_NDOFManagerWin32.cpp | 4 ---- intern/ghost/intern/GHOST_NDOFManagerWin32.h | 4 ---- intern/ghost/intern/GHOST_System.cpp | 11 ++++++----- intern/ghost/intern/GHOST_System.h | 4 ++++ intern/ghost/intern/GHOST_SystemWin32.cpp | 6 +++--- 14 files changed, 31 insertions(+), 29 deletions(-) (limited to 'intern/ghost') diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h index f1484a298d3..ff1922af4f3 100644 --- a/intern/ghost/GHOST_C-api.h +++ b/intern/ghost/GHOST_C-api.h @@ -433,6 +433,7 @@ extern GHOST_TSuccess GHOST_GetButtonState(GHOST_SystemHandle systemhandle, GHOST_TButtonMask mask, int *isDown); +#ifdef WITH_INPUT_NDOF /*************************************************************************************** * Access to 3D mouse. ***************************************************************************************/ @@ -442,6 +443,7 @@ extern GHOST_TSuccess GHOST_GetButtonState(GHOST_SystemHandle systemhandle, * \param deadzone Deadzone of the 3D mouse (both for rotation and pan) relative to full range */ extern void GHOST_setNDOFDeadZone(float deadzone); +#endif /*************************************************************************************** diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h index 08045b93db9..03193d6e1da 100644 --- a/intern/ghost/GHOST_ISystem.h +++ b/intern/ghost/GHOST_ISystem.h @@ -377,11 +377,13 @@ public: */ virtual GHOST_TSuccess getButtonState(GHOST_TButtonMask mask, bool& isDown) const = 0; +#ifdef WITH_INPUT_NDOF /** * Sets 3D mouse deadzone * \param deadzone: Deadzone of the 3D mouse (both for rotation and pan) relative to full range */ virtual void setNDOFDeadZone(float deadzone) = 0; +#endif /** * Toggles console diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h index 0dd5d15b011..9ee4599a4a6 100644 --- a/intern/ghost/GHOST_Types.h +++ b/intern/ghost/GHOST_Types.h @@ -172,8 +172,10 @@ typedef enum { GHOST_kEventWheel, /// Mouse wheel event GHOST_kEventTrackpad, /// Trackpad event +#ifdef WITH_INPUT_NDOF GHOST_kEventNDOFMotion, /// N degree of freedom device motion event GHOST_kEventNDOFButton, /// N degree of freedom device button event +#endif GHOST_kEventKeyDown, GHOST_kEventKeyUp, @@ -478,6 +480,7 @@ typedef enum { GHOST_kFinished } GHOST_TProgress; +#ifdef WITH_INPUT_NDOF typedef struct { /** N-degree of freedom device data v3 [GSoC 2010] */ // Each component normally ranges from -1 to +1, but can exceed that. @@ -497,6 +500,7 @@ typedef struct { GHOST_TButtonAction action; short button; } GHOST_TEventNDOFButtonData; +#endif // WITH_INPUT_NDOF typedef struct { /** The key code. */ diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp index ccd7f57f9a4..41bc735e1e2 100644 --- a/intern/ghost/intern/GHOST_C-api.cpp +++ b/intern/ghost/intern/GHOST_C-api.cpp @@ -406,12 +406,13 @@ GHOST_TSuccess GHOST_GetButtonState(GHOST_SystemHandle systemhandle, } +#ifdef WITH_INPUT_NDOF void GHOST_setNDOFDeadZone(float deadzone) { GHOST_ISystem *system = GHOST_ISystem::getSystem(); system->setNDOFDeadZone(deadzone); } - +#endif void GHOST_setAcceptDragOperation(GHOST_WindowHandle windowhandle, GHOST_TInt8 canAccept) { diff --git a/intern/ghost/intern/GHOST_EventNDOF.h b/intern/ghost/intern/GHOST_EventNDOF.h index b4037896b93..754e1091860 100644 --- a/intern/ghost/intern/GHOST_EventNDOF.h +++ b/intern/ghost/intern/GHOST_EventNDOF.h @@ -22,9 +22,12 @@ /** \file ghost/intern/GHOST_EventNDOF.h * \ingroup GHOST - * Declaration of GHOST_EventManager class. */ +#ifndef WITH_INPUT_NDOF +# error NDOF code included in non-NDOF-enabled build +#endif + #ifndef __GHOST_EVENTNDOF_H__ #define __GHOST_EVENTNDOF_H__ diff --git a/intern/ghost/intern/GHOST_NDOFManager.h b/intern/ghost/intern/GHOST_NDOFManager.h index d3c70bbac50..83d06ef5871 100644 --- a/intern/ghost/intern/GHOST_NDOFManager.h +++ b/intern/ghost/intern/GHOST_NDOFManager.h @@ -21,6 +21,10 @@ * ***** END GPL LICENSE BLOCK ***** */ +#ifndef WITH_INPUT_NDOF +# error NDOF code included in non-NDOF-enabled build +#endif + #ifndef __GHOST_NDOFMANAGER_H__ #define __GHOST_NDOFMANAGER_H__ diff --git a/intern/ghost/intern/GHOST_NDOFManagerCocoa.h b/intern/ghost/intern/GHOST_NDOFManagerCocoa.h index 464ba48145e..3f1bfcf57fc 100644 --- a/intern/ghost/intern/GHOST_NDOFManagerCocoa.h +++ b/intern/ghost/intern/GHOST_NDOFManagerCocoa.h @@ -24,8 +24,6 @@ #ifndef __GHOST_NDOFMANAGERCOCOA_H__ #define __GHOST_NDOFMANAGERCOCOA_H__ -#ifdef WITH_INPUT_NDOF - #include "GHOST_NDOFManager.h" // Event capture is handled within the NDOF manager on Macintosh, @@ -40,6 +38,4 @@ public: bool available(); }; - -#endif // WITH_INPUT_NDOF #endif // #include guard diff --git a/intern/ghost/intern/GHOST_NDOFManagerUnix.cpp b/intern/ghost/intern/GHOST_NDOFManagerUnix.cpp index 8fea2a0261b..ded13b5c094 100644 --- a/intern/ghost/intern/GHOST_NDOFManagerUnix.cpp +++ b/intern/ghost/intern/GHOST_NDOFManagerUnix.cpp @@ -21,8 +21,6 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifdef WITH_INPUT_NDOF - #include "GHOST_NDOFManagerUnix.h" #include "GHOST_System.h" @@ -144,5 +142,3 @@ bool GHOST_NDOFManagerUnix::processEvents() return anyProcessed; } - -#endif /* WITH_INPUT_NDOF */ diff --git a/intern/ghost/intern/GHOST_NDOFManagerUnix.h b/intern/ghost/intern/GHOST_NDOFManagerUnix.h index 278a8cb6fe0..3fd171d9e76 100644 --- a/intern/ghost/intern/GHOST_NDOFManagerUnix.h +++ b/intern/ghost/intern/GHOST_NDOFManagerUnix.h @@ -24,8 +24,6 @@ #ifndef __GHOST_NDOFMANAGERUNIX_H__ #define __GHOST_NDOFMANAGERUNIX_H__ -#ifdef WITH_INPUT_NDOF - #include "GHOST_NDOFManager.h" /* Event capture is handled within the NDOF manager on Linux, @@ -43,5 +41,4 @@ private: bool m_available; }; -#endif /* WITH_INPUT_NDOF */ #endif /* __GHOST_NDOFMANAGERUNIX_H__ */ diff --git a/intern/ghost/intern/GHOST_NDOFManagerWin32.cpp b/intern/ghost/intern/GHOST_NDOFManagerWin32.cpp index 7ccd2e602b4..0023ee7e1d0 100644 --- a/intern/ghost/intern/GHOST_NDOFManagerWin32.cpp +++ b/intern/ghost/intern/GHOST_NDOFManagerWin32.cpp @@ -22,8 +22,6 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifdef WITH_INPUT_NDOF // use contents of this file - #include "GHOST_NDOFManagerWin32.h" @@ -40,5 +38,3 @@ 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 9b5192817eb..2f7bc9ee732 100644 --- a/intern/ghost/intern/GHOST_NDOFManagerWin32.h +++ b/intern/ghost/intern/GHOST_NDOFManagerWin32.h @@ -25,8 +25,6 @@ #ifndef __GHOST_NDOFMANAGERWIN32_H__ #define __GHOST_NDOFMANAGERWIN32_H__ -#ifdef WITH_INPUT_NDOF - #include "GHOST_NDOFManager.h" @@ -37,6 +35,4 @@ public: bool available(); }; - -#endif // WITH_INPUT_NDOF #endif // #include guard diff --git a/intern/ghost/intern/GHOST_System.cpp b/intern/ghost/intern/GHOST_System.cpp index c53580818e6..56d68b98ce0 100644 --- a/intern/ghost/intern/GHOST_System.cpp +++ b/intern/ghost/intern/GHOST_System.cpp @@ -38,11 +38,13 @@ #include "GHOST_DisplayManager.h" #include "GHOST_EventManager.h" -#include "GHOST_NDOFManager.h" #include "GHOST_TimerTask.h" #include "GHOST_TimerManager.h" #include "GHOST_WindowManager.h" +#ifdef WITH_INPUT_NDOF +# include "GHOST_NDOFManager.h" +#endif GHOST_System::GHOST_System() : m_nativePixel(false), @@ -292,14 +294,12 @@ GHOST_TSuccess GHOST_System::getButtonState(GHOST_TButtonMask mask, bool& isDown return success; } +#ifdef WITH_INPUT_NDOF void GHOST_System::setNDOFDeadZone(float deadzone) { -#ifdef WITH_INPUT_NDOF this->m_ndofManager->setDeadZone(deadzone); -#else - (void)deadzone; -#endif } +#endif GHOST_TSuccess GHOST_System::init() { @@ -345,6 +345,7 @@ GHOST_TSuccess GHOST_System::exit() delete m_ndofManager; m_ndofManager = NULL; #endif + return GHOST_kSuccess; } diff --git a/intern/ghost/intern/GHOST_System.h b/intern/ghost/intern/GHOST_System.h index a10259bc9e9..af083996d91 100644 --- a/intern/ghost/intern/GHOST_System.h +++ b/intern/ghost/intern/GHOST_System.h @@ -48,7 +48,9 @@ class GHOST_Event; class GHOST_TimerManager; class GHOST_Window; class GHOST_WindowManager; +#ifdef WITH_INPUT_NDOF class GHOST_NDOFManager; +#endif /** * Implementation of platform independent functionality of the GHOST_ISystem @@ -236,6 +238,7 @@ public: */ GHOST_TSuccess getButtonState(GHOST_TButtonMask mask, bool& isDown) const; +#ifdef WITH_INPUT_NDOF /*************************************************************************************** * Access to 3D mouse. ***************************************************************************************/ @@ -245,6 +248,7 @@ public: * \param deadzone: Deadzone of the 3D mouse (both for rotation and pan) relative to full range */ void setNDOFDeadZone(float deadzone); +#endif /*************************************************************************************** * Other (internal) functionality. diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index 1ce8002520f..f884b0fadb1 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -57,7 +57,7 @@ #include "GHOST_WindowWin32.h" #ifdef WITH_INPUT_NDOF -#include "GHOST_NDOFManagerWin32.h" + #include "GHOST_NDOFManagerWin32.h" #endif // Key code values not found in winuser.h @@ -125,9 +125,9 @@ static void initRawInput() { #ifdef WITH_INPUT_NDOF -#define DEVICE_COUNT 2 + #define DEVICE_COUNT 2 #else -#define DEVICE_COUNT 1 + #define DEVICE_COUNT 1 #endif RAWINPUTDEVICE devices[DEVICE_COUNT]; -- cgit v1.2.3