Bug 1299929 - Part 2: Add extra info for VRController; r?kip
MozReview-Commit-ID: 5y8X5ZPnsHb
--- a/gfx/vr/VRDisplayHost.cpp
+++ b/gfx/vr/VRDisplayHost.cpp
@@ -150,9 +150,27 @@ VRControllerHost::VRControllerHost(VRDev
MOZ_COUNT_CTOR(VRControllerHost);
mControllerInfo.mType = aType;
mControllerInfo.mControllerID = VRDisplayManager::AllocateDisplayID();
}
VRControllerHost::~VRControllerHost()
{
MOZ_COUNT_DTOR(VRControllerHost);
+}
+
+const VRControllerInfo&
+VRControllerHost::GetControllerInfo() const
+{
+ return mControllerInfo;
+}
+
+void
+VRControllerHost::SetIndex(uint32_t aIndex)
+{
+ mIndex = aIndex;
+}
+
+uint32_t
+VRControllerHost::GetIndex()
+{
+ return mIndex;
}
\ No newline at end of file
--- a/gfx/vr/VRDisplayHost.h
+++ b/gfx/vr/VRDisplayHost.h
@@ -82,21 +82,25 @@ protected:
private:
VRDisplayInfo mLastUpdateDisplayInfo;
};
class VRControllerHost {
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VRControllerHost)
- const VRControllerInfo& GetControllerInfo() const { return mControllerInfo; }
+ const VRControllerInfo& GetControllerInfo() const;
+ void SetIndex(uint32_t aIndex);
+ uint32_t GetIndex();
protected:
explicit VRControllerHost(VRDeviceType aType);
virtual ~VRControllerHost();
VRControllerInfo mControllerInfo;
+ // The controller index in VRControllerManager.
+ uint32_t mIndex;
};
} // namespace gfx
} // namespace mozilla
#endif /* GFX_VR_DISPLAY_HOST_H */
--- a/gfx/vr/gfxVROpenVR.cpp
+++ b/gfx/vr/gfxVROpenVR.cpp
@@ -450,16 +450,28 @@ VRControllerOpenVR::VRControllerOpenVR()
mControllerInfo.mControllerName.AssignLiteral("OpenVR HMD");
}
VRControllerOpenVR::~VRControllerOpenVR()
{
MOZ_COUNT_DTOR_INHERITED(VRControllerOpenVR, VRControllerHost);
}
+void
+VRControllerOpenVR::SetTrackedIndex(uint32_t aTrackedIndex)
+{
+ mTrackedIndex = aTrackedIndex;
+}
+
+uint32_t
+VRControllerOpenVR::GetTrackedIndex()
+{
+ return mTrackedIndex;
+}
+
VRControllerManagerOpenVR::VRControllerManagerOpenVR()
: mOpenVRInstalled(false), mVRSystem(nullptr)
{
}
VRControllerManagerOpenVR::~VRControllerManagerOpenVR()
{
Destroy();
@@ -568,16 +580,18 @@ VRControllerManagerOpenVR::ScanForDevice
continue;
}
if (mVRSystem->GetTrackedDeviceClass(trackedDevice) != vr::TrackedDeviceClass_Controller) {
continue;
}
RefPtr<VRControllerOpenVR> openVRController = new VRControllerOpenVR();
+ openVRController->SetIndex(mControllerCount);
+ openVRController->SetTrackedIndex(trackedDevice);
mOpenVRController.AppendElement(openVRController);
// Not already present, add it.
AddGamepad("OpenVR Gamepad", GamepadMappingType::_empty,
kOpenVRControllerAxes, kOpenVRControllerButtons);
++mControllerCount;
}
}
\ No newline at end of file
--- a/gfx/vr/gfxVROpenVR.h
+++ b/gfx/vr/gfxVROpenVR.h
@@ -87,19 +87,24 @@ protected:
};
namespace impl {
class VRControllerOpenVR : public VRControllerHost
{
public:
explicit VRControllerOpenVR();
+ void SetTrackedIndex(uint32_t aTrackedIndex);
+ uint32_t GetTrackedIndex();
protected:
virtual ~VRControllerOpenVR();
+
+ // The index of tracked devices from vr::IVRSystem.
+ uint32_t mTrackedIndex;
};
} // namespace impl
class VRControllerManagerOpenVR : public VRControllerManager
{
public:
static already_AddRefed<VRControllerManagerOpenVR> Create();