Showing the changes to gvr-interface/src/GVRInterface.cpp (1 of 2 files). Show all
Unified · Split
| @@ -11,6 +11,7 @@ · 10 unmodified lines | ||
| 11 | 11 | |
| 12 | 12 | #include <QtAndroidExtras/QAndroidJniEnvironment> |
| 13 | 13 | #include <QtAndroidExtras/QAndroidJniObject> |
| 14 | +#include <QtCore/QTimer> | |
| 14 | 15 | #include <qpa/qplatformnativeinterface.h> |
| 15 | 16 | #include <QtWidgets/QMenuBar> |
| 16 | 17 | |
| @@ -22,7 +23,8 @@ · 5 unmodified lines | ||
| 22 | 23 | #include "GVRInterface.h" |
| 23 | 24 | |
| 24 | 25 | GVRInterface::GVRInterface(int argc, char* argv[]) : |
| 25 | − QApplication(argc, argv) | |
| 26 | + QApplication(argc, argv), | |
| 27 | + _inVRMode(false) | |
| 26 | 28 | { |
| 27 | 29 | _client = new RenderingClient(this); |
| 28 | 30 | |
| @@ -34,13 +36,24 @@ GVRInterface::GVRInterface(int argc, char* argv[]) : · 5 unmodified lines | ||
| 34 | 36 | jobject activity = (jobject) interface->nativeResourceForIntegration("QtActivity"); |
| 35 | 37 | |
| 36 | 38 | 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 | + } | |
| 37 | 51 | } |
| 38 | 52 | |
| 39 | 53 | void GVRInterface::handleApplicationStateChange(Qt::ApplicationState state) { |
| 40 | 54 | switch(state) { |
| 41 | 55 | case Qt::ApplicationActive: |
| 42 | 56 | qDebug() << "The application is active."; |
| 43 | − resumeOVR(); | |
| 44 | 57 | break; |
| 45 | 58 | case Qt::ApplicationSuspended: |
| 46 | 59 | qDebug() << "The application is being suspended."; |