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