diff --git a/app/src/main/cpp/Device.h b/app/src/main/cpp/Device.h index 68713b4113..62d9dccf94 100644 --- a/app/src/main/cpp/Device.h +++ b/app/src/main/cpp/Device.h @@ -16,6 +16,7 @@ const CapabilityFlags AngularAcceleration = 1 << 5; const CapabilityFlags LinearAcceleration = 1 << 6; const CapabilityFlags StageParameters = 1 << 7; const CapabilityFlags MountDetection = 1 << 8; +const CapabilityFlags PositionNeckModel = 1 << 9; enum class Eye { Left, Right }; enum class RenderMode { StandAlone, Immersive }; const int32_t EyeCount = 2; diff --git a/app/src/main/cpp/DeviceDelegate.h b/app/src/main/cpp/DeviceDelegate.h index ff99625e60..d8b98d0f88 100644 --- a/app/src/main/cpp/DeviceDelegate.h +++ b/app/src/main/cpp/DeviceDelegate.h @@ -39,6 +39,7 @@ class ImmersiveDisplay { const double aBottomDegrees) = 0; virtual void SetEyeOffset(const device::Eye aEye, const float aX, const float aY, const float aZ) = 0; virtual void SetEyeResolution(const int32_t aWidth, const int32_t aHeight) = 0; + virtual void SetSittingToStandingTransform(const vrb::Matrix& aTransform) = 0; virtual void CompleteEnumeration() = 0; }; diff --git a/app/src/main/cpp/ExternalVR.cpp b/app/src/main/cpp/ExternalVR.cpp index a881e771c2..3a3d61bb1a 100644 --- a/app/src/main/cpp/ExternalVR.cpp +++ b/app/src/main/cpp/ExternalVR.cpp @@ -256,6 +256,9 @@ ExternalVR::SetCapabilityFlags(const device::CapabilityFlags aFlags) { if (device::MountDetection & aFlags) { result |= static_cast(mozilla::gfx::VRDisplayCapabilityFlags::Cap_MountDetection); } + if (device::PositionNeckModel & aFlags) { + result |= static_cast(mozilla::gfx::VRDisplayCapabilityFlags::Cap_PositionNeckModel); + } m.deviceCapabilities = aFlags; m.system.displayState.capabilityFlags = static_cast(result); m.system.sensorState.flags = m.system.displayState.capabilityFlags; @@ -292,6 +295,11 @@ ExternalVR::SetEyeResolution(const int32_t aWidth, const int32_t aHeight) { m.system.displayState.eyeResolution.height = aHeight; } +void +ExternalVR::SetSittingToStandingTransform(const vrb::Matrix& aTransform) { + memcpy(&(m.system.displayState.sittingToStandingTransform), aTransform.Data(), sizeof(m.system.displayState.sittingToStandingTransform)); +} + void ExternalVR::PushSystemState() { Lock lock(m.data.systemMutex); diff --git a/app/src/main/cpp/ExternalVR.h b/app/src/main/cpp/ExternalVR.h index 5011c3d97f..00dc7f0c2d 100644 --- a/app/src/main/cpp/ExternalVR.h +++ b/app/src/main/cpp/ExternalVR.h @@ -44,6 +44,7 @@ class ExternalVR : public ImmersiveDisplay { const double aBottomDegrees) override; void SetEyeOffset(const device::Eye aEye, const float aX, const float aY, const float aZ) override; void SetEyeResolution(const int32_t aX, const int32_t aY) override; + void SetSittingToStandingTransform(const vrb::Matrix& aTransform) override; void CompleteEnumeration() override; // ExternalVR interface void PushSystemState(); diff --git a/app/src/main/cpp/moz_external_vr.h b/app/src/main/cpp/moz_external_vr.h index ecd4bea64a..7d4f1f9671 100644 --- a/app/src/main/cpp/moz_external_vr.h +++ b/app/src/main/cpp/moz_external_vr.h @@ -34,7 +34,7 @@ enum class GamepadCapabilityFlags : uint16_t; #endif // MOZILLA_INTERNAL_API namespace gfx { -static const int32_t kVRExternalVersion = 6; +static const int32_t kVRExternalVersion = 7; // We assign VR presentations to groups with a bitmask. // Currently, we will only display either content or chrome. @@ -88,26 +88,26 @@ enum class ControllerCapabilityFlags : uint16_t { /** * Cap_Position is set if the Gamepad is capable of tracking its position. */ - Cap_Position = 1 << 1, + Cap_Position = 1 << 1, /** * Cap_Orientation is set if the Gamepad is capable of tracking its * orientation. */ - Cap_Orientation = 1 << 2, + Cap_Orientation = 1 << 2, /** * Cap_AngularAcceleration is set if the Gamepad is capable of tracking its * angular acceleration. */ - Cap_AngularAcceleration = 1 << 3, + Cap_AngularAcceleration = 1 << 3, /** * Cap_LinearAcceleration is set if the Gamepad is capable of tracking its * linear acceleration. */ - Cap_LinearAcceleration = 1 << 4, + Cap_LinearAcceleration = 1 << 4, /** * Cap_All used for validity checking during IPC serialization */ - Cap_All = (1 << 5) - 1 + Cap_All = (1 << 5) - 1 }; #endif // ifndef MOZILLA_INTERNAL_API @@ -117,12 +117,12 @@ enum class VRDisplayCapabilityFlags : uint16_t { /** * Cap_Position is set if the VRDisplay is capable of tracking its position. */ - Cap_Position = 1 << 1, + Cap_Position = 1 << 1, /** * Cap_Orientation is set if the VRDisplay is capable of tracking its * orientation. */ - Cap_Orientation = 1 << 2, + Cap_Orientation = 1 << 2, /** * Cap_Present is set if the VRDisplay is capable of presenting content to an * HMD or similar device. Can be used to indicate "magic window" devices that @@ -130,7 +130,7 @@ enum class VRDisplayCapabilityFlags : uint16_t { * meaningful. If false then calls to requestPresent should always fail, and * getEyeParameters should return null. */ - Cap_Present = 1 << 3, + Cap_Present = 1 << 3, /** * Cap_External is set if the VRDisplay is separate from the device's * primary display. If presenting VR content will obscure @@ -138,31 +138,36 @@ enum class VRDisplayCapabilityFlags : uint16_t { * un-set, the application should not attempt to mirror VR content * or update non-VR UI because that content will not be visible. */ - Cap_External = 1 << 4, + Cap_External = 1 << 4, /** * Cap_AngularAcceleration is set if the VRDisplay is capable of tracking its * angular acceleration. */ - Cap_AngularAcceleration = 1 << 5, + Cap_AngularAcceleration = 1 << 5, /** * Cap_LinearAcceleration is set if the VRDisplay is capable of tracking its * linear acceleration. */ - Cap_LinearAcceleration = 1 << 6, + Cap_LinearAcceleration = 1 << 6, /** * Cap_StageParameters is set if the VRDisplay is capable of room scale VR * and can report the StageParameters to describe the space. */ - Cap_StageParameters = 1 << 7, + Cap_StageParameters = 1 << 7, /** * Cap_MountDetection is set if the VRDisplay is capable of sensing when the * user is wearing the device. */ - Cap_MountDetection = 1 << 8, + Cap_MountDetection = 1 << 8, + /** + * Cap_PositionNeckModel is set if the VRDisplay is capable of setting a + * neck model in position even if still doesn't support 6DOF tracking. + */ + Cap_PositionNeckModel = 1 << 9, /** * Cap_All used for validity checking during IPC serialization */ - Cap_All = (1 << 9) - 1 + Cap_All = (1 << 9) - 1 }; #ifdef MOZILLA_INTERNAL_API diff --git a/app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp b/app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp index 5d95a363a2..fec88e94d5 100644 --- a/app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp +++ b/app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp @@ -1116,9 +1116,13 @@ DeviceDelegateOculusVR::StartFrame() { if (m.immersiveDisplay) { m.immersiveDisplay->SetEyeOffset(device::Eye::Left, -ipd * 0.5f, 0.f, 0.f); m.immersiveDisplay->SetEyeOffset(device::Eye::Right, ipd * 0.5f, 0.f, 0.f); - device::CapabilityFlags caps = device::Orientation | device::Present; + device::CapabilityFlags caps = device::Orientation | device::Present | device::StageParameters; if (m.predictedTracking.Status & VRAPI_TRACKING_STATUS_POSITION_TRACKED) { caps |= device::Position; + m.immersiveDisplay->SetSittingToStandingTransform(vrb::Matrix::Identity()); + } else { + caps |= device::Position; + m.immersiveDisplay->SetSittingToStandingTransform(vrb::Matrix::Translation(vrb::Vector(0.0f, 1.65f, 0.0f))); } m.immersiveDisplay->SetCapabilityFlags(caps); }