From 4f29f56b4e0bf5f76e689868ca091a2af94590fe Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 17 May 2017 12:54:10 +0200 Subject: tracker/steamvr: add "[disconnected]" in device list --- tracker-steamvr/dialog.ui | 4 ++-- tracker-steamvr/steamvr.cpp | 8 +++++++- tracker-steamvr/steamvr.hpp | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) (limited to 'tracker-steamvr') diff --git a/tracker-steamvr/dialog.ui b/tracker-steamvr/dialog.ui index 12a01816..88af913d 100644 --- a/tracker-steamvr/dialog.ui +++ b/tracker-steamvr/dialog.ui @@ -9,7 +9,7 @@ 0 0 - 394 + 452 85 @@ -43,7 +43,7 @@ - 3 + 1 0 diff --git a/tracker-steamvr/steamvr.cpp b/tracker-steamvr/steamvr.cpp index 43bccdb8..8585574a 100644 --- a/tracker-steamvr/steamvr.cpp +++ b/tracker-steamvr/steamvr.cpp @@ -106,6 +106,7 @@ void device_list::fill_device_specs(QList& list) dev.model = str; dev.pose = device_states[k]; dev.k = k; + dev.is_connected = device_states[k].bDeviceIsConnected; list.push_back(dev); } @@ -303,7 +304,12 @@ steamvr_dialog::steamvr_dialog() device_list list; for (const device_spec& spec : list.devices()) - ui.device->addItem(spec.to_string(), spec.to_string()); + { + QString text = spec.to_string(); + if (!spec.is_connected) + text = QStringLiteral("%1 [disconnected]").arg(text); + ui.device->addItem(text, spec.to_string()); + } tie_setting(s.device_serial, ui.device); } diff --git a/tracker-steamvr/steamvr.hpp b/tracker-steamvr/steamvr.hpp index 721fded7..af8fdbc8 100644 --- a/tracker-steamvr/steamvr.hpp +++ b/tracker-steamvr/steamvr.hpp @@ -40,6 +40,7 @@ struct device_spec QString model, serial, type; unsigned k; QString to_string() const; + bool is_connected; }; struct device_list final @@ -48,7 +49,7 @@ struct device_list final device_list(); void refresh_device_list(); - const QList& devices() const & { return device_specs; } + const QList& devices() const { return device_specs; } static OTR_NEVER_INLINE maybe_pose get_pose(int k); static QString strerror(error_t error); @@ -61,7 +62,6 @@ private: QList device_specs; static QMutex mtx; static tt vr_init_(); - static void vr_deleter(); static void fill_device_specs(QList& list); static tt vr_init(); }; -- cgit v1.2.3