int main(int argc, char *argv[]) { QGuiApplication a(argc, argv); COpenVROverlayController::SharedInstance()->Init(); // Get the base path DWORD size = MAX_PATH; WCHAR path[MAX_PATH]; HKEY oculusKey; RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\Oculus VR, LLC\\Oculus", 0, KEY_READ | KEY_WOW64_32KEY, &oculusKey); RegQueryValueEx(oculusKey, L"Base", NULL, NULL, (PBYTE)path, &size); // Create a QML engine. QQmlEngine qmlEngine; qmlEngine.rootContext()->setContextProperty("ReviveManifest", CReviveManifestController::SharedInstance()); // Set the properties. QString str = QString::fromWCharArray(path); QUrl url = QUrl::fromLocalFile(str); QString base = QDir::fromNativeSeparators(str); qmlEngine.rootContext()->setContextProperty("baseURL", url.url()); qmlEngine.rootContext()->setContextProperty("basePath", base); QQmlComponent qmlComponent( &qmlEngine, QUrl("qrc:/Overlay.qml")); if (qmlComponent.isError()) { qDebug(qUtf8Printable(qmlComponent.errorString())); return -1; } QObject *rootObject = qmlComponent.create(); QQuickItem *rootItem = qobject_cast<QQuickItem*>( rootObject ); COpenVROverlayController::SharedInstance()->SetQuickItem( rootItem ); // don't show the window that you're going display in an overlay //view.show(); return a.exec(); }
int main(int argc, char *argv[]) { QApplication a(argc, argv); // Open the log file and install our handler. QString logPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/Revive/"; if (QDir().mkpath(logPath)) { g_LogFile = new QFile(logPath + "ReviveOverlay.txt"); g_LogFile->open(QIODevice::WriteOnly | QIODevice::Truncate); } qInstallMessageHandler(myMessageOutput); // Handle command-line arguments if (a.arguments().contains("-manifest")) { // Only initialize the manifest vr::EVRInitError err = vr::VRInitError_None; vr::VR_Init( &err, vr::VRApplication_Utility ); if ( err != vr::VRInitError_None ) return -1; QString filePath = QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + "/app.vrmanifest"); vr::VRApplications()->AddApplicationManifest(qPrintable(filePath)); vr::VRApplications()->SetApplicationAutoLaunch(CReviveManifestController::AppKey, true); vr::VR_Shutdown(); return 0; } // Check if we need to copy over input files QString inputPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/Revive/Input/"; if (!QDir().exists(inputPath) && QDir().mkpath(inputPath)) { QDir inputDir(QCoreApplication::applicationDirPath() + "/Input"); if (inputDir.exists()) { QStringList names = inputDir.entryList(QStringList("*.json")); QStringList files; for (QString file : names) files.append(inputDir.path() + "/" + file); WindowsServices::CopyFiles(files, inputPath, names); } } if (COpenVROverlayController::SharedInstance()->Init()) { // If the dashboard was successfully created keep running in the background a.setQuitOnLastWindowClosed(false); } if (!CTrayIconController::SharedInstance()->Init()) qDebug("Failed to initialize the tray icon"); if (!CReviveManifestController::SharedInstance()->Init()) qDebug("Failed to initialize the revive manifest"); // Create a QML engine. QQmlEngine qmlEngine; qmlEngine.rootContext()->setContextProperty("Revive", CReviveManifestController::SharedInstance()); qmlEngine.rootContext()->setContextProperty("OpenVR", COpenVROverlayController::SharedInstance()); QQmlComponent qmlComponent( &qmlEngine, QUrl("qrc:/Overlay.qml")); if (qmlComponent.isError()) { qDebug(qUtf8Printable(qmlComponent.errorString())); return -1; } QObject *rootObject = qmlComponent.create(); QQuickItem *rootItem = qobject_cast<QQuickItem*>( rootObject ); COpenVROverlayController::SharedInstance()->SetQuickItem( rootItem ); win_sparkle_set_appcast_url("https://raw.githubusercontent.com/LibreVR/Revive/master/appcast.xml"); win_sparkle_set_can_shutdown_callback([]() { return (BOOL)!QApplication::startingUp(); }); win_sparkle_set_shutdown_request_callback([]() { CTrayIconController::SharedInstance()->quit(); }); win_sparkle_init(); QObject::connect(&a, &QApplication::aboutToQuit, win_sparkle_cleanup); return a.exec(); }
int main(int argc, char *argv[]) { // Open the log file and install out handler. QString logPath = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); if (QDir().mkpath(logPath + "/Revive")) { g_LogFile = new QFile(logPath + "/Revive/ReviveOverlay.log"); g_LogFile->open(QIODevice::WriteOnly | QIODevice::Truncate); } qInstallMessageHandler(myMessageOutput); QGuiApplication a(argc, argv); if (a.arguments().contains("-manifest")) { // Only initialize the manifest vr::EVRInitError err = vr::VRInitError_None; vr::IVRSystem *pVRSystem = vr::VR_Init( &err, vr::VRApplication_Utility ); if ( err != vr::VRInitError_None ) return -1; if (!CReviveManifestController::SharedInstance()->Init()) return -1; vr::VR_Shutdown(); return 0; } COpenVROverlayController::SharedInstance()->Init(); CReviveManifestController::SharedInstance()->Init(); // Get the base path DWORD size = MAX_PATH; WCHAR path[MAX_PATH]; HKEY oculusKey; LONG error; error = RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\Oculus VR, LLC\\Oculus", 0, KEY_READ | KEY_WOW64_32KEY, &oculusKey); if (error != ERROR_SUCCESS) { qDebug("Unable to open Oculus key."); return -1; } error = RegQueryValueEx(oculusKey, L"Base", NULL, NULL, (PBYTE)path, &size); if (error != ERROR_SUCCESS) { qDebug("Unable to read Base path."); return -1; } RegCloseKey(oculusKey); // Create a QML engine. QQmlEngine qmlEngine; qmlEngine.rootContext()->setContextProperty("ReviveManifest", CReviveManifestController::SharedInstance()); // Set the properties. QString str = QString::fromWCharArray(path); QUrl runtime = QUrl::fromLocalFile(vr::VR_RuntimePath()); QUrl url = QUrl::fromLocalFile(str); QString base = QDir::fromNativeSeparators(str); qmlEngine.rootContext()->setContextProperty("openvrURL", runtime.url()); qmlEngine.rootContext()->setContextProperty("baseURL", url.url()); qmlEngine.rootContext()->setContextProperty("basePath", base); qDebug("Runtime directory: %s", qUtf8Printable(runtime.url())); qDebug("Oculus directory: %s", qUtf8Printable(url.url())); QQmlComponent qmlComponent( &qmlEngine, QUrl("qrc:/Overlay.qml")); if (qmlComponent.isError()) { qDebug(qUtf8Printable(qmlComponent.errorString())); return -1; } QObject *rootObject = qmlComponent.create(); QQuickItem *rootItem = qobject_cast<QQuickItem*>( rootObject ); COpenVROverlayController::SharedInstance()->SetQuickItem( rootItem ); return a.exec(); }