From 20b58b225fb8a4a44d00ef8b3575ea9595dfe91d Mon Sep 17 00:00:00 2001 From: "Randall E. Barker" Date: Wed, 18 Mar 2020 01:09:00 -0700 Subject: [PATCH] Set correct CapabilityFlags for Pico G2 (#2977) --- app/src/picovr/cpp/DeviceDelegatePicoVR.cpp | 22 +++++++++++-------- .../mozilla/vrbrowser/PlatformActivity.java | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/src/picovr/cpp/DeviceDelegatePicoVR.cpp b/app/src/picovr/cpp/DeviceDelegatePicoVR.cpp index d77df8013..05343569d 100644 --- a/app/src/picovr/cpp/DeviceDelegatePicoVR.cpp +++ b/app/src/picovr/cpp/DeviceDelegatePicoVR.cpp @@ -33,7 +33,7 @@ static const int32_t kMaxControllerCount = 2; static const int32_t kNumButtons = 6; static const int32_t kNumG2Buttons = 2; static const int32_t kNumAxes = 2; -static const int32_t kTypeNeo2 = 1; +static const int32_t k6DofHeadSet = 1; static const int32_t kButtonApp = 1; static const int32_t kButtonTrigger = 1 << 1; static const int32_t kButtonTouchPad = 1 << 2; @@ -179,7 +179,7 @@ struct DeviceDelegatePicoVR::State { touchPadPressed); controllerDelegate->SetButtonState(i, ControllerDelegate::BUTTON_TRIGGER, 1, triggerPressed, triggerPressed); - if (type == kTypeNeo2) { + if (type == k6DofHeadSet) { controllerDelegate->SetButtonState(i, ControllerDelegate::BUTTON_OTHERS, 2, gripPressed, gripPressed, gripPressed ? 20.0f : 0.0f); controllerDelegate->SetButtonState(i, @@ -197,7 +197,7 @@ struct DeviceDelegatePicoVR::State { controllerDelegate->SetAxes(i, axes, kNumAxes); - if (type == kTypeNeo2) { + if (type == k6DofHeadSet) { if (!triggerPressed) { controllerDelegate->SetScrolledDelta(i, -controller.axisX, controller.axisY); } @@ -211,7 +211,7 @@ struct DeviceDelegatePicoVR::State { vrb::Matrix transform = controller.transform; if (renderMode == device::RenderMode::StandAlone) { - if (type == kTypeNeo2) { + if (type == k6DofHeadSet) { transform.TranslateInPlace(headOffset); } else { vrb::Matrix head = vrb::Matrix::Rotation(orientation); @@ -264,7 +264,11 @@ DeviceDelegatePicoVR::RegisterImmersiveDisplay(ImmersiveDisplayPtr aDisplay) { } m.immersiveDisplay->SetDeviceName("Pico"); - m.immersiveDisplay->SetCapabilityFlags(device::Position | device::Orientation | device::Present | device::ImmersiveVRSession | device::InlineSession); + device::CapabilityFlags flags = device::Orientation | device::Present | device::ImmersiveVRSession | device::InlineSession; + if (m.type == k6DofHeadSet) { + flags |= device::Position; + } + m.immersiveDisplay->SetCapabilityFlags(flags); m.immersiveDisplay->SetEyeResolution(m.renderWidth / 2, m.renderHeight / 2); m.immersiveDisplay->CompleteEnumeration(); } @@ -288,7 +292,7 @@ DeviceDelegatePicoVR::GetReorientTransform() const { void DeviceDelegatePicoVR::SetReorientTransform(const vrb::Matrix& aMatrix) { - if (m.type == kTypeNeo2) { + if (m.type == k6DofHeadSet) { m.reorientMatrix = aMatrix; } } @@ -311,7 +315,7 @@ DeviceDelegatePicoVR::SetControllerDelegate(ControllerDelegatePtr& aController) for (State::Controller& controller: m.controllers) { const int32_t index = controller.index; - if (m.type == kTypeNeo2) { + if (m.type == k6DofHeadSet) { vrb::Matrix beam = vrb::Matrix::Rotation(vrb::Vector(1.0f, 0.0f, 0.0f), -vrb::PI_FLOAT / 11.5f); beam.TranslateInPlace(vrb::Vector(0.0f, 0.012f, -0.06f)); m.controllerDelegate->CreateController(index, int32_t(controller.hand), controller.IsRightHand() ? "Pico Neo 2 (Right)" : "Pico Neo 2 (LEFT)", beam); @@ -335,12 +339,12 @@ DeviceDelegatePicoVR::ReleaseControllerDelegate() { int32_t DeviceDelegatePicoVR::GetControllerModelCount() const { - return m.type == kTypeNeo2 ? 2 : 1; + return m.type == k6DofHeadSet ? 2 : 1; } const std::string DeviceDelegatePicoVR::GetControllerModelName(const int32_t aModelIndex) const { - if (m.type == kTypeNeo2) { + if (m.type == k6DofHeadSet) { if (aModelIndex == 0) { return "left_controller.obj"; } else if (aModelIndex == 1) { diff --git a/app/src/picovr/java/org/mozilla/vrbrowser/PlatformActivity.java b/app/src/picovr/java/org/mozilla/vrbrowser/PlatformActivity.java index 9d75a1da8..5eb510575 100644 --- a/app/src/picovr/java/org/mozilla/vrbrowser/PlatformActivity.java +++ b/app/src/picovr/java/org/mozilla/vrbrowser/PlatformActivity.java @@ -82,7 +82,7 @@ protected void onCreate(Bundle bundle) { if (ControllerClient.isControllerServiceExisted(this)) { mControllerManager = new CVControllerManager(this); mControllerManager.setListener(this); - mType = 1; // Neo2 + mType = 1; // 6Dof Headset // Enable high res PicovrSDK.SetEyeBufferSize(1920, 1920); } else {