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. --- source/blender/editors/space_view3d/view3d_walk.c | 34 +++++++++++++++++------ 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'source/blender/editors/space_view3d/view3d_walk.c') diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c index c9e4bb301b8..17c08ed4205 100644 --- a/source/blender/editors/space_view3d/view3d_walk.c +++ b/source/blender/editors/space_view3d/view3d_walk.c @@ -59,8 +59,10 @@ #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); } -- cgit v1.2.3