diff options
author | bubnikv <bubnikv@gmail.com> | 2020-03-04 13:36:36 +0300 |
---|---|---|
committer | bubnikv <bubnikv@gmail.com> | 2020-03-04 13:36:36 +0300 |
commit | 0b96855c2ee2ed0aa2a57890be70679ee7882a00 (patch) | |
tree | 365dd694af8217e79c6a9ec451a88c2b0f3a9fb6 /src/slic3r/GUI/AppConfig.cpp | |
parent | a87ba5d6a6912a06999d0b1f4e19280969b30ddf (diff) |
Reworked the 3DConnexion interfacing code to run the device
enumeration / connect / disconnect and read out at the background
thread only.
Diffstat (limited to 'src/slic3r/GUI/AppConfig.cpp')
-rw-r--r-- | src/slic3r/GUI/AppConfig.cpp | 80 |
1 files changed, 8 insertions, 72 deletions
diff --git a/src/slic3r/GUI/AppConfig.cpp b/src/slic3r/GUI/AppConfig.cpp index 35799e046..212d7bcf2 100644 --- a/src/slic3r/GUI/AppConfig.cpp +++ b/src/slic3r/GUI/AppConfig.cpp @@ -295,79 +295,15 @@ void AppConfig::set_mouse_device(const std::string& name, double translation_spe it->second["zoom_speed"] = std::to_string(zoom_speed); } -bool AppConfig::get_mouse_device_translation_speed(const std::string& name, double& speed) +std::vector<std::string> AppConfig::get_mouse_device_names() const { - 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("translation_speed"); - if (it_val == it->second.end()) - return false; - - speed = ::atof(it_val->second.c_str()); - return true; -} - -bool AppConfig::get_mouse_device_translation_deadzone(const std::string& name, double& deadzone) -{ - 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("translation_deadzone"); - if (it_val == it->second.end()) - return false; - - deadzone = ::atof(it_val->second.c_str()); - return true; -} - -bool AppConfig::get_mouse_device_rotation_speed(const std::string& name, float& 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("rotation_speed"); - if (it_val == it->second.end()) - return false; - - speed = (float)::atof(it_val->second.c_str()); - return true; -} - -bool AppConfig::get_mouse_device_rotation_deadzone(const std::string& name, float& deadzone) -{ - 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("rotation_deadzone"); - if (it_val == it->second.end()) - return false; - - deadzone = (float)::atof(it_val->second.c_str()); - return true; -} - -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; + static constexpr char *prefix = "mouse_device:"; + static constexpr size_t prefix_len = 13; // strlen(prefix); reports error C2131: expression did not evaluate to a constant on VS2019 + std::vector<std::string> out; + for (const std::pair<std::string, std::map<std::string, std::string>>& key_value_pair : m_storage) + if (boost::starts_with(key_value_pair.first, "mouse_device:") && key_value_pair.first.size() > prefix_len) + out.emplace_back(key_value_pair.first.substr(prefix_len)); + return out; } void AppConfig::update_config_dir(const std::string &dir) |