[Bf-blender-cvs] [45b2218] master: User Prefs for NDOF dead-zone

Campbell Barton noreply at git.blender.org
Wed Jul 1 05:51:12 CEST 2015


Commit: 45b221834184e6bdc28e83338014ddea6eb1fad0
Author: Campbell Barton
Date:   Wed Jul 1 13:45:19 2015 +1000
Branches: master
https://developer.blender.org/rB45b221834184e6bdc28e83338014ddea6eb1fad0

User Prefs for NDOF dead-zone

D1344 with edits

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

M	intern/ghost/GHOST_C-api.h
M	intern/ghost/GHOST_ISystem.h
M	intern/ghost/intern/GHOST_C-api.cpp
M	intern/ghost/intern/GHOST_NDOFManagerWin32.cpp
M	intern/ghost/intern/GHOST_NDOFManagerX11.cpp
M	intern/ghost/intern/GHOST_System.cpp
M	intern/ghost/intern/GHOST_System.h
M	release/scripts/startup/bl_ui/space_userpref.py
M	source/blender/blenkernel/BKE_blender.h
M	source/blender/editors/interface/resources.c
M	source/blender/makesdna/DNA_userdef_types.h
M	source/blender/makesrna/intern/rna_userdef.c
M	source/blender/windowmanager/WM_api.h
M	source/blender/windowmanager/intern/wm_event_system.c
M	source/blender/windowmanager/intern/wm_init_exit.c

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

diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index 8a80a51..7715979 100644
--- a/intern/ghost/GHOST_C-api.h
+++ b/intern/ghost/GHOST_C-api.h
@@ -434,6 +434,16 @@ extern GHOST_TSuccess GHOST_GetButtonState(GHOST_SystemHandle systemhandle,
                                            GHOST_TButtonMask mask,
                                            int *isDown);
 
+/***************************************************************************************
+ * Access to 3D mouse.
+ ***************************************************************************************/
+
+/**
+ * Sets 3D mouse deadzone
+ * \param deadzone Deadzone of the 3D mouse (both for rotation and pan) relative to full range
+ */
+extern void GHOST_setNDOFDeadZone(float deadzone);
+
 
 /***************************************************************************************
  * Drag'n'drop operations
diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h
index 25908a5..33540f3 100644
--- a/intern/ghost/GHOST_ISystem.h
+++ b/intern/ghost/GHOST_ISystem.h
@@ -379,6 +379,12 @@ public:
 	virtual GHOST_TSuccess getButtonState(GHOST_TButtonMask mask, bool& isDown) const = 0;
 
 	/**
+	 * 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;
+
+	/**
 	 * Toggles console
 	 * \param action
 	 * - 0: Hides
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index 8d01e8a..af992bf 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -413,6 +413,13 @@ GHOST_TSuccess GHOST_GetButtonState(GHOST_SystemHandle systemhandle,
 }
 
 
+void GHOST_setNDOFDeadZone(float deadzone)
+{
+	GHOST_ISystem *system = GHOST_ISystem::getSystem();
+	system->setNDOFDeadZone(deadzone);
+}
+
+
 void GHOST_setAcceptDragOperation(GHOST_WindowHandle windowhandle, GHOST_TInt8 canAccept)
 {
 	GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
diff --git a/intern/ghost/intern/GHOST_NDOFManagerWin32.cpp b/intern/ghost/intern/GHOST_NDOFManagerWin32.cpp
index 6c16279..7ccd2e6 100644
--- a/intern/ghost/intern/GHOST_NDOFManagerWin32.cpp
+++ b/intern/ghost/intern/GHOST_NDOFManagerWin32.cpp
@@ -30,7 +30,7 @@
 GHOST_NDOFManagerWin32::GHOST_NDOFManagerWin32(GHOST_System& sys)
     : GHOST_NDOFManager(sys)
 {
-	setDeadZone(0.1f);
+	/* pass */
 }
 
 // whether multi-axis functionality is available (via the OS or driver)
