* Move logging set up into own function
This does not affect the ability to log, the logging macros are
available globally.
* Clean up logging logic and add comments
The logic to find the logging location was broken, in that it always
placed the logs in the directory of the executable.
It was supposed to place the logs in
AppData/Roaming/matzman666/OpenVRAdvancedSettings/AdvancedSettings.log,
but it hasn't done this since at least git tag "v2.7". Since the change
hasn't been documented anywhere it is assumed to be an unintentional
regression.
The settings file is also currently placed in
AppData/Roaming/matzman666/OpenVRAdvancedSettings.ini, so this commit
undoes the probable regression until a strategy can be developed for
changing all paths at once.
* Move command line arg logging calls and add to manifest calls
The LOG_IF macros are cleaner than if blocks, and they do not need to be
in the middle of the Qt logic inside a giant try block.
* Remove unused QCoreApplication constructor in manifest logic
The object is not used in any of the manifest logic functions and
running without the remove/install manifest calls does not use it
either.
* Unindent logic in installManifest
The error checking was unnecessarily done in an else block. Moving it
into an if block and negating the result does the same but leaves the
rest of the logic at a much smaller indentation level.
* Change array in installManifest to be 0 intialized
Not zero initializing could lead to strange bugs if the terminating null
isn't there.
* Move manifest install/removal to separate function
The manifest handling is tangential to the actual main operation of the
program, hence moving it to a separate function improves readability of
the actual program.
The enum ReturnErrorCode has also been moved to the top in order to be
available to all functions. On introspection it is revealed that it
should always have been placed at the top.
* Unindent logic in removeManifest
The logic is unnecessarily indented, leading to harder to follow logic.
While the current logic isn't that hard to understand, it's better if it
follows the same rhythm as installManifest, which errors checks the same
way with a !QFile::exists( manifestQPath ).
* Move manifestPath out of install/removeManifest
Moving the variable outside of the functions reduces code duplication
and increases the versatility of the functions.
Variable was renamed from manifestQPath to manifestPath, because the Q
does not add anything to the name except (maybe wrongfully in the
future) typing a variable that has been typed with 'auto'.
The default variable has been removed, as it did not improve readability
at all.
* Rename installManifest to handleManifestInstallLogic
The new name better reflects the overall purpose. installManifest should
be a function that only installs the manifest.
* Move manifest related things into manifest namespace
* Move manifestInstallation logic into functions
The logic becomes clearer when replaced by function names instead of
just blocks of error checking.
* Refactor installManifest into separate functions
The uses for the removeManifest and installManifest functions could be
boiled down to three separate use cases:
* If the application was passed the "-installmanifest" arg:
Reinstall the manifest and enable application autostart.
* If the application was passed thed "-removemanifest" arg:
Remove the manifest.
* If the application was not passed "-desktop" and also not passed
"-nomanifest" (basically every start):
Install the manifest.
Where reinstalling means to remove the manifest if installed and then
install it.
The relatively complex logic in installManifest hid this logic behind
several if statements and changing what the "alreadyInstalled" bool
signified.
The refactored functions should make everything easier to understand.
* Add variable for manifest name
* Rename variables in main to camelCase
This appears to be the style chosen for the majority of the project.
* Change cerr to be LOG(ERROR) and add logging for manifest completion
The cerr calls are not likely to be seen by anybody. Logging them as
ERROR will make sure they are available for diagnostics.
* Add comments for new manifest functions
* Reorder namespaces and functions in main
Namespaces and functions are now ordered as they appear in main.
* Add static_cast to height and width in func call in main
width and height are "qreal" (typedef for double). Having them
implicitly cast to int leads to warnings on some compilers, and can lead
to doubt whether they're supposed to be converted.
* Move organizationName and applicationName into overlaycontroller.h
The string have been moved to static constexpr autos inside the
overlaycontroller.
Them remaining static means that they are included in the final binary,
even if they don't need to be included as static.
They should probably also not be directly gotten, instead being offered
up as static getters, but it's better to do them all at the same time in
a specific commit for that.
* Add comment to installApplicationManifest
Describing that OpenVR must be initialized before the function is
called.
* Change QApplication var name and add comments
The previous QApplication was named "a". This is obviously not
sufficient for such a large part of the application, even if the class
is rather boilerplate heavy.
* Add comments to Qt portions of main
Some things have been left uncommented. That's because I don't know what
it does.
* Change documentation for command line arguments, logging config
The information under the Desktop Mode header could be rolled under the
"-desktop" command line arg.
Support for the command line args of Easylogging++ and custom logging
files have not been supported for the original developer. Both should
probably be dropped in favor of having the same logging behavior for all
users.
* Remove error causing property from QML MyStackViewPage and PlayspacePage
The properties were causing an error message to be spammed in the log
QML QQuickText: Detected anchors on an item that is managed by a layout.
This is undefined behavior; use Layout.alignment instead.
and
QML RowLayout: Detected anchors on an item that is managed by a layout.
This is undefined behavior; use Layout.alignment instead.
Removing them fixed the spam and didn't noticeably change the appearance
of the pages.
204 lines
6.3 KiB
C++
204 lines
6.3 KiB
C++
|
|
#pragma once
|
|
|
|
#include <openvr.h>
|
|
#include <QtCore/QtCore>
|
|
// because of incompatibilities with QtOpenGL and GLEW we need to cherry pick
|
|
// includes
|
|
#include <QVector2D>
|
|
#include <QMatrix4x4>
|
|
#include <QVector>
|
|
#include <QVector2D>
|
|
#include <QVector3D>
|
|
#include <QObject>
|
|
#include <QSettings>
|
|
#include <QQmlEngine>
|
|
#include <QtGui/QOpenGLContext>
|
|
#include <QtWidgets/QGraphicsScene>
|
|
#include <QOffscreenSurface>
|
|
#include <QOpenGLFramebufferObject>
|
|
#include <QQuickWindow>
|
|
#include <QQuickItem>
|
|
#include <QQuickRenderControl>
|
|
#include <QSoundEffect>
|
|
#include <memory>
|
|
#include <easylogging++.h>
|
|
#include "utils/ChaperoneUtils.h"
|
|
|
|
#include "tabcontrollers/SteamVRTabController.h"
|
|
#include "tabcontrollers/ChaperoneTabController.h"
|
|
#include "tabcontrollers/MoveCenterTabController.h"
|
|
#include "tabcontrollers/FixFloorTabController.h"
|
|
#include "tabcontrollers/AudioTabController.h"
|
|
#include "tabcontrollers/StatisticsTabController.h"
|
|
#include "tabcontrollers/SettingsTabController.h"
|
|
#include "tabcontrollers/ReviveTabController.h"
|
|
#include "tabcontrollers/UtilitiesTabController.h"
|
|
#include "tabcontrollers/AccessibilityTabController.h"
|
|
|
|
// application namespace
|
|
namespace advsettings
|
|
{
|
|
class OverlayController : public QObject
|
|
{
|
|
Q_OBJECT
|
|
Q_PROPERTY( bool desktopMode READ isDesktopMode )
|
|
|
|
public:
|
|
static constexpr auto applicationOrganizationName = "matzman666";
|
|
static constexpr auto applicationName = "OpenVRAdvancedSettings";
|
|
static constexpr const char* applicationKey = "matzman666.AdvancedSettings";
|
|
static constexpr const char* applicationDisplayName = "Advanced Settings";
|
|
static constexpr const char* applicationVersionString = "v2.8.0";
|
|
|
|
private:
|
|
vr::VROverlayHandle_t m_ulOverlayHandle = vr::k_ulOverlayHandleInvalid;
|
|
vr::VROverlayHandle_t m_ulOverlayThumbnailHandle
|
|
= vr::k_ulOverlayHandleInvalid;
|
|
|
|
std::unique_ptr<QQuickRenderControl> m_pRenderControl;
|
|
std::unique_ptr<QQuickWindow> m_pWindow;
|
|
std::unique_ptr<QOpenGLFramebufferObject> m_pFbo;
|
|
std::unique_ptr<QOpenGLContext> m_pOpenGLContext;
|
|
std::unique_ptr<QOffscreenSurface> m_pOffscreenSurface;
|
|
|
|
std::unique_ptr<QTimer> m_pPumpEventsTimer;
|
|
std::unique_ptr<QTimer> m_pRenderTimer;
|
|
bool dashboardVisible = false;
|
|
|
|
QPoint m_ptLastMouse;
|
|
Qt::MouseButtons m_lastMouseButtons = 0;
|
|
|
|
bool desktopMode;
|
|
bool noSound;
|
|
|
|
QUrl m_runtimePathUrl;
|
|
|
|
utils::ChaperoneUtils m_chaperoneUtils;
|
|
|
|
QSoundEffect activationSoundEffect;
|
|
QSoundEffect focusChangedSoundEffect;
|
|
QSoundEffect alarm01SoundEffect;
|
|
|
|
public: // I know it's an ugly hack to make them public to enable external
|
|
// access, but I am too lazy to implement getters.
|
|
SteamVRTabController steamVRTabController;
|
|
ChaperoneTabController chaperoneTabController;
|
|
MoveCenterTabController moveCenterTabController;
|
|
FixFloorTabController fixFloorTabController;
|
|
AudioTabController audioTabController;
|
|
StatisticsTabController statisticsTabController;
|
|
SettingsTabController settingsTabController;
|
|
ReviveTabController reviveTabController;
|
|
UtilitiesTabController utilitiesTabController;
|
|
AccessibilityTabController accessibilityTabController;
|
|
|
|
private:
|
|
OverlayController( bool desktopMode, bool noSound )
|
|
: QObject(), desktopMode( desktopMode ), noSound( noSound )
|
|
{
|
|
}
|
|
QPoint getMousePositionForEvent( vr::VREvent_Mouse_t mouse );
|
|
|
|
public:
|
|
virtual ~OverlayController();
|
|
|
|
void Init( QQmlEngine* qmlEngine );
|
|
void Shutdown();
|
|
|
|
bool isDashboardVisible()
|
|
{
|
|
return dashboardVisible;
|
|
}
|
|
|
|
void SetWidget( QQuickItem* quickItem,
|
|
const std::string& name,
|
|
const std::string& key = "" );
|
|
|
|
void AddOffsetToUniverseCenter( vr::ETrackingUniverseOrigin universe,
|
|
unsigned axisId,
|
|
float offset,
|
|
bool adjustBounds = true,
|
|
bool commit = true );
|
|
void AddOffsetToUniverseCenter( vr::ETrackingUniverseOrigin universe,
|
|
float offset[3],
|
|
bool adjustBounds = true,
|
|
bool commit = true );
|
|
void RotateUniverseCenter( vr::ETrackingUniverseOrigin universe,
|
|
float yAngle,
|
|
bool adjustBounds = true,
|
|
bool commit = true ); // around y axis
|
|
void AddOffsetToCollisionBounds( unsigned axisId,
|
|
float offset,
|
|
bool commit = true );
|
|
void AddOffsetToCollisionBounds( float offset[3], bool commit = true );
|
|
void RotateCollisionBounds( float angle,
|
|
bool commit = true ); // around y axis
|
|
|
|
bool isDesktopMode()
|
|
{
|
|
return desktopMode;
|
|
};
|
|
|
|
utils::ChaperoneUtils& chaperoneUtils() noexcept
|
|
{
|
|
return m_chaperoneUtils;
|
|
}
|
|
|
|
Q_INVOKABLE QString getVersionString();
|
|
Q_INVOKABLE QUrl getVRRuntimePathUrl();
|
|
|
|
Q_INVOKABLE bool soundDisabled();
|
|
|
|
const vr::VROverlayHandle_t& overlayHandle();
|
|
const vr::VROverlayHandle_t& overlayThumbnailHandle();
|
|
|
|
bool pollNextEvent( vr::VROverlayHandle_t ulOverlayHandle,
|
|
vr::VREvent_t* pEvent );
|
|
|
|
public slots:
|
|
void renderOverlay();
|
|
void OnRenderRequest();
|
|
void OnTimeoutPumpEvents();
|
|
|
|
void showKeyboard( QString existingText, unsigned long userValue = 0 );
|
|
|
|
void playActivationSound();
|
|
void playFocusChangedSound();
|
|
void playAlarm01Sound( bool loop = false );
|
|
void setAlarm01SoundVolume( float vol );
|
|
void cancelAlarm01Sound();
|
|
|
|
signals:
|
|
void keyBoardInputSignal( QString input, unsigned long userValue = 0 );
|
|
|
|
private:
|
|
static QSettings* _appSettings;
|
|
static std::unique_ptr<OverlayController> singleton;
|
|
|
|
public:
|
|
static OverlayController* getInstance()
|
|
{
|
|
return singleton.get();
|
|
}
|
|
|
|
static OverlayController* createInstance( bool desktopMode, bool noSound )
|
|
{
|
|
singleton.reset(
|
|
new advsettings::OverlayController( desktopMode, noSound ) );
|
|
return singleton.get();
|
|
}
|
|
|
|
static QSettings* appSettings()
|
|
{
|
|
return _appSettings;
|
|
}
|
|
|
|
static void setAppSettings( QSettings* settings )
|
|
{
|
|
_appSettings = settings;
|
|
}
|
|
};
|
|
|
|
} // namespace advsettings
|