From bc139ef46760fcb9b9b7e5e6bb8e4a914b8eb222 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 9 Sep 2016 20:01:15 +0200 Subject: tracker/rifts: show descriptive error messages, if any --- tracker-rift-080/ftnoir_tracker_rift_080.cpp | 48 +++++++++++++++++----------- 1 file changed, 29 insertions(+), 19 deletions(-) (limited to 'tracker-rift-080') diff --git a/tracker-rift-080/ftnoir_tracker_rift_080.cpp b/tracker-rift-080/ftnoir_tracker_rift_080.cpp index ce1f741a..f8091613 100644 --- a/tracker-rift-080/ftnoir_tracker_rift_080.cpp +++ b/tracker-rift-080/ftnoir_tracker_rift_080.cpp @@ -2,9 +2,13 @@ #include "ftnoir_tracker_rift_080.h" #include "api/plugin-api.hpp" #include "compat/pi-constant.hpp" + +#include + #include #include #include + #include using namespace OVR; @@ -22,30 +26,36 @@ Rift_Tracker::~Rift_Tracker() void Rift_Tracker::start_tracker(QFrame*) { - QString reason; ovrResult code; + ovrGraphicsLuid luid = {{0}}; if (!OVR_SUCCESS(code = ovr_Initialize(nullptr))) - { - reason = "initialize failed"; goto error; - } - { - ovrGraphicsLuid luid = {0}; - ovrResult res = ovr_Create(&hmd, &luid); - if (OVR_SUCCESS(code = res)) - { - ovr_ConfigureTracking(hmd, ovrTrackingCap_Orientation | ovrTrackingCap_MagYawCorrection | ovrTrackingCap_Position, ovrTrackingCap_Orientation); - } - else - { - reason = "can't open hmd"; - goto error; - } - } + + code = ovr_Create(&hmd, &luid); + if (!OVR_SUCCESS(code)) + goto error; + + ovr_ConfigureTracking(hmd, + ovrTrackingCap_Orientation | ovrTrackingCap_MagYawCorrection | ovrTrackingCap_Position, + ovrTrackingCap_Orientation); + return; error: - QMessageBox::warning(0,"Error", QString("Unable to start Rift tracker: %1 (%2)").arg(reason, code), QMessageBox::Ok,QMessageBox::NoButton); + ovrErrorInfo err; + err.Result = code; + err.ErrorString[0] = '\0'; + ovr_GetLastErrorInfo(&err); + + QString strerror(err.ErrorString); + if (strerror.size() == 0) + strerror = "Unknown reason"; + + QMessageBox::warning(nullptr, + "Error", + QStringLiteral("Unable to start Rift tracker: %1").arg(strerror), + QMessageBox::Ok, + QMessageBox::NoButton); } void Rift_Tracker::data(double *data) @@ -59,7 +69,7 @@ void Rift_Tracker::data(double *data) Quatf quat = pose.Orientation; float yaw, pitch, roll; quat.GetEulerAngles(&yaw, &pitch, &roll); - double yaw_ = yaw; + double yaw_ = double(yaw); if (s.useYawSpring) { yaw_ = old_yaw*s.persistence + (yaw_-old_yaw); -- cgit v1.2.3