Bug 1424378 - Switch off Windows MR mode when the amount of button or axes is less than our expectation; r?kip
MozReview-Commit-ID: AONBdKV0Zqj
--- a/gfx/vr/gfxVROpenVR.cpp
+++ b/gfx/vr/gfxVROpenVR.cpp
@@ -1183,16 +1183,23 @@ VRSystemManagerOpenVR::ScanForController
nsCString deviceId;
GetControllerDeviceId(deviceType, trackedDevice, deviceId);
RefPtr<VRControllerOpenVR> openVRController =
new VRControllerOpenVR(hand, mOpenVRHMD->GetDisplayInfo().GetDisplayID(),
numButtons, numTriggers, numAxes, deviceId);
openVRController->SetTrackedIndex(trackedDevice);
mOpenVRController.AppendElement(openVRController);
+ // If the Windows MR controller doesn't has the amount
+ // of buttons or axes as our expectation, switching off
+ // the workaround for Windows MR.
+ if (mIsWindowsMR && (numAxes < 4 || numButtons < 5)) {
+ mIsWindowsMR = false;
+ NS_WARNING("OpenVR - Switching off Windows MR mode.");
+ }
// Not already present, add it.
AddGamepad(openVRController->GetControllerInfo());
++mControllerCount;
}
}
}
void
@@ -1211,42 +1218,42 @@ void
VRSystemManagerOpenVR::GetControllerDeviceId(::vr::ETrackedDeviceClass aDeviceType,
::vr::TrackedDeviceIndex_t aDeviceIndex, nsCString& aId)
{
switch (aDeviceType) {
case ::vr::TrackedDeviceClass_Controller:
{
::vr::ETrackedPropertyError err;
uint32_t requiredBufferLen;
- bool founded = false;
+ bool isFound = false;
char charBuf[128];
requiredBufferLen = mVRSystem->GetStringTrackedDeviceProperty(aDeviceIndex,
::vr::Prop_RenderModelName_String, charBuf, 128, &err);
if (requiredBufferLen > 128) {
MOZ_CRASH("Larger than the buffer size.");
}
MOZ_ASSERT(requiredBufferLen && err == ::vr::TrackedProp_Success);
nsCString deviceId(charBuf);
if (deviceId.Find("knuckles") != kNotFound) {
aId.AssignLiteral("OpenVR Knuckles");
- founded = true;
+ isFound = true;
}
requiredBufferLen = mVRSystem->GetStringTrackedDeviceProperty(aDeviceIndex,
::vr::Prop_SerialNumber_String, charBuf, 128, &err);
if (requiredBufferLen > 128) {
MOZ_CRASH("Larger than the buffer size.");
}
MOZ_ASSERT(requiredBufferLen && err == ::vr::TrackedProp_Success);
deviceId.Assign(charBuf);
if (deviceId.Find("MRSOURCE") != kNotFound) {
aId.AssignLiteral("Spatial Controller (Spatial Interaction Source) ");
mIsWindowsMR = true;
- founded = true;
+ isFound = true;
}
- if (!founded) {
+ if (!isFound) {
aId.AssignLiteral("OpenVR Gamepad");
}
break;
}
case ::vr::TrackedDeviceClass_GenericTracker:
{
aId.AssignLiteral("OpenVR Tracker");
break;