Refactor update rates of tab controllers
Previous way of controlling when controllers were run was split among the different controllers, meaning that third parties would require knowledge of internal state of controllers in order to be on the same update schedule as them. This refactor moves the logic into a seperate class. Additionally, it also stops the use of the `adjustUpdateRate` function on all tab controllers, since it broke the prime-number-ability of less collisions.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "../overlaycontroller.h"
|
||||
#include "../settings/settings.h"
|
||||
#include "../settings/settings_object.h"
|
||||
#include "../utils/update_rate.h"
|
||||
#ifdef _WIN32
|
||||
# include "audiomanager/AudioManagerWindows.h"
|
||||
#elif __linux__
|
||||
@@ -26,8 +27,6 @@ void AudioTabController::initStage1()
|
||||
audioManager.reset( new AudioManagerDummy() );
|
||||
#endif
|
||||
audioManager->init( this );
|
||||
m_audioSettingsUpdateCounter
|
||||
= utils::adjustUpdateRate( k_audioSettingsUpdateCounter );
|
||||
initOverride();
|
||||
m_playbackDevices = audioManager->getPlaybackDevices();
|
||||
m_recordingDevices = audioManager->getRecordingDevices();
|
||||
@@ -190,51 +189,48 @@ bool AudioTabController::audioProfileDefault() const
|
||||
|
||||
void AudioTabController::eventLoopTick()
|
||||
{
|
||||
if ( updateRate.shouldSubjectNotRun( UpdateSubject::AudioTabController ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !eventLoopMutex.try_lock() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( settingsUpdateCounter >= m_audioSettingsUpdateCounter )
|
||||
vr::EVRSettingsError vrSettingsError;
|
||||
char mirrorDeviceId[1024];
|
||||
vr::VRSettings()->GetString( vr::k_pch_audio_Section,
|
||||
vr::k_pch_audio_PlaybackMirrorDevice_String,
|
||||
mirrorDeviceId,
|
||||
1024,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
vr::EVRSettingsError vrSettingsError;
|
||||
char mirrorDeviceId[1024];
|
||||
vr::VRSettings()->GetString(
|
||||
vr::k_pch_audio_Section,
|
||||
vr::k_pch_audio_PlaybackMirrorDevice_String,
|
||||
mirrorDeviceId,
|
||||
1024,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_audio_PlaybackMirrorDevice_String
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
if ( lastMirrorDevId.compare( mirrorDeviceId ) != 0 )
|
||||
{
|
||||
audioManager->setMirrorDevice( mirrorDeviceId );
|
||||
findMirrorDeviceIndex( audioManager->getMirrorDevId() );
|
||||
lastMirrorDevId = mirrorDeviceId;
|
||||
}
|
||||
if ( m_mirrorDeviceIndex >= 0 )
|
||||
{
|
||||
setMirrorVolume( audioManager->getMirrorVolume() );
|
||||
setMirrorMuted( audioManager->getMirrorMuted() );
|
||||
}
|
||||
if ( m_recordingDeviceIndex >= 0 )
|
||||
{
|
||||
setMicVolume( audioManager->getMicVolume() );
|
||||
setMicMuted( audioManager->getMicMuted() );
|
||||
}
|
||||
settingsUpdateCounter = 0;
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_audio_PlaybackMirrorDevice_String
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
else
|
||||
if ( lastMirrorDevId.compare( mirrorDeviceId ) != 0 )
|
||||
{
|
||||
settingsUpdateCounter++;
|
||||
audioManager->setMirrorDevice( mirrorDeviceId );
|
||||
findMirrorDeviceIndex( audioManager->getMirrorDevId() );
|
||||
lastMirrorDevId = mirrorDeviceId;
|
||||
}
|
||||
if ( m_mirrorDeviceIndex >= 0 )
|
||||
{
|
||||
setMirrorVolume( audioManager->getMirrorVolume() );
|
||||
setMirrorMuted( audioManager->getMirrorMuted() );
|
||||
}
|
||||
if ( m_recordingDeviceIndex >= 0 )
|
||||
{
|
||||
setMicVolume( audioManager->getMicVolume() );
|
||||
setMicMuted( audioManager->getMicMuted() );
|
||||
}
|
||||
|
||||
eventLoopMutex.unlock();
|
||||
}
|
||||
|
||||
|
||||
@@ -131,8 +131,6 @@ private:
|
||||
bool m_isPlaybackOverride = false;
|
||||
bool m_isRecordingOverride = false;
|
||||
|
||||
unsigned int m_audioSettingsUpdateCounter = 90;
|
||||
|
||||
int m_defaultProfileIndex = -1;
|
||||
|
||||
unsigned settingsUpdateCounter = 0;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "../settings/settings.h"
|
||||
#include "../utils/Matrix.h"
|
||||
#include "../quaternion/quaternion.h"
|
||||
#include "../utils/update_rate.h"
|
||||
#include <cmath>
|
||||
|
||||
// application namespace
|
||||
@@ -18,8 +19,6 @@ void ChaperoneTabController::initStage1()
|
||||
}
|
||||
|
||||
reloadChaperoneProfiles();
|
||||
m_chaperoneSettingsUpdateCounter
|
||||
= utils::adjustUpdateRate( k_chaperoneSettingsUpdateCounter );
|
||||
initCenterMarkerOverlay();
|
||||
eventLoopTick( m_trackingUniverse, nullptr );
|
||||
}
|
||||
@@ -42,15 +41,13 @@ void ChaperoneTabController::initStage2( OverlayController* var_parent )
|
||||
|
||||
void ChaperoneTabController::dashboardLoopTick()
|
||||
{
|
||||
if ( settingsUpdateCounter >= m_chaperoneSettingsUpdateCounter )
|
||||
if ( updateRate.shouldSubjectNotRun(
|
||||
UpdateSubject::ChaperoneTabController ) )
|
||||
{
|
||||
updateChaperoneSettings();
|
||||
settingsUpdateCounter = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
settingsUpdateCounter++;
|
||||
return;
|
||||
}
|
||||
|
||||
updateChaperoneSettings();
|
||||
}
|
||||
|
||||
ChaperoneTabController::~ChaperoneTabController()
|
||||
|
||||
@@ -363,8 +363,6 @@ private:
|
||||
|
||||
int m_updateTicksChaperoneReload = 0;
|
||||
|
||||
unsigned int m_chaperoneSettingsUpdateCounter = 101;
|
||||
|
||||
vr::VRActionHandle_t m_rightActionHandle;
|
||||
vr::VRActionHandle_t m_leftActionHandle;
|
||||
vr::VRInputValueHandle_t m_leftInputHandle;
|
||||
|
||||
@@ -39,8 +39,6 @@ namespace advsettings
|
||||
void MoveCenterTabController::initStage1()
|
||||
{
|
||||
reloadOffsetProfiles();
|
||||
m_moveCenterSettingsUpdateCounter
|
||||
= utils::adjustUpdateRate( k_moveCenterSettingsUpdateCounter );
|
||||
m_lastDragUpdateTimePoint = std::chrono::steady_clock::now();
|
||||
m_lastGravityUpdateTimePoint = std::chrono::steady_clock::now();
|
||||
}
|
||||
|
||||
@@ -204,8 +204,6 @@ private:
|
||||
unsigned m_dragComfortFrameSkipCounter = 0;
|
||||
unsigned m_turnComfortFrameSkipCounter = 0;
|
||||
|
||||
unsigned int m_moveCenterSettingsUpdateCounter = 83;
|
||||
|
||||
// Matrix used For Center Marker
|
||||
vr::HmdMatrix34_t m_offsetmatrix = utils::k_forwardUpMatrix;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "SettingsTabController.h"
|
||||
#include <QQuickWindow>
|
||||
#include "../overlaycontroller.h"
|
||||
#include "../utils/update_rate.h"
|
||||
|
||||
// application namespace
|
||||
namespace advsettings
|
||||
@@ -9,8 +10,6 @@ void SettingsTabController::initStage1()
|
||||
{
|
||||
m_autoStartEnabled = vr::VRApplications()->GetApplicationAutoLaunch(
|
||||
application_strings::applicationKey );
|
||||
m_settingsTabSettingsUpdateCounter
|
||||
= utils::adjustUpdateRate( k_settingsTabSettingsUpdateCounter );
|
||||
}
|
||||
|
||||
void SettingsTabController::initStage2( OverlayController* var_parent )
|
||||
@@ -22,16 +21,14 @@ void SettingsTabController::initStage2( OverlayController* var_parent )
|
||||
|
||||
void SettingsTabController::dashboardLoopTick()
|
||||
{
|
||||
if ( settingsUpdateCounter >= m_settingsTabSettingsUpdateCounter )
|
||||
if ( updateRate.shouldSubjectNotRun(
|
||||
UpdateSubject::SettingsTabController ) )
|
||||
{
|
||||
setAutoStartEnabled( vr::VRApplications()->GetApplicationAutoLaunch(
|
||||
application_strings::applicationKey ) );
|
||||
settingsUpdateCounter = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
settingsUpdateCounter++;
|
||||
return;
|
||||
}
|
||||
|
||||
setAutoStartEnabled( vr::VRApplications()->GetApplicationAutoLaunch(
|
||||
application_strings::applicationKey ) );
|
||||
}
|
||||
|
||||
bool SettingsTabController::autoStartEnabled() const
|
||||
|
||||
@@ -26,13 +26,9 @@ class SettingsTabController : public QObject
|
||||
private:
|
||||
OverlayController* parent;
|
||||
|
||||
unsigned settingsUpdateCounter = 0;
|
||||
|
||||
bool m_autoStartEnabled = false;
|
||||
bool m_nativeChaperoneToggle = false;
|
||||
|
||||
unsigned int m_settingsTabSettingsUpdateCounter = 157;
|
||||
|
||||
public:
|
||||
void initStage1();
|
||||
void initStage2( OverlayController* parent );
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
#include "SteamVRTabController.h"
|
||||
#include <QQuickWindow>
|
||||
#include "../overlaycontroller.h"
|
||||
#include "../utils/update_rate.h"
|
||||
|
||||
// application namespace
|
||||
namespace advsettings
|
||||
{
|
||||
void SteamVRTabController::initStage1()
|
||||
{
|
||||
m_steamVrSettingsUpdateCounter
|
||||
= utils::adjustUpdateRate( k_steamVrSettingsUpdateCounter );
|
||||
dashboardLoopTick();
|
||||
}
|
||||
|
||||
@@ -19,149 +18,141 @@ void SteamVRTabController::initStage2( OverlayController* var_parent )
|
||||
|
||||
void SteamVRTabController::dashboardLoopTick()
|
||||
{
|
||||
if ( settingsUpdateCounter >= m_steamVrSettingsUpdateCounter )
|
||||
if ( updateRate.shouldSubjectNotRun( UpdateSubject::SteamVrTabController ) )
|
||||
{
|
||||
vr::EVRSettingsError vrSettingsError;
|
||||
|
||||
// Checks and synchs performance graph
|
||||
auto pg = vr::VRSettings()->GetBool( vr::k_pch_Perf_Section,
|
||||
vr::k_pch_Perf_PerfGraphInHMD_Bool,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_Perf_PerfGraphInHMD_Bool
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
setPerformanceGraph( pg );
|
||||
|
||||
// synch systembutton
|
||||
auto sb = vr::VRSettings()->GetBool(
|
||||
vr::k_pch_SteamVR_Section,
|
||||
vr::k_pch_SteamVR_SendSystemButtonToAllApps_Bool,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_SteamVR_SendSystemButtonToAllApps_Bool
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
setSystemButton( sb );
|
||||
|
||||
// synch nofadetogrid
|
||||
auto nf = vr::VRSettings()->GetBool( vr::k_pch_SteamVR_Section,
|
||||
vr::k_pch_SteamVR_DoNotFadeToGrid,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_SteamVR_DoNotFadeToGrid
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
setNoFadeToGrid( nf );
|
||||
|
||||
// synch multipleDriver
|
||||
auto md = vr::VRSettings()->GetBool(
|
||||
vr::k_pch_SteamVR_Section,
|
||||
vr::k_pch_SteamVR_ActivateMultipleDrivers_Bool,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_SteamVR_ActivateMultipleDrivers_Bool
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
setMultipleDriver( md );
|
||||
|
||||
// synch dnd
|
||||
auto donotd = vr::VRSettings()->GetBool(
|
||||
vr::k_pch_Notifications_Section,
|
||||
vr::k_pch_Notifications_DoNotDisturb_Bool,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_Notifications_DoNotDisturb_Bool
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
setDND( donotd );
|
||||
|
||||
// synch camera
|
||||
auto ca = vr::VRSettings()->GetBool( vr::k_pch_Camera_Section,
|
||||
vr::k_pch_Camera_EnableCamera_Bool,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_Camera_EnableCamera_Bool
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
setCameraActive( ca );
|
||||
|
||||
// synch camera room
|
||||
auto cr = vr::VRSettings()->GetBool(
|
||||
vr::k_pch_Camera_Section,
|
||||
vr::k_pch_Camera_EnableCameraForRoomView_Bool,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_Camera_EnableCameraForRoomView_Bool
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
setCameraRoom( cr );
|
||||
|
||||
// synch camera dashboard
|
||||
auto cd = vr::VRSettings()->GetBool(
|
||||
vr::k_pch_Camera_Section,
|
||||
vr::k_pch_Camera_EnableCameraInDashboard_Bool,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_Camera_EnableCameraInDashboard_Bool
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
setCameraDashboard( cd );
|
||||
|
||||
// synch camera bounds
|
||||
auto cb = vr::VRSettings()->GetBool(
|
||||
vr::k_pch_Camera_Section,
|
||||
vr::k_pch_Camera_EnableCameraForCollisionBounds_Bool,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING )
|
||||
<< "Could not read \""
|
||||
<< vr::k_pch_Camera_EnableCameraForCollisionBounds_Bool
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
setCameraBounds( cb );
|
||||
|
||||
settingsUpdateCounter = 0;
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
vr::EVRSettingsError vrSettingsError;
|
||||
|
||||
// Checks and synchs performance graph
|
||||
auto pg = vr::VRSettings()->GetBool( vr::k_pch_Perf_Section,
|
||||
vr::k_pch_Perf_PerfGraphInHMD_Bool,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
settingsUpdateCounter++;
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_Perf_PerfGraphInHMD_Bool << "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
setPerformanceGraph( pg );
|
||||
|
||||
// synch systembutton
|
||||
auto sb = vr::VRSettings()->GetBool(
|
||||
vr::k_pch_SteamVR_Section,
|
||||
vr::k_pch_SteamVR_SendSystemButtonToAllApps_Bool,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_SteamVR_SendSystemButtonToAllApps_Bool
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
setSystemButton( sb );
|
||||
|
||||
// synch nofadetogrid
|
||||
auto nf = vr::VRSettings()->GetBool( vr::k_pch_SteamVR_Section,
|
||||
vr::k_pch_SteamVR_DoNotFadeToGrid,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_SteamVR_DoNotFadeToGrid << "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
setNoFadeToGrid( nf );
|
||||
|
||||
// synch multipleDriver
|
||||
auto md = vr::VRSettings()->GetBool(
|
||||
vr::k_pch_SteamVR_Section,
|
||||
vr::k_pch_SteamVR_ActivateMultipleDrivers_Bool,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_SteamVR_ActivateMultipleDrivers_Bool
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
setMultipleDriver( md );
|
||||
|
||||
// synch dnd
|
||||
auto donotd
|
||||
= vr::VRSettings()->GetBool( vr::k_pch_Notifications_Section,
|
||||
vr::k_pch_Notifications_DoNotDisturb_Bool,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_Notifications_DoNotDisturb_Bool
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
setDND( donotd );
|
||||
|
||||
// synch camera
|
||||
auto ca = vr::VRSettings()->GetBool( vr::k_pch_Camera_Section,
|
||||
vr::k_pch_Camera_EnableCamera_Bool,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_Camera_EnableCamera_Bool << "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
setCameraActive( ca );
|
||||
|
||||
// synch camera room
|
||||
auto cr = vr::VRSettings()->GetBool(
|
||||
vr::k_pch_Camera_Section,
|
||||
vr::k_pch_Camera_EnableCameraForRoomView_Bool,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_Camera_EnableCameraForRoomView_Bool
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
setCameraRoom( cr );
|
||||
|
||||
// synch camera dashboard
|
||||
auto cd = vr::VRSettings()->GetBool(
|
||||
vr::k_pch_Camera_Section,
|
||||
vr::k_pch_Camera_EnableCameraInDashboard_Bool,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_Camera_EnableCameraInDashboard_Bool
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
setCameraDashboard( cd );
|
||||
|
||||
// synch camera bounds
|
||||
auto cb = vr::VRSettings()->GetBool(
|
||||
vr::k_pch_Camera_Section,
|
||||
vr::k_pch_Camera_EnableCameraForCollisionBounds_Bool,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_Camera_EnableCameraForCollisionBounds_Bool
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
setCameraBounds( cb );
|
||||
}
|
||||
|
||||
bool SteamVRTabController::performanceGraph() const
|
||||
|
||||
@@ -49,10 +49,6 @@ private:
|
||||
bool m_cameraRoom = false;
|
||||
bool m_cameraDashboard = false;
|
||||
|
||||
unsigned settingsUpdateCounter = 0;
|
||||
|
||||
unsigned int m_steamVrSettingsUpdateCounter = 97;
|
||||
|
||||
public:
|
||||
void initStage1();
|
||||
void initStage2( OverlayController* parent );
|
||||
|
||||
@@ -4,18 +4,13 @@
|
||||
#include "../overlaycontroller.h"
|
||||
#include "../keyboard_input/input_sender.h"
|
||||
#include "../settings/settings.h"
|
||||
#include "../utils/update_rate.h"
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
// application namespace
|
||||
namespace advsettings
|
||||
{
|
||||
void UtilitiesTabController::initStage1()
|
||||
{
|
||||
m_utilitiesSettingsUpdateCounter
|
||||
= utils::adjustUpdateRate( k_utilitiesSettingsUpdateCounter );
|
||||
}
|
||||
|
||||
void UtilitiesTabController::initStage2( OverlayController* var_parent )
|
||||
{
|
||||
this->m_parent = var_parent;
|
||||
@@ -270,87 +265,81 @@ vr::VROverlayHandle_t createBatteryOverlay( vr::TrackedDeviceIndex_t index )
|
||||
|
||||
void UtilitiesTabController::eventLoopTick()
|
||||
{
|
||||
if ( settingsUpdateCounter >= m_utilitiesSettingsUpdateCounter )
|
||||
if ( updateRate.shouldSubjectNotRun(
|
||||
UpdateSubject::UtilitiesTabController ) )
|
||||
{
|
||||
// attach battery overlay to all tracked devices that aren't a
|
||||
// controller or hmd
|
||||
for ( vr::TrackedDeviceIndex_t i = 0; i < vr::k_unMaxTrackedDeviceCount;
|
||||
i++ )
|
||||
return;
|
||||
}
|
||||
|
||||
// attach battery overlay to all tracked devices that aren't a
|
||||
// controller or hmd
|
||||
for ( vr::TrackedDeviceIndex_t i = 0; i < vr::k_unMaxTrackedDeviceCount;
|
||||
i++ )
|
||||
{
|
||||
vr::ETrackedDeviceClass deviceClass
|
||||
= vr::VRSystem()->GetTrackedDeviceClass( i );
|
||||
if ( deviceClass
|
||||
== vr::ETrackedDeviceClass::TrackedDeviceClass_GenericTracker )
|
||||
{
|
||||
vr::ETrackedDeviceClass deviceClass
|
||||
= vr::VRSystem()->GetTrackedDeviceClass( i );
|
||||
if ( deviceClass
|
||||
== vr::ETrackedDeviceClass::TrackedDeviceClass_GenericTracker )
|
||||
if ( m_batteryOverlayHandles[i] == 0 )
|
||||
{
|
||||
if ( m_batteryOverlayHandles[i] == 0 )
|
||||
LOG( INFO ) << "Creating battery overlay for device " << i;
|
||||
m_batteryOverlayHandles[i] = createBatteryOverlay( i );
|
||||
m_batteryVisible[i] = true;
|
||||
}
|
||||
|
||||
bool shouldShow = vr::VROverlay()->IsDashboardVisible();
|
||||
|
||||
if ( shouldShow != m_batteryVisible[i] )
|
||||
{
|
||||
if ( shouldShow )
|
||||
{
|
||||
LOG( INFO ) << "Creating battery overlay for device " << i;
|
||||
m_batteryOverlayHandles[i] = createBatteryOverlay( i );
|
||||
m_batteryVisible[i] = true;
|
||||
vr::VROverlay()->ShowOverlay( m_batteryOverlayHandles[i] );
|
||||
}
|
||||
|
||||
bool shouldShow = vr::VROverlay()->IsDashboardVisible();
|
||||
|
||||
if ( shouldShow != m_batteryVisible[i] )
|
||||
else
|
||||
{
|
||||
if ( shouldShow )
|
||||
vr::VROverlay()->HideOverlay( m_batteryOverlayHandles[i] );
|
||||
}
|
||||
m_batteryVisible[i] = shouldShow;
|
||||
}
|
||||
|
||||
bool hasBatteryStatus
|
||||
= vr::VRSystem()->GetBoolTrackedDeviceProperty(
|
||||
i,
|
||||
vr::ETrackedDeviceProperty::
|
||||
Prop_DeviceProvidesBatteryStatus_Bool );
|
||||
if ( hasBatteryStatus )
|
||||
{
|
||||
float battery = vr::VRSystem()->GetFloatTrackedDeviceProperty(
|
||||
i,
|
||||
vr::ETrackedDeviceProperty::
|
||||
Prop_DeviceBatteryPercentage_Float );
|
||||
int batteryState = static_cast<int>(
|
||||
ceil( static_cast<double>( battery * 5 ) ) );
|
||||
|
||||
if ( batteryState != m_batteryState[i] )
|
||||
{
|
||||
LOG( INFO )
|
||||
<< "Updating battery overlay for device " << i << " to "
|
||||
<< batteryState << "(" << battery << ")"
|
||||
<< QString::number( m_batteryOverlayHandles[i] );
|
||||
QString batteryIconPath
|
||||
= getBatteryIconPath( batteryState );
|
||||
if ( QFile::exists( batteryIconPath ) )
|
||||
{
|
||||
vr::VROverlay()->ShowOverlay(
|
||||
m_batteryOverlayHandles[i] );
|
||||
vr::VROverlay()->SetOverlayFromFile(
|
||||
m_batteryOverlayHandles[i],
|
||||
batteryIconPath.toStdString().c_str() );
|
||||
}
|
||||
else
|
||||
{
|
||||
vr::VROverlay()->HideOverlay(
|
||||
m_batteryOverlayHandles[i] );
|
||||
}
|
||||
m_batteryVisible[i] = shouldShow;
|
||||
}
|
||||
|
||||
bool hasBatteryStatus
|
||||
= vr::VRSystem()->GetBoolTrackedDeviceProperty(
|
||||
i,
|
||||
vr::ETrackedDeviceProperty::
|
||||
Prop_DeviceProvidesBatteryStatus_Bool );
|
||||
if ( hasBatteryStatus )
|
||||
{
|
||||
float battery
|
||||
= vr::VRSystem()->GetFloatTrackedDeviceProperty(
|
||||
i,
|
||||
vr::ETrackedDeviceProperty::
|
||||
Prop_DeviceBatteryPercentage_Float );
|
||||
int batteryState = static_cast<int>(
|
||||
ceil( static_cast<double>( battery * 5 ) ) );
|
||||
|
||||
if ( batteryState != m_batteryState[i] )
|
||||
{
|
||||
LOG( INFO )
|
||||
<< "Updating battery overlay for device " << i
|
||||
<< " to " << batteryState << "(" << battery << ")"
|
||||
<< QString::number( m_batteryOverlayHandles[i] );
|
||||
QString batteryIconPath
|
||||
= getBatteryIconPath( batteryState );
|
||||
if ( QFile::exists( batteryIconPath ) )
|
||||
{
|
||||
vr::VROverlay()->SetOverlayFromFile(
|
||||
m_batteryOverlayHandles[i],
|
||||
batteryIconPath.toStdString().c_str() );
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG( ERROR ) << "Could not find battery icon \""
|
||||
<< batteryIconPath << "\"";
|
||||
}
|
||||
m_batteryState[i] = batteryState;
|
||||
LOG( ERROR ) << "Could not find battery icon \""
|
||||
<< batteryIconPath << "\"";
|
||||
}
|
||||
m_batteryState[i] = batteryState;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
settingsUpdateCounter = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
settingsUpdateCounter++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,10 +32,7 @@ private:
|
||||
int m_batteryState[vr::k_unMaxTrackedDeviceCount];
|
||||
bool m_batteryVisible[vr::k_unMaxTrackedDeviceCount];
|
||||
|
||||
unsigned int m_utilitiesSettingsUpdateCounter = 19;
|
||||
|
||||
public:
|
||||
void initStage1();
|
||||
void initStage2( OverlayController* var_parent );
|
||||
|
||||
void eventLoopTick();
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <QApplication>
|
||||
#include "../settings/settings.h"
|
||||
#include "../overlaycontroller.h"
|
||||
#include "../utils/update_rate.h"
|
||||
#include <cmath>
|
||||
|
||||
namespace advsettings
|
||||
@@ -15,9 +16,6 @@ void VideoTabController::initStage1()
|
||||
synchGain( true );
|
||||
resetGain();
|
||||
|
||||
m_videoDashboardUpdateCounter
|
||||
= utils::adjustUpdateRate( k_videoDashboardUpdateCounter );
|
||||
|
||||
initBrightnessOverlay();
|
||||
initColorOverlay();
|
||||
initMotionSmoothing();
|
||||
@@ -141,101 +139,98 @@ void VideoTabController::eventLoopTick() {}
|
||||
|
||||
void VideoTabController::dashboardLoopTick()
|
||||
{
|
||||
if ( settingsUpdateCounter >= m_videoDashboardUpdateCounter )
|
||||
if ( updateRate.shouldSubjectNotRun( UpdateSubject::VideoDashboard ) )
|
||||
{
|
||||
vr::EVRSettingsError vrSettingsError;
|
||||
return;
|
||||
}
|
||||
|
||||
// checks supersampling override and resynchs if necessry
|
||||
// also prints error if can't find.
|
||||
auto sso = vr::VRSettings()->GetBool(
|
||||
vr::k_pch_SteamVR_Section,
|
||||
vr::k_pch_SteamVR_SupersampleManualOverride_Bool,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_SteamVR_SupersampleManualOverride_Bool
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
vr::EVRSettingsError vrSettingsError;
|
||||
|
||||
setAllowSupersampleOverride( sso );
|
||||
// checks supersampling and re-synchs if necessary
|
||||
auto ss = vr::VRSettings()->GetFloat(
|
||||
vr::k_pch_SteamVR_Section,
|
||||
vr::k_pch_SteamVR_SupersampleScale_Float,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_SteamVR_SupersampleScale_Float
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
if ( m_superSampling != 1.0f )
|
||||
{
|
||||
LOG( DEBUG ) << "OpenVR returns an error and we have a custom "
|
||||
"supersampling value: "
|
||||
<< m_superSampling;
|
||||
setSuperSampling( 1.0 );
|
||||
}
|
||||
}
|
||||
else if ( fabs( static_cast<double>( m_superSampling - ss ) ) > 0.05 )
|
||||
{
|
||||
LOG( INFO ) << "OpenVR reports a changed supersampling value: "
|
||||
<< m_superSampling << " => " << ss;
|
||||
setSuperSampling( ss );
|
||||
}
|
||||
// checks if Supersampling filter is on and changes if it has been
|
||||
// changed elsewhere
|
||||
// checks supersampling override and resynchs if necessry
|
||||
// also prints error if can't find.
|
||||
auto sso = vr::VRSettings()->GetBool(
|
||||
vr::k_pch_SteamVR_Section,
|
||||
vr::k_pch_SteamVR_SupersampleManualOverride_Bool,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_SteamVR_SupersampleManualOverride_Bool
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
|
||||
auto sf = vr::VRSettings()->GetBool(
|
||||
vr::k_pch_SteamVR_Section,
|
||||
vr::k_pch_SteamVR_AllowSupersampleFiltering_Bool,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
setAllowSupersampleOverride( sso );
|
||||
// checks supersampling and re-synchs if necessary
|
||||
auto ss
|
||||
= vr::VRSettings()->GetFloat( vr::k_pch_SteamVR_Section,
|
||||
vr::k_pch_SteamVR_SupersampleScale_Float,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_SteamVR_SupersampleScale_Float
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
if ( m_superSampling != 1.0f )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_SteamVR_AllowSupersampleFiltering_Bool
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
LOG( DEBUG ) << "OpenVR returns an error and we have a custom "
|
||||
"supersampling value: "
|
||||
<< m_superSampling;
|
||||
setSuperSampling( 1.0 );
|
||||
}
|
||||
setAllowSupersampleFiltering( sf );
|
||||
}
|
||||
else if ( fabs( static_cast<double>( m_superSampling - ss ) ) > 0.05 )
|
||||
{
|
||||
LOG( INFO ) << "OpenVR reports a changed supersampling value: "
|
||||
<< m_superSampling << " => " << ss;
|
||||
setSuperSampling( ss );
|
||||
}
|
||||
// checks if Supersampling filter is on and changes if it has been
|
||||
// changed elsewhere
|
||||
|
||||
// Checks if Motion smoothing setting can be read and synchs adv
|
||||
// settings to steamvr/openvr
|
||||
auto ms
|
||||
= vr::VRSettings()->GetBool( vr::k_pch_SteamVR_Section,
|
||||
auto sf = vr::VRSettings()->GetBool(
|
||||
vr::k_pch_SteamVR_Section,
|
||||
vr::k_pch_SteamVR_AllowSupersampleFiltering_Bool,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_SteamVR_AllowSupersampleFiltering_Bool
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
setAllowSupersampleFiltering( sf );
|
||||
|
||||
// Checks if Motion smoothing setting can be read and synchs adv
|
||||
// settings to steamvr/openvr
|
||||
auto ms = vr::VRSettings()->GetBool( vr::k_pch_SteamVR_Section,
|
||||
vr::k_pch_SteamVR_MotionSmoothing_Bool,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_SteamVR_MotionSmoothing_Bool
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
setMotionSmoothing( ms );
|
||||
|
||||
// Synch's our saved Values of gain to the SteamVR's version
|
||||
// This will allow other apps to modify Gain.
|
||||
|
||||
bool valueAdjust = true;
|
||||
if ( isOverlayMethodActive() )
|
||||
{
|
||||
valueAdjust = false;
|
||||
}
|
||||
synchGain( valueAdjust );
|
||||
|
||||
settingsUpdateCounter = 0;
|
||||
}
|
||||
else
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
settingsUpdateCounter++;
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_SteamVR_MotionSmoothing_Bool
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
setMotionSmoothing( ms );
|
||||
|
||||
// Synch's our saved Values of gain to the SteamVR's version
|
||||
// This will allow other apps to modify Gain.
|
||||
|
||||
bool valueAdjust = true;
|
||||
if ( isOverlayMethodActive() )
|
||||
{
|
||||
valueAdjust = false;
|
||||
}
|
||||
synchGain( valueAdjust );
|
||||
|
||||
settingsUpdateCounter = 0;
|
||||
}
|
||||
|
||||
void VideoTabController::reloadVideoConfig()
|
||||
|
||||
Reference in New Issue
Block a user