mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-04-07 18:32:45 +02:00
Merge pull request #12903 from druiz17/add-more-hmd-data
Get the correct device name connect to OpenVr
This commit is contained in:
commit
236e75b6c6
10 changed files with 57 additions and 19 deletions
|
@ -17,6 +17,7 @@ StackView {
|
|||
id: stack
|
||||
initialItem: inputConfiguration
|
||||
property alias messageVisible: imageMessageBox.visible
|
||||
property alias selectedPlugin: box.currentText
|
||||
Rectangle {
|
||||
id: inputConfiguration
|
||||
anchors.fill: parent
|
||||
|
|
|
@ -34,7 +34,7 @@ Rectangle {
|
|||
readonly property bool hmdHead: headBox.checked
|
||||
readonly property bool headPuck: headPuckBox.checked
|
||||
readonly property bool handController: handBox.checked
|
||||
|
||||
|
||||
readonly property bool handPuck: handPuckBox.checked
|
||||
readonly property bool hmdDesktop: hmdInDesktop.checked
|
||||
|
||||
|
@ -105,7 +105,7 @@ Rectangle {
|
|||
|
||||
RalewayBold {
|
||||
size: 12
|
||||
text: "Vive HMD"
|
||||
text: stack.selectedPlugin + " HMD"
|
||||
color: hifi.colors.lightGrayText
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ Rectangle {
|
|||
anchors.topMargin: 5
|
||||
anchors.left: openVrConfiguration.left
|
||||
anchors.leftMargin: leftMargin + 10
|
||||
|
||||
|
||||
onClicked: {
|
||||
if (checked) {
|
||||
headBox.checked = false;
|
||||
|
@ -772,12 +772,12 @@ Rectangle {
|
|||
|
||||
RalewayBold {
|
||||
id: advanceSettings
|
||||
|
||||
|
||||
text: "Advanced Settings"
|
||||
size: 12
|
||||
|
||||
|
||||
color: hifi.colors.white
|
||||
|
||||
|
||||
anchors.top: advanceSeperator.bottom
|
||||
anchors.topMargin: 10
|
||||
anchors.left: parent.left
|
||||
|
@ -795,7 +795,7 @@ Rectangle {
|
|||
anchors.topMargin: 5
|
||||
anchors.left: openVrConfiguration.left
|
||||
anchors.leftMargin: leftMargin + 10
|
||||
|
||||
|
||||
onClicked: {
|
||||
if (!checked & hmdInDesktop.checked) {
|
||||
headBox.checked = true;
|
||||
|
@ -809,9 +809,9 @@ Rectangle {
|
|||
RalewayBold {
|
||||
id: viveDesktopText
|
||||
size: 10
|
||||
text: "Use Vive devices in desktop mode"
|
||||
text: "Use " + stack.selectedPlugin + " devices in desktop mode"
|
||||
color: hifi.colors.white
|
||||
|
||||
|
||||
anchors {
|
||||
left: viveInDesktop.right
|
||||
leftMargin: 5
|
||||
|
@ -819,7 +819,7 @@ Rectangle {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
NumberAnimation {
|
||||
id: numberAnimation
|
||||
target: openVrConfiguration
|
||||
|
|
|
@ -32,7 +32,8 @@ QStringList InputConfiguration::inputPlugins() {
|
|||
for (auto plugin : PluginManager::getInstance()->getInputPlugins()) {
|
||||
QString pluginName = plugin->getName();
|
||||
if (pluginName == QString("OpenVR")) {
|
||||
inputPlugins << QString("Vive");
|
||||
QString headsetName = plugin->getDeviceName();
|
||||
inputPlugins << headsetName;
|
||||
} else {
|
||||
inputPlugins << pluginName;
|
||||
}
|
||||
|
@ -54,7 +55,8 @@ QStringList InputConfiguration::activeInputPlugins() {
|
|||
if (plugin->configurable()) {
|
||||
QString pluginName = plugin->getName();
|
||||
if (pluginName == QString("OpenVR")) {
|
||||
activePlugins << QString("Vive");
|
||||
QString headsetName = plugin->getDeviceName();
|
||||
activePlugins << headsetName;
|
||||
} else {
|
||||
activePlugins << pluginName;
|
||||
}
|
||||
|
@ -74,7 +76,7 @@ QString InputConfiguration::configurationLayout(QString pluginName) {
|
|||
|
||||
QString sourcePath;
|
||||
for (auto plugin : PluginManager::getInstance()->getInputPlugins()) {
|
||||
if (plugin->getName() == pluginName) {
|
||||
if (plugin->getName() == pluginName || plugin->getDeviceName() == pluginName) {
|
||||
return plugin->configurationLayout();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,10 +26,11 @@ public:
|
|||
// If an input plugin is only a single device, it will only return it's primary name.
|
||||
virtual QStringList getSubdeviceNames() { return { getName() }; };
|
||||
virtual void setConfigurationSettings(const QJsonObject configurationSettings) { }
|
||||
virtual QJsonObject configurationSettings() { return QJsonObject(); }
|
||||
virtual QJsonObject configurationSettings() { return QJsonObject(); }
|
||||
virtual QString configurationLayout() { return QString(); }
|
||||
virtual QString getDeviceName() { return QString(); }
|
||||
virtual void calibrate() {}
|
||||
virtual bool uncalibrate() { return false; }
|
||||
virtual bool uncalibrate() { return false; }
|
||||
virtual bool configurable() { return false; }
|
||||
virtual bool isHandController() const { return false; }
|
||||
virtual bool isHeadController() const { return false; }
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
|
||||
Q_DECLARE_LOGGING_CATEGORY(displayplugins)
|
||||
|
||||
const char* OpenVrDisplayPlugin::NAME { "OpenVR (Vive)" };
|
||||
const char* StandingHMDSensorMode { "Standing HMD Sensor Mode" }; // this probably shouldn't be hardcoded here
|
||||
const char* OpenVrThreadedSubmit { "OpenVR Threaded Submit" }; // this probably shouldn't be hardcoded here
|
||||
|
||||
|
@ -410,6 +409,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 +452,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
|
||||
|
|
|
@ -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;
|
||||
|
@ -78,7 +78,6 @@ private:
|
|||
vr::IVRSystem* _system { nullptr };
|
||||
std::atomic<vr::EDeviceActivityLevel> _hmdActivityLevel { vr::k_EDeviceActivityLevel_Unknown };
|
||||
std::atomic<uint32_t> _keyboardSupressionCount{ 0 };
|
||||
static const char* NAME;
|
||||
|
||||
vr::HmdMatrix34_t _lastGoodHMDPose;
|
||||
mat4 _sensorResetMat;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include "ViveControllerManager.h"
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
#include <PerfStat.h>
|
||||
#include <PathUtils.h>
|
||||
|
@ -339,6 +340,12 @@ void ViveControllerManager::InputDevice::update(float deltaTime, const controlle
|
|||
_validTrackedObjects.clear();
|
||||
_trackedControllers = 0;
|
||||
|
||||
if (_headsetName == "") {
|
||||
_headsetName = getOpenVrDeviceName();
|
||||
if (_headsetName == "HTC") {
|
||||
_headsetName += " Vive";
|
||||
}
|
||||
}
|
||||
// While the keyboard is open, we defer strictly to the keyboard values
|
||||
if (isOpenVrKeyboardShown()) {
|
||||
_axisStateMap.clear();
|
||||
|
|
|
@ -52,6 +52,8 @@ public:
|
|||
bool activate() override;
|
||||
void deactivate() override;
|
||||
|
||||
QString getDeviceName() { return QString::fromStdString(_inputDevice->_headsetName); }
|
||||
|
||||
void pluginFocusOutEvent() override { _inputDevice->focusOutEvent(); }
|
||||
void pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) override;
|
||||
|
||||
|
@ -161,6 +163,7 @@ private:
|
|||
HandConfig _handConfig { HandConfig::HandController };
|
||||
FilteredStick _filteredLeftStick;
|
||||
FilteredStick _filteredRightStick;
|
||||
std::string _headsetName {""};
|
||||
|
||||
std::vector<PuckPosePair> _validTrackedObjects;
|
||||
std::map<uint32_t, glm::mat4> _pucksPostOffset;
|
||||
|
|
Loading…
Reference in a new issue