3DConnexion devices' Y axis used for zoom in/zoom out

This commit is contained in:
Enrico Turri 2020-01-03 14:42:52 +01:00
parent a4ad0a0925
commit 83cbe1dd33
5 changed files with 96 additions and 9 deletions

View file

@ -271,7 +271,11 @@ void AppConfig::set_recent_projects(const std::vector<std::string>& recent_proje
}
}
#if ENABLE_3DCONNEXION_Y_AS_ZOOM
void AppConfig::set_mouse_device(const std::string& name, double translation_speed, double translation_deadzone, float rotation_speed, float rotation_deadzone, double zoom_speed)
#else
void AppConfig::set_mouse_device(const std::string& name, double translation_speed, double translation_deadzone, float rotation_speed, float rotation_deadzone)
#endif // ENABLE_3DCONNEXION_Y_AS_ZOOM
{
std::string key = std::string("mouse_device:") + name;
auto it = m_storage.find(key);
@ -283,6 +287,9 @@ void AppConfig::set_mouse_device(const std::string& name, double translation_spe
it->second["translation_deadzone"] = std::to_string(translation_deadzone);
it->second["rotation_speed"] = std::to_string(rotation_speed);
it->second["rotation_deadzone"] = std::to_string(rotation_deadzone);
#if ENABLE_3DCONNEXION_Y_AS_ZOOM
it->second["zoom_speed"] = std::to_string(zoom_speed);
#endif // ENABLE_3DCONNEXION_Y_AS_ZOOM
}
bool AppConfig::get_mouse_device_translation_speed(const std::string& name, double& speed)
@ -345,6 +352,23 @@ bool AppConfig::get_mouse_device_rotation_deadzone(const std::string& name, floa
return true;
}
#if ENABLE_3DCONNEXION_Y_AS_ZOOM
bool AppConfig::get_mouse_device_zoom_speed(const std::string& name, double& speed)
{
std::string key = std::string("mouse_device:") + name;
auto it = m_storage.find(key);
if (it == m_storage.end())
return false;
auto it_val = it->second.find("zoom_speed");
if (it_val == it->second.end())
return false;
speed = (float)::atof(it_val->second.c_str());
return true;
}
#endif // ENABLE_3DCONNEXION_Y_AS_ZOOM
void AppConfig::update_config_dir(const std::string &dir)
{
this->set("recent", "config_directory", dir);