diff --git a/intern/ghost/intern/GHOST_NDOFManagerX11.cpp b/intern/ghost/intern/GHOST_NDOFManagerX11.cpp
index 75e476c..753321b 100644
--- a/intern/ghost/intern/GHOST_NDOFManagerX11.cpp
+++ b/intern/ghost/intern/GHOST_NDOFManagerX11.cpp
@@ -33,8 +33,6 @@ GHOST_NDOFManagerX11::GHOST_NDOFManagerX11(GHOST_System& sys)
     : GHOST_NDOFManager(sys),
       m_available(false)
 {
-	setDeadZone(0.1f); /* how to calibrate on Linux? throw away slight motion! */
-
 	if (spnav_open() != -1) {
 		m_available = true;
 
diff --git a/intern/ghost/intern/GHOST_System.cpp b/intern/ghost/intern/GHOST_System.cpp
index baa1bdf..1698d2f 100644
--- a/intern/ghost/intern/GHOST_System.cpp
+++ b/intern/ghost/intern/GHOST_System.cpp
@@ -295,6 +295,15 @@ GHOST_TSuccess GHOST_System::getButtonState(GHOST_TButtonMask mask, bool& isDown
 	return success;
 }
 
+void GHOST_System::setNDOFDeadZone(float deadzone)
+{
+#ifdef WITH_INPUT_NDOF
+	this->m_ndofManager->setDeadZone(deadzone);
+#else
+	(void)deadzone;
+#endif
+}
+
 GHOST_TSuccess GHOST_System::init()
 {
 	m_timerManager = new GHOST_TimerManager();
diff --git a/intern/ghost/intern/GHOST_System.h b/intern/ghost/intern/GHOST_System.h
index 4f689ce..9dcba11 100644
--- a/intern/ghost/intern/GHOST_System.h
+++ b/intern/ghost/intern/GHOST_System.h
@@ -238,6 +238,16 @@ public:
 	GHOST_TSuccess getButtonState(GHOST_TButtonMask mask, bool& isDown) const;
 	
 	/***************************************************************************************
+	 * Access to 3D mouse.
+	 ***************************************************************************************/
+
+	/**
+	 * Sets 3D mouse deadzone
+	 * \param deadzone: Deadzone of the 3D mouse (both for rotation and pan) relative to full range
+	 */
+	void setNDOFDeadZone(float deadzone);
+
+	/***************************************************************************************
 	 * Other (internal) functionality.
 	 ***************************************************************************************/
 
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 0272f75..58bb383 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -988,6 +988,7 @@ class USERPREF_MT_ndof_settings(Menu):
 
         layout.prop(input_prefs, "ndof_sensitivity")
         layout.prop(input_prefs, "ndof_orbit_sensitivity")
+        layout.prop(input_prefs, "ndof_deadzone")
 
         if is_view3d:
             layout.separator()
@@ -1130,10 +1131,12 @@ class USERPREF_PT_input(Panel):
             sub.prop(walk, "jump_height")
 
         col.separator()
-        sub = col.column()
-        sub.label(text="NDOF Device:")
+        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)
 
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h
index 8367fd4..1638ba4 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -42,7 +42,7 @@ extern "C" {
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION         275
-#define BLENDER_SUBVERSION      1
+#define BLENDER_SUBVERSION      2
 /* Several breakages with 270, e.g. constraint deg vs rad */
 #define BLENDER_MINVERSION      270
 #define BLENDER_MINSUBVERSION   5
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index b9d8817..e831144 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -2631,6 +2631,10 @@ void init_userdef_do_versions(void)
 		}
 	}
 
+	if (!USER_VERSION_ATLEAST(275, 2)) {
+		U.ndof_deadzone = 0.1;
+	}
+
 	if (U.pixelsize == 0.0f)
 		U.pixelsize = 1.0f;
 	
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 3a0e346..48ed356 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -491,7 +491,6 @@ typedef struct UserDef {
 	int memcachelimit;
 	int prefetchframes;
 	float pad_rot_angle; /* control the rotation step of the view when PAD2, PAD4, PAD6&PAD8 is use */
-	float pad3;
 	short frameserverport;
 	short pad4;
 	short obcenter_dia;
@@ -519,6 +518,7 @@ typedef struct UserDef {
 
 	float ndof_sensitivity;	/* overall sensitivity of 3D mouse */
 	float ndof_orbit_sensitivity;
+	float ndof_deadzone; /* deadzone of 3D mouse */
 	int ndof_flag;			/* flags for 3D mouse */
 
 	short ogl_multisamples;	/* amount of samples for OpenGL FSA, if zero no FSA */
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 9123a06..9604f64 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -267,6 +267,12 @@ static void rna_userdef_autokeymode_set(PointerRNA *ptr, int value)
 	}
 }
 
+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);
+}
+
 static void rna_userdef_timecode_style_set(PointerRNA *ptr, int value)
 {
 	UserDef *userdef = (UserDef *)ptr->data;
@@ -4303,6 +4309,11 @@ static void rna_def_userdef_input(BlenderRNA *brna)
 	RNA_def_property_range(prop, 0.01f, 40.0f);
 	RNA_def_property_ui_text(prop, "Orbit Sensitivity", "Overall sensitivity of the 3D Mouse for orbiting");
 
+	prop = RNA_def_property(srna, "ndof_deadzone", PROP_FLOAT, PROP_FACTOR);
+	RNA_def_property_range(prop, 0.0f, 1.0f);
+	RNA_def_property_ui_text(prop, "Deadzone", "Deadzone of the 3D Mouse");
+	RNA_def_property_update(prop, 0, "rna_userdef_ndof_deadzone_update");
+
 	prop = RNA_def_property(srna, "ndof_pan_yz_swap_axis", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "ndof_flag", NDOF_PAN_YZ_SWAP_AXIS);
 	RNA_def_property_ui_text(prop, "Y/Z Swap Axis",
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index bdb373a..9e27190 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -181,6 +181,9 @@ 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);
 
+			/* 3D mouse */
+void		WM_ndof_deadzone_set(float deadzone);
+
 			/* 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);
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 075390f..15b155c 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -623,6 +623,11 @@ bool WM_event_is_absolute(const wmEvent *event)
 	return (event->tablet_data != NULL);
 }
 
+void WM_ndof_deadzone_set(float deadzone)
+{
+	GHOST_setNDOFDeadZone(deadzone);
+}
+
 static void wm_add_reports(const bContext *C, ReportList *reports)
 {
 	/* if the caller owns them, handle this */
diff --git a/source/blender/windowmanager/intern/wm_init_exit.

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list