[Bf-blender-cvs] [c8711b6] master: Fix T40621: Tablet in walk mode fails

Campbell Barton noreply at git.blender.org
Mon Jun 1 12:13:02 CEST 2015


Commit: c8711b6f6f2293f2cbf530be38b75e274c75d9ca
Author: Campbell Barton
Date:   Mon Jun 1 19:57:38 2015 +1000
Branches: master
https://developer.blender.org/rBc8711b6f6f2293f2cbf530be38b75e274c75d9ca

Fix T40621: Tablet in walk mode fails

Add support for walk mode /w absolute pointing devices.

===================================================================

M	source/blender/editors/space_view3d/view3d_walk.c
M	source/blender/windowmanager/WM_api.h
M	source/blender/windowmanager/intern/wm_event_system.c

===================================================================

diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c
index fb98f8b..1d5c2a3 100644
--- a/source/blender/editors/space_view3d/view3d_walk.c
+++ b/source/blender/editors/space_view3d/view3d_walk.c
@@ -26,8 +26,6 @@
 
 /* defines VIEW3D_OT_navigate - walk modal operator */
 
-//#define NDOF_WALK_DEBUG
-//#define NDOF_WALK_DRAW_TOOMUCH  /* is this needed for ndof? - commented so redraw doesnt thrash - campbell */
 #include "DNA_scene_types.h"
 #include "DNA_object_types.h"
 
@@ -58,6 +56,11 @@
 
 #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 */
+
+#define USE_TABLET_SUPPORT
+
 /* prototypes */
 static float getVelocityZeroTime(const float gravity, const float velocity);
 
@@ -276,6 +279,14 @@ typedef struct WalkInfo {
 	/* mouse reverse */
 	bool is_reversed;
 
+#ifdef USE_TABLET_SUPPORT
+	/* check if we had a cursor event before */
+	bool is_cursor_first;
+
+	/* tablet devices (we can't relocate the cursor) */
+	bool is_cursor_absolute;
+#endif
+
 	/* gravity system */
 	eWalkGravityState gravity_state;
 	float gravity;
@@ -519,6 +530,12 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op)
 
 	walk->is_reversed = ((U.walk_navigation.flag & USER_WALK_MOUSE_REVERSE) != 0);
 
+#ifdef USE_TABLET_SUPPORT
+	walk->is_cursor_first = true;
+
+	walk->is_cursor_absolute = false;
+#endif
+
 	walk->active_directions = 0;
 
 #ifdef NDOF_WALK_DRAW_TOOMUCH
@@ -586,10 +603,16 @@ static int walkEnd(bContext *C, WalkInfo *walk)
 	/* restore the cursor */
 	WM_cursor_modal_restore(win);
 
-	/* center the mouse */
-	WM_cursor_warp(win,
-	               walk->ar->winrct.xmin + walk->center_mval[0],
-	               walk->ar->winrct.ymin + walk->center_mval[1]);
+#ifdef USE_TABLET_SUPPORT
+	if (walk->is_cursor_absolute == false)
+#endif
+	{
+		/* center the mouse */
+		WM_cursor_warp(
+		        win,
+		        walk->ar->winrct.xmin + walk->center_mval[0],
+		        walk->ar->winrct.ymin + walk->center_mval[1]);
+	}
 
 	if (walk->state == WALK_CONFIRM) {
 		MEM_freeN(walk);
@@ -617,6 +640,27 @@ static void walkEvent(bContext *C, wmOperator *UNUSED(op), WalkInfo *walk, const
 	}
 	else if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
 
+#ifdef USE_TABLET_SUPPORT
+		if (walk->is_cursor_first) {
+			/* wait until we get the 'warp' event */
+			if ((walk->center_mval[0] == event->mval[0]) &&
+			    (walk->center_mval[1] == event->mval[1]))
+			{
+				walk->is_cursor_first = false;
+			}
+			return;
+		}
+
+		if ((walk->is_cursor_absolute == false) && WM_event_is_absolute(event)) {
+			walk->is_cursor_absolute = true;
+			copy_v2_v2_int(walk->prev_mval, event->mval);
+			copy_v2_v2_int(walk->center_mval, event->mval);
+			/* without this we can't turn 180d */
+			CLAMP_MIN(walk->mouse_speed, 4.0f);
+		}
+#endif  /* USE_TABLET_SUPPORT */
+
+
 		walk->moffset[0] += event->mval[0] - walk->prev_mval[0];
 		walk->moffset[1] += event->mval[1] - walk->prev_mval[1];
 
@@ -627,6 +671,12 @@ static void walkEvent(bContext *C, wmOperator *UNUSED(op), WalkInfo *walk, const
 		{
 			walk->redraw = true;
 
+#ifdef USE_TABLET_SUPPORT
+			if (walk->is_cursor_absolute) {
+				/* pass */
+			}
+			else
+#endif
 			if (wm_event_is_last_mousemove(event)) {
 				wmWindow *win = CTX_wm_window(C);
 
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index bb37499..bdb373a 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -179,6 +179,7 @@ struct wmEventHandler *WM_event_add_dropbox_handler(ListBase *handlers, ListBase
 			/* mouse */
 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);
 
 			/* notifiers */
 void		WM_event_add_notifier(const struct bContext *C, unsigned int type, void *reference);
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 1faede5..5177e85 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -618,6 +618,11 @@ void WM_report_banner_show(const bContext *C)
 	wm_reports->reporttimer->customdata = rti;
 }
 
+bool WM_event_is_absolute(const wmEvent *event)
+{
+	return (event->tablet_data != NULL);
+}
+
 static void wm_add_reports(const bContext *C, ReportList *reports)
 {
 	/* if the caller owns them, handle this */




More information about the Bf-blender-cvs mailing list