diff options
-rw-r--r-- | tracker-steamvr/steamvr.cpp | 26 | ||||
-rw-r--r-- | tracker-steamvr/steamvr.hpp | 1 |
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 |