From 250426f7922d43f9d4a6d2feadacf6996fe41572 Mon Sep 17 00:00:00 2001 From: jriegel Date: Sun, 14 Sep 2014 13:54:02 +0200 Subject: [PATCH] FreeCAD-VR: Handling the safety warning --- src/Gui/View3DInventorRiftViewer.cpp | 37 +++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/Gui/View3DInventorRiftViewer.cpp b/src/Gui/View3DInventorRiftViewer.cpp index 23d9277c2..a0289d2f8 100644 --- a/src/Gui/View3DInventorRiftViewer.cpp +++ b/src/Gui/View3DInventorRiftViewer.cpp @@ -102,6 +102,7 @@ public: ~CoinRiftWidget(); void setSceneGraph(SoNode *sceneGraph); protected: + void handlingSafetyWarning(void); void initializeGL(); void paintGL(); void resizeGL(int width, int height) { @@ -350,8 +351,12 @@ void CoinRiftWidget::initializeGL() void CoinRiftWidget::paintGL() { - const int ms(1000 / 60 /*fps*/); + const int ms(1000 / 75 /*fps*/); QTimer::singleShot(ms, this, SLOT(updateGL())); + + // handling the sfety warning + handlingSafetyWarning(); + makeCurrent(); ovrPosef eyePose[2]; @@ -422,6 +427,36 @@ void CoinRiftWidget::paintGL() doneCurrent(); } +void CoinRiftWidget::handlingSafetyWarning(void) +{ + // Health and Safety Warning display state. + ovrHSWDisplayState hswDisplayState; + ovrHmd_GetHSWDisplayState(hmd, &hswDisplayState); + if (hswDisplayState.Displayed) + { + // Dismiss the warning if the user pressed the appropriate key or if the user + // is tapping the side of the HMD. + // If the user has requested to dismiss the warning via keyboard or controller input... + //if (Util_GetAndResetHSWDismissedState()) + ovrHmd_DismissHSWDisplay(hmd); + //else + //{ + // // Detect a moderate tap on the side of the HMD. + // ovrTrackingState ts = ovrHmd_GetTrackingState(hmd, ovr_GetTimeInSeconds()); + // if (ts.StatusFlags & ovrStatus_OrientationTracked) + // { + // const OVR::Vector3f v(ts.RawSensorData.Accelerometer.x, + // ts.RawSensorData.Accelerometer.y, + // ts.RawSensorData.Accelerometer.z); + // // Arbitrary value and representing moderate tap on the side of the DK2 Rift. + // if (v.LengthSq() > 250.f) + // ovrHmd_DismissHSWDisplay(hmd); + // } + //} + } + +} + static CoinRiftWidget *window=0;