NDOF: compile 3D mouse code only if WITH_INPUT_NDOF
authorMike Erwin <significant.bit@gmail.com>
Thu, 18 Aug 2016 04:21:55 +0000 (00:21 -0400)
committerMike Erwin <significant.bit@gmail.com>
Thu, 18 Aug 2016 04:22:18 +0000 (00:22 -0400)
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.

49 files changed:
intern/ghost/GHOST_C-api.h
intern/ghost/GHOST_ISystem.h
intern/ghost/GHOST_Types.h
intern/ghost/intern/GHOST_C-api.cpp
intern/ghost/intern/GHOST_EventNDOF.h
intern/ghost/intern/GHOST_NDOFManager.h
intern/ghost/intern/GHOST_NDOFManagerCocoa.h
intern/ghost/intern/GHOST_NDOFManagerUnix.cpp
intern/ghost/intern/GHOST_NDOFManagerUnix.h
intern/ghost/intern/GHOST_NDOFManagerWin32.cpp
intern/ghost/intern/GHOST_NDOFManagerWin32.h
intern/ghost/intern/GHOST_System.cpp
intern/ghost/intern/GHOST_System.h
intern/ghost/intern/GHOST_SystemWin32.cpp
release/scripts/startup/bl_ui/space_userpref.py
source/blender/editors/CMakeLists.txt
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/view2d_ops.c
source/blender/editors/sculpt_paint/paint_stroke.c
source/blender/editors/space_action/action_ops.c
source/blender/editors/space_clip/clip_intern.h
source/blender/editors/space_clip/clip_ops.c
source/blender/editors/space_clip/space_clip.c
source/blender/editors/space_graph/graph_ops.c
source/blender/editors/space_image/image_intern.h
source/blender/editors/space_image/image_ops.c
source/blender/editors/space_image/space_image.c
source/blender/editors/space_logic/space_logic.c
source/blender/editors/space_nla/nla_ops.c
source/blender/editors/space_node/node_ops.c
source/blender/editors/space_sequencer/sequencer_ops.c
source/blender/editors/space_time/time_ops.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/space_view3d/view3d_edit.c
source/blender/editors/space_view3d/view3d_fly.c
source/blender/editors/space_view3d/view3d_intern.h
source/blender/editors/space_view3d/view3d_ops.c
source/blender/editors/space_view3d/view3d_walk.c
source/blender/editors/transform/transform_ops.c
source/blender/makesrna/intern/CMakeLists.txt
source/blender/makesrna/intern/rna_userdef.c
source/blender/makesrna/intern/rna_wm.c
source/blender/windowmanager/CMakeLists.txt
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/WM_types.h
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_init_exit.c
source/blender/windowmanager/intern/wm_operators.c
source/blender/windowmanager/wm_event_types.h

index f1484a298d3d22a83dee63296227b89222a30ab2..ff1922af4f3b2208197b877c92fb3350a66d8644 100644 (file)
@@ -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
 
 
 /***************************************************************************************
index 08045b93db9ad530efe3396dc5efe2ec87c4dceb..03193d6e1da0f87ee4ecba089dde40c49d34b1a2 100644 (file)
@@ -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
index 0dd5d15b0116b8b899aff9d62c2e8ab9c29dd7ed..9ee4599a4a6dc33b4d6277dedf4841650a1bd40f 100644 (file)
@@ -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. */
index ccd7f57f9a4bf041bb73e5855dc979f23476224d..41bc735e1e23785bdb903350450cced963f9ca6c 100644 (file)
@@ -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)
 {
index b4037896b93561bdda030575f84876a0071286f2..754e1091860a8b165a974f1917e41d95a4ecf248 100644 (file)
 
 /** \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__
 
index d3c70bbac50085fcdee107e1563eef29d92c4b42..83d06ef5871403b2da9642b0c371a9c78d501d31 100644 (file)
  * ***** 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__
 
index 464ba48145eaacfc6aab8975462726747e743f61..3f1bfcf57fc98b1f53130e56e44de655d1cc70fb 100644 (file)
@@ -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
index 8fea2a0261bb37c9b50240f27ae2e18035ec2b61..ded13b5c0949129320c391d2d7a7b04450fd73e8 100644 (file)
@@ -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 */
index 278a8cb6fe09080fe44eb6cc792a17636c45676c..3fd171d9e760dd7b08fd76eb7bbe3a83bc6b9101 100644 (file)
@@ -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__ */
index 7ccd2e602b4d2645e53bcddb5e60e22254c2a95a..0023ee7e1d03ff6d90299cf71a91972def0de001 100644 (file)
@@ -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
index 9b5192817ebce61c1f866a069513d19cd389b40f..2f7bc9ee732f336c0c18c3872cdda648067cc97a 100644 (file)
@@ -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
index c53580818e610fda353ec95dee5fbdad89ce75c4..56d68b98ce0d1a4c2b2b4e1178bcd6846e727d2b 100644 (file)
 
 #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;
 }
 
index a10259bc9e97395c6b01b7c78b666dad580ec6da..af083996d91b6865003b684047ac6feb2672466b 100644 (file)
@@ -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.
index 1ce8002520fadfbd650a7d81de378eae1e60bae4..f884b0fadb1e54efa446ef943e99fad55696b6ab 100644 (file)
@@ -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
 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];
index 1512f4f46009f0fc71046810b7d685db996899b8..dcafac66fcac44da5ac0e02517ad87b452808b8d 100644 (file)
@@ -1177,15 +1177,16 @@ class USERPREF_PT_input(Panel):
             sub.prop(walk, "view_height")
             sub.prop(walk, "jump_height")
 
-        col.separator()
-        col.label(text="NDOF Device:")
-        sub = col.column(align=True)
-        sub.prop(inputs, "ndof_sensitivity", text="NDOF Sensitivity")
-        sub.prop(inputs, "ndof_orbit_sensitivity", text="NDOF Orbit Sensitivity")
-        sub.prop(inputs, "ndof_deadzone", text="NDOF Deadzone")
-        sub = col.column(align=True)
-        sub.row().prop(inputs, "ndof_view_navigate_method", expand=True)
-        sub.row().prop(inputs, "ndof_view_rotate_method", expand=True)
+        if inputs.use_ndof:
+            col.separator()
+            col.label(text="NDOF Device:")
+            sub = col.column(align=True)
+            sub.prop(inputs, "ndof_sensitivity", text="NDOF Sensitivity")
+            sub.prop(inputs, "ndof_orbit_sensitivity", text="NDOF Orbit Sensitivity")
+            sub.prop(inputs, "ndof_deadzone", text="NDOF Deadzone")
+            sub = col.column(align=True)
+            sub.row().prop(inputs, "ndof_view_navigate_method", expand=True)
+            sub.row().prop(inputs, "ndof_view_rotate_method", expand=True)
 
         row.separator()
 
index 084006ce277ead0d42dc059fb5086fe63d0ef917..1559512d713f2108fe09a56e254f769610a4316f 100644 (file)
 # ***** END GPL LICENSE BLOCK *****
 
 if(WITH_BLENDER)
+       if(WITH_INPUT_NDOF)
+               add_definitions(-DWITH_INPUT_NDOF)
+       endif()
+
        add_subdirectory(animation)
        add_subdirectory(armature)
        add_subdirectory(curve)
index 79831cefde6badb83bebf8c0a8d4799fd943ba5f..d05a80bed62ee36ae64fdce1224a0b7af99d5927 100644 (file)
@@ -5415,6 +5415,7 @@ static bool ui_numedit_but_HSVCUBE(
        return changed;
 }
 
