From a735ec1b48c159403637dcd202a4ca4d98278821 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Wed, 9 Oct 2019 14:18:43 +0200 Subject: [PATCH] ENABLE_3DCONNEXION_DEVICES -> Added tech ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT for debug output --- src/libslic3r/Technologies.hpp | 2 ++ src/slic3r/GUI/Mouse3DController.cpp | 28 +++++++++++++++++++++++++++- src/slic3r/GUI/Mouse3DController.hpp | 8 +++++++- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index da982c49a..f64bea172 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -39,6 +39,8 @@ // Enabled 3Dconnexion devices #define ENABLE_3DCONNEXION_DEVICES (1 && ENABLE_2_0_0_ALPHA1) +// Enabled 3Dconnexion devices debug output +#define ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT (1 && ENABLE_3DCONNEXION_DEVICES) #endif // _technologies_h_ diff --git a/src/slic3r/GUI/Mouse3DController.cpp b/src/slic3r/GUI/Mouse3DController.cpp index 86f6fa5a7..00d5e184a 100644 --- a/src/slic3r/GUI/Mouse3DController.cpp +++ b/src/slic3r/GUI/Mouse3DController.cpp @@ -111,7 +111,7 @@ bool Mouse3DController::State::apply(Camera& camera) ret = true; } - if (has_any_button()) + if (has_button()) { unsigned int button = m_buttons.front(); switch (button) @@ -234,6 +234,18 @@ void Mouse3DController::render_settings_dialog(unsigned int canvas_width, unsign if (ImGui::SliderFloat(_(L("Rotation##2")), &rotation_deadzone, 0.0f, State::MaxRotationDeadzone, "%.2f")) m_state.set_rotation_deadzone(rotation_deadzone); +#if ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT + ImGui::Separator(); + ImGui::PushStyleColor(ImGuiCol_Text, color); + imgui.text(_(L("DEBUG:"))); + ImGui::PopStyleColor(); + Vec3f translation = m_state.get_translation().cast(); + Vec3f rotation = m_state.get_rotation(); + unsigned int button = m_state.get_button(); + ImGui::InputFloat3("Translation##3", translation.data(), "%.3f", ImGuiInputTextFlags_ReadOnly); + ImGui::InputFloat3("Rotation##3", rotation.data(), "%.3f", ImGuiInputTextFlags_ReadOnly); +#endif // ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT + imgui.end(); ImGui::PopStyleVar(); @@ -256,6 +268,20 @@ bool Mouse3DController::connect_device() unsigned short vendor_id = 0; unsigned short product_id = 0; +#if ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT + hid_device_info* cur = devices; + while (cur != nullptr) + { + std::cout << "Detected device '"; + std::wcout << ((cur->manufacturer_string != nullptr) ? cur->manufacturer_string : L"Unknown"); + std::cout << "::"; + std::wcout << ((cur->product_string != nullptr) ? cur->product_string : L"Unknown"); + std::cout << "' code: " << cur->vendor_id << "/" << cur->product_id << " (" << std::hex << cur->vendor_id << "/" << cur->product_id << std::dec << ")" << std::endl; + + cur = cur->next; + } +#endif // ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT + hid_device_info* current = devices; while (current != nullptr) { diff --git a/src/slic3r/GUI/Mouse3DController.hpp b/src/slic3r/GUI/Mouse3DController.hpp index 33295a68a..3136f9396 100644 --- a/src/slic3r/GUI/Mouse3DController.hpp +++ b/src/slic3r/GUI/Mouse3DController.hpp @@ -68,7 +68,13 @@ class Mouse3DController bool has_translation() const { return !m_translation.empty(); } bool has_rotation() const { return !m_rotation.empty(); } - bool has_any_button() const { return !m_buttons.empty(); } + bool has_button() const { return !m_buttons.empty(); } + +#if ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT + Vec3d get_translation() const { return has_translation() ? m_translation.front() : Vec3d::Zero(); } + Vec3f get_rotation() const { return has_rotation() ? m_rotation.front() : Vec3f::Zero(); } + unsigned int get_button() const { return has_button() ? m_buttons.front() : 0; } +#endif // ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT bool process_mouse_wheel();