diff --git a/plugins/openvr/src/OpenVrDisplayPlugin.cpp b/plugins/openvr/src/OpenVrDisplayPlugin.cpp index 2949e72c74..615b176527 100644 --- a/plugins/openvr/src/OpenVrDisplayPlugin.cpp +++ b/plugins/openvr/src/OpenVrDisplayPlugin.cpp @@ -410,6 +410,15 @@ void OpenVrDisplayPlugin::init() { emit deviceConnected(getName()); } +const QString OpenVrDisplayPlugin::getName() const { + std::string headsetName = getOpenVrDeviceName(); + if (headsetName == "HTC") { + headsetName += " Vive"; + } + + return QString::fromStdString(headsetName); +} + bool OpenVrDisplayPlugin::internalActivate() { if (!_system) { _system = acquireOpenVrSystem(); @@ -444,7 +453,6 @@ bool OpenVrDisplayPlugin::internalActivate() { _openVrDisplayActive = true; _container->setIsOptionChecked(StandingHMDSensorMode, true); - _system->GetRecommendedRenderTargetSize(&_renderTargetSize.x, &_renderTargetSize.y); // Recommended render target size is per-eye, so double the X size for // left + right eyes diff --git a/plugins/openvr/src/OpenVrDisplayPlugin.h b/plugins/openvr/src/OpenVrDisplayPlugin.h index f681852cd5..e6fc6367d5 100644 --- a/plugins/openvr/src/OpenVrDisplayPlugin.h +++ b/plugins/openvr/src/OpenVrDisplayPlugin.h @@ -36,7 +36,7 @@ class OpenVrDisplayPlugin : public HmdDisplayPlugin { using Parent = HmdDisplayPlugin; public: bool isSupported() const override; - const QString getName() const override { return NAME; } + const QString getName() const override; glm::mat4 getEyeProjection(Eye eye, const glm::mat4& baseProjection) const override; glm::mat4 getCullingProjection(const glm::mat4& baseProjection) const override; diff --git a/plugins/openvr/src/OpenVrHelpers.cpp b/plugins/openvr/src/OpenVrHelpers.cpp index c8a0cb5f8b..9a57413f95 100644 --- a/plugins/openvr/src/OpenVrHelpers.cpp +++ b/plugins/openvr/src/OpenVrHelpers.cpp @@ -66,6 +66,22 @@ bool oculusViaOpenVR() { return enableDebugOpenVR && isOculusPresent() && vr::VR_IsHmdPresent(); } +std::string getOpenVrDeviceName() { + auto system = acquireOpenVrSystem(); + std::string trackingSystemName = ""; + if (system) { + uint32_t HmdTrackingIndex = 0; + uint32_t bufferLength = system->GetStringTrackedDeviceProperty(HmdTrackingIndex, vr::Prop_TrackingSystemName_String, NULL, 0, NULL); + if (bufferLength > 0) { + char* stringBuffer = new char[bufferLength]; + system->GetStringTrackedDeviceProperty(HmdTrackingIndex, vr::Prop_ManufacturerName_String, stringBuffer, bufferLength, NULL); + trackingSystemName = stringBuffer; + delete[] stringBuffer; + } + } + return trackingSystemName; +} + bool openVrSupported() { static const QString DEBUG_FLAG("HIFI_DEBUG_OPENVR"); static bool enableDebugOpenVR = QProcessEnvironment::systemEnvironment().contains(DEBUG_FLAG); diff --git a/plugins/openvr/src/OpenVrHelpers.h b/plugins/openvr/src/OpenVrHelpers.h index c54f2326c2..833e5ba65d 100644 --- a/plugins/openvr/src/OpenVrHelpers.h +++ b/plugins/openvr/src/OpenVrHelpers.h @@ -14,6 +14,7 @@ #include #include +#include bool oculusViaOpenVR(); // is the user using Oculus via OpenVR bool openVrSupported(); @@ -26,6 +27,7 @@ void enableOpenVrKeyboard(PluginContainer* container); void disableOpenVrKeyboard(); bool isOpenVrKeyboardShown(); QString getVrSettingString(const char* section, const char* setting); +std::string getOpenVrDeviceName(); template diff --git a/plugins/openvr/src/ViveControllerManager.cpp b/plugins/openvr/src/ViveControllerManager.cpp index 1f63769b22..caa9fc3d70 100644 --- a/plugins/openvr/src/ViveControllerManager.cpp +++ b/plugins/openvr/src/ViveControllerManager.cpp @@ -334,21 +334,6 @@ ViveControllerManager::InputDevice::InputDevice(vr::IVRSystem*& system) : _configStringMap[Config::FeetHipsChestAndShoulders] = QString("FeetHipsChestAndShoulders"); } -std::string ViveControllerManager::InputDevice::getTrackingSystemName() { - std::string trackingSystemName = ""; - if (_system) { - uint32_t HmdTrackingIndex = 0; - uint32_t bufferLength = _system->GetStringTrackedDeviceProperty(HmdTrackingIndex, vr::Prop_TrackingSystemName_String, NULL, 0, NULL); - if (bufferLength > 0) { - char* stringBuffer = new char[bufferLength]; - _system->GetStringTrackedDeviceProperty(HmdTrackingIndex, vr::Prop_ManufacturerName_String, stringBuffer, bufferLength, NULL); - trackingSystemName = stringBuffer; - delete[] stringBuffer; - } - } - return trackingSystemName; -} - void ViveControllerManager::InputDevice::update(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) { _poseStateMap.clear(); _buttonPressedMap.clear(); @@ -356,7 +341,7 @@ void ViveControllerManager::InputDevice::update(float deltaTime, const controlle _trackedControllers = 0; if (_headsetName == "") { - _headsetName = getTrackingSystemName(); + _headsetName = getOpenVrDeviceName(); if (_headsetName == "HTC") { _headsetName += " Vive"; } diff --git a/plugins/openvr/src/ViveControllerManager.h b/plugins/openvr/src/ViveControllerManager.h index d66db45ee9..f3631ece9d 100644 --- a/plugins/openvr/src/ViveControllerManager.h +++ b/plugins/openvr/src/ViveControllerManager.h @@ -78,7 +78,6 @@ private: void calibrateOrUncalibrate(const controller::InputCalibrationData& inputCalibration); void calibrate(const controller::InputCalibrationData& inputCalibration); void uncalibrate(); - std::string getTrackingSystemName(); void sendUserActivityData(QString activity); void configureCalibrationSettings(const QJsonObject configurationSettings); QJsonObject configurationSettings();