From eb8140a7f7c38ddb15235d5b04a3b74bc83e0da5 Mon Sep 17 00:00:00 2001 From: ykeara Date: Sun, 7 Jun 2020 12:06:25 -0500 Subject: [PATCH] Fixed Synchro Bug 5.2.0 release (#470) * fixed synch bug * refactored chaperone tab controller for better ui synching/updated * refactored steamvr tab controller * refactored video tab controller * cleanup * update version strings fix implicit conversions --- build_scripts/compile_version_string.txt | 2 +- src/overlaycontroller.cpp | 5 +- src/tabcontrollers/ChaperoneTabController.cpp | 136 +++++----- src/tabcontrollers/ChaperoneTabController.h | 7 +- src/tabcontrollers/SteamVRTabController.cpp | 250 ++++++++---------- src/tabcontrollers/SteamVRTabController.h | 3 + src/tabcontrollers/VideoTabController.cpp | 236 +++++------------ src/tabcontrollers/VideoTabController.h | 7 +- src/utils/update_rate.h | 2 +- ver/versioncheck.json | 2 +- 10 files changed, 253 insertions(+), 397 deletions(-) diff --git a/build_scripts/compile_version_string.txt b/build_scripts/compile_version_string.txt index 6389c36..abe9224 100644 --- a/build_scripts/compile_version_string.txt +++ b/build_scripts/compile_version_string.txt @@ -1 +1 @@ -5.1.2-dev \ No newline at end of file +5.2.0-release \ No newline at end of file diff --git a/src/overlaycontroller.cpp b/src/overlaycontroller.cpp index 3c5e242..419c748 100644 --- a/src/overlaycontroller.cpp +++ b/src/overlaycontroller.cpp @@ -491,6 +491,7 @@ void OverlayController::SetWidget( QQuickItem* quickItem, m_utilitiesTabController.initStage2( this ); m_moveCenterTabController.initStage2( this ); m_rotationTabController.initStage2( this ); + m_videoTabController.initStage2(); } void OverlayController::OnRenderRequest() @@ -918,6 +919,7 @@ void OverlayController::OnTimeoutPumpEvents() { mainEventLoop(); m_customTickRateCounter = 0; + updateRate.incrementCounter(); } else { @@ -938,6 +940,7 @@ void OverlayController::OnTimeoutPumpEvents() // main event loop. (this function should trigger about every 11ms // assuming 90fps compositor) mainEventLoop(); + updateRate.incrementCounter(); // wait for the next frame after executing our main event loop once. m_lastFrame = m_currentFrame; @@ -957,8 +960,6 @@ void OverlayController::OnTimeoutPumpEvents() m_vsyncTooLateCounter++; } } - - updateRate.incrementCounter(); } void OverlayController::mainEventLoop() diff --git a/src/tabcontrollers/ChaperoneTabController.cpp b/src/tabcontrollers/ChaperoneTabController.cpp index 405a2f5..229a450 100644 --- a/src/tabcontrollers/ChaperoneTabController.cpp +++ b/src/tabcontrollers/ChaperoneTabController.cpp @@ -27,9 +27,8 @@ void ChaperoneTabController::initStage2( OverlayController* var_parent ) { this->parent = var_parent; - updateChaperoneSettings(); // force one update of OVR saved settings to make - // sure our m_ variables are correct - // Force call Update Overlay Once, so Default state is in correct location + updateChaperoneSettings(); + if ( m_centerMarkerOverlayIsInit ) { vr::HmdMatrix34_t temp = { { { 1.0f, 0.0f, 0.0f, 0.0f }, @@ -344,42 +343,22 @@ void ChaperoneTabController::eventLoopTick( void ChaperoneTabController::updateChaperoneSettings() { - setBoundsVisibility( static_cast( chaperoneColorA() ) / 255.0f ); + setBoundsVisibility( boundsVisibility() ); setFadeDistance( fadeDistance(), true ); setCenterMarker( centerMarker() ); setPlaySpaceMarker( playSpaceMarker() ); setChaperoneColorR( chaperoneColorR() ); setChaperoneColorG( chaperoneColorG() ); setChaperoneColorB( chaperoneColorB() ); + setChaperoneFloorToggle( chaperoneFloorToggle() ); setCollisionBoundStyle( collisionBoundStyle() ); -} - -float ChaperoneTabController::boundsVisibility() const -{ - return m_visibility; + setHeight( height() ); } void ChaperoneTabController::setBoundsVisibility( float value, bool notify ) { - if ( fabs( static_cast( m_visibility - value ) ) > 0.005 ) - { - if ( value <= 0.3f ) - { - m_visibility = 0.3f; - } - else - { - m_visibility = value; - } - setChaperoneColorA( static_cast( 255 * m_visibility ), notify ); - ovr_overlay_wrapper::setOverlayAlpha( - m_chaperoneFloorOverlayHandle, m_visibility, "" ); - - if ( notify ) - { - emit boundsVisibilityChanged( m_visibility ); - } - } + setChaperoneColorA( + static_cast( static_cast( value ) * 255.0f ), notify ); } float ChaperoneTabController::fadeDistance() @@ -391,7 +370,6 @@ float ChaperoneTabController::fadeDistance() "" ); if ( p.first == ovr_settings_wrapper::SettingsError::NoError ) { - m_fadeDistance = p.second; return p.second; } return m_fadeDistance; @@ -470,7 +448,6 @@ bool ChaperoneTabController::centerMarker() "" ); if ( p.first == ovr_settings_wrapper::SettingsError::NoError ) { - m_centerMarker = p.second; return p.second; } @@ -487,7 +464,6 @@ void ChaperoneTabController::setCenterMarker( bool value, bool notify ) vr::k_pch_CollisionBounds_CenterMarkerOn_Bool, m_centerMarker, "" ); - if ( notify ) { emit centerMarkerChanged( m_centerMarker ); @@ -504,7 +480,6 @@ bool ChaperoneTabController::playSpaceMarker() "" ); if ( p.first == ovr_settings_wrapper::SettingsError::NoError ) { - m_playSpaceMarker = p.second; return p.second; } @@ -531,7 +506,8 @@ void ChaperoneTabController::setPlaySpaceMarker( bool value, bool notify ) bool ChaperoneTabController::forceBounds() const { - // todo ivrchaperonewrapper + // Currently th ere is no way to get from OVR if force bounds is on/off as + // of OVR 1.12.5 return m_forceBounds; } @@ -608,11 +584,10 @@ int ChaperoneTabController::chaperoneColorR() vr::k_pch_CollisionBounds_Section, vr::k_pch_CollisionBounds_ColorGammaR_Int32, "" ); - if ( p.first != ovr_settings_wrapper::SettingsError::NoError ) + if ( p.first == ovr_settings_wrapper::SettingsError::NoError ) { - return m_chaperoneColorR; + return p.second; } - m_chaperoneColorR = p.second; return m_chaperoneColorR; } int ChaperoneTabController::chaperoneColorG() @@ -622,11 +597,10 @@ int ChaperoneTabController::chaperoneColorG() vr::k_pch_CollisionBounds_Section, vr::k_pch_CollisionBounds_ColorGammaG_Int32, "" ); - if ( p.first != ovr_settings_wrapper::SettingsError::NoError ) + if ( p.first == ovr_settings_wrapper::SettingsError::NoError ) { - return m_chaperoneColorG; + return p.second; } - m_chaperoneColorG = p.second; return m_chaperoneColorG; } int ChaperoneTabController::chaperoneColorB() @@ -636,28 +610,42 @@ int ChaperoneTabController::chaperoneColorB() vr::k_pch_CollisionBounds_Section, vr::k_pch_CollisionBounds_ColorGammaB_Int32, "" ); - if ( p.first != ovr_settings_wrapper::SettingsError::NoError ) + if ( p.first == ovr_settings_wrapper::SettingsError::NoError ) { - return m_chaperoneColorB; + return p.second; } - m_chaperoneColorB = p.second; return m_chaperoneColorB; } // aka transparancy -int ChaperoneTabController::chaperoneColorA() const +int ChaperoneTabController::chaperoneColorA() { std::pair p = ovr_settings_wrapper::getInt32( vr::k_pch_CollisionBounds_Section, vr::k_pch_CollisionBounds_ColorGammaA_Int32, "" ); - if ( p.first != ovr_settings_wrapper::SettingsError::NoError ) + if ( p.first == ovr_settings_wrapper::SettingsError::NoError ) { - return 255; + return m_chaperoneColorA; } return p.second; } +float ChaperoneTabController::boundsVisibility() +{ + std::pair p + = ovr_settings_wrapper::getInt32( + vr::k_pch_CollisionBounds_Section, + vr::k_pch_CollisionBounds_ColorGammaA_Int32, + "" ); + if ( p.first == ovr_settings_wrapper::SettingsError::NoError ) + { + return static_cast( static_cast( m_chaperoneColorA ) + / 255.0f ); + } + return static_cast( static_cast( p.second ) / 255.0f ); +} + bool ChaperoneTabController::chaperoneFloorToggle() { std::pair p @@ -665,11 +653,11 @@ bool ChaperoneTabController::chaperoneFloorToggle() vr::k_pch_CollisionBounds_Section, vr::k_pch_CollisionBounds_GroundPerimeterOn_Bool, "" ); - if ( p.first != ovr_settings_wrapper::SettingsError::NoError ) + if ( p.first == ovr_settings_wrapper::SettingsError::NoError ) { - return false; + return p.second; } - return p.second; + return m_chaperoneFloorToggle; } int ChaperoneTabController::collisionBoundStyle() @@ -678,11 +666,10 @@ int ChaperoneTabController::collisionBoundStyle() = ovr_settings_wrapper::getInt32( vr::k_pch_CollisionBounds_Section, vr::k_pch_CollisionBounds_Style_Int32, "" ); - if ( p.first != ovr_settings_wrapper::SettingsError::NoError ) + if ( p.first == ovr_settings_wrapper::SettingsError::NoError ) { - return m_collisionBoundStyle; + return p.second; } - m_collisionBoundStyle = p.second; return m_collisionBoundStyle; } @@ -818,25 +805,34 @@ void ChaperoneTabController::updateCenterMarkerOverlayColor() void ChaperoneTabController::setChaperoneColorA( int value, bool notify ) { - if ( value > 255 ) + if ( value != m_chaperoneColorA ) { - value = 255; - LOG( WARNING ) << "Alpha Channel larger than 255, setting to 255"; + if ( value > 255 ) + { + value = 255; + LOG( WARNING ) << "Alpha Channel larger than 255, setting to 255"; + } + else if ( value < 0 ) + { + value = 0; + LOG( WARNING ) << "Alpha Channel smaller than 0, setting to 0"; + } + m_chaperoneColorA = value; + ovr_settings_wrapper::setInt32( + vr::k_pch_CollisionBounds_Section, + vr::k_pch_CollisionBounds_ColorGammaA_Int32, + value, + "" ); + ovr_overlay_wrapper::setOverlayAlpha( m_chaperoneFloorOverlayHandle, + static_cast( value ) + / 255.0f, + "" ); + if ( notify ) + { + emit chaperoneColorAChanged( value ); + } } - else if ( value < 0 ) - { - value = 0; - LOG( WARNING ) << "Alpha Channel smaller than 0, setting to 0"; - } - ovr_settings_wrapper::setInt32( vr::k_pch_CollisionBounds_Section, - vr::k_pch_CollisionBounds_ColorGammaA_Int32, - value, - "" ); - if ( notify ) - { - emit chaperoneColorAChanged( value ); - } -} +} // namespace advsettings void ChaperoneTabController::setCenterMarkerNew( bool value, bool notify ) { @@ -1222,7 +1218,7 @@ void ChaperoneTabController::addChaperoneProfile( profile->includesVisibility = includeVisbility; if ( includeVisbility ) { - profile->visibility = m_visibility; + profile->visibility = boundsVisibility(); } profile->includesFadeDistance = includeFadeDistance; if ( includeFadeDistance ) @@ -1570,7 +1566,7 @@ void ChaperoneTabController::initCenterMarkerOverlay() m_chaperoneFloorOverlayHandle, 0.5f ); updateCenterMarkerOverlayColor(); ovr_overlay_wrapper::setOverlayAlpha( - m_chaperoneFloorOverlayHandle, m_visibility, "" ); + m_chaperoneFloorOverlayHandle, boundsVisibility(), "" ); m_centerMarkerOverlayIsInit = true; } else diff --git a/src/tabcontrollers/ChaperoneTabController.h b/src/tabcontrollers/ChaperoneTabController.h index 231d04c..6b4235e 100644 --- a/src/tabcontrollers/ChaperoneTabController.h +++ b/src/tabcontrollers/ChaperoneTabController.h @@ -33,7 +33,6 @@ struct ChaperoneProfile : settings::ISettingsObject vr::HmdMatrix34_t standingCenter; float playSpaceAreaX = 0.0f; float playSpaceAreaZ = 0.0f; - bool includesVisibility = false; float visibility = 0.6f; @@ -324,7 +323,6 @@ class ChaperoneTabController : public QObject private: OverlayController* parent; - float m_visibility = 0.6f; float m_fadeDistance = 0.7f; float m_height = 2.0f; bool m_centerMarker = false; @@ -354,6 +352,7 @@ private: int m_chaperoneColorR = 0; int m_chaperoneColorG = 255; int m_chaperoneColorB = 255; + int m_chaperoneColorA = 153; int m_collisionBoundStyle = 0; @@ -397,7 +396,6 @@ public: void updateCenterMarkerOverlay( vr::HmdMatrix34_t* centerPlaySpaceMatrix ); - float boundsVisibility() const; float fadeDistance(); float height(); bool centerMarker(); @@ -408,7 +406,8 @@ public: int chaperoneColorR(); int chaperoneColorG(); int chaperoneColorB(); - int chaperoneColorA() const; + int chaperoneColorA(); + float boundsVisibility(); bool centerMarkerNew(); bool m_centerMarkerOverlayNeedsUpdate = false; diff --git a/src/tabcontrollers/SteamVRTabController.cpp b/src/tabcontrollers/SteamVRTabController.cpp index 7ccf7d3..90ccbc5 100644 --- a/src/tabcontrollers/SteamVRTabController.cpp +++ b/src/tabcontrollers/SteamVRTabController.cpp @@ -14,6 +14,7 @@ void SteamVRTabController::initStage1() void SteamVRTabController::initStage2( OverlayController* var_parent ) { this->parent = var_parent; + synchSteamVR(); } void SteamVRTabController::dashboardLoopTick() @@ -22,141 +23,33 @@ void SteamVRTabController::dashboardLoopTick() { return; } + synchSteamVR(); +} - 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 ); +void SteamVRTabController::synchSteamVR() +{ + // Un-comment these if other Apps make heavy use OR ADDED to STEAMVR + // officially + setPerformanceGraph( performanceGraph() ); + // setSystemButton(systemButton()); + setMultipleDriver( multipleDriver() ); + setDND( dnd() ); + setNoFadeToGrid( noFadeToGrid() ); + setCameraActive( cameraActive() ); + setCameraRoom( cameraRoom() ); + setCameraDashboard( cameraDashboard() ); + setCameraBounds( cameraBounds() ); } bool SteamVRTabController::performanceGraph() const { + auto p = ovr_settings_wrapper::getBool( + vr::k_pch_Perf_Section, vr::k_pch_Perf_PerfGraphInHMD_Bool ); + + if ( p.first == ovr_settings_wrapper::SettingsError::NoError ) + { + return p.second; + } return m_performanceGraphToggle; } @@ -166,9 +59,9 @@ void SteamVRTabController::setPerformanceGraph( const bool value, if ( m_performanceGraphToggle != value ) { m_performanceGraphToggle = value; - vr::VRSettings()->SetBool( vr::k_pch_Perf_Section, - vr::k_pch_Perf_PerfGraphInHMD_Bool, - m_performanceGraphToggle ); + ovr_settings_wrapper::setBool( vr::k_pch_Perf_Section, + vr::k_pch_Perf_PerfGraphInHMD_Bool, + m_performanceGraphToggle ); if ( notify ) { emit performanceGraphChanged( m_performanceGraphToggle ); @@ -178,6 +71,14 @@ void SteamVRTabController::setPerformanceGraph( const bool value, bool SteamVRTabController::multipleDriver() const { + auto p = ovr_settings_wrapper::getBool( + vr::k_pch_SteamVR_Section, + vr::k_pch_SteamVR_ActivateMultipleDrivers_Bool ); + + if ( p.first == ovr_settings_wrapper::SettingsError::NoError ) + { + return p.second; + } return m_multipleDriverToggle; } @@ -187,7 +88,7 @@ void SteamVRTabController::setMultipleDriver( const bool value, if ( m_multipleDriverToggle != value ) { m_multipleDriverToggle = value; - vr::VRSettings()->SetBool( + ovr_settings_wrapper::setBool( vr::k_pch_SteamVR_Section, vr::k_pch_SteamVR_ActivateMultipleDrivers_Bool, m_multipleDriverToggle ); @@ -200,6 +101,13 @@ void SteamVRTabController::setMultipleDriver( const bool value, bool SteamVRTabController::noFadeToGrid() const { + auto p = ovr_settings_wrapper::getBool( vr::k_pch_SteamVR_Section, + vr::k_pch_SteamVR_DoNotFadeToGrid ); + + if ( p.first == ovr_settings_wrapper::SettingsError::NoError ) + { + return p.second; + } return m_noFadeToGridToggle; } @@ -209,9 +117,9 @@ void SteamVRTabController::setNoFadeToGrid( const bool value, if ( m_noFadeToGridToggle != value ) { m_noFadeToGridToggle = value; - vr::VRSettings()->SetBool( vr::k_pch_SteamVR_Section, - vr::k_pch_SteamVR_DoNotFadeToGrid, - m_noFadeToGridToggle ); + ovr_settings_wrapper::setBool( vr::k_pch_SteamVR_Section, + vr::k_pch_SteamVR_DoNotFadeToGrid, + m_noFadeToGridToggle ); if ( notify ) { emit noFadeToGridChanged( m_noFadeToGridToggle ); @@ -221,6 +129,14 @@ void SteamVRTabController::setNoFadeToGrid( const bool value, bool SteamVRTabController::systemButton() const { + auto p = ovr_settings_wrapper::getBool( + vr::k_pch_SteamVR_Section, + vr::k_pch_SteamVR_SendSystemButtonToAllApps_Bool ); + + if ( p.first == ovr_settings_wrapper::SettingsError::NoError ) + { + return p.second; + } return m_systemButtonToggle; } @@ -230,7 +146,7 @@ void SteamVRTabController::setSystemButton( const bool value, if ( m_systemButtonToggle != value ) { m_systemButtonToggle = value; - vr::VRSettings()->SetBool( + ovr_settings_wrapper::setBool( vr::k_pch_SteamVR_Section, vr::k_pch_SteamVR_SendSystemButtonToAllApps_Bool, m_systemButtonToggle ); @@ -243,6 +159,14 @@ void SteamVRTabController::setSystemButton( const bool value, bool SteamVRTabController::dnd() const { + auto p = ovr_settings_wrapper::getBool( + vr::k_pch_Notifications_Section, + vr::k_pch_Notifications_DoNotDisturb_Bool ); + + if ( p.first == ovr_settings_wrapper::SettingsError::NoError ) + { + return p.second; + } return m_dnd; } @@ -251,9 +175,10 @@ void SteamVRTabController::setDND( const bool value, const bool notify ) if ( m_dnd != value ) { m_dnd = value; - vr::VRSettings()->SetBool( vr::k_pch_Notifications_Section, - vr::k_pch_Notifications_DoNotDisturb_Bool, - m_dnd ); + ovr_settings_wrapper::setBool( + vr::k_pch_Notifications_Section, + vr::k_pch_Notifications_DoNotDisturb_Bool, + m_dnd ); if ( notify ) { emit dNDChanged( m_dnd ); @@ -266,6 +191,13 @@ void SteamVRTabController::setDND( const bool value, const bool notify ) bool SteamVRTabController::cameraActive() const { + auto p = ovr_settings_wrapper::getBool( + vr::k_pch_Camera_Section, vr::k_pch_Camera_EnableCamera_Bool ); + + if ( p.first == ovr_settings_wrapper::SettingsError::NoError ) + { + return p.second; + } return m_cameraActive; } @@ -275,9 +207,9 @@ void SteamVRTabController::setCameraActive( const bool value, if ( m_cameraActive != value ) { m_cameraActive = value; - vr::VRSettings()->SetBool( vr::k_pch_Camera_Section, - vr::k_pch_Camera_EnableCamera_Bool, - m_cameraActive ); + ovr_settings_wrapper::setBool( vr::k_pch_Camera_Section, + vr::k_pch_Camera_EnableCamera_Bool, + m_cameraActive ); if ( notify ) { emit cameraActiveChanged( m_cameraActive ); @@ -287,6 +219,14 @@ void SteamVRTabController::setCameraActive( const bool value, bool SteamVRTabController::cameraBounds() const { + auto p = ovr_settings_wrapper::getBool( + vr::k_pch_Camera_Section, + vr::k_pch_Camera_EnableCameraForCollisionBounds_Bool ); + + if ( p.first == ovr_settings_wrapper::SettingsError::NoError ) + { + return p.second; + } return m_cameraBounds; } @@ -296,7 +236,7 @@ void SteamVRTabController::setCameraBounds( const bool value, if ( m_cameraBounds != value ) { m_cameraBounds = value; - vr::VRSettings()->SetBool( + ovr_settings_wrapper::setBool( vr::k_pch_Camera_Section, vr::k_pch_Camera_EnableCameraForCollisionBounds_Bool, m_cameraBounds ); @@ -309,6 +249,14 @@ void SteamVRTabController::setCameraBounds( const bool value, bool SteamVRTabController::cameraRoom() const { + auto p = ovr_settings_wrapper::getBool( + vr::k_pch_Camera_Section, + vr::k_pch_Camera_EnableCameraForRoomView_Bool ); + + if ( p.first == ovr_settings_wrapper::SettingsError::NoError ) + { + return p.second; + } return m_cameraRoom; } @@ -317,7 +265,7 @@ void SteamVRTabController::setCameraRoom( const bool value, const bool notify ) if ( m_cameraRoom != value ) { m_cameraRoom = value; - vr::VRSettings()->SetBool( + ovr_settings_wrapper::setBool( vr::k_pch_Camera_Section, vr::k_pch_Camera_EnableCameraForRoomView_Bool, m_cameraRoom ); @@ -330,6 +278,14 @@ void SteamVRTabController::setCameraRoom( const bool value, const bool notify ) bool SteamVRTabController::cameraDashboard() const { + auto p = ovr_settings_wrapper::getBool( + vr::k_pch_Camera_Section, + vr::k_pch_Camera_EnableCameraInDashboard_Bool ); + + if ( p.first == ovr_settings_wrapper::SettingsError::NoError ) + { + return p.second; + } return m_cameraDashboard; } @@ -359,7 +315,7 @@ void SteamVRTabController::setCameraDashboard( const bool value, if ( m_cameraDashboard != value ) { m_cameraDashboard = value; - vr::VRSettings()->SetBool( + ovr_settings_wrapper::setBool( vr::k_pch_Camera_Section, vr::k_pch_Camera_EnableCameraInDashboard_Bool, m_cameraDashboard ); diff --git a/src/tabcontrollers/SteamVRTabController.h b/src/tabcontrollers/SteamVRTabController.h index 4010e96..0dced44 100644 --- a/src/tabcontrollers/SteamVRTabController.h +++ b/src/tabcontrollers/SteamVRTabController.h @@ -3,6 +3,7 @@ #include #include "../utils/FrameRateUtils.h" +#include "../openvr/ovr_settings_wrapper.h" class QQuickWindow; // application namespace @@ -49,6 +50,8 @@ private: bool m_cameraRoom = false; bool m_cameraDashboard = false; + void synchSteamVR(); + public: void initStage1(); void initStage2( OverlayController* parent ); diff --git a/src/tabcontrollers/VideoTabController.cpp b/src/tabcontrollers/VideoTabController.cpp index fecb515..f33ab93 100644 --- a/src/tabcontrollers/VideoTabController.cpp +++ b/src/tabcontrollers/VideoTabController.cpp @@ -18,8 +18,6 @@ void VideoTabController::initStage1() initBrightnessOverlay(); initColorOverlay(); - initMotionSmoothing(); - initSupersampleOverride(); m_overlayInit = true; reloadVideoConfig(); reloadVideoProfiles(); @@ -30,6 +28,19 @@ void VideoTabController::initStage1() } } +void VideoTabController::initStage2() +{ + synchSteamVR(); +} + +void VideoTabController::synchSteamVR() +{ + setMotionSmoothing( motionSmoothing() ); + setAllowSupersampleOverride( allowSupersampleOverride() ); + setSuperSampling( superSampling() ); + setAllowSupersampleFiltering( allowSupersampleFiltering() ); +} + void VideoTabController::initBrightnessOverlay() { std::string notifKey = std::string( application_strings::applicationKey ) @@ -143,94 +154,13 @@ void VideoTabController::dashboardLoopTick() { return; } - - vr::EVRSettingsError vrSettingsError; - - // 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 ); - } - - 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( 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 - - 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. - + synchSteamVR(); bool valueAdjust = true; if ( isOverlayMethodActive() ) { valueAdjust = false; } synchGain( valueAdjust ); - - settingsUpdateCounter = 0; } void VideoTabController::reloadVideoConfig() @@ -242,14 +172,9 @@ void VideoTabController::reloadVideoConfig() setColorGreen( colorGreen() ); setColorBlue( colorBlue() ); - vr::VROverlayError overlayError = vr::VROverlay()->SetOverlayAlpha( - m_brightnessOverlayHandle, brightnessOpacityValue() ); - if ( overlayError != vr::VROverlayError_None ) - { - LOG( ERROR ) << "Could not set alpha for Brightness Overlay: " - << vr::VROverlay()->GetOverlayErrorNameFromEnum( - overlayError ); - } + ovr_overlay_wrapper::setOverlayAlpha( m_brightnessOverlayHandle, + brightnessOpacityValue() ); + loadColorOverlay(); } @@ -283,7 +208,8 @@ void VideoTabController::setBrightnessEnabled( bool value, if ( overlayHandle != vr::k_ulOverlayHandleInvalid ) { setBrightnessOpacityValue( brightnessOpacityValue(), false ); - vr::VROverlay()->ShowOverlay( getBrightnessOverlayHandle() ); + ovr_overlay_wrapper::showOverlay( + getBrightnessOverlayHandle() ); LOG( INFO ) << "Brightness Overlay toggled on"; } } @@ -291,7 +217,8 @@ void VideoTabController::setBrightnessEnabled( bool value, { if ( overlayHandle != vr::k_ulOverlayHandleInvalid ) { - vr::VROverlay()->HideOverlay( getBrightnessOverlayHandle() ); + ovr_overlay_wrapper::hideOverlay( + getBrightnessOverlayHandle() ); LOG( INFO ) << "Brightness Overlay toggled off"; } } @@ -321,14 +248,8 @@ void VideoTabController::setBrightnessOpacityValue( float percvalue, settings::DoubleSetting::VIDEO_brightnessOpacityValue, 1.0 ); realvalue = 0; } - vr::VROverlayError overlayError = vr::VROverlay()->SetOverlayAlpha( - m_brightnessOverlayHandle, realvalue ); - if ( overlayError != vr::VROverlayError_None ) - { - LOG( ERROR ) << "Could not set alpha for brightness overlay: " - << vr::VROverlay()->GetOverlayErrorNameFromEnum( - overlayError ); - } + ovr_overlay_wrapper::setOverlayAlpha( m_brightnessOverlayHandle, + realvalue ); if ( notify ) { @@ -420,7 +341,7 @@ void VideoTabController::setColorOverlayEnabled( bool value, { if ( overlayHandle != vr::k_ulOverlayHandleInvalid ) { - vr::VROverlay()->ShowOverlay( getColorOverlayHandle() ); + ovr_overlay_wrapper::showOverlay( getColorOverlayHandle() ); LOG( INFO ) << "Color Overlay toggled on"; } } @@ -428,7 +349,7 @@ void VideoTabController::setColorOverlayEnabled( bool value, { if ( overlayHandle != vr::k_ulOverlayHandleInvalid ) { - vr::VROverlay()->HideOverlay( getColorOverlayHandle() ); + ovr_overlay_wrapper::hideOverlay( getColorOverlayHandle() ); LOG( INFO ) << "Color Overlay toggled off"; } } @@ -453,14 +374,7 @@ void VideoTabController::setColorOverlayOpacity( float value, bool notify ) settings::DoubleSetting::VIDEO_colorOverlayOpacity, static_cast( value ) ); - vr::VROverlayError overlayError - = vr::VROverlay()->SetOverlayAlpha( m_colorOverlayHandle, value ); - if ( overlayError != vr::VROverlayError_None ) - { - LOG( ERROR ) << "Could not set alpha for color overlay: " - << vr::VROverlay()->GetOverlayErrorNameFromEnum( - overlayError ); - } + ovr_overlay_wrapper::setOverlayAlpha( m_colorOverlayHandle, value ); if ( notify ) { @@ -745,54 +659,46 @@ void VideoTabController::setColor( float R, float VideoTabController::superSampling() const { + auto p = ovr_settings_wrapper::getFloat( + vr::k_pch_SteamVR_Section, vr::k_pch_SteamVR_SupersampleScale_Float ); + if ( p.first == ovr_settings_wrapper::SettingsError::NoError ) + { + return p.second; + } return m_superSampling; } bool VideoTabController::allowSupersampleOverride() const { - return m_allowSupersampleOverride; -} - -void VideoTabController::initSupersampleOverride() -{ - bool temporary = false; - vr::EVRSettingsError vrSettingsError; - temporary = vr::VRSettings()->GetBool( + auto p = ovr_settings_wrapper::getBool( vr::k_pch_SteamVR_Section, - vr::k_pch_SteamVR_SupersampleManualOverride_Bool, - &vrSettingsError ); - if ( vrSettingsError != vr::VRSettingsError_None ) + vr::k_pch_SteamVR_SupersampleManualOverride_Bool ); + if ( p.first == ovr_settings_wrapper::SettingsError::NoError ) { - LOG( WARNING ) << "Could not get SuperSampling Override State \"" - << vr::k_pch_SteamVR_SupersampleManualOverride_Bool - << "\" setting: " - << vr::VRSettings()->GetSettingsErrorNameFromEnum( - vrSettingsError ); + return p.second; } - setAllowSupersampleOverride( temporary, true ); + return m_allowSupersampleOverride; } void VideoTabController::setSuperSampling( float value, const bool notify ) { - bool override = false; - // Mirrors Desktop Clamp - if ( value < 0.2f ) - { - LOG( WARNING ) << "Encountered a supersampling value <= 0.2, setting " - "supersampling to 1.0"; - value = 1.0f; - override = true; - } - - if ( override - || fabs( static_cast( m_superSampling - value ) ) > .005 ) + if ( fabs( static_cast( m_superSampling - value ) ) > .005 ) { + // Mirrors Desktop Clamp + if ( value < 0.2f ) + { + LOG( WARNING ) + << "Encountered a supersampling value <= 0.2, setting " + "supersampling to 1.0"; + value = 1.0f; + } LOG( DEBUG ) << "Supersampling value changed: " << m_superSampling << " => " << value; m_superSampling = value; - vr::VRSettings()->SetFloat( vr::k_pch_SteamVR_Section, - vr::k_pch_SteamVR_SupersampleScale_Float, - m_superSampling ); + ovr_settings_wrapper::setFloat( + vr::k_pch_SteamVR_Section, + vr::k_pch_SteamVR_SupersampleScale_Float, + m_superSampling ); if ( notify ) { emit superSamplingChanged( m_superSampling ); @@ -806,7 +712,7 @@ void VideoTabController::setAllowSupersampleOverride( const bool value, if ( m_allowSupersampleOverride != value ) { m_allowSupersampleOverride = value; - vr::VRSettings()->SetBool( + ovr_settings_wrapper::setBool( vr::k_pch_SteamVR_Section, vr::k_pch_SteamVR_SupersampleManualOverride_Bool, m_allowSupersampleOverride ); @@ -825,6 +731,12 @@ void VideoTabController::setAllowSupersampleOverride( const bool value, bool VideoTabController::motionSmoothing() const { + auto p = ovr_settings_wrapper::getBool( + vr::k_pch_SteamVR_Section, vr::k_pch_SteamVR_MotionSmoothing_Bool ); + if ( p.first == ovr_settings_wrapper::SettingsError::NoError ) + { + return p.second; + } return m_motionSmoothing; } @@ -834,9 +746,9 @@ void VideoTabController::setMotionSmoothing( const bool value, if ( m_motionSmoothing != value ) { m_motionSmoothing = value; - vr::VRSettings()->SetBool( vr::k_pch_SteamVR_Section, - vr::k_pch_SteamVR_MotionSmoothing_Bool, - m_motionSmoothing ); + ovr_settings_wrapper::setBool( vr::k_pch_SteamVR_Section, + vr::k_pch_SteamVR_MotionSmoothing_Bool, + m_motionSmoothing ); if ( notify ) { emit motionSmoothingChanged( m_motionSmoothing ); @@ -844,27 +756,15 @@ void VideoTabController::setMotionSmoothing( const bool value, } } -void VideoTabController::initMotionSmoothing() -{ - bool temporary = false; - vr::EVRSettingsError vrSettingsError; - temporary - = vr::VRSettings()->GetBool( vr::k_pch_SteamVR_Section, - vr::k_pch_SteamVR_MotionSmoothing_Bool, - &vrSettingsError ); - if ( vrSettingsError != vr::VRSettingsError_None ) - { - LOG( WARNING ) << "Could not get MotionSmoothing State \"" - << vr::k_pch_SteamVR_MotionSmoothing_Bool - << "\" setting: " - << vr::VRSettings()->GetSettingsErrorNameFromEnum( - vrSettingsError ); - } - setMotionSmoothing( temporary, true ); -} - bool VideoTabController::allowSupersampleFiltering() const { + auto p = ovr_settings_wrapper::getBool( + vr::k_pch_SteamVR_Section, + vr::k_pch_SteamVR_AllowSupersampleFiltering_Bool ); + if ( p.first == ovr_settings_wrapper::SettingsError::NoError ) + { + return p.second; + } return m_allowSupersampleFiltering; } @@ -874,7 +774,7 @@ void VideoTabController::setAllowSupersampleFiltering( const bool value, if ( m_allowSupersampleFiltering != value ) { m_allowSupersampleFiltering = value; - vr::VRSettings()->SetBool( + ovr_settings_wrapper::setBool( vr::k_pch_SteamVR_Section, vr::k_pch_SteamVR_AllowSupersampleFiltering_Bool, m_allowSupersampleFiltering ); diff --git a/src/tabcontrollers/VideoTabController.h b/src/tabcontrollers/VideoTabController.h index 06d9037..4a7046a 100644 --- a/src/tabcontrollers/VideoTabController.h +++ b/src/tabcontrollers/VideoTabController.h @@ -4,6 +4,8 @@ #include #include #include +#include "../openvr/ovr_settings_wrapper.h" +#include "../openvr/ovr_overlay_wrapper.h" #include "../utils/FrameRateUtils.h" #include "../settings/settings_object.h" @@ -156,9 +158,6 @@ private: bool keepValue = false ); void resetGain(); - void initSupersampleOverride(); - void initMotionSmoothing(); - void initColorOverlay(); void loadColorOverlay(); @@ -167,6 +166,7 @@ private: void initBrightnessOverlay(); void synchGain( bool setValue = false ); + void synchSteamVR(); std::vector videoProfiles; @@ -204,6 +204,7 @@ public: bool isOverlayMethodActive() const; void initStage1(); + void initStage2(); void eventLoopTick(); void dashboardLoopTick(); diff --git a/src/utils/update_rate.h b/src/utils/update_rate.h index cdfa97e..9a5baa2 100644 --- a/src/utils/update_rate.h +++ b/src/utils/update_rate.h @@ -22,7 +22,7 @@ private: // counter is deliberately set as unsigned so that the program can continue // functioning if the counter should go above INT_MAX (or UINT_MAX in this // case) - unsigned int m_counter; + unsigned int m_counter = 0; }; extern UpdateRate updateRate; diff --git a/ver/versioncheck.json b/ver/versioncheck.json index a4f187c..ca1e6b0 100644 --- a/ver/versioncheck.json +++ b/ver/versioncheck.json @@ -1 +1 @@ -{ "major": 5, "minor": 1, "patch": 2, "updateMessage": "", "optionalMessage": "" } \ No newline at end of file +{ "major": 5, "minor": 2, "patch": 0, "updateMessage": "", "optionalMessage": "" } \ No newline at end of file