Skip to content

Commit

Permalink
Stereo 3D|UI: Oculus Rift settings only appear when Rift connected
Browse files Browse the repository at this point in the history
Also added a quick-setup button for setting a good configuration for
the Rift.
  • Loading branch information
skyjake committed Dec 22, 2013
1 parent 4d972fe commit dc9d476
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
1 change: 1 addition & 0 deletions doomsday/client/include/ui/dialogs/vrsettingsdialog.h
Expand Up @@ -33,6 +33,7 @@ class VRSettingsDialog : public DialogWidget

public slots:
void resetToDefaults();
void autoConfigForOculusRift();

private:
DENG2_PRIVATE(d)
Expand Down
30 changes: 28 additions & 2 deletions doomsday/client/src/ui/dialogs/vrsettingsdialog.cpp
Expand Up @@ -36,10 +36,12 @@ DENG_GUI_PIMPL(VRSettingsDialog)
CVarSliderWidget *humanHeight;
CVarSliderWidget *ipd;
CVarSliderWidget *riftPredictionLatency;
ButtonWidget *riftSetup;

Instance(Public *i)
: Base(i)
, riftPredictionLatency(0)
, riftSetup(0)
{
ScrollAreaWidget &area = self.area();

Expand Down Expand Up @@ -68,6 +70,10 @@ DENG_GUI_PIMPL(VRSettingsDialog)
{
area.add(riftPredictionLatency = new CVarSliderWidget("rend-vr-rift-latency"));
riftPredictionLatency->setDisplayFactor(1000);

area.add(riftSetup = new ButtonWidget);
riftSetup->setText(tr("Auto-Configure"));
riftSetup->setAction(new SignalAction(thisPublic, SLOT(autoConfigForOculusRift())));
}
}

Expand All @@ -92,7 +98,6 @@ VRSettingsDialog::VRSettingsDialog(String const &name)
LabelWidget *heightLabel = LabelWidget::newWithText(tr("Height (m):"), &area());
LabelWidget *ipdLabel = LabelWidget::newWithText(tr("IPD (mm):"), &area());
LabelWidget *dominantLabel = LabelWidget::newWithText(tr("Dominant Eye:"), &area());
LabelWidget *latencyLabel = LabelWidget::newWithText(tr("Prediction Latency:"), &area());

// Layout.
GridLayout layout(area().contentRule().left(), area().contentRule().top());
Expand All @@ -107,7 +112,17 @@ VRSettingsDialog::VRSettingsDialog(String const &name)

if(VR::hasHeadOrientation())
{
layout << *latencyLabel << *d->riftPredictionLatency;
LabelWidget *ovrLabel = LabelWidget::newWithText(_E(1)_E(D) + tr("Oculus Rift"), &area());
LabelWidget *latencyLabel = LabelWidget::newWithText(tr("Prediction Latency:"), &area());
LabelWidget *utilLabel = LabelWidget::newWithText(tr("Utilities:"), &area());

ovrLabel->margins().setTop("gap");

layout.setCellAlignment(Vector2i(0, 5), ui::AlignLeft);

layout.append(*ovrLabel, 2);
layout << *latencyLabel << *d->riftPredictionLatency
<< *utilLabel << *d->riftSetup;
}

area().setContentSize(layout.width(), layout.height());
Expand All @@ -132,3 +147,14 @@ void VRSettingsDialog::resetToDefaults()
d->fetch();
}

void VRSettingsDialog::autoConfigForOculusRift()
{
Con_Execute(CMDS_DDAY, "setfullres 1280 800", false, false);
Con_Execute(CMDS_DDAY, "bindcontrol lookpitch head-pitch", false, false);
Con_Execute(CMDS_DDAY, "bindcontrol yawbody head-yaw", false, false);

Con_SetInteger("rend-vr-mode", VR::MODE_OCULUS_RIFT);
Con_SetInteger("vid-fsaa", 0);
//Con_SetInteger("input-sharp", 0);
}

0 comments on commit dc9d476

Please sign in to comment.