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

Commit

Permalink
Bug 1299929 - Part 2: Add extra info for VRController; r=kip
Browse files Browse the repository at this point in the history
MozReview-Commit-ID: 5y8X5ZPnsHb
  • Loading branch information
daoshengmu committed Oct 13, 2016
1 parent dc7cdf3 commit a149d43
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
18 changes: 18 additions & 0 deletions gfx/vr/VRDisplayHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,22 @@ VRControllerHost::VRControllerHost(VRDeviceType aType)
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;
}
6 changes: 5 additions & 1 deletion gfx/vr/VRDisplayHost.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,17 @@ 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
Expand Down
14 changes: 14 additions & 0 deletions gfx/vr/gfxVROpenVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,18 @@ 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)
{
Expand Down Expand Up @@ -573,6 +585,8 @@ VRControllerManagerOpenVR::ScanForDevices()
}

RefPtr<VRControllerOpenVR> openVRController = new VRControllerOpenVR();
openVRController->SetIndex(mControllerCount);
openVRController->SetTrackedIndex(trackedDevice);
mOpenVRController.AppendElement(openVRController);

// Not already present, add it.
Expand Down
5 changes: 5 additions & 0 deletions gfx/vr/gfxVROpenVR.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,14 @@ 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
Expand Down

0 comments on commit a149d43

Please sign in to comment.