Bug 1455159 - Let Oculus Touch trigger listen touch events instead of using button values; r?kip
MozReview-Commit-ID: 6P5BW3PQo7
--- a/gfx/vr/gfxVROculus.cpp
+++ b/gfx/vr/gfxVROculus.cpp
@@ -1679,34 +1679,34 @@ VRSystemManagerOculus::HandleInput()
const uint32_t handIdx = static_cast<uint32_t>(hand) - 1;
uint32_t buttonIdx = 0;
switch (hand) {
case dom::GamepadHand::Left:
HandleButtonPress(i, buttonIdx, ovrButton_LThumb, inputState.Buttons,
inputState.Touches);
++buttonIdx;
- HandleIndexTriggerPress(i, buttonIdx, inputState.IndexTrigger[handIdx]);
+ HandleIndexTriggerPress(i, buttonIdx, inputState.IndexTrigger[handIdx], ovrTouch_LIndexTrigger, inputState.Touches);
++buttonIdx;
HandleHandTriggerPress(i, buttonIdx, inputState.HandTrigger[handIdx]);
++buttonIdx;
HandleButtonPress(i, buttonIdx, ovrButton_X, inputState.Buttons,
inputState.Touches);
++buttonIdx;
HandleButtonPress(i, buttonIdx, ovrButton_Y, inputState.Buttons,
inputState.Touches);
++buttonIdx;
HandleTouchEvent(i, buttonIdx, ovrTouch_LThumbRest, inputState.Touches);
++buttonIdx;
break;
case dom::GamepadHand::Right:
HandleButtonPress(i, buttonIdx, ovrButton_RThumb, inputState.Buttons,
inputState.Touches);
++buttonIdx;
- HandleIndexTriggerPress(i, buttonIdx, inputState.IndexTrigger[handIdx]);
+ HandleIndexTriggerPress(i, buttonIdx, inputState.IndexTrigger[handIdx], ovrTouch_RIndexTrigger, inputState.Touches);
++buttonIdx;
HandleHandTriggerPress(i, buttonIdx, inputState.HandTrigger[handIdx]);
++buttonIdx;
HandleButtonPress(i, buttonIdx, ovrButton_A, inputState.Buttons,
inputState.Touches);
++buttonIdx;
HandleButtonPress(i, buttonIdx, ovrButton_B, inputState.Buttons,
inputState.Touches);
@@ -1805,30 +1805,35 @@ VRSystemManagerOculus::HandleButtonPress
aButtonMask & aButtonTouched,
(aButtonMask & aButtonPressed) ? 1.0L : 0.0L);
}
}
void
VRSystemManagerOculus::HandleIndexTriggerPress(uint32_t aControllerIdx,
uint32_t aButton,
- float aValue)
+ float aValue,
+ uint64_t aTouchMask,
+ uint64_t aButtonTouched)
{
RefPtr<impl::VRControllerOculus> controller(mOculusController[aControllerIdx]);
MOZ_ASSERT(controller);
+
+ const uint64_t touchedDiff = (controller->GetButtonTouched() ^ aButtonTouched);
const float oldValue = controller->GetIndexTrigger();
// We prefer to let developers to set their own threshold for the adjustment.
// Therefore, we don't check ButtonPressed and ButtonTouched with TouchMask here.
// we just check the button value is larger than the threshold value or not.
const float threshold = gfxPrefs::VRControllerTriggerThreshold();
// Avoid sending duplicated events in IPC channels.
- if (oldValue != aValue) {
+ if (oldValue != aValue ||
+ touchedDiff & aTouchMask) {
NewButtonEvent(aControllerIdx, aButton, aValue > threshold,
- aValue > threshold, aValue);
+ aButtonTouched & aTouchMask, aValue);
controller->SetIndexTrigger(aValue);
}
}
void
VRSystemManagerOculus::HandleHandTriggerPress(uint32_t aControllerIdx,
uint32_t aButton,
float aValue)
--- a/gfx/vr/gfxVROculus.h
+++ b/gfx/vr/gfxVROculus.h
@@ -209,17 +209,18 @@ private:
uint64_t aButtonMask,
uint64_t aButtonPressed,
uint64_t aButtonTouched);
void HandleAxisMove(uint32_t aControllerIdx, uint32_t aAxis,
float aValue);
void HandlePoseTracking(uint32_t aControllerIdx,
const dom::GamepadPoseState& aPose,
VRControllerHost* aController);
- void HandleIndexTriggerPress(uint32_t aControllerIdx, uint32_t aButton, float aValue);
+ void HandleIndexTriggerPress(uint32_t aControllerIdx, uint32_t aButton, float aValue,
+ uint64_t aTouchMask, uint64_t aButtonTouched);
void HandleHandTriggerPress(uint32_t aControllerIdx, uint32_t aButton, float aValue);
void HandleTouchEvent(uint32_t aControllerIdx, uint32_t aButton,
uint64_t aTouchMask, uint64_t aTouched);
void GetControllerPoseState(uint32_t aHandIdx, dom::GamepadPoseState& aPoseState,
bool aForceUpdate = false);
RefPtr<impl::VRDisplayOculus> mDisplay;
nsTArray<RefPtr<impl::VRControllerOculus>> mOculusController;