From 5aa49e4e8dc3fc53b4d5742ead1356a80da71c61 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 27 Jan 2015 11:47:06 -0800 Subject: [PATCH] check in idle timer for headset dock --- gvr-interface/src/GVRInterface.cpp | 17 +++++++++++++++-- gvr-interface/src/GVRInterface.h | 4 +++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/gvr-interface/src/GVRInterface.cpp b/gvr-interface/src/GVRInterface.cpp index 404f1d690b..3316d80047 100644 --- a/gvr-interface/src/GVRInterface.cpp +++ b/gvr-interface/src/GVRInterface.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -22,7 +23,8 @@ #include "GVRInterface.h" GVRInterface::GVRInterface(int argc, char* argv[]) : - QApplication(argc, argv) + QApplication(argc, argv), + _inVRMode(false) { _client = new RenderingClient(this); @@ -34,13 +36,24 @@ GVRInterface::GVRInterface(int argc, char* argv[]) : jobject activity = (jobject) interface->nativeResourceForIntegration("QtActivity"); ovr_RegisterHmtReceivers(&*jniEnv, activity); + + // call our idle function whenever we can + QTimer* idleTimer = new QTimer(this); + connect(idleTimer, &QTimer::timeout, this, &GVRInterface::idle); + idleTimer->start(0); +} + +void GVRInterface::idle() { + if (!_inVRMode && ovr_IsHeadsetDocked()) { + qDebug() << "The headset just got docked - we should try and go into VR mode"; + _inVRMode = true; + } } void GVRInterface::handleApplicationStateChange(Qt::ApplicationState state) { switch(state) { case Qt::ApplicationActive: qDebug() << "The application is active."; - resumeOVR(); break; case Qt::ApplicationSuspended: qDebug() << "The application is being suspended."; diff --git a/gvr-interface/src/GVRInterface.h b/gvr-interface/src/GVRInterface.h index fc488396a6..3f95ad90cd 100644 --- a/gvr-interface/src/GVRInterface.h +++ b/gvr-interface/src/GVRInterface.h @@ -29,12 +29,14 @@ public: RenderingClient* getClient() { return _client; } private slots: - void handleApplicationStateChange(Qt::ApplicationState state); + void handleApplicationStateChange(Qt::ApplicationState state); + void idle(); private: void resumeOVR(); void pauseOVR(); RenderingClient* _client; + bool _inVRMode; }; #endif // hifi_GVRInterface_h