Bug 1346149 - Part 4: No longer need the index attribute in VRControllerHost; r?kip
MozReview-Commit-ID: 18KREzO4dy0
--- a/gfx/vr/VRDisplayHost.cpp
+++ b/gfx/vr/VRDisplayHost.cpp
@@ -159,28 +159,16 @@ VRControllerHost::~VRControllerHost()
const VRControllerInfo&
VRControllerHost::GetControllerInfo() const
{
return mControllerInfo;
}
void
-VRControllerHost::SetIndex(uint32_t aIndex)
-{
- mIndex = aIndex;
-}
-
-uint32_t
-VRControllerHost::GetIndex()
-{
- return mIndex;
-}
-
-void
VRControllerHost::SetButtonPressed(uint64_t aBit)
{
mButtonPressed = aBit;
}
uint64_t
VRControllerHost::GetButtonPressed()
{
--- a/gfx/vr/VRDisplayHost.h
+++ b/gfx/vr/VRDisplayHost.h
@@ -84,31 +84,27 @@ private:
VRDisplayInfo mLastUpdateDisplayInfo;
};
class VRControllerHost {
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VRControllerHost)
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();
dom::GamepadHand GetHand();
protected:
explicit VRControllerHost(VRDeviceType aType);
virtual ~VRControllerHost();
VRControllerInfo mControllerInfo;
- // The controller index in VRControllerManager.
- uint32_t mIndex;
// The current button pressed bit of button mask.
uint64_t mButtonPressed;
dom::GamepadPoseState mPose;
};
} // namespace gfx
} // namespace mozilla
--- a/gfx/vr/gfxVROculus.cpp
+++ b/gfx/vr/gfxVROculus.cpp
@@ -1251,17 +1251,16 @@ VRSystemManagerOculus::ScanForController
case ovrControllerType::ovrControllerType_LTouch:
hand = GamepadHand::Left;
break;
case ovrControllerType::ovrControllerType_RTouch:
hand = GamepadHand::Right;
break;
}
RefPtr<VRControllerOculus> oculusController = new VRControllerOculus(hand);
- oculusController->SetIndex(mControllerCount);
mOculusController.AppendElement(oculusController);
// Not already present, add it.
AddGamepad(oculusController->GetControllerInfo());
++mControllerCount;
}
}
}
--- a/gfx/vr/gfxVROpenVR.cpp
+++ b/gfx/vr/gfxVROpenVR.cpp
@@ -557,23 +557,23 @@ VRSystemManagerOpenVR::HandleInput()
for (uint32_t j = 0; j < vr::k_unControllerStateAxisCount; ++j) {
const uint32_t axisType = mVRSystem->GetInt32TrackedDeviceProperty(
trackedIndex,
static_cast<vr::TrackedDeviceProperty>(
vr::Prop_Axis0Type_Int32 + j));
switch (axisType) {
case vr::EVRControllerAxisType::k_eControllerAxis_Joystick:
case vr::EVRControllerAxisType::k_eControllerAxis_TrackPad:
- HandleAxisMove(controller->GetIndex(), axisIdx,
+ HandleAxisMove(i, axisIdx,
state.rAxis[j].x);
++axisIdx;
- HandleAxisMove(controller->GetIndex(), axisIdx,
+ HandleAxisMove(i, axisIdx,
state.rAxis[j].y);
++axisIdx;
- HandleButtonPress(controller->GetIndex(), buttonIdx,
+ HandleButtonPress(i, buttonIdx,
vr::ButtonMaskFromId(
static_cast<vr::EVRButtonId>(vr::k_EButton_Axis0 + j)),
state.ulButtonPressed);
++buttonIdx;
break;
case vr::EVRControllerAxisType::k_eControllerAxis_Trigger:
HandleTriggerPress(i, buttonIdx,
vr::ButtonMaskFromId(
@@ -585,59 +585,59 @@ VRSystemManagerOpenVR::HandleInput()
}
MOZ_ASSERT(axisIdx ==
controller->GetControllerInfo().GetNumAxes());
const uint64_t supportedButtons = mVRSystem->GetUint64TrackedDeviceProperty(
trackedIndex, vr::Prop_SupportedButtons_Uint64);
if (supportedButtons &
BTN_MASK_FROM_ID(k_EButton_A)) {
- HandleButtonPress(controller->GetIndex(), buttonIdx,
+ HandleButtonPress(i, buttonIdx,
BTN_MASK_FROM_ID(k_EButton_A),
state.ulButtonPressed);
++buttonIdx;
}
if (supportedButtons &
BTN_MASK_FROM_ID(k_EButton_Grip)) {
- HandleButtonPress(controller->GetIndex(), buttonIdx,
+ HandleButtonPress(i, buttonIdx,
BTN_MASK_FROM_ID(k_EButton_Grip),
state.ulButtonPressed);
++buttonIdx;
}
if (supportedButtons &
BTN_MASK_FROM_ID(k_EButton_ApplicationMenu)) {
- HandleButtonPress(controller->GetIndex(), buttonIdx,
+ HandleButtonPress(i, buttonIdx,
BTN_MASK_FROM_ID(k_EButton_ApplicationMenu),
state.ulButtonPressed);
++buttonIdx;
}
if (supportedButtons &
BTN_MASK_FROM_ID(k_EButton_DPad_Left)) {
- HandleButtonPress(controller->GetIndex(), buttonIdx,
+ HandleButtonPress(i, buttonIdx,
BTN_MASK_FROM_ID(k_EButton_DPad_Left),
state.ulButtonPressed);
++buttonIdx;
}
if (supportedButtons &
BTN_MASK_FROM_ID(k_EButton_DPad_Up)) {
- HandleButtonPress(controller->GetIndex(), buttonIdx,
+ HandleButtonPress(i, buttonIdx,
BTN_MASK_FROM_ID(k_EButton_DPad_Up),
state.ulButtonPressed);
++buttonIdx;
}
if (supportedButtons &
BTN_MASK_FROM_ID(k_EButton_DPad_Right)) {
- HandleButtonPress(controller->GetIndex(), buttonIdx,
+ HandleButtonPress(i, buttonIdx,
BTN_MASK_FROM_ID(k_EButton_DPad_Right),
state.ulButtonPressed);
++buttonIdx;
}
if (supportedButtons &
BTN_MASK_FROM_ID(k_EButton_DPad_Down)) {
- HandleButtonPress(controller->GetIndex(), buttonIdx,
+ HandleButtonPress(i, buttonIdx,
BTN_MASK_FROM_ID(k_EButton_DPad_Down),
state.ulButtonPressed);
++buttonIdx;
}
MOZ_ASSERT(buttonIdx ==
controller->GetControllerInfo().GetNumButtons());
controller->SetButtonPressed(state.ulButtonPressed);
@@ -671,17 +671,17 @@ VRSystemManagerOpenVR::HandleInput()
poseState.flags |= GamepadCapabilityFlags::Cap_Position;
poseState.position[0] = m._41;
poseState.position[1] = m._42;
poseState.position[2] = m._43;
poseState.linearVelocity[0] = pose.vVelocity.v[0];
poseState.linearVelocity[1] = pose.vVelocity.v[1];
poseState.linearVelocity[2] = pose.vVelocity.v[2];
- HandlePoseTracking(controller->GetIndex(), poseState, controller);
+ HandlePoseTracking(i, poseState, controller);
}
}
}
}
void
VRSystemManagerOpenVR::HandleButtonPress(uint32_t aControllerIdx,
uint32_t aButton,
@@ -784,17 +784,17 @@ VRSystemManagerOpenVR::ScanForController
trackedIndexArray[newControllerCount] = trackedDevice;
++newControllerCount;
}
if (newControllerCount != mControllerCount) {
// The controller count is changed, removing the existing gamepads first.
for (uint32_t i = 0; i < mOpenVRController.Length(); ++i) {
- RemoveGamepad(mOpenVRController[i]->GetIndex());
+ RemoveGamepad(i);
}
mControllerCount = 0;
mOpenVRController.Clear();
// Re-adding controllers to VRControllerManager.
for (vr::TrackedDeviceIndex_t i = 0; i < newControllerCount; ++i) {
const vr::TrackedDeviceIndex_t trackedDevice = trackedIndexArray[i];
const vr::ETrackedControllerRole role = mVRSystem->
@@ -862,17 +862,16 @@ VRSystemManagerOpenVR::ScanForController
}
if (supportButtons &
BTN_MASK_FROM_ID(k_EButton_DPad_Down)) {
++numButtons;
}
RefPtr<VRControllerOpenVR> openVRController =
new VRControllerOpenVR(hand, numButtons, numAxes);
- openVRController->SetIndex(mControllerCount);
openVRController->SetTrackedIndex(trackedDevice);
mOpenVRController.AppendElement(openVRController);
// Not already present, add it.
AddGamepad(openVRController->GetControllerInfo());
++mControllerCount;
}
}
--- a/gfx/vr/gfxVRPuppet.cpp
+++ b/gfx/vr/gfxVRPuppet.cpp
@@ -433,17 +433,16 @@ VRSystemManagerPuppet::ScanForController
mControllerCount = 0;
mPuppetController.Clear();
// Re-adding controllers to VRControllerManager.
for (uint32_t i = 0; i < newControllerCount; ++i) {
dom::GamepadHand hand = (i % 2) ? dom::GamepadHand::Right :
dom::GamepadHand::Left;
RefPtr<VRControllerPuppet> puppetController = new VRControllerPuppet(hand);
- puppetController->SetIndex(mControllerCount);
mPuppetController.AppendElement(puppetController);
// Not already present, add it.
AddGamepad(puppetController->GetControllerInfo());
++mControllerCount;
}
}
}