Added installer support & installer script.
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
* GLOBAL:
|
||||||
|
FORMAT = "[%level] %datetime{%Y-%M-%d %H:%m:%s}: %msg"
|
||||||
|
ENABLED = true
|
||||||
|
TO_FILE = true
|
||||||
|
TO_STANDARD_OUTPUT = true
|
||||||
|
MAX_LOG_FILE_SIZE = 2097152 ## 2MB
|
||||||
|
* DEBUG:
|
||||||
|
ENABLED = true
|
||||||
|
* TRACE:
|
||||||
|
ENABLED = false
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
* GLOBAL:
|
||||||
|
FORMAT = "[%level] %datetime{%Y-%M-%d %H:%m:%s}: %msg"
|
||||||
|
FILENAME = "AdvancedSettings.log"
|
||||||
|
ENABLED = true
|
||||||
|
TO_FILE = true
|
||||||
|
TO_STANDARD_OUTPUT = true
|
||||||
|
MAX_LOG_FILE_SIZE = 2097152 ## 2MB
|
||||||
|
* DEBUG:
|
||||||
|
ENABLED = true
|
||||||
|
* TRACE:
|
||||||
|
ENABLED = false
|
||||||
+115
@@ -0,0 +1,115 @@
|
|||||||
|
;--------------------------------
|
||||||
|
;Include Modern UI
|
||||||
|
|
||||||
|
!include "MUI2.nsh"
|
||||||
|
|
||||||
|
;--------------------------------
|
||||||
|
;General
|
||||||
|
|
||||||
|
!define BASEDIR "bin\win64"
|
||||||
|
|
||||||
|
;Name and file
|
||||||
|
Name "OpenVR Advanced Settings"
|
||||||
|
OutFile "OpenVR-AdvancedSettings-Installer.exe"
|
||||||
|
|
||||||
|
;Default installation folder
|
||||||
|
InstallDir "$PROGRAMFILES64\OpenVR-AdvancedSettings"
|
||||||
|
|
||||||
|
;Get installation folder from registry if available
|
||||||
|
InstallDirRegKey HKLM "Software\OpenVR-AdvancedSettings" ""
|
||||||
|
|
||||||
|
;Request application privileges for Windows Vista
|
||||||
|
RequestExecutionLevel admin
|
||||||
|
|
||||||
|
;--------------------------------
|
||||||
|
;Interface Settings
|
||||||
|
|
||||||
|
!define MUI_ABORTWARNING
|
||||||
|
|
||||||
|
;--------------------------------
|
||||||
|
;Pages
|
||||||
|
|
||||||
|
!insertmacro MUI_PAGE_LICENSE "LICENSE"
|
||||||
|
!insertmacro MUI_PAGE_DIRECTORY
|
||||||
|
!insertmacro MUI_PAGE_INSTFILES
|
||||||
|
|
||||||
|
!insertmacro MUI_UNPAGE_CONFIRM
|
||||||
|
!insertmacro MUI_UNPAGE_INSTFILES
|
||||||
|
|
||||||
|
;--------------------------------
|
||||||
|
;Languages
|
||||||
|
|
||||||
|
!insertmacro MUI_LANGUAGE "English"
|
||||||
|
|
||||||
|
;--------------------------------
|
||||||
|
;Macros
|
||||||
|
|
||||||
|
!macro TerminateOverlay
|
||||||
|
DetailPrint "Terminating OpenVR Advanced Settings overlay..."
|
||||||
|
nsExec::ExecToLog '"taskkill" /F /IM AdvancedSettings.exe'
|
||||||
|
Sleep 2000 ; give 2 seconds for the application to finish exiting
|
||||||
|
!macroend
|
||||||
|
|
||||||
|
;--------------------------------
|
||||||
|
|
||||||
|
;Installer Sections
|
||||||
|
|
||||||
|
Section "Install" SecInstall
|
||||||
|
|
||||||
|
IfSilent install
|
||||||
|
!insertmacro TerminateOverlay
|
||||||
|
|
||||||
|
install:
|
||||||
|
|
||||||
|
SetOutPath "$INSTDIR"
|
||||||
|
|
||||||
|
RMDir /r "$INSTDIR\"
|
||||||
|
|
||||||
|
;ADD YOUR OWN FILES HERE...
|
||||||
|
File "LICENSE"
|
||||||
|
File "${BASEDIR}\*.exe"
|
||||||
|
File "${BASEDIR}\*.dll"
|
||||||
|
File "${BASEDIR}\*.bat"
|
||||||
|
File "${BASEDIR}\*.vrmanifest"
|
||||||
|
File "${BASEDIR}\*.conf"
|
||||||
|
File /r "${BASEDIR}\res"
|
||||||
|
File /r "${BASEDIR}\qtdata"
|
||||||
|
|
||||||
|
; Install redistributable
|
||||||
|
ExecWait '"$INSTDIR\vcredist_x64.exe" /install /quiet'
|
||||||
|
|
||||||
|
; Install the vrmanifest
|
||||||
|
nsExec::ExecToLog '"$INSTDIR\AdvancedSettings.exe" -installmanifest'
|
||||||
|
|
||||||
|
;Store installation folder
|
||||||
|
WriteRegStr HKCU "Software\OpenVR-AdvancedSettings" "" $INSTDIR
|
||||||
|
|
||||||
|
;Create uninstaller
|
||||||
|
WriteUninstaller "$INSTDIR\Uninstall.exe"
|
||||||
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenVRAdvancedSettings" "DisplayName" "OpenVR Advanced Settings"
|
||||||
|
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenVRAdvancedSettings" "UninstallString" "$\"$INSTDIR\Uninstall.exe$\""
|
||||||
|
|
||||||
|
; If SteamVR is already running, execute the dashboard as the user
|
||||||
|
FindWindow $0 "Qt5QWindowIcon" "SteamVR Status"
|
||||||
|
StrCmp $0 0 +2
|
||||||
|
Exec '"$INSTDIR\AdvancedSettings.exe"'
|
||||||
|
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
|
;--------------------------------
|
||||||
|
;Uninstaller Section
|
||||||
|
|
||||||
|
Section "Uninstall"
|
||||||
|
|
||||||
|
!insertmacro TerminateOverlay
|
||||||
|
|
||||||
|
; Remove the vrmanifest
|
||||||
|
nsExec::ExecToLog '"$INSTDIR\AdvancedSettings.exe" -removemanifest'
|
||||||
|
|
||||||
|
RMDir /r "$INSTDIR"
|
||||||
|
|
||||||
|
DeleteRegKey /ifempty HKCU "Software\OpenVR-AdvancedSettings"
|
||||||
|
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenVRAdvancedSettings"
|
||||||
|
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
+126
-37
@@ -5,6 +5,8 @@
|
|||||||
#include <QQmlEngine>
|
#include <QQmlEngine>
|
||||||
#include <QQmlComponent>
|
#include <QQmlComponent>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
#include <QStandardPaths>
|
||||||
|
#include <openvr.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
|
|
||||||
@@ -46,22 +48,54 @@ void myQtMessageHandler(QtMsgType type, const QMessageLogContext &context, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void installManifest(bool cleaninstall = false) {
|
||||||
|
auto manifestQPath = QDir::cleanPath(QDir(QCoreApplication::applicationDirPath()).absoluteFilePath("manifest.vrmanifest"));
|
||||||
|
if (QFile::exists(manifestQPath)) {
|
||||||
|
bool alreadyInstalled = false;
|
||||||
|
if (vr::VRApplications()->IsApplicationInstalled(advsettings::OverlayController::applicationKey)) {
|
||||||
|
if (cleaninstall) {
|
||||||
|
char buffer[1024];
|
||||||
|
auto appError = vr::VRApplicationError_None;
|
||||||
|
vr::VRApplications()->GetApplicationPropertyString(advsettings::OverlayController::applicationKey, vr::VRApplicationProperty_WorkingDirectory_String, buffer, 1024, &appError);
|
||||||
|
if (appError == vr::VRApplicationError_None) {
|
||||||
|
auto oldManifestQPath = QDir::cleanPath(QDir(buffer).absoluteFilePath("manifest.vrmanifest"));
|
||||||
|
if (oldManifestQPath.compare(manifestQPath, Qt::CaseInsensitive) != 0) {
|
||||||
|
vr::VRApplications()->RemoveApplicationManifest(QDir::toNativeSeparators(oldManifestQPath).toStdString().c_str());
|
||||||
|
} else {
|
||||||
|
alreadyInstalled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
alreadyInstalled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
auto apperror = vr::VRApplications()->AddApplicationManifest(QDir::toNativeSeparators(manifestQPath).toStdString().c_str());
|
||||||
|
if (apperror != vr::VRApplicationError_None) {
|
||||||
|
throw std::runtime_error(std::string("Could not add application manifest: ") + std::string(vr::VRApplications()->GetApplicationsErrorNameFromEnum(apperror)));
|
||||||
|
} else if (!alreadyInstalled || cleaninstall) {
|
||||||
|
auto apperror = vr::VRApplications()->SetApplicationAutoLaunch(advsettings::OverlayController::applicationKey, true);
|
||||||
|
if (apperror != vr::VRApplicationError_None) {
|
||||||
|
throw std::runtime_error(std::string("Could not set auto start: ") + std::string(vr::VRApplications()->GetApplicationsErrorNameFromEnum(apperror)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw std::runtime_error(std::string("Could not find application manifest: ") + manifestQPath.toStdString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void removeManifest() {
|
||||||
|
auto manifestQPath = QDir::cleanPath(QDir(QCoreApplication::applicationDirPath()).absoluteFilePath("manifest.vrmanifest"));
|
||||||
|
if (QFile::exists(manifestQPath)) {
|
||||||
|
if (vr::VRApplications()->IsApplicationInstalled(advsettings::OverlayController::applicationKey)) {
|
||||||
|
vr::VRApplications()->RemoveApplicationManifest(QDir::toNativeSeparators(manifestQPath).toStdString().c_str());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw std::runtime_error(std::string("Could not find application manifest: ") + manifestQPath.toStdString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
// Configure logger
|
|
||||||
START_EASYLOGGINGPP(argc, argv);
|
|
||||||
el::Loggers::addFlag(el::LoggingFlag::DisableApplicationAbortOnFatalLog);
|
|
||||||
auto logconfigfile = QFileInfo(logConfigFileName).absoluteFilePath();
|
|
||||||
if (QFile::exists(logconfigfile)) {
|
|
||||||
el::Configurations conf(logconfigfile.toStdString());
|
|
||||||
el::Loggers::reconfigureAllLoggers(conf);
|
|
||||||
LOG(INFO) << "Log Config: " << QDir::toNativeSeparators(logconfigfile).toStdString();
|
|
||||||
} else {
|
|
||||||
el::Configurations conf;
|
|
||||||
conf.parseFromText(logConfigDefault);
|
|
||||||
el::Loggers::reconfigureAllLoggers(conf);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool desktopMode = false;
|
bool desktopMode = false;
|
||||||
bool noSound = false;
|
bool noSound = false;
|
||||||
@@ -70,23 +104,92 @@ int main(int argc, char *argv[]) {
|
|||||||
// Parse command line arguments
|
// Parse command line arguments
|
||||||
for (int i = 1; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
if (std::string(argv[i]).compare("-desktop") == 0) {
|
if (std::string(argv[i]).compare("-desktop") == 0) {
|
||||||
LOG(INFO) << "Desktop mode enabled.";
|
|
||||||
desktopMode = true;
|
desktopMode = true;
|
||||||
} else if (std::string(argv[i]).compare("-nosound") == 0) {
|
} else if (std::string(argv[i]).compare("-nosound") == 0) {
|
||||||
LOG(INFO) << "Sound effects disabled.";
|
|
||||||
noSound = true;
|
noSound = true;
|
||||||
} else if (std::string(argv[i]).compare("-nomanifest") == 0) {
|
} else if (std::string(argv[i]).compare("-nomanifest") == 0) {
|
||||||
LOG(INFO) << "vrmanifest disabled.";
|
|
||||||
noManifest = true;
|
noManifest = true;
|
||||||
|
} else if (std::string(argv[i]).compare("-installmanifest") == 0) {
|
||||||
|
int exitcode = 0;
|
||||||
|
QCoreApplication coreApp(argc, argv);
|
||||||
|
auto initError = vr::VRInitError_None;
|
||||||
|
vr::VR_Init(&initError, vr::VRApplication_Utility);
|
||||||
|
if (initError == vr::VRInitError_None) {
|
||||||
|
try {
|
||||||
|
installManifest(true);
|
||||||
|
} catch (std::exception& e) {
|
||||||
|
exitcode = -1;
|
||||||
|
std::cerr << e.what() << std::endl;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
exitcode = -2;
|
||||||
|
std::cerr << std::string("Failed to initialize OpenVR: " + std::string(vr::VR_GetVRInitErrorAsEnglishDescription(initError))) << std::endl;
|
||||||
|
}
|
||||||
|
vr::VR_Shutdown();
|
||||||
|
exit(exitcode);
|
||||||
|
} else if (std::string(argv[i]).compare("-removemanifest") == 0) {
|
||||||
|
int exitcode = 0;
|
||||||
|
QCoreApplication coreApp(argc, argv);
|
||||||
|
auto initError = vr::VRInitError_None;
|
||||||
|
vr::VR_Init(&initError, vr::VRApplication_Utility);
|
||||||
|
if (initError == vr::VRInitError_None) {
|
||||||
|
try {
|
||||||
|
removeManifest();
|
||||||
|
} catch (std::exception& e) {
|
||||||
|
exitcode = -1;
|
||||||
|
std::cerr << e.what() << std::endl;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
exitcode = -2;
|
||||||
|
std::cerr << std::string("Failed to initialize OpenVR: " + std::string(vr::VR_GetVRInitErrorAsEnglishDescription(initError))) << std::endl;
|
||||||
|
}
|
||||||
|
vr::VR_Shutdown();
|
||||||
|
exit(exitcode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(INFO) << "Starting Application.";
|
|
||||||
try {
|
try {
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
a.setOrganizationName("matzman666");
|
||||||
|
a.setApplicationName("OpenVRAdvancedSettings");
|
||||||
|
a.setApplicationDisplayName(advsettings::OverlayController::applicationName);
|
||||||
|
a.setApplicationVersion(advsettings::OverlayController::applicationVersionString);
|
||||||
|
|
||||||
qInstallMessageHandler(myQtMessageHandler);
|
qInstallMessageHandler(myQtMessageHandler);
|
||||||
|
|
||||||
QSettings appSettings(QSettings::IniFormat, QSettings::UserScope, "matzman666", "OpenVRAdvancedSettings");
|
// Configure logger
|
||||||
|
QString logFilePath;
|
||||||
|
START_EASYLOGGINGPP(argc, argv);
|
||||||
|
el::Loggers::addFlag(el::LoggingFlag::DisableApplicationAbortOnFatalLog);
|
||||||
|
auto logconfigfile = QFileInfo(logConfigFileName).absoluteFilePath();
|
||||||
|
el::Configurations conf;
|
||||||
|
if (QFile::exists(logconfigfile)) {
|
||||||
|
conf.parseFromFile(logconfigfile.toStdString());
|
||||||
|
} else {
|
||||||
|
conf.parseFromText(logConfigDefault);
|
||||||
|
}
|
||||||
|
if (!conf.get(el::Level::Global, el::ConfigurationType::Filename)) {
|
||||||
|
logFilePath = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).absoluteFilePath("AdvancedSettings.log");
|
||||||
|
conf.set(el::Level::Global, el::ConfigurationType::Filename, QDir::toNativeSeparators(logFilePath).toStdString());
|
||||||
|
}
|
||||||
|
conf.setRemainingToDefault();
|
||||||
|
el::Loggers::reconfigureAllLoggers(conf);
|
||||||
|
LOG(INFO) << "Log Config: " << QDir::toNativeSeparators(logconfigfile).toStdString();
|
||||||
|
if (!logFilePath.isEmpty()) {
|
||||||
|
LOG(INFO) << "Log File: " << logFilePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (desktopMode) {
|
||||||
|
LOG(INFO) << "Desktop mode enabled.";
|
||||||
|
}
|
||||||
|
if (noSound) {
|
||||||
|
LOG(INFO) << "Sound effects disabled.";
|
||||||
|
}
|
||||||
|
if (noManifest) {
|
||||||
|
LOG(INFO) << "vrmanifest disabled.";
|
||||||
|
}
|
||||||
|
|
||||||
|
QSettings appSettings(QSettings::IniFormat, QSettings::UserScope, a.organizationName(), a.applicationName());
|
||||||
advsettings::OverlayController::setAppSettings(&appSettings);
|
advsettings::OverlayController::setAppSettings(&appSettings);
|
||||||
LOG(INFO) << "Settings File: " << appSettings.fileName().toStdString();
|
LOG(INFO) << "Settings File: " << appSettings.fileName().toStdString();
|
||||||
|
|
||||||
@@ -104,24 +207,10 @@ int main(int argc, char *argv[]) {
|
|||||||
controller->SetWidget(qobject_cast<QQuickItem*>(quickObj), advsettings::OverlayController::applicationName, advsettings::OverlayController::applicationKey);
|
controller->SetWidget(qobject_cast<QQuickItem*>(quickObj), advsettings::OverlayController::applicationName, advsettings::OverlayController::applicationKey);
|
||||||
|
|
||||||
if (!desktopMode && !noManifest) {
|
if (!desktopMode && !noManifest) {
|
||||||
auto manifestQPath = QDir(QApplication::applicationDirPath()).absoluteFilePath("manifest.vrmanifest");
|
try {
|
||||||
//std::string manifestPath = QDir::toNativeSeparators(QApplication::applicationDirPath()).toStdString() + "\\manifest.vrmanifest";
|
installManifest();
|
||||||
if (QFile::exists(manifestQPath)) {
|
} catch (std::exception& e) {
|
||||||
bool firstTime = false;
|
LOG(ERROR) << e.what();
|
||||||
if (!vr::VRApplications()->IsApplicationInstalled(advsettings::OverlayController::applicationKey)) {
|
|
||||||
firstTime;
|
|
||||||
}
|
|
||||||
auto apperror = vr::VRApplications()->AddApplicationManifest(QDir::toNativeSeparators(manifestQPath).toStdString().c_str());
|
|
||||||
if (apperror != vr::VRApplicationError_None) {
|
|
||||||
LOG(ERROR) << "Could not add application manifest: " << vr::VRApplications()->GetApplicationsErrorNameFromEnum(apperror);
|
|
||||||
} else if (firstTime) {
|
|
||||||
auto apperror = vr::VRApplications()->SetApplicationAutoLaunch(advsettings::OverlayController::applicationKey, true);
|
|
||||||
if (apperror != vr::VRApplicationError_None) {
|
|
||||||
LOG(ERROR) << "Could not set auto start: " << vr::VRApplications()->GetApplicationsErrorNameFromEnum(apperror);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
LOG(ERROR) << "Could not find application manifest: " << manifestQPath;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user