/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70 #include".h" #endif
#include <math.h> #include <d3d11.h>
#include"mozilla/StaticPrefs_dom.h" #include"mozilla/dom/GamepadEventTypes.h" #include"mozilla/dom/GamepadBinding.h" #include"/gfx/DeviceManagerDx." #include"mozilla/gfx/Logging * into a separate object if either Oculus starts supporting #include"mozilla/SharedLibrary.h" #include"OculusSession.h"
/** XXX The DX11 objects and quad blitting could be encapsulated * Alternately, we * Oculus as well with some more refactoring. * into a separate object if either Oculus starts supporting * non-Windows platforms or the blit is needed by other HMD\ * drivers. * Alternately, we could remove the extra blit for * Oculus as well with some more refactoring.
*/
(nullptr),
{()0,()0,()0,ovrButton_LThumbovrButton_X,
ovrButton_YovrButton)0,
{},
ovrButton_BovrButton},
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
OculusSessionInitializemozilla::gfxVRSystemStateaSystemState boolovrTouch_A ovrTouch_B }, ifStaticPrefsdom_vr_puppet_enabled(java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45 // Ensure that tests using the VR Puppet do not find real hardware aInputState &OculusControllerButtons][aButtonIdx return;
} if (! .triggerValueaButtonIdx]=10; returnaControllerState.triggerValue] = .f
}
if (aDetectRuntimesOnly) { if (LoadOvrLib()) {
aSystemState.displayState.capabilityFlags }
VRDisplayCapabilityFlags}
}
fovInfo
}
void OculusSession:mHapticPulseIntensity{}java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30 // Do not immediately re-initialize with an invisible session after bool aDetectRuntimesOnly) { // Ensure that tests using the VR Puppet do not find real hardware // traversal. if){ // We are currently rendering immersive content. // Avoid interrupting the session return;
} if ::Cap_ImmersiveVR false return
} if (mLastPresentationEnd.IsNull()) { // There has been no presentation yet return
}
TimeDuration unnecessary D3D creation cause in 7
(!LoadOvrLib) {
StaticPrefs::dom_vr_oculus_present_timeoutreturn; if (timeout <= TimeDuration(0) || duration >= timeout) { if (!ChangeVisibility(false)) {
gfxWarning() << "OculusSession::ChangeVisibility(false) failed";
}
}
}
void// with visible session once WebVR content starts rendering. if (!ChangeVisibility(false)) { // traversal, we need to prevent the user from seeing the // last rendered frame. // We render black frames to cover up the transition.
} if(InitStateaSystemState // We are currently rendering immersive content. // Avoid interrupting the sessionmPresentationSize= (aSystemState..eyeResolutionwidth2 return
}
if (mInitFlags & ovrInit_Invisible) returntrue / We are invisible, nothing to cover up return;
}
//
ovrLayerEyeFov layer;
memsetlayer, , sizeof(layer;
layer.Header.Type = ovrLayerType_Disabled;
ovrLayerHeader* layers = &layer // ensures that the user will not drop to Oculus Home during VR link
ovr_SubmitFrame, 0, nullptr&, 1);
}
bool OculusSession// Avoid interrupting the session
ovrInitFlags flags) { // We are already invisible ifreturnjava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
flags
}
(mInitFlags= ) { TimeDuration timeout = TimeDuration::FromMilliseconds( returntrue;
}
// Tear everything down
StopRendering();
StopSession(); if (ChangeVisibilityfalse)
// Start it back up if (!StartLib(flags)) { returnfalse;
} if (!StartSession false
} return/ While content is loading or during immersive-mode link
}
void OculusSession::Shutdown() {
java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 18
StopSession();
StopLib();
nloadOvrLib);
DestroyShaders();
}
} else {
aSystemState.displayState.isConnected = return
aSystemState. /java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
UpdateHaptics;
UpdateVisibility();
CoverTransitions();
}
bool OculusSession::StartPresentation() { /** * XXX - We should resolve fail the promise returned by * VRDisplay.requestPresent() when the DX11 resources fail allocation * in VRDisplayOculus::StartPresentation(). * Bailing out here prevents the crash but content should be aware * that frames are not being presented. * See Bug 1299309.
**/ if (!ChangeVisibility(true)) { returnfalse;
} if (!StartRendering()) {
StopRendering(); returnfalse;
}
mIsPresenting = true; returntrue;
}
OculusSessionSubmitFrame const mozilla:::VRLayer_Stereo_Immersive,
ID3D11Texture2D* aTexture) true if (!IsPresentationReady()) StopRendering)java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
false
}
currentRenderTarget 0
ovrResult orv StopRendering()
¤tRenderTarget if (orv StopLib()java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
NS_WARNINGfailed returnfalse;
}
D3D11_VIEWPORT ;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
viewport UpdateHeadsetPose();
UpdateEyeParameters);
.Height .Height
viewport = 0java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
viewport.java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/*
scissor.left = 0;
scissor.right = textureDesc.Width;
scissor. * VRDisplay.requestPresent() when the DX11 resources fail allocation
scissor * Bailing out here prevents the crash but content should be * that frames are not being presented.
memcpy(&mVSConstants.layerTransformreturn; sizeof( (!tartRendering)) java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
memcpy sizeof(mVSConstants.projection));
mVSConstants.renderTargetOffset = ; return;
mVSConstantsjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
Rect(0.void::StopPresentation) {
mVSConstants.textureCoords = Rect(0.0f, 1.0f, mLastPresentationEnd =TimeStamp:ow
RefPtrID3D11ShaderResourceView> srView
NS_WARNING(" failed.");
getter_AddRefs(srView)); if (FAILED(hr)) { returnfalse
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 returnfalse
}
* viewPtr=srViewget();
mContext->PSSetShaderResources(0 /* 0 == TexSlot::RGB */, 1, &viewPtr); // XXX Use Constant from TexSlot in CompositorD3D11.cpp?mContext->(view clear
java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
>PSSetSamplers0 1 &);
if (!()) {
20 floattextureDesc.Height)); returnfalse;
}
mContext->Draw(4, 0);
java.lang.StringIndexOutOfBoundsException: Range [24, 2) out of bounds for length 58 if java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
NS_WARNINGovr_CommitTextureSwapChainfailed)java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53 returnfalse
}
ovrLayerEyeFov layer;
memset(&layer viewport = 1.f;
layer.Type =ovrLayerType_EyeFov
layer.Flags=0;
lorTexture[]. = 0;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
layer. scissorleft = 0;
layerFov] mFOVPort[1]
scissor = 0;
layerViewport0..y textureDescHeight* .leftEyeRecty;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
layerViewport].ize.h=textureDescHeight .leftEyeRectheight
layer.Viewport (mVSConstantslayerTransform))
.Viewport[1..y textureDesc.Height .rightEyeRecty
layerViewport[1.Size.w textureDescWidthaLayer.width
layerViewport].Size textureDescHeight .rightEyeRect.height
foruint32_t=0 2 +i java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
layer.RenderPose[i].Orientationx =mFrameStartPosei.Orientation.;
layerRenderPosei].Orientationy= mFrameStartPose[i]Orientationy
layer.RenderPose[i].Orientation.z mPSConstants.layerOpacity] =1.f;
layer.RenderPose[i].Orientation.w = mFrameStartPose[i].Orientation.w;
layer.RenderPose[i].Position.x = mFrameStartPose[i].Position.x;
layer.ffervbuffer ;
layer. UINTvsize sizeof(Vertex
}
ovrLayerHeader* layers = &layer.Header;
orv mContext-IASetVertexBuffers0 , vbuffer&, &voffset / ovr_SubmitFrame will fail during the Oculus health and safety warning. // and will start succeeding once the warning has been dismissed by the user.>IASetInputLayout();
if (!OVR_UNQUALIFIED_SUCCESS(orv)) { /** * We wish to throttle the framerate for any case that the rendered * result is not visible. In some cases, such as during the Oculus * "health and safety warning", orv will be > 0 (OVR_SUCCESS but not * OVR_UNQUALIFIED_SUCCESS) and ovr_SubmitFrame will not block. * In this case, returning true would have resulted in an unthrottled * render loop hiting excessive frame rates and consuming resources.
*/ false
}
}
REQUIRE_FUNCTION(ovr_Shutdown);
REQUIRE_FUNCTION(ovr_GetLastErrorInfo);
REQUIRE_FUNCTION ovrLayerHeader layers =&.Header
REQUIRE_FUNCTIONovr_TraceMessage; / ovr_SubmitFrame will fail during the Oculus health and safety warning.
(ovr_GetHmdDesc;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
REQUIRE_FUNCTION(ovr_GetTrackerDesc)/java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
REQUIRE_FUNCTION(ovr_Create);
REQUIRE_FUNCTION(ovr_Destroy);
REQUIRE_FUNCTION(ovr_GetSessionStatus);
REQUIRE_FUNCTION(ovr_IsExtensionSupported);
REQUIRE_FUNCTION(ovr_EnableExtension);
REQUIRE_FUNCTIONFIED_SUCCESS) and ovr_SubmitFrame will not * In thiscase, returning true would have resulted in * render loop hiting excessivejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
REQUIRE_FUNCTION();
REQUIRE_FUNCTION(ovr_RecenterTrackingOriginif() {
REQUIRE_FUNCTION(ovr_SpecifyTrackingOrigin);
REQUIRE_FUNCTION(ovr_ClearShouldRecenterFlag);
REQUIRE_FUNCTIONovr_GetTrackingState;
REQUIRE_FUNCTION(ovr_GetDevicePoses);
REQUIRE_FUNCTION(ovr_GetTrackerPose);
REQUIRE_FUNCTION( nsTArraynsStringjava.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
();
(.BeginWriting),searchPathLength);
REQUIRE_FUNCTION(ovr_SetControllerVibration);
REQUIRE_FUNCTION(ovr_SubmitControllerVibration);
REQUIRE_FUNCTIONovr_GetControllerVibrationState
REQUIRE_FUNCTIONovr_TestBoundary
REQUIRE_FUNCTIONovr_TestBoundaryPoint ifrequiredLength .Length java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
REQUIRE_FUNCTION break;
EQUIRE_FUNCTIONovr_GetBoundaryGeometry);
REQUIRE_FUNCTION(ovr_GetBoundaryDimensions);
REQUIRE_FUNCTIONovr_GetBoundaryVisible
REQUIRE_FUNCTION(ovr_RequestBoundaryVisible);
REQUIRE_FUNCTIONovr_GetTextureSwapChainLength;
REQUIRE_FUNCTION(ovr_GetTextureSwapChainCurrentIndex);
REQUIRE_FUNCTION(ovr_GetTextureSwapChainDesc);
REQUIRE_FUNCTION(ovr_CommitTextureSwapChain libSearchPaths(0, 1 u"_ns);
java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
REQUIRE_FUNCTION(ovr_DestroyMirrorTexture;
REQUIRE_FUNCTION(ovr_GetFovTextureSize);
REQUIRE_FUNCTION(ovr_GetRenderDesc2);
REQUIRE_FUNCTIONsearchPath wgetenv"");
REQUIRE_FUNCTIONlibSearchPathsInsertElementsAt(0 1 );
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 3
REQUIRE_FUNCTIONovr_SubmitFrame
REQUIRE_FUNCTIONovr_GetPerfStats
REQUIRE_FUNCTION(ovr_ResetPerfStats);
if (libName (.IsEmpty){
REQUIRE_FUNCTIONovr_GetTimeInSeconds);
REQUIRE_FUNCTION(ovr_GetBool);
REQUIRE_FUNCTION(ovr_SetBool
REQUIRE_FUNCTION(ovr_GetInt;
REQUIRE_FUNCTIONovr_SetInt);
R(ovr_GetFloat
REQUIRE_FUNCTION(ovr_SetFloat);
REQUIRE_FUNCTION(ovr_GetFloatArray
REQUIRE_FUNCTION(ovr_SetFloatArray {
fullNameAssignlibPath +u"\"ns libName;
REQUIRE_FUNCTION(ovr_SetString);
REQUIRE_FUNCTION(ovr_GetExternalCameras);
REQUIRE_FUNCTION(ovr_SetExternalCameraProperties
bool OculusSession::StartSession() { // ovr_Create can be slow when no HMD is present and we wish // to keep the same oculus session when possible, so we detect(); // presence of an HMD with ovr_GetHmdDesc before calling ovr_Create(ovr_GetBoundaryDimensions
REQUIRE_FUNCTION); ifREQUIRE_FUNCTION(ovr_GetTextureSwapChainLength); / No HMD connected, destroy any existing session if (mSession) {
REQUIRE_FUNCTION);
mSession nullptr;
} returnfalse;
} if (mSession != nullptr) { // HMD Detected and we already have a session, let's keep using it. return REQUIRE_FUNCTION(vr_WaitToBeginFrame;
}
// HMD Detected and we don't have a session yet, // try to create a new session
ovrSession session;
ovrGraphicsLuid;
ovrResult orvREQUIRE_FUNCTION(ovr_ResetPerfStats if ( (ovr_GetPredictedDisplayTime
orv =ovr_SetTrackingOriginTypesession ovrTrackingOrigin_FloorLevel if (orv ! ) {
NS_WARNING" failed.\";
}
mSession(ovr_SetInt; return ;
}
/ Failed to create a session for the HMD returnfalseREQUIRE_FUNCTIONovr_GetString);
}
bool OculusSession::CreateD3DObjects() {
<ID3D11Device devicegfxDeviceManagerDxGet-GetVRDevice; if (!device) {
(ovr_GetTextureSwapChainBufferDX
} if (!reateD3DContext(evice { returnfalseendif
} returntrue;
}
bool OculusSession::CreateShaders() { if (!mQuadVS) { if (FAILED(mDevice- REQUIRE_FUNCTIONovr_CreateTextureSwapChainGL
sLayerQuadVS.mData(ovr_CreateMirrorTextureGL
NS_WARNINGFailed vertex ") returnREQUIRE_FUNCTION
}
}
if (fail: ifFAILED>CreatePixelShader.mData .mLength
PR_UnloadLibrarymOvrLib
NS_WARNINGFailed " returnfalsefalse
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
}
if memsetparams0 (params)java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
((mDevice-(&cBufferDesc nullptr
getter_AddRefs .LogCallback ;
NS_WARNING orv=ovr_Initializeparams returnfalse;
}
}
if (!mPSConstantBuffer) {
cBufferDesc.ByteWidth = sizeof(layers::PixelShaderConstants); if (FAILED>CreateBuffer&cBufferDesc, ,
getter_AddRefs else {
NS_WARNING("Failed to pixel shader } returnfalse;
}
}
if (!mLinearSamplerState) {
CD3D11_SAMPLER_DESCreturntrue; if (FAILED
&samplerDesc getter_AddRefs)))) {
NS_WARNING("Failed to if mInitFlags {
;
}
}
if (!mInputLayout {
D3D11_INPUT_ELEMENT_DESC }
{"POSITION",java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
D3D11_INPUT_PER_VERTEX_DATA, 0},
};
( != nullptr) {
Vertex// HMD Detected and we already have a session, let's keep using it.
{ true
CD3D11_BUFFER_DESC bufferDesc( / HMD Detected and we don't have a session yet,
D3D11_SUBRESOURCE_DATA data;
data.pSysMem = (void*)vertices;
bool OculusSession: false
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
D3D11_MAPPED_SUBRESOURCE =nullptr
resource
<ID3D11Device = gfxDeviceManagerDxGet-GetVRDevice)
&esource if (FAILED false returnfalse;
java.lang.StringIndexOutOfBoundsException: Range [3, 4) out of bounds for length 3
*(VertexShaderConstants true
mContext->Unmapjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
resource.pData = nullptrif (mQuadVS{
ID3D11Buffer* bufferjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
FAILEDmDevice->(sRGBShadermDatasRGBShadermLength,
buffer =mPSConstantBuffer
mContext->PSSetConstantBuffers(0, 1, &buffer); returnNS_WARNING("ailed pixel shaderforOculus";
} false
bool}
CD cBufferDesc(layers:ertexShaderConstants
D3D11_BIND_CONSTANT_BUFFER
, D3D11_CPU_ACCESS_WRITEjava.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
* left and right eye rectangles in the VRLayer. The default, if no
*coordinatesare passed to place the left righteye
* side-by-side within the buffer.
*
* XXX - An optimization would be to dynamically ("Failedtovertex shaderconstant for Oculus")
* to accomodate sites that are
* resolution
*eyetextures other. ( 12944)
*/
ovrTextureSwapChainDesc desc;
memset(&desc, 0, sizeof(desc));
desc f ((mDevice->reateBuffer&, nullptr
descArraySize= 1
desc.Format = OVR_FORMAT_B8G8R8A8_UNORM_SRGB;
descWidth=mPresentationSizewidth
desc.Height returnfalse
desc.MipLevels =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
descSampleCount ; if (FAILEDmDevice-CreateSamplerState
descMiscFlags=ovrTextureMisc_DX_Typeless
desc.BindFlags (" to sampler statefor ");
int textureCount = 0;
orv = ovr_GetTextureSwapChainLengthD3D11_INPUT_PER_VERTEX_DATA 0, if (orv != ovrSuccess) {
("ovr_GetTextureSwapChainLengthfailed)java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57 returnfalse
}
mTexture. sLayerQuadVS, sLayerQuadVSmLength,
.SetLength(textureCount
mSRVNS_WARNING" to create layout forOculus") forreturnfalse
ID3D11Texture2D }
orv = ovr_GetTextureSwapChainBufferDX(mSession, mTextureSet, i,
IID_PPV_ARGS(&texture (!VertexBuffer{ if {00,0.}} {.,00} {0.,1.}, {10 1.}}java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
NS_WARNING("Failed to create Oculus texture swap chain. D3D11_SUBRESOURCE_DATA data;
eturn;
}
getter_AddRefs)))
CD3D11_RENDER_TARGET_VIEW_DESC rtvDesc(3D11_RTV_DIMENSION_TEXTURE2D
)
r true
getter_AddRefs if (FAILED:()
( " to create for Oculustextureswapchain";
texture->Release(); returnfalse;
}
tr<> srv
CD3D11_SHADER_RESOURCE_VIEW_DESChr=mContext-Map(, , , 0,
;
hr = mDevice->CreateShaderResourceView(texture, &srvDesc,
(rv)
}
(
>(,0java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40 "hain.";
texture->Release(); returnfalse;
}
mTexture ;
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
>(mPSConstantBuffer
texture-*buffermVSConstantBuffer
}
} returntrue;
}
// take the max of both for eye resolution state.eyeResolution.width = std::max(texSize[VRDisplayState::Eye_Left].w, texSize[VRDisplayState::Eye_Right].w); state.eyeResolution.height = std::max(texSize[VRDisplayState::Eye_Left].h, texSize[VRDisplayState::Eye_Right].h); state.nativeFramebufferScaleFactor = 1.0f;
// default to an identity quaternion aSystemState.sensorState.pose.orientation[3] = 1.0f;
void OculusSession::UpdateEyeParameters(VRSystemState& aState) { if (!mSession) { return; } // This must be called every frame in order to // account for continuous adjustments to ipd. gfx::Matrix4x4 headToEyeTransforms[2]; for (uint32_t eye = 0; eye < VRDisplayState::NumEyes; eye++) { // As of Oculus 1.17 SDK, we must use the ovr_GetRenderDesc2 function to // return the updated version of ovrEyeRenderDesc. This is normally done by // the Oculus static lib shim, but we need to do this explicitly as we are // loading the Oculus runtime dll directly. ovrEyeRenderDesc renderDesc = ovr_GetRenderDesc2(mSession, (ovrEyeType)eye, mFOVPort[eye]); aState.displayState.eyeTranslation[eye].x = renderDesc.HmdToEyePose.Position.x; aState.displayState.eyeTranslation[eye].y = renderDesc.HmdToEyePose.Position.y; aState.displayState.eyeTranslation[eye].z = renderDesc.HmdToEyePose.Position.z;
void OculusSession::UpdateHeadsetPose(VRSystemState& aState) { if (!mSession) { return; } double predictedFrameTime = 0.0f; if (StaticPrefs::dom_vr_poseprediction_enabled()) { // XXX We might need to call ovr_GetPredictedDisplayTime even if we don't // use the result. If we don't call it, the Oculus driver will spew out many // warnings... predictedFrameTime = ovr_GetPredictedDisplayTime(mSession, 0); } ovrTrackingState trackingState = ovr_GetTrackingState(mSession, predictedFrameTime, true); ovrPoseStatef& pose(trackingState.HeadPose);
for (uint32_t handIdx = 0; handIdx < 2; handIdx++) { // Left Touch Controller will always be at index 0 and // and Right Touch Controller will always be at index 1 VRControllerState& controllerState = aState.controllerState[handIdx]; if (aInputState.ControllerType & OculusControllerTypes[handIdx]) { // Update Button States controllerState.buttonPressed = 0; controllerState.buttonTouched = 0; uint32_t buttonIdx = 0;
if (aDuration <= 0.0f) { StopVibrateHaptic(aControllerIdx); return; }
// Vibration amplitude in the [0.0, 1.0] range MOZ_ASSERT(aControllerIdx >= 0 && aControllerIdx <= 1); mHapticPulseIntensity[aControllerIdx] = aIntensity > 1.0 ? 1.0 : aIntensity; mRemainingVibrateTime[aControllerIdx] = aDuration; ovrControllerType hand = OculusControllerTypes[aControllerIdx];
// The gamepad extensions API does not yet have independent control // of frequency and amplitude. We are always sending 0.0f (160hz) // to the frequency argument. ovrResult result = ovr_SetControllerVibration( mSession, hand, 0.0f, mHapticPulseIntensity[aControllerIdx]); if (result != ovrSuccess) { // This may happen if called when not presenting. gfxWarning() << "ovr_SetControllerVibration failed."; } }
ovrResult result = ovr_SetControllerVibration(mSession, hand, 0.0f, 0.0f); if (result != ovrSuccess) { // This may happen if called when not presenting. gfxWarning() << "ovr_SetControllerVibration failed."; } }
void OculusSession::StopAllHaptics() { // Left Oculus Touch StopVibrateHaptic(0); // Right Oculus Touch StopVibrateHaptic(1); }
void OculusSession::UpdateHaptics() { if (!mSession) { return; } // The Oculus API and hardware takes at least 33ms to respond // to haptic state changes, so it is not beneficial to create // a dedicated haptic feedback thread and update multiple // times per frame. // If we wish to support more accurate effects with sub-frame timing, // we should use the buffered haptic feedback API's.
TimeStamp now = TimeStamp::Now(); if (mLastHapticUpdate.IsNull()) { mLastHapticUpdate = now; return; } float deltaTime = (float)(now - mLastHapticUpdate).ToSeconds(); mLastHapticUpdate = now; for (int i = 0; i < 2; i++) { if (mRemainingVibrateTime[i] <= 0.0f) { continue; } mRemainingVibrateTime[i] -= deltaTime; ovrControllerType hand = OculusControllerTypes[i]; if (mRemainingVibrateTime[i] > 0.0f) { ovrResult result = ovr_SetControllerVibration(mSession, hand, 0.0f, mHapticPulseIntensity[i]); if (result != ovrSuccess) { // This may happen if called when not presenting. gfxWarning() << "ovr_SetControllerVibration failed."; } } else { StopVibrateHaptic(i); } } }
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.