History

check in idle timer for headset dock

Stephen Birarda committed 11 years ago

Commit 5aa49e41 parent c0b61e42 files · +18 −3Browse files

Showing the changes to gvr-interface/src/GVRInterface.cpp (1 of 2 files). Show all

Unified · Split

gvr-interface/src/GVRInterface.cpp+15−2
@@ -11,6 +11,7 @@ · 10 unmodified lines
1111
1212 #include <QtAndroidExtras/QAndroidJniEnvironment>
1313 #include <QtAndroidExtras/QAndroidJniObject>
14+#include <QtCore/QTimer>
1415 #include <qpa/qplatformnativeinterface.h>
1516 #include <QtWidgets/QMenuBar>
1617
@@ -22,7 +23,8 @@ · 5 unmodified lines
2223 #include "GVRInterface.h"
2324
2425 GVRInterface::GVRInterface(int argc, char* argv[]) :
25− QApplication(argc, argv)
26+ QApplication(argc, argv),
27+ _inVRMode(false)
2628 {
2729 _client = new RenderingClient(this);
2830
@@ -34,13 +36,24 @@ GVRInterface::GVRInterface(int argc, char* argv[]) : · 5 unmodified lines
3436 jobject activity = (jobject) interface->nativeResourceForIntegration("QtActivity");
3537
3638 ovr_RegisterHmtReceivers(&*jniEnv, activity);
39+
40+ // call our idle function whenever we can
41+ QTimer* idleTimer = new QTimer(this);
42+ connect(idleTimer, &QTimer::timeout, this, &GVRInterface::idle);
43+ idleTimer->start(0);
44+}
45+
46+void GVRInterface::idle() {
47+ if (!_inVRMode && ovr_IsHeadsetDocked()) {
48+ qDebug() << "The headset just got docked - we should try and go into VR mode";
49+ _inVRMode = true;
50+ }
3751 }
3852
3953 void GVRInterface::handleApplicationStateChange(Qt::ApplicationState state) {
4054 switch(state) {
4155 case Qt::ApplicationActive:
4256 qDebug() << "The application is active.";
43− resumeOVR();
4457 break;
4558 case Qt::ApplicationSuspended:
4659 qDebug() << "The application is being suspended.";