User Prefs for NDOF dead-zone

D1344 with edits
This commit is contained in:
Campbell Barton 2015-07-01 13:45:19 +10:00
parent b71c27a446
commit 45b2218341
15 changed files with 76 additions and 7 deletions

View File

@ -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

View File

@ -378,6 +378,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

View File

@ -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;

View File

@ -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)

View File

@ -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;

View File

@ -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();

View File

@ -237,6 +237,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.
***************************************************************************************/

View File

@ -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)

View File

@ -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

View File

@ -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;

View File

@ -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 */

View File

@ -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",

View File

@ -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);

View File

@ -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 */

View File

@ -171,6 +171,9 @@ void WM_init(bContext *C, int argc, const char **argv)
/* get the default database, plus a wm */
wm_homefile_read(C, NULL, G.factory_startup, NULL);
/* sets 3D mouse deadzone */
WM_ndof_deadzone_set(U.ndof_deadzone);
BLF_lang_set(NULL);
if (!G.background) {