mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 04:09:50 +00:00
Bug 1353523 - Add adjustable threshold value for VR controller trigger inputs; r=kip
MozReview-Commit-ID: KQMccZeE2IK --HG-- extra : rebase_source : b8c60e59c7f9678fdb15f3dcc6770198ec35b82a
This commit is contained in:
parent
03c1939e54
commit
b4fb3b9c83
@ -348,6 +348,7 @@ private:
|
||||
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);
|
||||
|
@ -1199,8 +1199,7 @@ VRSystemManagerOculus::HandleInput()
|
||||
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;
|
||||
@ -1217,8 +1216,7 @@ VRSystemManagerOculus::HandleInput()
|
||||
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;
|
||||
@ -1318,19 +1316,20 @@ VRSystemManagerOculus::HandleButtonPress(uint32_t aControllerIdx,
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -1343,10 +1342,15 @@ VRSystemManagerOculus::HandleHandTriggerPress(uint32_t aControllerIdx,
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -169,10 +169,8 @@ private:
|
||||
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;
|
||||
|
@ -647,11 +647,8 @@ VRSystemManagerOpenVR::HandleInput()
|
||||
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;
|
||||
}
|
||||
@ -786,23 +783,21 @@ VRSystemManagerOpenVR::HandleButtonPress(uint32_t aControllerIdx,
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -132,10 +132,7 @@ private:
|
||||
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,
|
||||
|
@ -5056,6 +5056,8 @@ pref("dom.vr.enabled", false);
|
||||
// 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user