--- a/gfx/thebes/gfxPrefs.h
+++ b/gfx/thebes/gfxPrefs.h
@@ -343,16 +343,17 @@ private:
DECL_GFX_PREF(Live, "browser.ui.zoom.force-user-scalable", ForceUserScalable, bool, false);
DECL_GFX_PREF(Live, "browser.viewport.desktopWidth", DesktopViewportWidth, int32_t, 980);
DECL_GFX_PREF(Live, "dom.ipc.plugins.asyncdrawing.enabled", PluginAsyncDrawingEnabled, bool, false);
DECL_GFX_PREF(Live, "dom.meta-viewport.enabled", MetaViewportEnabled, bool, false);
DECL_GFX_PREF(Once, "dom.vr.enabled", VREnabled, bool, false);
DECL_GFX_PREF(Live, "dom.vr.autoactivate.enabled", VRAutoActivateEnabled, bool, false);
+ DECL_GFX_PREF(Live, "dom.vr.controller_trigger_threshold", VRControllerTriggerThreshold, float, 0.1f);
DECL_GFX_PREF(Live, "dom.vr.navigation.timeout", VRNavigationTimeout, int32_t, 1000);
DECL_GFX_PREF(Once, "dom.vr.oculus.enabled", VROculusEnabled, bool, true);
DECL_GFX_PREF(Once, "dom.vr.openvr.enabled", VROpenVREnabled, bool, false);
DECL_GFX_PREF(Once, "dom.vr.osvr.enabled", VROSVREnabled, bool, false);
DECL_GFX_PREF(Live, "dom.vr.poseprediction.enabled", VRPosePredictionEnabled, bool, true);
DECL_GFX_PREF(Live, "dom.vr.require-gesture", VRRequireGesture, bool, true);
DECL_GFX_PREF(Live, "dom.vr.puppet.enabled", VRPuppetEnabled, bool, false);
DECL_GFX_PREF(Live, "dom.w3c_pointer_events.enabled", PointerEventsEnabled, bool, false);
--- a/gfx/vr/gfxVROculus.cpp
+++ b/gfx/vr/gfxVROculus.cpp
@@ -1194,36 +1194,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, ovrTouch_LIndexTrigger,
- inputState.IndexTrigger[handIdx], inputState.Touches);
+ HandleIndexTriggerPress(i, buttonIdx, inputState.IndexTrigger[handIdx]);
++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, ovrTouch_RIndexTrigger,
- inputState.IndexTrigger[handIdx], inputState.Touches);
+ HandleIndexTriggerPress(i, buttonIdx, inputState.IndexTrigger[handIdx]);
++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);
@@ -1313,45 +1311,51 @@ VRSystemManagerOculus::HandleButtonPress
aButtonMask & aButtonTouched,
(aButtonMask & aButtonPressed) ? 1.0L : 0.0L);
}
}
void
VRSystemManagerOculus::HandleIndexTriggerPress(uint32_t aControllerIdx,
uint32_t aButton,
- uint64_t aTouchMask,
- float aValue,
- uint64_t aButtonTouched)
+ float aValue)
{
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) ||
- (touchedDiff & aTouchMask)) {
- NewButtonEvent(aControllerIdx, aButton, aValue > 0.1f, aTouchMask & aButtonTouched, aValue);
+ if (oldValue != aValue) {
+ NewButtonEvent(aControllerIdx, aButton, aValue > threshold,
+ aValue > threshold, aValue);
controller->SetIndexTrigger(aValue);
}
}
void
VRSystemManagerOculus::HandleHandTriggerPress(uint32_t aControllerIdx,
uint32_t aButton,
float aValue)
{
RefPtr<impl::VRControllerOculus> controller(mOculusController[aControllerIdx]);
MOZ_ASSERT(controller);
const float oldValue = controller->GetHandTrigger();
+ // 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) {
- NewButtonEvent(aControllerIdx, aButton, aValue > 0.1f, aValue > 0.1f, aValue);
+ NewButtonEvent(aControllerIdx, aButton, aValue > threshold,
+ aValue > threshold, aValue);
controller->SetHandTrigger(aValue);
}
}
void
VRSystemManagerOculus::HandleTouchEvent(uint32_t aControllerIdx, uint32_t aButton,
uint64_t aTouchMask, uint64_t aButtonTouched)
{
--- a/gfx/vr/gfxVROculus.h
+++ b/gfx/vr/gfxVROculus.h
@@ -164,20 +164,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,
- uint64_t aTouchMask, float aValue, uint64_t aButtonTouched);
- void HandleHandTriggerPress(uint32_t aControllerIdx, uint32_t aButton,
- float aValue);
+ void HandleIndexTriggerPress(uint32_t aControllerIdx, uint32_t aButton, float aValue);
+ void HandleHandTriggerPress(uint32_t aControllerIdx, uint32_t aButton, float aValue);
void HandleTouchEvent(uint32_t aControllerIdx, uint32_t aButton,
uint64_t aTouchMask, uint64_t aTouched);
PRLibrary* mOvrLib;
RefPtr<impl::VRDisplayOculus> mHMDInfo;
nsTArray<RefPtr<impl::VRControllerOculus>> mOculusController;
RefPtr<nsIThread> mOculusThread;
ovrSession mSession;
bool mStarted;
--- a/gfx/vr/gfxVROpenVR.cpp
+++ b/gfx/vr/gfxVROpenVR.cpp
@@ -642,21 +642,18 @@ VRSystemManagerOpenVR::HandleInput()
state.rAxis[j].y);
++axisIdx;
HandleButtonPress(i, buttonIdx,
::vr::ButtonMaskFromId(
static_cast<::vr::EVRButtonId>(::vr::k_EButton_Axis0 + j)),
state.ulButtonPressed, state.ulButtonTouched);
++buttonIdx;
break;
- case ::vr::EVRControllerAxisType::k_eControllerAxis_Trigger:
- HandleTriggerPress(i, buttonIdx,
- ::vr::ButtonMaskFromId(
- static_cast<::vr::EVRButtonId>(::vr::k_EButton_Axis0 + j)),
- state.rAxis[j].x, state.ulButtonPressed, state.ulButtonTouched);
+ case vr::EVRControllerAxisType::k_eControllerAxis_Trigger:
+ HandleTriggerPress(i, buttonIdx, state.rAxis[j].x);
++buttonIdx;
break;
}
}
MOZ_ASSERT(axisIdx ==
controller->GetControllerInfo().GetNumAxes());
const uint64_t supportedButtons = mVRSystem->GetUint64TrackedDeviceProperty(
@@ -781,33 +778,31 @@ VRSystemManagerOpenVR::HandleButtonPress
aButtonMask & aButtonTouched,
(aButtonMask & aButtonPressed) ? 1.0L : 0.0L);
}
}
void
VRSystemManagerOpenVR::HandleTriggerPress(uint32_t aControllerIdx,
uint32_t aButton,
- uint64_t aButtonMask,
- float aValue,
- uint64_t aButtonPressed,
- uint64_t aButtonTouched)
+ float aValue)
{
RefPtr<impl::VRControllerOpenVR> controller(mOpenVRController[aControllerIdx]);
MOZ_ASSERT(controller);
- const uint64_t pressedDiff = (controller->GetButtonPressed() ^ aButtonPressed);
- const uint64_t touchedDiff = (controller->GetButtonTouched() ^ aButtonTouched);
const float oldValue = controller->GetTrigger();
+ // For OpenVR, the threshold value of ButtonPressed and ButtonTouched is 0.55.
+ // We prefer to let developers to set their own threshold for the adjustment.
+ // Therefore, we don't check ButtonPressed and ButtonTouched with ButtonMask 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) ||
- (pressedDiff & aButtonMask) ||
- (touchedDiff & aButtonMask)) {
- NewButtonEvent(aControllerIdx, aButton, aButtonMask & aButtonPressed,
- aButtonMask & aButtonTouched, aValue);
+ if (oldValue != aValue) {
+ NewButtonEvent(aControllerIdx, aButton, aValue > threshold,
+ aValue > threshold, aValue);
controller->SetTrigger(aValue);
}
}
void
VRSystemManagerOpenVR::HandleAxisMove(uint32_t aControllerIdx, uint32_t aAxis,
float aValue)
{
--- a/gfx/vr/gfxVROpenVR.h
+++ b/gfx/vr/gfxVROpenVR.h
@@ -127,20 +127,17 @@ protected:
private:
void HandleButtonPress(uint32_t aControllerIdx,
uint32_t aButton,
uint64_t aButtonMask,
uint64_t aButtonPressed,
uint64_t aButtonTouched);
void HandleTriggerPress(uint32_t aControllerIdx,
uint32_t aButton,
- uint64_t aButtonMask,
- float aValue,
- uint64_t aButtonPressed,
- uint64_t aButtonTouched);
+ float aValue);
void HandleAxisMove(uint32_t aControllerIdx, uint32_t aAxis,
float aValue);
void HandlePoseTracking(uint32_t aControllerIdx,
const dom::GamepadPoseState& aPose,
VRControllerHost* aController);
dom::GamepadHand GetGamepadHandFromControllerRole(
::vr::ETrackedControllerRole aRole);
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -5051,16 +5051,18 @@ pref("dom.vr.enabled", false);
// It is often desirable to automatically start vr presentation when
// a user puts on the VR headset. This is done by emitting the
// Window.vrdisplayactivate event when the headset's sensors detect it
// being worn. This can result in WebVR content taking over the headset
// when the user is using it outside the browser or inadvertent start of
// presentation due to the high sensitivity of the proximity sensor in some
// headsets, so it is off by default.
pref("dom.vr.autoactivate.enabled", false);
+// The threshold value of trigger inputs for VR controllers
+pref("dom.vr.controller_trigger_threshold", "0.1");
// Maximum number of milliseconds the browser will wait for content to call
// VRDisplay.requestPresent after emitting vrdisplayactivate during VR
// link traversal. This prevents a long running event handler for
// vrdisplayactivate from later calling VRDisplay.requestPresent, which would
// result in a non-responsive browser in the VR headset.
pref("dom.vr.navigation.timeout", 5000);
// Oculus device
pref("dom.vr.oculus.enabled", true);