+#ifdef WITH_INPUT_NDOF
 static void ui_ndofedit_but_HSVCUBE(
         uiBut *but, uiHandleButtonData *data,
         const wmNDOFMotionData *ndof,
@@ -5487,6 +5488,7 @@ static void ui_ndofedit_but_HSVCUBE(
        copy_v3_v3(data->vec, rgb);
        ui_but_v3_set(but, data->vec);
 }
+#endif /* WITH_INPUT_NDOF */
 
 static int ui_do_but_HSVCUBE(
         bContext *C, uiBlock *block, uiBut *but,
@@ -5514,6 +5516,7 @@ static int ui_do_but_HSVCUBE(
                        
                        return WM_UI_HANDLER_BREAK;
                }
+#ifdef WITH_INPUT_NDOF
                else if (event->type == NDOF_MOTION) {
                        const wmNDOFMotionData *ndof = event->customdata;
                        const enum eSnapType snap = ui_event_to_snap(event);
@@ -5525,6 +5528,7 @@ static int ui_do_but_HSVCUBE(
                        
                        return WM_UI_HANDLER_BREAK;
                }
+#endif /* WITH_INPUT_NDOF */
                /* XXX hardcoded keymap check.... */
                else if (event->type == BACKSPACEKEY && event->val == KM_PRESS) {
                        if (ELEM(but->a1, UI_GRAD_V_ALT, UI_GRAD_L_ALT)) {
@@ -5680,6 +5684,7 @@ static bool ui_numedit_but_HSVCIRCLE(
        return changed;
 }
 
+#ifdef WITH_INPUT_NDOF
 static void ui_ndofedit_but_HSVCIRCLE(
         uiBut *but, uiHandleButtonData *data,
         const wmNDOFMotionData *ndof,
@@ -5750,7 +5755,7 @@ static void ui_ndofedit_but_HSVCIRCLE(
        
        ui_but_v3_set(but, data->vec);
 }
-
+#endif /* WITH_INPUT_NDOF */
 
 static int ui_do_but_HSVCIRCLE(
         bContext *C, uiBlock *block, uiBut *but,
@@ -5778,6 +5783,7 @@ static int ui_do_but_HSVCIRCLE(
                        
                        return WM_UI_HANDLER_BREAK;
                }
+#ifdef WITH_INPUT_NDOF
                else if (event->type == NDOF_MOTION) {
                        const enum eSnapType snap = ui_event_to_snap(event);
                        const wmNDOFMotionData *ndof = event->customdata;
@@ -5789,6 +5795,7 @@ static int ui_do_but_HSVCIRCLE(
                        
                        return WM_UI_HANDLER_BREAK;
                }
+#endif /* WITH_INPUT_NDOF */
                /* XXX hardcoded keymap check.... */
                else if (event->type == BACKSPACEKEY && event->val == KM_PRESS) {
                        int len;
index f60fed398ec5b4c5e07eaedc653b2eda9574a7ae..f095ba9a03d8c33347f851df973182f063bc777a 100644 (file)
@@ -1296,7 +1296,7 @@ static void VIEW2D_OT_zoom_border(wmOperatorType *ot)
        WM_operator_properties_gesture_border(ot, false);
 }
 
-
+#ifdef WITH_INPUT_NDOF
 static int view2d_ndof_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 {
        if (event->type != NDOF_MOTION) {
@@ -1369,6 +1369,7 @@ static void VIEW2D_OT_ndof(wmOperatorType *ot)
        /* flags */
        ot->flag = OPTYPE_LOCK_BYPASS;
 }
+#endif /* WITH_INPUT_NDOF */
 
 /* ********************************************************* */
 /* SMOOTH VIEW */
@@ -2067,7 +2068,9 @@ void ED_operatortypes_view2d(void)
        WM_operatortype_append(VIEW2D_OT_zoom);
        WM_operatortype_append(VIEW2D_OT_zoom_border);
 
+#ifdef WITH_INPUT_NDOF
        WM_operatortype_append(VIEW2D_OT_ndof);
+#endif
 
        WM_operatortype_append(VIEW2D_OT_smoothview);
        
@@ -2097,7 +2100,9 @@ void ED_keymap_view2d(wmKeyConfig *keyconf)
        WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_down", WHEELDOWNMOUSE, KM_PRESS, KM_SHIFT, 0);
        WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_up", WHEELUPMOUSE, KM_PRESS, KM_SHIFT, 0);
        
+#ifdef WITH_INPUT_NDOF
        WM_keymap_add_item(keymap, "VIEW2D_OT_ndof", NDOF_MOTION, 0, 0, 0);
+#endif
 
        /* zoom - single step */
        WM_keymap_add_item(keymap, "VIEW2D_OT_zoom_out", WHEELOUTMOUSE, KM_PRESS, 0, 0);
index 1431958501dad88f80ca8869865c254941378679..d53d87db228b3a117983f4da01fb05d43115ca8b 100644 (file)
@@ -1102,12 +1102,14 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
        paint_stroke_add_sample(p, stroke, event->mval[0], event->mval[1], pressure);
        paint_stroke_sample_average(stroke, &sample_average);
 
+#ifdef WITH_INPUT_NDOF
        /* let NDOF motion pass through to the 3D view so we can paint and rotate simultaneously!
         * this isn't perfect... even when an extra MOUSEMOVE is spoofed, the stroke discards it
         * since the 2D deltas are zero -- code in this file needs to be updated to use the
         * post-NDOF_MOTION MOUSEMOVE */
        if (event->type == NDOF_MOTION)
                return OPERATOR_PASS_THROUGH;
+#endif
 
        /* one time initialization */
        if (!stroke->stroke_init) {
index a261202b69045d5f9089c7f6034aeca62eaabaaf..718a4fd3c387c04219c9c13a2174c234f08a8194 100644 (file)
@@ -240,7 +240,9 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap)
        /* auto-set range */
        WM_keymap_add_item(keymap, "ACTION_OT_previewrange_set", PKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
        WM_keymap_add_item(keymap, "ACTION_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
+#ifdef WITH_INPUT_NDOF
        WM_keymap_add_item(keymap, "ACTION_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0);
+#endif
        WM_keymap_add_item(keymap, "ACTION_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "ACTION_OT_view_frame", PAD0, KM_PRESS, 0, 0);
 
index 13dcd405ee62d3f239654effb5855dcc624943b3..14393c6968b8461157616c92a846cebd8bd7f8e2 100644 (file)
@@ -106,7 +106,9 @@ void CLIP_OT_change_frame(wmOperatorType *ot);
 void CLIP_OT_rebuild_proxy(struct wmOperatorType *ot);
 void CLIP_OT_mode_set(struct wmOperatorType *ot);
 
+#ifdef WITH_INPUT_NDOF
 void CLIP_OT_view_ndof(struct wmOperatorType *ot);
+#endif
 
 void CLIP_OT_prefetch(struct wmOperatorType *ot);
 
index 83876ae26691e607ed99d7221389d2adfeb1104a..6778a0b180596776124e07c3666d62302929343c 100644 (file)
@@ -1405,6 +1405,7 @@ void CLIP_OT_mode_set(wmOperatorType *ot)
        RNA_def_enum(ot->srna, "mode", rna_enum_clip_editor_mode_items, SC_MODE_TRACKING, "Mode", "");
 }
 
+#ifdef WITH_INPUT_NDOF
 /********************** NDOF operator *********************/
 
 /* Combined pan/zoom from a 3D mouse device.
@@ -1451,6 +1452,7 @@ void CLIP_OT_view_ndof(wmOperatorType *ot)
        ot->invoke = clip_view_ndof_invoke;
        ot->poll = ED_space_clip_view_clip_poll;
 }
+#endif /* WITH_INPUT_NDOF */
 
 /********************** Prefetch operator *********************/
 
index 4f653bab682b66266eab227d29a2b717b7d826f4..05e69968e356c47e7defe6168110599e5198ffcf 100644 (file)
@@ -429,7 +429,9 @@ static void clip_operatortypes(void)
        WM_operatortype_append(CLIP_OT_change_frame);
        WM_operatortype_append(CLIP_OT_rebuild_proxy);
        WM_operatortype_append(CLIP_OT_mode_set);
+#ifdef WITH_INPUT_NDOF
        WM_operatortype_append(CLIP_OT_view_ndof);
+#endif
        WM_operatortype_append(CLIP_OT_prefetch);
        WM_operatortype_append(CLIP_OT_set_scene_frames);
        WM_operatortype_append(CLIP_OT_cursor_set);
@@ -622,8 +624,10 @@ static void clip_keymap(struct wmKeyConfig *keyconf)
 
        WM_keymap_add_item(keymap, "CLIP_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
 
+#ifdef WITH_INPUT_NDOF
        WM_keymap_add_item(keymap, "CLIP_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "CLIP_OT_view_ndof", NDOF_MOTION, 0, 0, 0);
+#endif
 
        /* jump to special frame */
        kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", LEFTARROWKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
@@ -779,7 +783,9 @@ static void clip_keymap(struct wmKeyConfig *keyconf)
 
        /* view */
        WM_keymap_add_item(keymap, "CLIP_OT_graph_view_all", HOMEKEY, KM_PRESS, 0, 0);
+#ifdef WITH_INPUT_NDOF
        WM_keymap_add_item(keymap, "CLIP_OT_graph_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0);
+#endif
        WM_keymap_add_item(keymap, "CLIP_OT_graph_center_current_frame", PADPERIOD, KM_PRESS, 0, 0);
 
        kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", LKEY, KM_PRESS, 0, 0);
@@ -810,7 +816,9 @@ static void clip_keymap(struct wmKeyConfig *keyconf)
        RNA_boolean_set(kmi->ptr, "extend", true);  /* toggle */
 
        WM_keymap_add_item(keymap, "CLIP_OT_dopesheet_view_all", HOMEKEY, KM_PRESS, 0, 0);
+#ifdef WITH_INPUT_NDOF
        WM_keymap_add_item(keymap, "CLIP_OT_dopesheet_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0);
+#endif
 }
 
 const char *clip_context_dir[] = {"edit_movieclip", "edit_mask", NULL};
index 478dbd3d9c06d2aa65a86d46f6e22bc976d73565..75f0da83e77106b4fdf51a8113a1a9bdad6fc692 100644 (file)
@@ -632,7 +632,9 @@ static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap)
        /* auto-set range */
        WM_keymap_add_item(keymap, "GRAPH_OT_previewrange_set", PKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
        WM_keymap_add_item(keymap, "GRAPH_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
+#ifdef WITH_INPUT_NDOF
        WM_keymap_add_item(keymap, "GRAPH_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0);
+#endif
        WM_keymap_add_item(keymap, "GRAPH_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "GRAPH_OT_view_frame", PAD0, KM_PRESS, 0, 0);
 
index 69993c3be65834cb328b888948c18cb1d145f723..52d04ad49562b8883bd57bdcc8c3a64b870c4a7e 100644 (file)
@@ -64,7 +64,9 @@ void IMAGE_OT_view_zoom_in(struct wmOperatorType *ot);
 void IMAGE_OT_view_zoom_out(struct wmOperatorType *ot);
 void IMAGE_OT_view_zoom_ratio(struct wmOperatorType *ot);
 void IMAGE_OT_view_zoom_border(struct wmOperatorType *ot);
+#ifdef WITH_INPUT_NDOF
 void IMAGE_OT_view_ndof(struct wmOperatorType *ot);
+#endif
 
 void IMAGE_OT_new(struct wmOperatorType *ot);
 void IMAGE_OT_open(struct wmOperatorType *ot);
index 1158e692182063fd68bdb707e78d3cc5268c2186..f9d76da9f87344821f11cd7d81d868cae16eca1a 100644 (file)
@@ -656,6 +656,7 @@ void IMAGE_OT_view_zoom(wmOperatorType *ot)
        RNA_def_property_flag(prop, PROP_HIDDEN);
 }
 
+#ifdef WITH_INPUT_NDOF
 /********************** NDOF operator *********************/
 
 /* Combined pan/zoom from a 3D mouse device.
@@ -705,6 +706,7 @@ void IMAGE_OT_view_ndof(wmOperatorType *ot)
        /* flags */
        ot->flag = OPTYPE_LOCK_BYPASS;
 }
+#endif /* WITH_INPUT_NDOF */
 
 /********************** view all operator *********************/
 
index 35a658eac236f0eb51ee61f29111294646ba3bae..6ddf78290aafb6c551ea39f8b2b10c4a4920eea9 100644 (file)
@@ -235,7 +235,9 @@ static void image_operatortypes(void)
        WM_operatortype_append(IMAGE_OT_view_zoom_out);
        WM_operatortype_append(IMAGE_OT_view_zoom_ratio);
        WM_operatortype_append(IMAGE_OT_view_zoom_border);
+#ifdef WITH_INPUT_NDOF
        WM_operatortype_append(IMAGE_OT_view_ndof);
+#endif
 
        WM_operatortype_append(IMAGE_OT_new);
        WM_operatortype_append(IMAGE_OT_open);
@@ -296,8 +298,10 @@ static void image_keymap(struct wmKeyConfig *keyconf)
        WM_keymap_add_item(keymap, "IMAGE_OT_view_pan", MIDDLEMOUSE, KM_PRESS, KM_SHIFT, 0);
        WM_keymap_add_item(keymap, "IMAGE_OT_view_pan", MOUSEPAN, 0, 0, 0);
 
+#ifdef WITH_INPUT_NDOF
        WM_keymap_add_item(keymap, "IMAGE_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0); // or view selected?
        WM_keymap_add_item(keymap, "IMAGE_OT_view_ndof", NDOF_MOTION, 0, 0, 0);
+#endif
 
        WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_in", WHEELINMOUSE, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_out", WHEELOUTMOUSE, KM_PRESS, 0, 0);
index 69966e9bf346ed3e26c9cdc509abfe2e127145ec..12ca141128b706e6558525f6e2db6fac0e06f816 100644 (file)
@@ -186,7 +186,9 @@ static void logic_keymap(struct wmKeyConfig *keyconf)
        WM_keymap_add_menu(keymap, "LOGIC_MT_logicbricks_add", AKEY, KM_PRESS, KM_SHIFT, 0);
        
        WM_keymap_add_item(keymap, "LOGIC_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
+#ifdef WITH_INPUT_NDOF
        WM_keymap_add_item(keymap, "LOGIC_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0);
+#endif
 }
 
 static void logic_refresh(const bContext *UNUSED(C), ScrArea *UNUSED(sa))
index 386950ead3a919d4b20116d68e6c7046e0799a61..48037a10b2d2daa4590eebc75f56fcd394beb9cc 100644 (file)
@@ -242,7 +242,9 @@ static void nla_keymap_main(wmKeyConfig *keyconf, wmKeyMap *keymap)
        WM_keymap_add_item(keymap, "NLA_OT_previewrange_set", PKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
        
        WM_keymap_add_item(keymap, "NLA_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
+#ifdef WITH_INPUT_NDOF
        WM_keymap_add_item(keymap, "NLA_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0);
+#endif
        WM_keymap_add_item(keymap, "NLA_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "NLA_OT_view_frame", PAD0, KM_PRESS, 0, 0);
        
index 7788173a8ee65ee5d4cf5e89ec02e9742576ddd3..5118d52efc4629747741640b2bbe1b7d504e010a 100644 (file)
@@ -295,7 +295,9 @@ void node_keymap(struct wmKeyConfig *keyconf)
        WM_keymap_add_item(keymap, "NODE_OT_hide_socket_toggle", HKEY, KM_PRESS, KM_CTRL, 0);
        
        WM_keymap_add_item(keymap, "NODE_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
+#ifdef WITH_INPUT_NDOF
        WM_keymap_add_item(keymap, "NODE_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0);
+#endif
        WM_keymap_add_item(keymap, "NODE_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
 
        kmi = WM_keymap_add_item(keymap, "NODE_OT_select_border", BKEY, KM_PRESS, 0, 0);
index 655e029cfddd3f2628261f65883a68fe735db042..a3cfcae77b87ad590c2cc807003c0b05d3fbfb96 100644 (file)
@@ -201,7 +201,9 @@ void sequencer_keymap(wmKeyConfig *keyconf)
        WM_keymap_add_item(keymap, "SEQUENCER_OT_meta_separate", GKEY, KM_PRESS, KM_ALT, 0);
 
        WM_keymap_add_item(keymap, "SEQUENCER_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
+#ifdef WITH_INPUT_NDOF
        WM_keymap_add_item(keymap, "SEQUENCER_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0);
+#endif
        WM_keymap_add_item(keymap, "SEQUENCER_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "SEQUENCER_OT_view_frame", PAD0, KM_PRESS, 0, 0);
 
@@ -340,7 +342,9 @@ void sequencer_keymap(wmKeyConfig *keyconf)
        /* Preview Region ----------------------------------------------------------- */
        keymap = WM_keymap_find(keyconf, "SequencerPreview", SPACE_SEQ, 0);
        WM_keymap_add_item(keymap, "SEQUENCER_OT_view_all_preview", HOMEKEY, KM_PRESS, 0, 0);
+#ifdef WITH_INPUT_NDOF
        WM_keymap_add_item(keymap, "SEQUENCER_OT_view_all_preview", NDOF_BUTTON_FIT, KM_PRESS, 0, 0);
+#endif
 
        WM_keymap_add_item(keymap, "SEQUENCER_OT_view_ghost_border", OKEY, KM_PRESS, 0, 0);
 
index 7dd45327352d00109450a3d01f80c8e887606f42..872793128f05bdae79bd6eed0d017126b59f87f9 100644 (file)
@@ -219,7 +219,9 @@ void time_keymap(wmKeyConfig *keyconf)
        WM_keymap_add_item(keymap, "TIME_OT_start_frame_set", SKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "TIME_OT_end_frame_set", EKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "TIME_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
+#ifdef WITH_INPUT_NDOF
        WM_keymap_add_item(keymap, "TIME_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0);
+#endif
        WM_keymap_add_item(keymap, "TIME_OT_view_frame", PAD0, KM_PRESS, 0, 0);
 }
 
index 1de06af0478e5894abfe653fac54988a2f7906be..d2a52de0e28617d5afb12cd0b17fc9eb25feecc2 100644 (file)
@@ -645,6 +645,7 @@ static void draw_view_axis(RegionView3D *rv3d, rcti *rect)
        glDisable(GL_BLEND);
 }
 
+#ifdef WITH_INPUT_NDOF
 /* draw center and axis of rotation for ongoing 3D mouse navigation */
 static void draw_rotation_guide(RegionView3D *rv3d)
 {
@@ -749,6 +750,7 @@ static void draw_rotation_guide(RegionView3D *rv3d)
        glDisable(GL_POINT_SMOOTH);
        glDepthMask(1);
 }
+#endif /* WITH_INPUT_NDOF */
 
 static void draw_view_icon(RegionView3D *rv3d, rcti *rect)
 {
@@ -3917,10 +3919,11 @@ static void view3d_main_region_draw_objects(const bContext *C, Scene *scene, Vie
                BDR_drawSketch(C);
        }
 
+#ifdef WITH_INPUT_NDOF
        if ((U.ndof_flag & NDOF_SHOW_GUIDE) && ((rv3d->viewlock & RV3D_LOCKED) == 0) && (rv3d->persp != RV3D_CAMOB))
                /* TODO: draw something else (but not this) during fly mode */
                draw_rotation_guide(rv3d);
-
+#endif
 }
 
 static bool is_cursor_visible(Scene *scene)
index 215d90a887843f86793e82035f65c6ac6c937331..9b8ca2d26da07ff3e19c40d836e546d7d48939be 100644 (file)
@@ -1329,6 +1329,8 @@ void VIEW3D_OT_rotate(wmOperatorType *ot)
        ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR;
 }
 
+#ifdef WITH_INPUT_NDOF
+
 /** \name NDOF Utility Functions
  * \{ */
 
@@ -1894,6 +1896,8 @@ void VIEW3D_OT_ndof_all(struct wmOperatorType *ot)
        ot->flag = 0;
 }
 
+#endif /* WITH_INPUT_NDOF */
+
 /* ************************ viewmove ******************************** */
 
 
index 31377d0fce89d87748ee22693776d3282a47d5c8..04a6aa215f46d32a35308a9e41472b8413362e60 100644 (file)
 
 /* defines VIEW3D_OT_fly modal operator */
 
-//#define NDOF_FLY_DEBUG
-//#define NDOF_FLY_DRAW_TOOMUCH  /* is this needed for ndof? - commented so redraw doesnt thrash - campbell */
+#ifdef WITH_INPUT_NDOF
+//#  define NDOF_FLY_DEBUG
+//#  define NDOF_FLY_DRAW_TOOMUCH  /* is this needed for ndof? - commented so redraw doesnt thrash - campbell */
+#endif /* WITH_INPUT_NDOF */
 
 #include "DNA_object_types.h"
 
@@ -203,7 +205,10 @@ typedef struct FlyInfo {
        int mval[2]; /* latest 2D mouse values */
        int center_mval[2]; /* center mouse values */
        float width, height; /* camera viewport dimensions */
+
+#ifdef WITH_INPUT_NDOF
        wmNDOFMotionData *ndof;  /* latest 3D mouse values */
+#endif
 
        /* fly state state */
        float speed; /* the speed the view is moving per redraw */
@@ -381,7 +386,10 @@ static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent
        fly->timer = WM_event_add_timer(CTX_wm_manager(C), win, TIMER, 0.01f);
 
        copy_v2_v2_int(fly->mval, event->mval);
+
+#ifdef WITH_INPUT_NDOF
        fly->ndof = NULL;
+#endif
 
        fly->time_lastdraw = fly->time_lastwheel = PIL_check_seconds_timer();
 
@@ -449,8 +457,10 @@ static int flyEnd(bContext *C, FlyInfo *fly)
 
        rv3d->rflag &= ~RV3D_NAVIGATING;
 
+#ifdef WITH_INPUT_NDOF
        if (fly->ndof)
                MEM_freeN(fly->ndof);
+#endif
 
        if (fly->state == FLY_CONFIRM) {
                MEM_freeN(fly);
@@ -469,6 +479,7 @@ static void flyEvent(bContext *C, wmOperator *op, FlyInfo *fly, const wmEvent *e
        else if (event->type == MOUSEMOVE) {
                copy_v2_v2_int(fly->mval, event->mval);
        }
+#ifdef WITH_INPUT_NDOF
        else if (event->type == NDOF_MOTION) {
                /* do these automagically get delivered? yes. */
                // puts("ndof motion detected in fly mode!");
@@ -478,15 +489,15 @@ static void flyEvent(bContext *C, wmOperator *op, FlyInfo *fly, const wmEvent *e
                switch (incoming_ndof->progress) {
                        case P_STARTING:
                                /* start keeping track of 3D mouse position */
-#ifdef NDOF_FLY_DEBUG
+#  ifdef NDOF_FLY_DEBUG
                                puts("start keeping track of 3D mouse position");
-#endif
+#  endif
                                /* fall-through */
                        case P_IN_PROGRESS:
                                /* update 3D mouse position */
-#ifdef NDOF_FLY_DEBUG
+#  ifdef NDOF_FLY_DEBUG
                                putchar('.'); fflush(stdout);
-#endif
+#  endif
                                if (fly->ndof == NULL) {
                                        // fly->ndof = MEM_mallocN(sizeof(wmNDOFMotionData), tag_name);
                                        fly->ndof = MEM_dupallocN(incoming_ndof);
@@ -498,9 +509,9 @@ static void flyEvent(bContext *C, wmOperator *op, FlyInfo *fly, const wmEvent *e
                                break;
                        case P_FINISHING:
                                /* stop keeping track of 3D mouse position */
-#ifdef NDOF_FLY_DEBUG
+#  ifdef NDOF_FLY_DEBUG
                                puts("stop keeping track of 3D mouse position");
-#endif
+#  endif
                                if (fly->ndof) {
                                        MEM_freeN(fly->ndof);
                                        // free(fly->ndof);
@@ -513,6 +524,7 @@ static void flyEvent(bContext *C, wmOperator *op, FlyInfo *fly, const wmEvent *e
                                break; /* should always be one of the above 3 */
                }
        }
+#endif /* WITH_INPUT_NDOF */
        /* handle modal keymap first */
        else if (event->type == EVT_MODAL_MAP) {
                switch (event->val) {
@@ -959,6 +971,7 @@ static int flyApply(bContext *C, FlyInfo *fly)
        return OPERATOR_FINISHED;
 }
 
+#ifdef WITH_INPUT_NDOF
 static void flyApply_ndof(bContext *C, FlyInfo *fly)
 {
        Object *lock_ob = ED_view3d_cameracontrol_object_get(fly->v3d_camera_control);
@@ -977,6 +990,7 @@ static void flyApply_ndof(bContext *C, FlyInfo *fly)
                }
        }
 }
+#endif /* WITH_INPUT_NDOF */
 
 static int fly_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 {
@@ -1023,12 +1037,15 @@ static int fly_modal(bContext *C, wmOperator *op, const wmEvent *event)
 
        flyEvent(C, op, fly, event);
 
+#ifdef WITH_INPUT_NDOF
        if (fly->ndof) { /* 3D mouse overrules [2D mouse + timer] */
                if (event->type == NDOF_MOTION) {
                        flyApply_ndof(C, fly);
                }
        }
-       else if (event->type == TIMER && event->customdata == fly->timer) {
+       else
+#endif /* WITH_INPUT_NDOF */
+       if (event->type == TIMER && event->customdata == fly->timer) {
                flyApply(C, fly);
        }
 
index bdd2702a6ce56a7610600fd5c4d99a470df42f03..314dadbaa52e26153e605b886f9a352c323e5aa8 100644 (file)
@@ -46,7 +46,6 @@ struct bContext;
 struct bMotionPath;
 struct bPoseChannel;
 struct Mesh;
-struct wmNDOFMotionData;
 struct wmOperatorType;
 struct wmWindowManager;
 struct wmKeyConfig;
@@ -76,10 +75,12 @@ void VIEW3D_OT_dolly(struct wmOperatorType *ot);
 void VIEW3D_OT_zoom_camera_1_to_1(struct wmOperatorType *ot);
 void VIEW3D_OT_move(struct wmOperatorType *ot);
 void VIEW3D_OT_rotate(struct wmOperatorType *ot);
+#ifdef WITH_INPUT_NDOF
 void VIEW3D_OT_ndof_orbit(struct wmOperatorType *ot);
 void VIEW3D_OT_ndof_orbit_zoom(struct wmOperatorType *ot);
 void VIEW3D_OT_ndof_pan(struct wmOperatorType *ot);
 void VIEW3D_OT_ndof_all(struct wmOperatorType *ot);
+#endif /* WITH_INPUT_NDOF */
 void VIEW3D_OT_view_all(struct wmOperatorType *ot);
 void VIEW3D_OT_viewnumpad(struct wmOperatorType *ot);
 void VIEW3D_OT_view_selected(struct wmOperatorType *ot);
@@ -111,11 +112,15 @@ void view3d_orbit_apply_dyn_ofs(
         float r_ofs[3], const float ofs_old[3], const float viewquat_old[4],
         const float viewquat_new[4], const float dyn_ofs[3]);
 
+#ifdef WITH_INPUT_NDOF
+struct wmNDOFMotionData;
+
 void view3d_ndof_fly(
         const struct wmNDOFMotionData *ndof,
         struct View3D *v3d, struct RegionView3D *rv3d,
         const bool use_precision, const short protectflag,
         bool *r_has_translate, bool *r_has_rotate);
+#endif /* WITH_INPUT_NDOF */
 
 /* view3d_fly.c */
 void view3d_keymap(struct wmKeyConfig *keyconf);
index b273f46fca32a023d8cadb9f4357dcbb482ccbab..cfeb8af280e061e1cc25db86067d550ee0451e02 100644 (file)
@@ -164,10 +164,12 @@ void view3d_operatortypes(void)
        WM_operatortype_append(VIEW3D_OT_zoom);
        WM_operatortype_append(VIEW3D_OT_zoom_camera_1_to_1);
        WM_operatortype_append(VIEW3D_OT_dolly);
+#ifdef WITH_INPUT_NDOF
        WM_operatortype_append(VIEW3D_OT_ndof_orbit_zoom);
        WM_operatortype_append(VIEW3D_OT_ndof_orbit);
        WM_operatortype_append(VIEW3D_OT_ndof_pan);
        WM_operatortype_append(VIEW3D_OT_ndof_all);
+#endif /* WITH_INPUT_NDOF */
        WM_operatortype_append(VIEW3D_OT_view_all);
        WM_operatortype_append(VIEW3D_OT_viewnumpad);
        WM_operatortype_append(VIEW3D_OT_view_orbit);
@@ -363,7 +365,7 @@ void view3d_keymap(wmKeyConfig *keyconf)
 
        WM_keymap_add_item(keymap, "VIEW3D_OT_localview", PADSLASHKEY, KM_PRESS, 0, 0);
        
-       /* NDOF: begin */
+#ifdef WITH_INPUT_NDOF
        /* note: positioned here so keymaps show keyboard keys if assigned */
        /* 3D mouse */
        WM_keymap_add_item(keymap, "VIEW3D_OT_ndof_orbit_zoom", NDOF_MOTION, 0, 0, 0);
@@ -392,8 +394,7 @@ void view3d_keymap(wmKeyConfig *keyconf)
        kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_TOP, KM_PRESS, KM_SHIFT, 0);
        RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_TOP);
        RNA_boolean_set(kmi->ptr, "align_active", true);
-       /* NDOF: end */
-       
+#endif /* WITH_INPUT_NDOF */
 
        /* layers, shift + alt are properties set in invoke() */
        RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", ACCENTGRAVEKEY, KM_PRESS, 0, 0)->ptr, "nr", 0);
index c9e4bb301b82f6f846588458b4f2ebee57db8e12..17c08ed4205a461e9fc087e06b6c11670f4f0d96 100644 (file)
 
 #include "view3d_intern.h"  /* own include */
 
-//#define NDOF_WALK_DEBUG
-//#define NDOF_WALK_DRAW_TOOMUCH  /* is this needed for ndof? - commented so redraw doesnt thrash - campbell */
+#ifdef WITH_INPUT_NDOF
+//#  define NDOF_WALK_DEBUG
+//#  define NDOF_WALK_DRAW_TOOMUCH  /* is this needed for ndof? - commented so redraw doesnt thrash - campbell */
+#endif
 
 #define USE_TABLET_SUPPORT
 
@@ -254,7 +256,10 @@ typedef struct WalkInfo {
        int prev_mval[2]; /* previous 2D mouse values */
        int center_mval[2]; /* center mouse values */
        int moffset[2];
+
+#ifdef WITH_INPUT_NDOF
        wmNDOFMotionData *ndof;  /* latest 3D mouse values */
+#endif
 
        /* walk state state */
        float base_speed; /* the base speed without run/slow down modifications */
@@ -572,7 +577,9 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op)
 
        walk->timer = WM_event_add_timer(CTX_wm_manager(C), win, TIMER, 0.01f);
 
+#ifdef WITH_INPUT_NDOF
        walk->ndof = NULL;
+#endif
 
        walk->time_lastdraw = PIL_check_seconds_timer();
 
@@ -639,8 +646,10 @@ static int walkEnd(bContext *C, WalkInfo *walk)
 
        rv3d->rflag &= ~RV3D_NAVIGATING;
 
+#ifdef WITH_INPUT_NDOF
        if (walk->ndof)
                MEM_freeN(walk->ndof);
+#endif
 
        /* restore the cursor */
        WM_cursor_modal_restore(win);
@@ -743,6 +752,7 @@ static void walkEvent(bContext *C, wmOperator *op, WalkInfo *walk, const wmEvent
                        }
                }
        }
+#ifdef WITH_INPUT_NDOF
        else if (event->type == NDOF_MOTION) {
                /* do these automagically get delivered? yes. */
                // puts("ndof motion detected in walk mode!");
@@ -752,15 +762,15 @@ static void walkEvent(bContext *C, wmOperator *op, WalkInfo *walk, const wmEvent
                switch (incoming_ndof->progress) {
                        case P_STARTING:
                                /* start keeping track of 3D mouse position */
-#ifdef NDOF_WALK_DEBUG
+#  ifdef NDOF_WALK_DEBUG
                                puts("start keeping track of 3D mouse position");
-#endif
+#  endif
                                /* fall-through */
                        case P_IN_PROGRESS:
                                /* update 3D mouse position */
-#ifdef NDOF_WALK_DEBUG
+#  ifdef NDOF_WALK_DEBUG
                                putchar('.'); fflush(stdout);
-#endif
+#  endif
                                if (walk->ndof == NULL) {
                                        // walk->ndof = MEM_mallocN(sizeof(wmNDOFMotionData), tag_name);
                                        walk->ndof = MEM_dupallocN(incoming_ndof);
@@ -772,9 +782,9 @@ static void walkEvent(bContext *C, wmOperator *op, WalkInfo *walk, const wmEvent
                                break;
                        case P_FINISHING:
                                /* stop keeping track of 3D mouse position */
-#ifdef NDOF_WALK_DEBUG
+#  ifdef NDOF_WALK_DEBUG
                                puts("stop keeping track of 3D mouse position");
-#endif
+#  endif
                                if (walk->ndof) {
                                        MEM_freeN(walk->ndof);
                                        // free(walk->ndof);
@@ -789,6 +799,7 @@ static void walkEvent(bContext *C, wmOperator *op, WalkInfo *walk, const wmEvent
                                break; /* should always be one of the above 3 */
                }
        }
+#endif /* WITH_INPUT_NDOF */
        /* handle modal keymap first */
        else if (event->type == EVT_MODAL_MAP) {
                switch (event->val) {
@@ -1323,6 +1334,7 @@ static int walkApply(bContext *C, wmOperator *op, WalkInfo *walk)
 #undef WALK_BOOST_FACTOR
 }
 
+#ifdef WITH_INPUT_NDOF
 static void walkApply_ndof(bContext *C, WalkInfo *walk)
 {
        Object *lock_ob = ED_view3d_cameracontrol_object_get(walk->v3d_camera_control);
@@ -1341,6 +1353,7 @@ static void walkApply_ndof(bContext *C, WalkInfo *walk)
                }
        }
 }
+#endif /* WITH_INPUT_NDOF */
 
 /****** walk operator ******/
 static int walk_invoke(bContext *C, wmOperator *op, const wmEvent *event)
@@ -1388,12 +1401,15 @@ static int walk_modal(bContext *C, wmOperator *op, const wmEvent *event)
 
        walkEvent(C, op, walk, event);
 
+#ifdef WITH_INPUT_NDOF
        if (walk->ndof) { /* 3D mouse overrules [2D mouse + timer] */
                if (event->type == NDOF_MOTION) {
                        walkApply_ndof(C, walk);
                }
        }
-       else if (event->type == TIMER && event->customdata == walk->timer) {
+       else
+#endif /* WITH_INPUT_NDOF */
+       if (event->type == TIMER && event->customdata == walk->timer) {
                walkApply(C, op, walk);
        }
 
index 6e399d9fde366994c5f4cd189ed13e5121494f85..cbe58ddf58679bd275b08b3b56b973241dc5213d 100644 (file)
@@ -386,7 +386,7 @@ static int transform_modal(bContext *C, wmOperator *op, const wmEvent *event)
        TransInfo *t = op->customdata;
        const enum TfmMode mode_prev = t->mode;
 
-#if 0
+#if defined(WITH_INPUT_NDOF) && 0
        // stable 2D mouse coords map to different 3D coords while the 3D mouse is active
        // in other words, 2D deltas are no longer good enough!
        // disable until individual 'transformers' behave better
index 44e99bd2995e9e59c7ff5b4cd3ceb1a61ce5904f..0f3ea27a7f9d2aefc70a6391c7062f8134c8846c 100644 (file)
@@ -327,6 +327,10 @@ if(WITH_OPENVDB)
        endif()
 endif()
 
+if(WITH_INPUT_NDOF)
+       add_definitions(-DWITH_INPUT_NDOF)
+endif()
+
 # Build makesrna executable
 blender_include_dirs(
        .
index cbf7bb4d5e01461b0b9b8e53126eb3549f57cf41..29c0e948a4c0133b71d7a8ba2059ddc788f3bccf 100644 (file)
@@ -292,11 +292,13 @@ static void rna_userdef_autokeymode_set(PointerRNA *ptr, int value)
        }
 }
 
+#ifdef WITH_INPUT_NDOF
 static void rna_userdef_ndof_deadzone_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
 {
        UserDef *userdef = ptr->data;
        WM_ndof_deadzone_set(userdef->ndof_deadzone);
 }
+#endif
 
 static void rna_userdef_timecode_style_set(PointerRNA *ptr, int value)
 {
@@ -4333,6 +4335,7 @@ static void rna_def_userdef_input(BlenderRNA *brna)
                {0, NULL, 0, NULL, NULL}
        };
 
+#ifdef WITH_INPUT_NDOF
        static EnumPropertyItem ndof_view_navigation_items[] = {
                {0, "FREE", 0, "Free", "Use full 6 degrees of freedom by default"},
                {NDOF_MODE_ORBIT, "ORBIT", 0, "Orbit", "Orbit about the view center by default"},
@@ -4344,6 +4347,7 @@ static void rna_def_userdef_input(BlenderRNA *brna)
                {0, "TRACKBALL", 0, "Trackball", "Use trackball style rotation in the viewport"},
                {0, NULL, 0, NULL, NULL}
        };
+#endif /* WITH_INPUT_NDOF */
 
        static EnumPropertyItem view_zoom_styles[] = {
                {USER_ZOOM_CONT, "CONTINUE", 0, "Continue", "Old style zoom, continues while moving mouse up or down"},
@@ -4421,6 +4425,7 @@ static void rna_def_userdef_input(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Tweak Threshold",
                                 "Number of pixels you have to drag before tweak event is triggered");
 
+#ifdef WITH_INPUT_NDOF
        /* 3D mouse settings */
        /* global options */
        prop = RNA_def_property(srna, "ndof_sensitivity", PROP_FLOAT, PROP_NONE);
@@ -4501,6 +4506,13 @@ static void rna_def_userdef_input(BlenderRNA *brna)
        RNA_def_property_boolean_sdna(prop, NULL, "ndof_flag", NDOF_FLY_HELICOPTER);
        RNA_def_property_ui_text(prop, "Helicopter Mode", "Device up/down directly controls your Z position");
 
+       /* let Python know whether NDOF is enabled */
+       prop = RNA_def_boolean(srna, "use_ndof", true, "", "");
+#else
+       prop = RNA_def_boolean(srna, "use_ndof", false, "", "");
+#endif /* WITH_INPUT_NDOF */
+       RNA_def_property_flag(prop, PROP_IDPROPERTY);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 
        prop = RNA_def_property(srna, "mouse_double_click_time", PROP_INT, PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "dbl_click_time");
index 026d2e209a3e0ce3ad1667a4c5e88fac5c466cb1..ba77e2a17688456059232e0f0f3198948614b43c 100644 (file)
@@ -118,6 +118,7 @@ static EnumPropertyItem event_textinput_type_items[] = {
        {0, NULL, 0, NULL, NULL}
 };
 
+#ifdef WITH_INPUT_NDOF
 static EnumPropertyItem event_ndof_type_items[] = {
        {NDOF_MOTION, "NDOF_MOTION", 0, "Motion", ""},
        /* buttons on all 3dconnexion devices */
@@ -167,7 +168,8 @@ static EnumPropertyItem event_ndof_type_items[] = {
        {NDOF_BUTTON_C, "NDOF_BUTTON_C", 0, "Button C", ""},
        {0, NULL, 0, NULL, NULL}
 };
-#endif
+#endif /* WITH_INPUT_NDOF */
+#endif /* RNA_RUNTIME */
 
 /* not returned: CAPSLOCKKEY, UNKNOWNKEY */
 EnumPropertyItem rna_enum_event_type_items[] = {
@@ -332,6 +334,7 @@ EnumPropertyItem rna_enum_event_type_items[] = {
        {TIMERREPORT, "TIMER_REPORT", 0, "Timer Report", "TmrReport"},
        {TIMERREGION, "TIMERREGION", 0, "Timer Region", "TmrReg"},
        {0, "", 0, NULL, NULL},
+#ifdef WITH_INPUT_NDOF
        {NDOF_MOTION, "NDOF_MOTION", 0, "NDOF Motion", "NdofMov"},
        /* buttons on all 3dconnexion devices */
        {NDOF_BUTTON_MENU, "NDOF_BUTTON_MENU", 0, "NDOF Menu", "NdofMenu"},
@@ -379,6 +382,7 @@ EnumPropertyItem rna_enum_event_type_items[] = {
        {NDOF_BUTTON_B, "NDOF_BUTTON_B", 0, "NDOF Button B", "NdofBB"},
        {NDOF_BUTTON_C, "NDOF_BUTTON_C", 0, "NDOF Button C", "NdofBC"},
        {0, NULL, 0, NULL, NULL}
+#endif /* WITH_INPUT_NDOF */
 };
 
 EnumPropertyItem rna_enum_event_value_items[] = {
@@ -701,10 +705,12 @@ static void rna_wmKeyMapItem_map_type_set(PointerRNA *ptr, int value)
                                kmi->type = TIMER;
                                kmi->val = KM_NOTHING;
                                break;
+#ifdef WITH_INPUT_NDOF
                        case KMI_TYPE_NDOF:
                                kmi->type = NDOF_MOTION;
                                kmi->val = KM_NOTHING;
                                break;
+#endif
                }
        }
 }
@@ -738,7 +744,9 @@ static EnumPropertyItem *rna_KeyMapItem_type_itemf(bContext *UNUSED(C), PointerR
        if (map_type == KMI_TYPE_MOUSE) return event_mouse_type_items;
        if (map_type == KMI_TYPE_TWEAK) return event_tweak_type_items;
        if (map_type == KMI_TYPE_TIMER) return event_timer_type_items;
+#ifdef WITH_INPUT_NDOF
        if (map_type == KMI_TYPE_NDOF) return event_ndof_type_items;
+#endif
        if (map_type == KMI_TYPE_TEXTINPUT) return event_textinput_type_items;
        else return rna_enum_event_type_items;
 }
@@ -2014,7 +2022,9 @@ static void rna_def_keyconfig(BlenderRNA *brna)
                {KMI_TYPE_KEYBOARD, "KEYBOARD", 0, "Keyboard", ""},
                {KMI_TYPE_TWEAK, "TWEAK", 0, "Tweak", ""},
                {KMI_TYPE_MOUSE, "MOUSE", 0, "Mouse", ""},
+#ifdef WITH_INPUT_NDOF
                {KMI_TYPE_NDOF, "NDOF", 0, "NDOF", ""},
+#endif
                {KMI_TYPE_TEXTINPUT, "TEXTINPUT", 0, "Text Input", ""},
                {KMI_TYPE_TIMER, "TIMER", 0, "Timer", ""},
                {0, NULL, 0, NULL, NULL}
index 01188cb7f6502f9ebd574c0f65a5249c8e52ed6a..b6245a8c0d1b507cb09d0e6c6c96b7cff72b5a22 100644 (file)
@@ -146,6 +146,10 @@ if(WITH_OPENSUBDIV)
        add_definitions(-DWITH_OPENSUBDIV)
 endif()
 
+if(WITH_INPUT_NDOF)
+       add_definitions(-DWITH_INPUT_NDOF)
+endif()
+
 if(WIN32)
        if(WITH_INPUT_IME)
                add_definitions(-DWITH_INPUT_IME)
index 69905fc296bb07ebe6c8dab310fa3fe31d8f1f99..2b82f1becb3b3643b56af3d0930b62bf5d414db4 100644 (file)
@@ -64,7 +64,10 @@ struct wmDrag;
 struct ImBuf;
 struct ImageFormatData;
 struct ARegion;
+
+#ifdef WITH_INPUT_NDOF
 struct wmNDOFMotionData;
+#endif
 
 typedef struct wmJob wmJob;
 
@@ -186,9 +189,10 @@ void               WM_event_add_mousemove(struct bContext *C);
 bool        WM_modal_tweak_exit(const struct wmEvent *event, int tweak_event);
 bool           WM_event_is_absolute(const struct wmEvent *event);
 
+#ifdef WITH_INPUT_NDOF
                        /* 3D mouse */
 void           WM_ndof_deadzone_set(float deadzone);
-
+#endif
                        /* notifiers */
 void           WM_event_add_notifier(const struct bContext *C, unsigned int type, void *reference);
 void           WM_main_add_notifier(unsigned int type, void *reference);
@@ -498,11 +502,13 @@ bool write_crash_blend(void);
                        /* Lock the interface for any communication */
 void        WM_set_locked_interface(struct wmWindowManager *wm, bool lock);
 
+#ifdef WITH_INPUT_NDOF
 void        WM_event_ndof_pan_get(const struct wmNDOFMotionData *ndof, float r_pan[3], const bool use_zoom);
 void        WM_event_ndof_rotate_get(const struct wmNDOFMotionData *ndof, float r_rot[3]);
 
 float       WM_event_ndof_to_axis_angle(const struct wmNDOFMotionData *ndof, float axis[3]);
 void        WM_event_ndof_to_quat(const struct wmNDOFMotionData *ndof, float q[4]);
+#endif /* WITH_INPUT_NDOF */
 
 float       WM_event_tablet_data(const struct wmEvent *event, int *pen_flip, float tilt[2]);
 bool        WM_event_is_tablet(const struct wmEvent *event);
index 3c0e99bddd0711beb32364a8dd29b0f8d728b1e5..0fe3e8a0fcf390e4c3c17beeb917950342f3e3c0 100644 (file)
@@ -485,6 +485,7 @@ typedef enum {  /* motion progress, for modal handlers */
        P_FINISHED
 } wmProgress;
 
+#ifdef WITH_INPUT_NDOF
 typedef struct wmNDOFMotionData {
        /* awfully similar to GHOST_TEventNDOFMotionData... */
        /* Each component normally ranges from -1 to +1, but can exceed that.
@@ -496,6 +497,7 @@ typedef struct wmNDOFMotionData {
        float dt; /* time since previous NDOF Motion event */
        wmProgress progress; /* is this the first event, the last, or one of many in between? */
 } wmNDOFMotionData;
+#endif /* WITH_INPUT_NDOF */
 
 typedef struct wmTimer {
        struct wmTimer *next, *prev;
index 01dc77127d23fc89bf1a1688c5d284de453746a0..77d743997692e9171faebcf3902f4065435a0097 100644 (file)
@@ -567,6 +567,7 @@ void WM_event_print(const wmEvent *event)
                       BLI_str_utf8_size(event->utf8_buf), event->utf8_buf,
                       event->keymap_idname, (const void *)event);
 
+#ifdef WITH_INPUT_NDOF
                if (ISNDOF(event->type)) {
                        const wmNDOFMotionData *ndof = event->customdata;
                        if (event->type == NDOF_MOTION) {
@@ -577,6 +578,7 @@ void WM_event_print(const wmEvent *event)
                                /* ndof buttons printed already */
                        }
                }
+#endif /* WITH_INPUT_NDOF */
 
                if (event->tablet_data) {
                        const wmTabletData *wmtab = event->tablet_data;
@@ -613,10 +615,12 @@ bool WM_event_is_absolute(const wmEvent *event)
        return (event->tablet_data != NULL);
 }
 
+#ifdef WITH_INPUT_NDOF
 void WM_ndof_deadzone_set(float deadzone)
 {
        GHOST_setNDOFDeadZone(deadzone);
 }
+#endif
 
 static void wm_add_reports(ReportList *reports)
 {
@@ -2423,9 +2427,11 @@ void wm_event_do_handlers(bContext *C)
                                        /* for regions having custom cursors */
                                        wm_paintcursor_test(C, event);
                                }
+#ifdef WITH_INPUT_NDOF
                                else if (event->type == NDOF_MOTION) {
                                        win->addmousemove = true;
                                }
+#endif
 
                                for (sa = win->screen->areabase.first; sa; sa = sa->next) {
                                        /* after restoring a screen from SCREENMAXIMIZED we have to wait
@@ -3026,6 +3032,7 @@ static void update_tablet_data(wmWindow *win, wmEvent *event)
        }
 }
 
+#ifdef WITH_INPUT_NDOF
 /* adds customdata to event */
 static void attach_ndof_data(wmEvent *event, const GHOST_TEventNDOFMotionData *ghost)
 {
@@ -3052,6 +3059,7 @@ static void attach_ndof_data(wmEvent *event, const GHOST_TEventNDOFMotionData *g
        event->customdata = data;
        event->customdatafree = 1;
 }
+#endif /* WITH_INPUT_NDOF */
 
 /* imperfect but probably usable... draw/enable drags to other windows */
 static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *win, wmEvent *event)
@@ -3439,6 +3447,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
                        break;
                }
 
+#ifdef WITH_INPUT_NDOF
                case GHOST_kEventNDOFMotion:
                {
                        event.type = NDOF_MOTION;
@@ -3474,6 +3483,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
 
                        break;
                }
+#endif /* WITH_INPUT_NDOF */
 
                case GHOST_kEventUnknown:
                case GHOST_kNumEventTypes:
@@ -3545,6 +3555,7 @@ void WM_set_locked_interface(wmWindowManager *wm, bool lock)
 }
 
 
+#ifdef WITH_INPUT_NDOF
 /* -------------------------------------------------------------------- */
 /* NDOF */
 
@@ -3587,6 +3598,7 @@ void WM_event_ndof_to_quat(const struct wmNDOFMotionData *ndof, float q[4])
        angle = WM_event_ndof_to_axis_angle(ndof, axis);
        axis_angle_to_quat(q, axis, angle);
 }
+#endif /* WITH_INPUT_NDOF */
 
 /* if this is a tablet event, return tablet pressure and set *pen_flip
  * to 1 if the eraser tool is being used, 0 otherwise */
index 3022d8654609670a2fafbc55cf27e00f9989858b..73622cda483fef34cbffd226f77ecc6986334f6f 100644 (file)
@@ -198,8 +198,11 @@ void WM_init(bContext *C, int argc, const char **argv)
        BLT_lang_set(NULL);
 
        if (!G.background) {
+
+#ifdef WITH_INPUT_NDOF
                /* sets 3D mouse deadzone */
                WM_ndof_deadzone_set(U.ndof_deadzone);
+#endif
 
                GPU_init();
 
index 78273615602f8f7bff2ece3bc654c863f098c628..fcdab746d57d96ed785ad1d2ab30afb901d43862 100644 (file)
@@ -4348,7 +4348,6 @@ void wm_window_keymap(wmKeyConfig *keyconf)
 {
        wmKeyMap *keymap = WM_keymap_find(keyconf, "Window", 0, 0);
        wmKeyMapItem *kmi;
-       const char *data_path;
        
        /* note, this doesn't replace existing keymap items */
        WM_keymap_verify_item(keymap, "WM_OT_window_duplicate", WKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
@@ -4386,7 +4385,9 @@ void wm_window_keymap(wmKeyConfig *keyconf)
 
        /* menus that can be accessed anywhere in blender */
        WM_keymap_verify_item(keymap, "WM_OT_search_menu", SPACEKEY, KM_PRESS, 0, 0);
+#ifdef WITH_INPUT_NDOF
        WM_keymap_add_menu(keymap, "USERPREF_MT_ndof_settings", NDOF_BUTTON_MENU, KM_PRESS, 0, 0);
+#endif
 
        /* Space switching */
        kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", F2KEY, KM_PRESS, KM_SHIFT, 0); /* new in 2.5x, was DXF export */
@@ -4433,8 +4434,9 @@ void wm_window_keymap(wmKeyConfig *keyconf)
        RNA_string_set(kmi->ptr, "data_path", "area.type");
        RNA_string_set(kmi->ptr, "value", "DOPESHEET_EDITOR");
        
+#ifdef WITH_INPUT_NDOF
        /* ndof speed */
-       data_path = "user_preferences.inputs.ndof_sensitivity";
+       const char *data_path = "user_preferences.inputs.ndof_sensitivity";
        kmi = WM_keymap_add_item(keymap, "WM_OT_context_scale_float", NDOF_BUTTON_PLUS, KM_PRESS, 0, 0);
        RNA_string_set(kmi->ptr, "data_path", data_path);
        RNA_float_set(kmi->ptr, "value", 1.1f);
@@ -4450,9 +4452,7 @@ void wm_window_keymap(wmKeyConfig *keyconf)
        kmi = WM_keymap_add_item(keymap, "WM_OT_context_scale_float", NDOF_BUTTON_MINUS, KM_PRESS, KM_SHIFT, 0);
        RNA_string_set(kmi->ptr, "data_path", data_path);
        RNA_float_set(kmi->ptr, "value", 1.0f / 1.5f);
-       data_path = NULL;
-       (void)data_path;
-
+#endif /* WITH_INPUT_NDOF */
 
        gesture_circle_modal_keymap(keyconf);
        gesture_border_modal_keymap(keyconf);
index 3085f13884660b232d31fbdedb3fae48750621b9..0936b294d1baa64a1d4fe4ec2402480d6640b9ac 100644 (file)
@@ -40,7 +40,9 @@ enum {
        EVT_DATA_GESTURE     = 1,
        EVT_DATA_TIMER       = 2,
        EVT_DATA_DRAGDROP    = 3,
+#ifdef WITH_INPUT_NDOF
        EVT_DATA_NDOF_MOTION = 4,
+#endif
 };
 
 /* tablet active, matches GHOST_TTabletMode */
@@ -236,6 +238,7 @@ enum {
 
        /* *** End of keyboard codes. *** */
 
+#ifdef WITH_INPUT_NDOF
        /* NDOF (from SpaceNavigator & friends)
         * These should be kept in sync with GHOST_NDOFManager.h
         * Ordering matters, exact values do not. */
@@ -290,6 +293,7 @@ enum {
        NDOF_BUTTON_C,
        /* the end */
        NDOF_LAST,
+#endif /* WITH_INPUT_NDOF */
 
        /* ********** End of Input devices. ********** */
 
@@ -369,8 +373,12 @@ enum {
 /* test whether the event is tweak event */
 #define ISTWEAK(event_type)  ((event_type) >= EVT_TWEAK_L && (event_type) <= EVT_GESTURE)
 
+#ifdef WITH_INPUT_NDOF
 /* test whether the event is a NDOF event */
-#define ISNDOF(event_type)  ((event_type) >= NDOF_MOTION && (event_type) < NDOF_LAST)
+#  define ISNDOF(event_type)  ((event_type) >= NDOF_MOTION && (event_type) < NDOF_LAST)
+#else
+#  define ISNDOF(event_type)  false
+#endif
 
 /* test whether event type is acceptable as hotkey, excluding modifiers */
 #define ISHOTKEY(event_type)                                                  \