mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-19 11:09:21 +02:00
check in idle timer for headset dock
This commit is contained in:
parent
c0b61e4c38
commit
5aa49e4e8d
2 changed files with 18 additions and 3 deletions
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
#include <QtAndroidExtras/QAndroidJniEnvironment>
|
#include <QtAndroidExtras/QAndroidJniEnvironment>
|
||||||
#include <QtAndroidExtras/QAndroidJniObject>
|
#include <QtAndroidExtras/QAndroidJniObject>
|
||||||
|
#include <QtCore/QTimer>
|
||||||
#include <qpa/qplatformnativeinterface.h>
|
#include <qpa/qplatformnativeinterface.h>
|
||||||
#include <QtWidgets/QMenuBar>
|
#include <QtWidgets/QMenuBar>
|
||||||
|
|
||||||
|
@ -22,7 +23,8 @@
|
||||||
#include "GVRInterface.h"
|
#include "GVRInterface.h"
|
||||||
|
|
||||||
GVRInterface::GVRInterface(int argc, char* argv[]) :
|
GVRInterface::GVRInterface(int argc, char* argv[]) :
|
||||||
QApplication(argc, argv)
|
QApplication(argc, argv),
|
||||||
|
_inVRMode(false)
|
||||||
{
|
{
|
||||||
_client = new RenderingClient(this);
|
_client = new RenderingClient(this);
|
||||||
|
|
||||||
|
@ -34,13 +36,24 @@ GVRInterface::GVRInterface(int argc, char* argv[]) :
|
||||||
jobject activity = (jobject) interface->nativeResourceForIntegration("QtActivity");
|
jobject activity = (jobject) interface->nativeResourceForIntegration("QtActivity");
|
||||||
|
|
||||||
ovr_RegisterHmtReceivers(&*jniEnv, activity);
|
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) {
|
void GVRInterface::handleApplicationStateChange(Qt::ApplicationState state) {
|
||||||
switch(state) {
|
switch(state) {
|
||||||
case Qt::ApplicationActive:
|
case Qt::ApplicationActive:
|
||||||
qDebug() << "The application is active.";
|
qDebug() << "The application is active.";
|
||||||
resumeOVR();
|
|
||||||
break;
|
break;
|
||||||
case Qt::ApplicationSuspended:
|
case Qt::ApplicationSuspended:
|
||||||
qDebug() << "The application is being suspended.";
|
qDebug() << "The application is being suspended.";
|
||||||
|
|
|
@ -30,11 +30,13 @@ public:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void handleApplicationStateChange(Qt::ApplicationState state);
|
void handleApplicationStateChange(Qt::ApplicationState state);
|
||||||
|
void idle();
|
||||||
private:
|
private:
|
||||||
void resumeOVR();
|
void resumeOVR();
|
||||||
void pauseOVR();
|
void pauseOVR();
|
||||||
|
|
||||||
RenderingClient* _client;
|
RenderingClient* _client;
|
||||||
|
bool _inVRMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_GVRInterface_h
|
#endif // hifi_GVRInterface_h
|
||||||
|
|
Loading…
Reference in a new issue