ENABLE_3DCONNEXION_DEVICES -> Added tech ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT for debug output

This commit is contained in:
Enrico Turri 2019-10-09 14:18:43 +02:00
parent b41a0656b9
commit a735ec1b48
3 changed files with 36 additions and 2 deletions

View file

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

View file

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

View file

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