mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 14:47:19 +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/QAndroidJniObject>
|
||||
#include <QtCore/QTimer>
|
||||
#include <qpa/qplatformnativeinterface.h>
|
||||
#include <QtWidgets/QMenuBar>
|
||||
|
||||
|
@ -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.";
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue