Bug 1305891 - Part 2: Accept GamepadHand as the parameter when VRControllerHost constructs; r?kip
MozReview-Commit-ID: IYscauVw8iE
--- a/gfx/vr/VRDisplayHost.cpp
+++ b/gfx/vr/VRDisplayHost.cpp
@@ -194,20 +194,14 @@ VRControllerHost::SetPose(const dom::Gam
}
const dom::GamepadPoseState&
VRControllerHost::GetPose()
{
return mPose;
}
-void
-VRControllerHost::SetHand(dom::GamepadHand aHand)
-{
- mControllerInfo.mHand = aHand;
-}
-
dom::GamepadHand
VRControllerHost::GetHand()
{
return mControllerInfo.mHand;
}
--- a/gfx/vr/VRDisplayHost.h
+++ b/gfx/vr/VRDisplayHost.h
@@ -90,17 +90,16 @@ public:
const VRControllerInfo& GetControllerInfo() const;
void SetIndex(uint32_t aIndex);
uint32_t GetIndex();
void SetButtonPressed(uint64_t aBit);
uint64_t GetButtonPressed();
void SetPose(const dom::GamepadPoseState& aPose);
const dom::GamepadPoseState& GetPose();
- virtual void SetHand(dom::GamepadHand aHand);
dom::GamepadHand GetHand();
protected:
explicit VRControllerHost(VRDeviceType aType);
virtual ~VRControllerHost();
VRControllerInfo mControllerInfo;
// The controller index in VRControllerManager.
--- a/gfx/vr/gfxVROculus.cpp
+++ b/gfx/vr/gfxVROculus.cpp
@@ -827,23 +827,26 @@ VRDisplayOculus::SubmitFrame(TextureSour
void
VRDisplayOculus::NotifyVSync()
{
ovrSessionStatus sessionStatus;
ovrResult ovr = ovr_GetSessionStatus(mSession, &sessionStatus);
mDisplayInfo.mIsConnected = (ovr == ovrSuccess && sessionStatus.HmdPresent);
}
-VRControllerOculus::VRControllerOculus()
+VRControllerOculus::VRControllerOculus(dom::GamepadHand aHand)
: VRControllerHost(VRDeviceType::Oculus)
{
MOZ_COUNT_CTOR_INHERITED(VRControllerOculus, VRControllerHost);
- mControllerInfo.mControllerName.AssignLiteral("Oculus Touch");
+ mControllerInfo.mControllerName.AssignLiteral("Oculus Touch (");
+ mControllerInfo.mControllerName.AppendPrintf("%s%s",
+ GamepadHandValues::strings[uint32_t(aHand)].value,
+ ")");
mControllerInfo.mMappingType = GamepadMappingType::_empty;
- mControllerInfo.mHand = GamepadHand::_empty;
+ mControllerInfo.mHand = aHand;
mControllerInfo.mNumButtons = kNumOculusButton;
mControllerInfo.mNumAxes = static_cast<uint32_t>(
OculusControllerAxisType::NumVRControllerAxisType);;
}
float
VRControllerOculus::GetAxisMove(uint32_t aAxis)
{
@@ -851,26 +854,16 @@ VRControllerOculus::GetAxisMove(uint32_t
}
void
VRControllerOculus::SetAxisMove(uint32_t aAxis, float aValue)
{
mAxisMove[aAxis] = aValue;
}
-void
-VRControllerOculus::SetHand(dom::GamepadHand aHand)
-{
- VRControllerHost::SetHand(aHand);
- mControllerInfo.mControllerName.AssignLiteral("Oculus Touch (");
- mControllerInfo.mControllerName.AppendPrintf("%s%s",
- GamepadHandValues::strings[uint32_t(aHand)].value,
- ")");
-}
-
VRControllerOculus::~VRControllerOculus()
{
MOZ_COUNT_DTOR_INHERITED(VRControllerOculus, VRControllerHost);
}
/*static*/ already_AddRefed<VRSystemManagerOculus>
VRSystemManagerOculus::Create()
{
@@ -1148,19 +1141,18 @@ VRSystemManagerOculus::ScanForController
switch (activeControllerArray[i]) {
case ovrControllerType::ovrControllerType_LTouch:
hand = GamepadHand::Left;
break;
case ovrControllerType::ovrControllerType_RTouch:
hand = GamepadHand::Right;
break;
}
- RefPtr<VRControllerOculus> oculusController = new VRControllerOculus();
+ RefPtr<VRControllerOculus> oculusController = new VRControllerOculus(hand);
oculusController->SetIndex(mControllerCount);
- oculusController->SetHand(hand);
mOculusController.AppendElement(oculusController);
// Not already present, add it.
AddGamepad(oculusController->GetControllerInfo());
++mControllerCount;
}
}
}
--- a/gfx/vr/gfxVROculus.h
+++ b/gfx/vr/gfxVROculus.h
@@ -92,20 +92,19 @@ protected:
{
float position[2];
};
};
class VRControllerOculus : public VRControllerHost
{
public:
- explicit VRControllerOculus();
+ explicit VRControllerOculus(dom::GamepadHand aHand);
float GetAxisMove(uint32_t aAxis);
void SetAxisMove(uint32_t aAxis, float aValue);
- virtual void SetHand(dom::GamepadHand aHand) override;
protected:
virtual ~VRControllerOculus();
float mAxisMove[static_cast<uint32_t>(
OculusControllerAxisType::NumVRControllerAxisType)];
};
} // namespace impl
--- a/gfx/vr/gfxVROpenVR.cpp
+++ b/gfx/vr/gfxVROpenVR.cpp
@@ -415,23 +415,23 @@ VRDisplayOpenVR::NotifyVSync()
{
// We update mIsConneced once per frame.
mDisplayInfo.mIsConnected = vr_IsHmdPresent();
// Make sure we respond to OpenVR events even when not presenting
PollEvents();
}
-VRControllerOpenVR::VRControllerOpenVR()
+VRControllerOpenVR::VRControllerOpenVR(dom::GamepadHand aHand)
: VRControllerHost(VRDeviceType::OpenVR)
{
MOZ_COUNT_CTOR_INHERITED(VRControllerOpenVR, VRControllerHost);
mControllerInfo.mControllerName.AssignLiteral("OpenVR Gamepad");
mControllerInfo.mMappingType = GamepadMappingType::_empty;
- mControllerInfo.mHand = GamepadHand::_empty;
+ mControllerInfo.mHand = aHand;
mControllerInfo.mNumButtons = gNumOpenVRButtonMask;
mControllerInfo.mNumAxes = gNumOpenVRAxis;
}
VRControllerOpenVR::~VRControllerOpenVR()
{
MOZ_COUNT_DTOR_INHERITED(VRControllerOpenVR, VRControllerHost);
}
@@ -728,20 +728,19 @@ VRSystemManagerOpenVR::ScanForController
break;
case vr::ETrackedControllerRole::TrackedControllerRole_LeftHand:
hand = GamepadHand::Left;
break;
case vr::ETrackedControllerRole::TrackedControllerRole_RightHand:
hand = GamepadHand::Right;
break;
}
- RefPtr<VRControllerOpenVR> openVRController = new VRControllerOpenVR();
+ RefPtr<VRControllerOpenVR> openVRController = new VRControllerOpenVR(hand);
openVRController->SetIndex(mControllerCount);
openVRController->SetTrackedIndex(trackedDevice);
- openVRController->SetHand(hand);
mOpenVRController.AppendElement(openVRController);
// Not already present, add it.
AddGamepad(openVRController->GetControllerInfo());
++mControllerCount;
}
}
}
--- a/gfx/vr/gfxVROpenVR.h
+++ b/gfx/vr/gfxVROpenVR.h
@@ -67,17 +67,17 @@ protected:
void UpdateStageParameters();
void PollEvents();
};
class VRControllerOpenVR : public VRControllerHost
{
public:
- explicit VRControllerOpenVR();
+ explicit VRControllerOpenVR(dom::GamepadHand aHand);
void SetTrackedIndex(uint32_t aTrackedIndex);
uint32_t GetTrackedIndex();
protected:
virtual ~VRControllerOpenVR();
// The index of tracked devices from vr::IVRSystem.
uint32_t mTrackedIndex;