summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-04-06 04:44:48 +0200
committerStanislaw Halik <sthalik@misaki.pl>2017-04-06 04:44:48 +0200
commit086fc2d81a68fe70c5897fbe6a1db0e1ba6df4cd (patch)
tree96fd95a49ae6aa6a40597c509d869697a83d732a
parent812e483c2b15b4e521797af1310fc9d4dccee882 (diff)
tracker/steamvr: determine device uniqueness harder
Use "type-model-serial" as the discriminator. The API might present a single device with two types as the same model and serial or something similarly stupid.
-rw-r--r--tracker-steamvr/steamvr.cpp26
-rw-r--r--tracker-steamvr/steamvr.hpp1
2 files changed, 22 insertions, 5 deletions
diff --git a/tracker-steamvr/steamvr.cpp b/tracker-steamvr/steamvr.cpp
index 901c4241..2552be56 100644
--- a/tracker-steamvr/steamvr.cpp
+++ b/tracker-steamvr/steamvr.cpp
@@ -181,7 +181,7 @@ void steamvr::start_tracker(QFrame*)
if (!v)
{
QMessageBox::warning(nullptr,
- tr("Valve SteamVR init error"), device_list::strerror(e),
+ tr("SteamVR init error"), device_list::strerror(e),
QMessageBox::Close, QMessageBox::NoButton);
return;
}
@@ -194,20 +194,30 @@ void steamvr::start_tracker(QFrame*)
if (sz == 0)
{
QMessageBox::warning(nullptr,
- tr("Valve SteamVR init error"),
+ tr("SteamVR init error"),
tr("No HMD connected"),
QMessageBox::Close, QMessageBox::NoButton);
return;
}
+ device_index = -1;
+
for (const device_spec& spec : specs)
{
- if (serial == "" || serial == spec.serial)
+ if (serial == "" || serial == spec.to_string())
{
device_index = int(spec.k);
break;
}
}
+
+ if (device_index == -1)
+ {
+ QMessageBox::warning(nullptr,
+ tr("SteamVR init error"),
+ tr("Can't find device with that serial"),
+ QMessageBox::Close, QMessageBox::NoButton);
+ }
});
}
@@ -267,8 +277,7 @@ steamvr_dialog::steamvr_dialog()
device_list list;
for (const device_spec& spec : list.devices())
- ui.device->addItem(QStringLiteral("<%3> %1 [%2]").arg(spec.model).arg(spec.serial).arg(spec.type),
- QVariant(spec.serial));
+ ui.device->addItem(spec.to_string(), spec.to_string());
tie_setting(s.device_serial, ui.device);
}
@@ -284,4 +293,11 @@ void steamvr_dialog::doCancel()
close();
}
+
+
+QString device_spec::to_string() const
+{
+ return QStringLiteral("<%1> %2 [%3]").arg(type).arg(model).arg(serial);
+}
+
OPENTRACK_DECLARE_TRACKER(steamvr, steamvr_dialog, steamvr_metadata)
diff --git a/tracker-steamvr/steamvr.hpp b/tracker-steamvr/steamvr.hpp
index a8903959..1f881607 100644
--- a/tracker-steamvr/steamvr.hpp
+++ b/tracker-steamvr/steamvr.hpp
@@ -39,6 +39,7 @@ struct device_spec
vr::TrackedDevicePose_t pose;
QString model, serial, type;
unsigned k;
+ QString to_string() const;
};
struct device_list final