Skip to content
This repository was archived by the owner on Aug 4, 2022. It is now read-only.

Commit a149d43

Browse files
committed
Bug 1299929 - Part 2: Add extra info for VRController; r=kip
MozReview-Commit-ID: 5y8X5ZPnsHb
1 parent dc7cdf3 commit a149d43

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed

gfx/vr/VRDisplayHost.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,22 @@ VRControllerHost::VRControllerHost(VRDeviceType aType)
155155
VRControllerHost::~VRControllerHost()
156156
{
157157
MOZ_COUNT_DTOR(VRControllerHost);
158+
}
159+
160+
const VRControllerInfo&
161+
VRControllerHost::GetControllerInfo() const
162+
{
163+
return mControllerInfo;
164+
}
165+
166+
void
167+
VRControllerHost::SetIndex(uint32_t aIndex)
168+
{
169+
mIndex = aIndex;
170+
}
171+
172+
uint32_t
173+
VRControllerHost::GetIndex()
174+
{
175+
return mIndex;
158176
}

gfx/vr/VRDisplayHost.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,17 @@ class VRControllerHost {
8787
public:
8888
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VRControllerHost)
8989

90-
const VRControllerInfo& GetControllerInfo() const { return mControllerInfo; }
90+
const VRControllerInfo& GetControllerInfo() const;
91+
void SetIndex(uint32_t aIndex);
92+
uint32_t GetIndex();
9193

9294
protected:
9395
explicit VRControllerHost(VRDeviceType aType);
9496
virtual ~VRControllerHost();
9597

9698
VRControllerInfo mControllerInfo;
99+
// The controller index in VRControllerManager.
100+
uint32_t mIndex;
97101
};
98102

99103
} // namespace gfx

gfx/vr/gfxVROpenVR.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,18 @@ VRControllerOpenVR::~VRControllerOpenVR()
455455
MOZ_COUNT_DTOR_INHERITED(VRControllerOpenVR, VRControllerHost);
456456
}
457457

458+
void
459+
VRControllerOpenVR::SetTrackedIndex(uint32_t aTrackedIndex)
460+
{
461+
mTrackedIndex = aTrackedIndex;
462+
}
463+
464+
uint32_t
465+
VRControllerOpenVR::GetTrackedIndex()
466+
{
467+
return mTrackedIndex;
468+
}
469+
458470
VRControllerManagerOpenVR::VRControllerManagerOpenVR()
459471
: mOpenVRInstalled(false), mVRSystem(nullptr)
460472
{
@@ -573,6 +585,8 @@ VRControllerManagerOpenVR::ScanForDevices()
573585
}
574586

575587
RefPtr<VRControllerOpenVR> openVRController = new VRControllerOpenVR();
588+
openVRController->SetIndex(mControllerCount);
589+
openVRController->SetTrackedIndex(trackedDevice);
576590
mOpenVRController.AppendElement(openVRController);
577591

578592
// Not already present, add it.

gfx/vr/gfxVROpenVR.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,14 @@ class VRControllerOpenVR : public VRControllerHost
9292
{
9393
public:
9494
explicit VRControllerOpenVR();
95+
void SetTrackedIndex(uint32_t aTrackedIndex);
96+
uint32_t GetTrackedIndex();
9597

9698
protected:
9799
virtual ~VRControllerOpenVR();
100+
101+
// The index of tracked devices from vr::IVRSystem.
102+
uint32_t mTrackedIndex;
98103
};
99104

100105
} // namespace impl

0 commit comments

Comments
 (0)