Skip to content

Commit

Permalink
Set correct CapabilityFlags for Pico G2 (#2977)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluemarvin committed Mar 18, 2020
1 parent 93eff89 commit 20b58b2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
22 changes: 13 additions & 9 deletions app/src/picovr/cpp/DeviceDelegatePicoVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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);
}
Expand All @@ -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);
Expand Down Expand Up @@ -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();
}
Expand All @@ -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;
}
}
Expand All @@ -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);
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 20b58b2

Please sign in to comment.