From 15fa0ac47aec1369defbab066b049179cf783535 Mon Sep 17 00:00:00 2001 From: ykeara Date: Wed, 9 Jan 2019 20:32:39 -0600 Subject: [PATCH] fixed naming bug in QML and formatted/cleaned up --- src/res/qml/SteamVRPage.qml | 97 +--------------- src/tabcontrollers/SteamVRTabController.cpp | 122 +++++++------------- src/tabcontrollers/SteamVRTabController.h | 10 +- 3 files changed, 45 insertions(+), 184 deletions(-) diff --git a/src/res/qml/SteamVRPage.qml b/src/res/qml/SteamVRPage.qml index 5619147..77abb3d 100644 --- a/src/res/qml/SteamVRPage.qml +++ b/src/res/qml/SteamVRPage.qml @@ -239,75 +239,6 @@ MyStackViewPage { } } } - /* - RowLayout { - spacing: 16 - - MyText { - text: "Compositor Render Target Multiplier*:" - Layout.preferredWidth: 450 - Layout.rightMargin: 12 - } - - MyPushButton2 { - text: "-" - Layout.preferredWidth: 40 - onClicked: { - steamvrCompositorSupersamplingSlider.decrease() - } - } - - MySlider { - id: steamvrCompositorSupersamplingSlider - from: 0.1 - to: 2 - stepSize: 0.1 - value: 1.0 - snapMode: Slider.SnapAlways - Layout.fillWidth: true - onPositionChanged: { - var val = this.from + ( this.position * (this.to - this.from)) - steamvrCompositorSupersamplingText.text = val.toFixed(1) - } - onValueChanged: { - SteamVRTabController.setCompositorSuperSampling(this.value.toFixed(1), false) - } - } - - MyPushButton2 { - text: "+" - Layout.preferredWidth: 40 - onClicked: { - steamvrCompositorSupersamplingSlider.increase() - } - } - - - MyTextField { - id: steamvrCompositorSupersamplingText - text: "0.0" - keyBoardUID: 402 - Layout.preferredWidth: 100 - Layout.leftMargin: 10 - horizontalAlignment: Text.AlignHCenter - function onInputEvent(input) { - var val = parseFloat(input) - if (!isNaN(val)) { - if (val < 0.1) { - val = 0.1 - } - var v = val.toFixed(1) - if (v <= steamvrCompositorSupersamplingSlider.to) { - steamvrCompositorSupersamplingSlider.value = v - } else { - SteamVRTabController.setCompositorSuperSampling(v, false) - } - } - text = SteamVRTabController.compositorSuperSampling.toFixed(1) - } - } - } - */ MyToggleButton { id: steamvrAllowSupersampleFilteringToggle text: "Enable Advanced Supersample Filtering" @@ -362,12 +293,6 @@ MyStackViewPage { if (s1 <= steamvrSupersamplingSlider.to) { steamvrSupersamplingSlider.value = s1 } - steamvrSupersamplingText.text = s1 - var s2 = SteamVRTabController.compositorSuperSampling.toFixed(1) - if (s2 <= steamvrCompositorSupersamplingSlider.to) { - steamvrCompositorSupersamplingSlider.value = s2 - } - steamvrCompositorSupersamplingText.text = s2 steamvrAllowSupersampleFilteringToggle.checked = SteamVRTabController.allowSupersampleFiltering steamvrMotionSmoothingToggle.checked = SteamVRTabController.motionSmoothing reloadSteamVRProfiles() @@ -382,32 +307,12 @@ MyStackViewPage { } steamvrSupersamplingText.text = s1 } - /* - onCompositorSuperSamplingChanged: { - var s2 = SteamVRTabController.compositorSuperSampling.toFixed(1) - if (s2 <= steamvrCompositorSupersamplingSlider.to && Math.abs(steamvrCompositorSupersamplingSlider.value-s2) > 0.08) { - steamvrCompositorSupersamplingSlider.value = s2 - } - steamvrCompositorSupersamplingText.text = s2 - } - */ onAllowSupersampleFilteringChanged: { steamvrAllowSupersampleFilteringToggle.checked = SteamVRTabController.allowSupersampleFiltering } - /* - onAllowInterleavedReprojectionChanged: { - steamvrAllowInterleavedReprojectionToggle.checked = SteamVRTabController.allowInterleavedReprojection - } - onAllowAsyncReprojectionChanged: { - steamvrAllowAsyncReprojectionToggle.checked = SteamVRTabController.allowAsyncReprojection - } - onForceReprojectionChanged: { - steamvrForceReprojectionToggle.checked = SteamVRTabController.forceReprojection - } - */ onMotionSmoothingChanged: { - steamvrMotionSmoothingToggle.checked = SteamVRTabController.allowMotionSmoothing + steamvrMotionSmoothingToggle.checked = SteamVRTabController.motionSmoothing } onSteamVRProfilesUpdated: { diff --git a/src/tabcontrollers/SteamVRTabController.cpp b/src/tabcontrollers/SteamVRTabController.cpp index 93dd14a..8427a7e 100644 --- a/src/tabcontrollers/SteamVRTabController.cpp +++ b/src/tabcontrollers/SteamVRTabController.cpp @@ -29,9 +29,10 @@ namespace advsettings // vrsettings_steamvr_allowInterleavedReprojection = // "allowInterleavedReprojection"; -//static const char* vrsettings_steamvr_supersampleScale = "supersampleScale"; -//static const char* vrsettings_steamvr_allowSupersampleFiltering = "allowSupersampleFiltering"; -//static const char* vrsettings_compositor_category = "compositor"; +// static const char* vrsettings_steamvr_supersampleScale = "supersampleScale"; +// static const char* vrsettings_steamvr_allowSupersampleFiltering = +// "allowSupersampleFiltering"; static const char* +// vrsettings_compositor_category = "compositor"; void SteamVRTabController::initStage1() { @@ -139,16 +140,19 @@ Q_INVOKABLE QString return QString::fromStdString( steamvrProfiles[index].profileName ); } } -//TODO DISC does it make any sense to check these settings once every ~ 1second? +// TODO DISC does it make any sense to check these settings once every ~ +// 1second. primary purpose seems to be to re-sync settings if changed via other +// means? void SteamVRTabController::eventLoopTick() { if ( settingsUpdateCounter >= 50 ) { vr::EVRSettingsError vrSettingsError; - auto ss - = vr::VRSettings()->GetFloat( vr::k_pch_SteamVR_Section, - vr::k_pch_SteamVR_SupersampleScale_Float, - &vrSettingsError ); + // 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 \"" @@ -170,10 +174,11 @@ void SteamVRTabController::eventLoopTick() << 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, + vr::k_pch_SteamVR_AllowSupersampleFiltering_Bool, &vrSettingsError ); if ( vrSettingsError != vr::VRSettingsError_None ) { @@ -185,23 +190,23 @@ void SteamVRTabController::eventLoopTick() } setAllowSupersampleFiltering( sf ); - //Checks if Motion smoothing setting can be read - 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); + // 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 ); settingsUpdateCounter = 0; - } else { @@ -225,7 +230,7 @@ void SteamVRTabController::setSuperSampling( float value, bool notify ) << " => " << value; m_superSampling = value; vr::VRSettings()->SetFloat( vr::k_pch_SteamVR_Section, - vr::k_pch_SteamVR_SupersampleScale_Float, + vr::k_pch_SteamVR_SupersampleScale_Float, m_superSampling ); vr::VRSettings()->Sync(); if ( notify ) @@ -234,46 +239,11 @@ void SteamVRTabController::setSuperSampling( float value, bool notify ) } } } -/* -void SteamVRTabController::setCompositorSuperSampling( float value, - bool notify ) -{ - bool override = false; - if ( value <= 0.01f ) - { - LOG( WARNING ) << "Encountered a compositor supersampling value <= " - "0.01, setting supersampling to 1.0"; - value = 1.0f; - override = true; - } - if ( override || m_compositorSuperSampling != value ) - { - LOG( DEBUG ) << "Compositor supersampling value changed: " - << m_compositorSuperSampling << " => " << value; - m_compositorSuperSampling = value; - vr::VRSettings()->SetFloat( - vrsettings_compositor_category, - vr::k_pch_SteamVR_RenderTargetMultiplier_Float, - m_compositorSuperSampling ); - vr::VRSettings()->Sync(); - if ( notify ) - { - emit compositorSuperSamplingChanged( m_compositorSuperSampling ); - } - } -} -*/ float SteamVRTabController::superSampling() const { return m_superSampling; } -/* -float SteamVRTabController::compositorSuperSampling() const -{ - return m_compositorSuperSampling; -} -*/ bool SteamVRTabController::motionSmoothing() const { @@ -355,9 +325,10 @@ void SteamVRTabController::setAllowSupersampleFiltering( bool value, if ( m_allowSupersampleFiltering != value ) { m_allowSupersampleFiltering = value; - vr::VRSettings()->SetBool( vr::k_pch_SteamVR_Section, - vr::k_pch_SteamVR_AllowSupersampleFiltering_Bool, - m_allowSupersampleFiltering ); + vr::VRSettings()->SetBool( + vr::k_pch_SteamVR_Section, + vr::k_pch_SteamVR_AllowSupersampleFiltering_Bool, + m_allowSupersampleFiltering ); vr::VRSettings()->Sync(); if ( notify ) { @@ -371,37 +342,22 @@ void SteamVRTabController::reset() { vr::EVRSettingsError vrSettingsError; - vr::VRSettings()->RemoveKeyInSection( vr::k_pch_SteamVR_Section, - vr::k_pch_SteamVR_SupersampleScale_Float, - &vrSettingsError ); - if ( vrSettingsError != vr::VRSettingsError_None ) - { - LOG( WARNING ) << "Could not remove \"" - << vr::k_pch_SteamVR_SupersampleScale_Float << "\" setting: " - << vr::VRSettings()->GetSettingsErrorNameFromEnum( - vrSettingsError ); - } - - /* - setCompositorSuperSampling( 1.0f ); // Is not in default.vrsettings yet vr::VRSettings()->RemoveKeyInSection( - vrsettings_compositor_category, - vr::k_pch_SteamVR_RenderTargetMultiplier_Float, + vr::k_pch_SteamVR_Section, + vr::k_pch_SteamVR_SupersampleScale_Float, &vrSettingsError ); if ( vrSettingsError != vr::VRSettingsError_None ) { LOG( WARNING ) << "Could not remove \"" - << vrsettings_compositor_category - << "::" << vr::k_pch_SteamVR_RenderTargetMultiplier_Float + << vr::k_pch_SteamVR_SupersampleScale_Float << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum( vrSettingsError ); } - */ vr::VRSettings()->RemoveKeyInSection( vr::k_pch_SteamVR_Section, - vr::k_pch_SteamVR_AllowSupersampleFiltering_Bool, + vr::k_pch_SteamVR_AllowSupersampleFiltering_Bool, &vrSettingsError ); if ( vrSettingsError != vr::VRSettingsError_None ) { diff --git a/src/tabcontrollers/SteamVRTabController.h b/src/tabcontrollers/SteamVRTabController.h index 887d2b4..a6c2220 100644 --- a/src/tabcontrollers/SteamVRTabController.h +++ b/src/tabcontrollers/SteamVRTabController.h @@ -31,7 +31,7 @@ class SteamVRTabController : public QObject /*Q_PROPERTY( float compositorSuperSampling READ compositorSuperSampling WRITE setCompositorSuperSampling NOTIFY compositorSuperSamplingChanged ) - */ + */ Q_PROPERTY( bool motionSmoothing READ motionSmoothing WRITE setMotionSmoothing NOTIFY motionSmoothingChanged ) @@ -44,7 +44,7 @@ private: QQuickWindow* widget; float m_superSampling = 1.0; - //float m_compositorSuperSampling = 1.0; + // float m_compositorSuperSampling = 1.0; bool m_motionSmoothing = true; bool m_allowSupersampleFiltering = true; @@ -61,7 +61,7 @@ public: void eventLoopTick(); float superSampling() const; - //float compositorSuperSampling() const; + // float compositorSuperSampling() const; bool motionSmoothing() const; bool allowSupersampleFiltering() const; @@ -73,7 +73,7 @@ public: public slots: void setSuperSampling( float value, bool notify = true ); - // void setCompositorSuperSampling( float value, bool notify = true ); + // void setCompositorSuperSampling( float value, bool notify = true ); void setMotionSmoothing( bool value, bool notify = true ); void setAllowSupersampleFiltering( bool value, bool notify = true ); @@ -89,7 +89,7 @@ public slots: signals: void superSamplingChanged( float value ); - //void compositorSuperSamplingChanged( float value ); + // void compositorSuperSamplingChanged( float value ); void motionSmoothingChanged( bool value ); void allowSupersampleFilteringChanged( bool value );