get actual name for OpenVrDispayPlugin

This commit is contained in:
Dante Ruiz 2018-02-28 16:32:53 -08:00
parent 1bc8484a4b
commit 1bae22fed0
6 changed files with 29 additions and 19 deletions

View file

@ -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

View file

@ -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;

View file

@ -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);

View file

@ -14,6 +14,7 @@
#include <controllers/Forward.h>
#include <plugins/Forward.h>
#include <string>
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<typename F>

View file

@ -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";
}

View file

@ -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();