From 263759a0df029114ba18c55154349620c6d14118 Mon Sep 17 00:00:00 2001 From: ykeara Date: Sat, 1 Jun 2019 11:02:55 -0500 Subject: [PATCH] Color overlay adjustment feature (#208) * perf graph overlay/checkbox added * added toggle Chaperone action * toggle chaperone non-functional * fixed chaperone toggle action const to once * Added Proximity Sensor Action back-end, not implemented via logic Until fixed by valve * added default WMR controller profile * formated * formated steamvrtabcontroller.h * fixed un-intended change * fixed audio profile Bug w/ changed devices * fixed name being used as param instead of ID * fixed loop logic in saveAudioProfile * audio profile fix WIP defaults OVR integration * fixed profile Saves, delete logic and mirror logic needed * fixed QML format, added TODO message * Fixed Audio Profile Behavior * fixed qml reference error * audiodeviceselector changed qml * Removed some comments * changed Visibility slider Minimum to 30% (steamVR minimum allowed) * fixed mirror/playback same issue * fixed Audio device refresh bug, removed currently un-used proximity logic (commented out) * removed dead code * fixed Manifest install/un-install behavior * removed un-used param * color overlay in prog * video overlay basic functions added * fixed qml errors * fixed init order error and chaperone min init error * fixed duplicate button id issue, init issue * fixed log call w/ manifest * removed commented log lines --- build_scripts/qt/resources.pri | 5 +- src/res/img/video/color.png | Bin 0 -> 1475 bytes src/res/qml/ChaperonePage.qml | 4 +- src/res/qml/ChaperoneWarningsPage.qml | 2 +- src/res/qml/video_page/VideoPage.qml | 6 +- .../brightness/BrightnessGroupBox.qml | 2 +- .../qml/video_page/color/ColorGroupBox.qml | 267 +++++++++++++++ src/tabcontrollers/VideoTabController.cpp | 313 +++++++++++++++++- src/tabcontrollers/VideoTabController.h | 69 +++- src/utils/setup.cpp | 8 +- 10 files changed, 643 insertions(+), 33 deletions(-) create mode 100644 src/res/img/video/color.png create mode 100644 src/res/qml/video_page/color/ColorGroupBox.qml diff --git a/build_scripts/qt/resources.pri b/build_scripts/qt/resources.pri index 7cf19f4..eef9506 100644 --- a/build_scripts/qt/resources.pri +++ b/build_scripts/qt/resources.pri @@ -39,8 +39,9 @@ DISTFILES += \ src/res/qml/audio_page/proximity/* \ src/res/qml/audio_page/push_to_talk/* \ src/res/qml/audio_page/profiles/* \ - src/res/qml/video_page/* \ - src/res/qml/video_page/brightness/* \ + src/res/qml/video_page/* \ + src/res/qml/video_page/brightness/* \ + src/res/qml/video_page/color/* \ src/res/qml/common/* \ src/res/qml/desktop_overlay_page/* \ src/res/qml/desktop_overlay_page/translation_left_right/SteamDesktopTranslationLeftRight.qml \ diff --git a/src/res/img/video/color.png b/src/res/img/video/color.png new file mode 100644 index 0000000000000000000000000000000000000000..be8926f2294ca1532c9c9fc128ccaaa96b6c60e4 GIT binary patch literal 1475 zcmeAS@N?(olHy`uVBq!ia0y~yU=n3uVC>^y0*b6ZpJoE27>k44ofy`glX(f`u%tWs zIx;Y9?C1WI$O`0h7I;J!GcfQS24TkI`72Tw7+51bT^vIy;@)00WMnW9U|#skd~Vi{ z*#}wj848~BGjP>21pHubI3&*?@{eJ`2X=;5dj^d^j1CV+rA9+zG;NG#hta|TYkBw} a@3(;6S>?=W*K&acFN3G6pUXO@geCx-{NlL) literal 0 HcmV?d00001 diff --git a/src/res/qml/ChaperonePage.qml b/src/res/qml/ChaperonePage.qml index de8f3a2..fc9a656 100644 --- a/src/res/qml/ChaperonePage.qml +++ b/src/res/qml/ChaperonePage.qml @@ -527,8 +527,8 @@ MyStackViewPage { Component.onCompleted: { chaperoneVisibilitySlider.value = ChaperoneTabController.boundsVisibility - if(chaperoneVisibilitySlider.value < 0.5){ - chaperoneVisibilitySlider.value = 0.5 + if(chaperoneVisibilitySlider.value < 0.3){ + chaperoneVisibilitySlider.value = 0.3 } var d = ChaperoneTabController.fadeDistance.toFixed(1) diff --git a/src/res/qml/ChaperoneWarningsPage.qml b/src/res/qml/ChaperoneWarningsPage.qml index 32da65f..ba41794 100644 --- a/src/res/qml/ChaperoneWarningsPage.qml +++ b/src/res/qml/ChaperoneWarningsPage.qml @@ -449,7 +449,7 @@ MyStackViewPage { MyTextField { id: velModifierText text: "0.00" - keyBoardUID: 803 + keyBoardUID: 804 Layout.preferredWidth: 100 Layout.leftMargin: 10 horizontalAlignment: Text.AlignHCenter diff --git a/src/res/qml/video_page/VideoPage.qml b/src/res/qml/video_page/VideoPage.qml index 5811d17..fcdc90f 100644 --- a/src/res/qml/video_page/VideoPage.qml +++ b/src/res/qml/video_page/VideoPage.qml @@ -4,6 +4,7 @@ import QtQuick.Layouts 1.3 import ovras.advsettings 1.0 import "../common" import "brightness" +import "color" MyStackViewPage { width: 1200 @@ -12,7 +13,10 @@ MyStackViewPage { content: ColumnLayout { spacing: 18 - BrightnessGroupBox { } + BrightnessGroupBox { + id: brightnessGroupBox} + ColorGroupBox { + id: colorGroupBox} Item { Layout.fillHeight: true diff --git a/src/res/qml/video_page/brightness/BrightnessGroupBox.qml b/src/res/qml/video_page/brightness/BrightnessGroupBox.qml index a1a12ff..c00c576 100644 --- a/src/res/qml/video_page/brightness/BrightnessGroupBox.qml +++ b/src/res/qml/video_page/brightness/BrightnessGroupBox.qml @@ -69,7 +69,7 @@ GroupBox { MyTextField { id: brightnessValueText text: "100%" - keyBoardUID: 301 + keyBoardUID: 901 Layout.preferredWidth: 100 Layout.leftMargin: 10 horizontalAlignment: Text.AlignHCenter diff --git a/src/res/qml/video_page/color/ColorGroupBox.qml b/src/res/qml/video_page/color/ColorGroupBox.qml new file mode 100644 index 0000000..6551925 --- /dev/null +++ b/src/res/qml/video_page/color/ColorGroupBox.qml @@ -0,0 +1,267 @@ +import QtQuick 2.7 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.3 +import ovras.advsettings 1.0 +import "../../common" + +GroupBox { + id: brightnessGroupBox + Layout.fillWidth: true + + label: MyText { + leftPadding: 10 + text: "Color Adjustment" + bottomPadding: -10 + } + background: Rectangle { + color: "transparent" + border.color: "#ffffff" + radius: 8 + } + + ColumnLayout { + anchors.fill: parent + + Rectangle { + color: "#ffffff" + height: 1 + Layout.fillWidth: true + Layout.bottomMargin: 5 + } + + RowLayout { + Layout.fillWidth: true + + MyToggleButton { + id: colorToggle + text: "Toggle On/Off" + onCheckedChanged: { + VideoTabController.setColorEnabled(this.checked, false) } + } + + Item { + Layout.preferredWidth: 150 + } + + MyText { + text: "Opacity:" + horizontalAlignment: Text.AlignRight + Layout.rightMargin: 10 + } + + MySlider { + id: colorOpacitySlider + from: 0.5 + to: 1.0 + stepSize: 0.01 + value: 1.0 + Layout.fillWidth: true + onPositionChanged: { + var val = ((this.position * 100)/2 + 50) + colorOpacityText.text = Math.round(val) + "%" + } + onValueChanged: { + + VideoTabController.setColorOpacityPerc(value.toFixed(2), false) + } + } + + MyTextField { + id: colorOpacityText + text: "100%" + keyBoardUID: 911 + Layout.preferredWidth: 100 + Layout.leftMargin: 10 + horizontalAlignment: Text.AlignHCenter + function onInputEvent(input) { + var val = parseFloat(input) + if (!isNaN(val)) { + if (val < 50) { + val = 50 + } else if (val > 100.0) { + val = 100.0 + } + var v = (val/100).toFixed(2) + colorOpacitySlider.value = v + } + text = Math.round(VideoTabController.colorOpacityPerc * 100) + "%" + } + } + } + + RowLayout { + Layout.fillWidth: true + + MyText { + text: "Red:" + horizontalAlignment: Text.AlignRight + Layout.preferredWidth: 200 + } + + MySlider { + id: colorRedSlider + from: 0.01 + to: 1.0 + stepSize: 0.01 + value: 1.0 + Layout.fillWidth: true + onPositionChanged: { + var val = (this.position * 100) + colorRedText.text = Math.round(val) + "%" + } + onValueChanged: { + + VideoTabController.setColorRed(value.toFixed(2), false) + } + } + + MyTextField { + id: colorRedText + text: "100%" + keyBoardUID: 912 + Layout.preferredWidth: 100 + Layout.leftMargin: 10 + horizontalAlignment: Text.AlignHCenter + function onInputEvent(input) { + var val = parseFloat(input) + if (!isNaN(val)) { + if (val < 5) { + val = 5 + } else if (val > 100.0) { + val = 100.0 + } + var v = (val/100).toFixed(2) + colorRedSlider.value = v + } + text = Math.round(VideoTabController.colorRed * 100) + "%" + } + } + } + + RowLayout { + Layout.fillWidth: true + + MyText { + text: "Green:" + horizontalAlignment: Text.AlignRight + Layout.preferredWidth: 200 + } + + MySlider { + id: colorGreenSlider + from: 0.01 + to: 1.0 + stepSize: 0.01 + value: 1.0 + Layout.fillWidth: true + onPositionChanged: { + var val = (this.position * 100) + colorGreenText.text = Math.round(val) + "%" + } + onValueChanged: { + + VideoTabController.setColorGreen(value.toFixed(2), false) + } + } + + MyTextField { + id: colorGreenText + text: "100%" + keyBoardUID: 913 + Layout.preferredWidth: 100 + Layout.leftMargin: 10 + horizontalAlignment: Text.AlignHCenter + function onInputEvent(input) { + var val = parseFloat(input) + if (!isNaN(val)) { + if (val < 5) { + val = 5 + } else if (val > 100.0) { + val = 100.0 + } + var v = (val/100).toFixed(2) + colorGreenSlider.value = v + } + text = Math.round(VideoTabController.colorGreen * 100) + "%" + } + } + } + + RowLayout { + Layout.fillWidth: true + + MyText { + text: "Blue:" + horizontalAlignment: Text.AlignRight + Layout.preferredWidth: 200 + } + + MySlider { + id: colorBlueSlider + from: 0.01 + to: 1.0 + stepSize: 0.01 + value: 1.0 + Layout.fillWidth: true + onPositionChanged: { + var val = (this.position * 100) + colorBlueText.text = Math.round(val) + "%" + } + onValueChanged: { + + VideoTabController.setColorBlue(value.toFixed(2), false) + } + } + + MyTextField { + id: colorBlueText + text: "100%" + keyBoardUID: 914 + Layout.preferredWidth: 100 + Layout.leftMargin: 10 + horizontalAlignment: Text.AlignHCenter + function onInputEvent(input) { + var val = parseFloat(input) + if (!isNaN(val)) { + if (val < 5) { + val = 5 + } else if (val > 100.0) { + val = 100.0 + } + var v = (val/100).toFixed(2) + colorBlueSlider.value = v + } + text = Math.round(VideoTabController.colorBlue * 100) + "%" + } + } + } + } + + Component.onCompleted: { + colorOpacitySlider.value = VideoTabController.colorOpacityPerc + colorToggle.checked = VideoTabController.colorEnabled + colorRedSlider.value = VideoTabController.colorRed + colorGreenSlider.value = VideoTabController.colorGreen + colorBlueSlider.value = VideoTabController.colorBlue + } + + Connections { + target: VideoTabController + + onColorOpacityPercChanged: { + colorOpacitySlider.value = VideoTabController.colorOpacityPerc + } + onColorEnabledChanged: { + colorToggle.checked = VideoTabController.colorEnabled + } + onColorRedChanged:{ + colorRedSlider.value = VideoTabController.colorRed + } + onColorGreenChanged:{ + colorGreenSlider.value = VideoTabController.colorGreen + } + onColorBlueChanged:{ + colorBlueSlider.value = VideoTabController.colorBlue + } + } +} diff --git a/src/tabcontrollers/VideoTabController.cpp b/src/tabcontrollers/VideoTabController.cpp index dadb48a..23800b5 100644 --- a/src/tabcontrollers/VideoTabController.cpp +++ b/src/tabcontrollers/VideoTabController.cpp @@ -6,16 +6,25 @@ namespace advsettings { -void VideoTabController::initStage1() {} +void VideoTabController::initStage1() +{ + initBrightnessOverlay(); + initColorOverlay(); + m_overlayInit = true; + reloadVideoConfig(); +} void VideoTabController::initStage2( OverlayController* var_parent, QQuickWindow* var_widget ) { this->parent = var_parent; this->widget = var_widget; +} +void VideoTabController::initBrightnessOverlay() +{ std::string notifKey = std::string( application_strings::applicationKey ) - + ".dimnotification"; + + ".brightnessoverlay"; vr::VROverlayError overlayError = vr::VROverlay()->CreateOverlay( notifKey.c_str(), notifKey.c_str(), &m_brightnessOverlayHandle ); @@ -40,18 +49,57 @@ void VideoTabController::initStage2( OverlayController* var_parent, } else { - LOG( ERROR ) << "Could not find notification icon \"" + LOG( ERROR ) << "Could not find brightness overlay \"" << video_keys::k_brightnessOverlayFilename << "\""; } } else { - LOG( ERROR ) << "Could not create dimmer notification overlay: " + LOG( ERROR ) << "Could not create brightness overlay: " << vr::VROverlay()->GetOverlayErrorNameFromEnum( overlayError ); } +} +void VideoTabController::initColorOverlay() +{ + std::string notifKey + = std::string( application_strings::applicationKey ) + ".coloroverlay"; - reloadVideoConfig(); + vr::VROverlayError overlayError = vr::VROverlay()->CreateOverlay( + notifKey.c_str(), notifKey.c_str(), &m_colorOverlayHandle ); + if ( overlayError == vr::VROverlayError_None ) + { + const auto notifIconPath = paths::binaryDirectoryFindFile( + video_keys::k_colorOverlayFilename ); + if ( notifIconPath.has_value() ) + { + vr::VROverlay()->SetOverlayFromFile( m_colorOverlayHandle, + notifIconPath->c_str() ); + vr::VROverlay()->SetOverlayWidthInMeters( m_colorOverlayHandle, + k_overlayWidth ); + // position it just slightly further out so we don't have to worry + // about render order. + vr::HmdMatrix34_t notificationTransform + = { { { 1.0f, 0.0f, 0.0f, 0.00f }, + { 0.0f, 1.0f, 0.0f, 0.00f }, + { 0.0f, 0.0f, 1.0f, ( k_hmdDistance - 0.01f ) } } }; + vr::VROverlay()->SetOverlayTransformTrackedDeviceRelative( + m_colorOverlayHandle, + vr::k_unTrackedDeviceIndex_Hmd, + ¬ificationTransform ); + } + else + { + LOG( ERROR ) << "Could not find Base color overlay: \"" + << video_keys::k_colorOverlayFilename << "\""; + } + } + else + { + LOG( ERROR ) << "Could not create color overlay: " + << vr::VROverlay()->GetOverlayErrorNameFromEnum( + overlayError ); + } } void VideoTabController::eventLoopTick() {} @@ -62,10 +110,21 @@ void VideoTabController::reloadVideoConfig() settings->beginGroup( getSettingsName() ); setBrightnessEnabled( settings->value( "brightnessEnabled", false ).toBool(), true ); - m_opacityValue = settings->value( "opacityValue", 0.0f ).toFloat(); + m_brightnessOpacityValue + = settings->value( "brightnessOpacityValue", 0.0f ).toFloat(); m_brightnessValue = settings->value( "brightnessValue", 1.0f ).toFloat(); + setColorEnabled( settings->value( "colorEnabled", false ).toBool(), true ); + m_colorOpacity = settings->value( "colorOpacity", 0.0f ).toFloat(); + m_colorOpacityPerc = settings->value( "colorOpacityPerc", 1.0f ).toFloat(); + setColorRed( settings->value( "colorRed", 0.0f ).toFloat() ); + setColorGreen( settings->value( "colorGreen", 0.0f ).toFloat() ); + setColorBlue( settings->value( "colorBlue", 0.0f ).toFloat() ); settings->endGroup(); - setOpacityValue(); + LOG( INFO ) << "bright opacityValue: " << m_brightnessOpacityValue + << " REd value is: " << m_colorRed; + setBrightnessOpacityValue(); + loadColorOverlay(); + settings->sync(); } void VideoTabController::saveVideoConfig() @@ -73,14 +132,21 @@ void VideoTabController::saveVideoConfig() auto settings = OverlayController::appSettings(); settings->beginGroup( getSettingsName() ); settings->setValue( "brightnessEnabled", brightnessEnabled() ); - settings->setValue( "opacityValue", opacityValue() ); + settings->setValue( "brightnessOpacityValue", brightnessOpacityValue() ); settings->setValue( "brightnessValue", brightnessValue() ); + settings->setValue( "colorEnabled", colorEnabled() ); + settings->setValue( "colorOpacity", colorOpacity() ); + settings->setValue( "colorOpacityPerc", colorOpacityPerc() ); + settings->setValue( "colorRed", colorRed() ); + settings->setValue( "colorGreen", colorGreen() ); + settings->setValue( "colorBlue", colorBlue() ); settings->endGroup(); + settings->sync(); } -float VideoTabController::opacityValue() const +float VideoTabController::brightnessOpacityValue() const { - return m_opacityValue; + return m_brightnessOpacityValue; } float VideoTabController::brightnessValue() const @@ -130,12 +196,12 @@ void VideoTabController::setBrightnessValue( float percvalue, bool notify ) float realvalue = static_cast( std::pow( static_cast( 1.0f - percvalue ), 1 / 3. ) ); - if ( realvalue != m_opacityValue ) + if ( realvalue != m_brightnessOpacityValue ) { m_brightnessValue = percvalue; if ( realvalue <= 1.0f && realvalue >= 0.0f ) { - m_opacityValue = realvalue; + m_brightnessOpacityValue = realvalue; vr::VROverlayError overlayError = vr::VROverlay()->SetOverlayAlpha( m_brightnessOverlayHandle, realvalue ); if ( overlayError != vr::VROverlayError_None ) @@ -150,7 +216,7 @@ void VideoTabController::setBrightnessValue( float percvalue, bool notify ) else { LOG( WARNING ) << "alpha value is invalid setting to 1.0"; - m_opacityValue = 0.0f; + m_brightnessOpacityValue = 0.0f; } if ( notify ) @@ -160,10 +226,10 @@ void VideoTabController::setBrightnessValue( float percvalue, bool notify ) } } -void VideoTabController::setOpacityValue() +void VideoTabController::setBrightnessOpacityValue() { vr::VROverlayError overlayError = vr::VROverlay()->SetOverlayAlpha( - m_brightnessOverlayHandle, m_opacityValue ); + m_brightnessOverlayHandle, m_brightnessOpacityValue ); if ( overlayError != vr::VROverlayError_None ) { LOG( ERROR ) << "Could not set alpha: " @@ -172,4 +238,221 @@ void VideoTabController::setOpacityValue() } emit brightnessValueChanged( m_brightnessValue ); } + +/* + * ------------------------- + * Color Overlay + * ------------------------- + */ + +// getters +bool VideoTabController::colorEnabled() const +{ + return m_colorEnabled; +} + +float VideoTabController::colorOpacity() const +{ + return m_colorOpacity; +} + +float VideoTabController::colorOpacityPerc() const +{ + return m_colorOpacityPerc; +} + +float VideoTabController::colorRed() const +{ + return m_colorRed; +} + +float VideoTabController::colorGreen() const +{ + return m_colorGreen; +} + +float VideoTabController::colorBlue() const +{ + return m_colorBlue; +} + +// setters +void VideoTabController::setColorEnabled( bool value, bool notify ) +{ + if ( value != m_colorEnabled ) + { + m_colorEnabled = value; + auto overlayHandle = getColorOverlayHandle(); + if ( value ) + { + if ( overlayHandle != vr::k_ulOverlayHandleInvalid ) + { + vr::VROverlay()->ShowOverlay( getColorOverlayHandle() ); + LOG( INFO ) << "Color Overlay toggled on"; + } + } + else + { + if ( overlayHandle != vr::k_ulOverlayHandleInvalid ) + { + vr::VROverlay()->HideOverlay( getColorOverlayHandle() ); + LOG( INFO ) << "Color Overlay toggled off"; + } + } + saveVideoConfig(); + if ( notify ) + { + emit colorEnabledChanged( value ); + } + } +} + +void VideoTabController::setColorOpacity( float value, bool notify ) +{ + if ( value != m_colorOpacity ) + { + vr::VROverlayError overlayError = vr::VROverlay()->SetOverlayAlpha( + m_colorOverlayHandle, m_colorOpacity ); + m_colorOpacity = value; + if ( overlayError != vr::VROverlayError_None ) + { + LOG( ERROR ) << "Could not set alpha for color overlay: " + << vr::VROverlay()->GetOverlayErrorNameFromEnum( + overlayError ); + } + saveVideoConfig(); + if ( notify ) + { + emit colorOpacityChanged( m_colorOpacity ); + } + } +} + +void VideoTabController::setColorRed( float value, bool notify ) +{ + if ( value != m_colorRed ) + { + m_colorRed = value; + vr::VROverlayError overlayError = vr::VROverlay()->SetOverlayColor( + m_colorOverlayHandle, m_colorRed, m_colorGreen, m_colorBlue ); + if ( overlayError != vr::VROverlayError_None ) + { + LOG( ERROR ) << "Could not set Red for color overlay: " + << vr::VROverlay()->GetOverlayErrorNameFromEnum( + overlayError ); + } + saveVideoConfig(); + if ( notify ) + { + emit colorRedChanged( m_colorRed ); + } + } +} + +void VideoTabController::setColorGreen( float value, bool notify ) +{ + if ( value != m_colorGreen ) + { + m_colorGreen = value; + vr::VROverlayError overlayError = vr::VROverlay()->SetOverlayColor( + m_colorOverlayHandle, m_colorRed, m_colorGreen, m_colorBlue ); + if ( overlayError != vr::VROverlayError_None ) + { + LOG( ERROR ) << "Could not set Green for color overlay: " + << vr::VROverlay()->GetOverlayErrorNameFromEnum( + overlayError ); + } + saveVideoConfig(); + if ( notify ) + { + emit colorGreenChanged( m_colorGreen ); + } + } +} + +void VideoTabController::setColorBlue( float value, bool notify ) +{ + if ( value != m_colorBlue ) + { + m_colorBlue = value; + vr::VROverlayError overlayError = vr::VROverlay()->SetOverlayColor( + m_colorOverlayHandle, m_colorRed, m_colorGreen, m_colorBlue ); + if ( overlayError != vr::VROverlayError_None ) + { + LOG( ERROR ) << "Could not set Blue for color overlay: " + << vr::VROverlay()->GetOverlayErrorNameFromEnum( + overlayError ); + } + saveVideoConfig(); + if ( notify ) + { + emit colorBlueChanged( m_colorBlue ); + } + } +} + +void VideoTabController::loadColorOverlay() +{ + vr::VROverlayError overlayError = vr::VROverlay()->SetOverlayColor( + m_colorOverlayHandle, m_colorRed, m_colorGreen, m_colorBlue ); + if ( overlayError != vr::VROverlayError_None ) + { + LOG( ERROR ) << "Could not set Colors for color overlay: " + << vr::VROverlay()->GetOverlayErrorNameFromEnum( + overlayError ); + } + + overlayError = vr::VROverlay()->SetOverlayAlpha( m_colorOverlayHandle, + m_colorOpacity ); + if ( overlayError != vr::VROverlayError_None ) + { + LOG( ERROR ) << "Could not set alpha: " + << vr::VROverlay()->GetOverlayErrorNameFromEnum( + overlayError ); + } +} + +void VideoTabController::setColorOpacityPerc( float percvalue, bool notify ) +{ + // This takes the Perceived value, and converts it to allow more accurate + // linear positioning. (human perception logarithmic) + + // clamp the "percieved" value to 50% this is to ensure useability. + if ( percvalue <= 0.5f ) + { + percvalue = 0.5f; + } + float realvalue = static_cast( + std::pow( static_cast( 1.0f - percvalue ), 0.5555f ) ); + + if ( realvalue != m_colorOpacity ) + { + m_colorOpacityPerc = percvalue; + if ( realvalue <= 1.0f && realvalue >= 0.0f ) + { + m_colorOpacity = realvalue; + vr::VROverlayError overlayError = vr::VROverlay()->SetOverlayAlpha( + m_colorOverlayHandle, realvalue ); + if ( overlayError != vr::VROverlayError_None ) + { + LOG( ERROR ) << "Could not set alpha of color overlay: " + << vr::VROverlay()->GetOverlayErrorNameFromEnum( + overlayError ); + } + // only saves if opacity Value is valid. [1-0] + saveVideoConfig(); + } + else + { + LOG( WARNING ) << "alpha value is invalid setting to 1.0"; + m_brightnessOpacityValue = 0.0f; + } + + if ( notify ) + { + emit brightnessValueChanged( percvalue ); + } + } +} + } // namespace advsettings diff --git a/src/tabcontrollers/VideoTabController.h b/src/tabcontrollers/VideoTabController.h index 6fede2b..f53f4d7 100644 --- a/src/tabcontrollers/VideoTabController.h +++ b/src/tabcontrollers/VideoTabController.h @@ -10,6 +10,7 @@ class QQuickWindow; namespace video_keys { constexpr auto k_brightnessOverlayFilename = "/res/img/video/dimmer.png"; +constexpr auto k_colorOverlayFilename = "/res/img/video/color.png"; } // namespace video_keys @@ -25,24 +26,54 @@ class VideoTabController : public QObject setBrightnessEnabled NOTIFY brightnessEnabledChanged ) Q_PROPERTY( float brightnessValue READ brightnessValue WRITE setBrightnessValue NOTIFY brightnessValueChanged ) + Q_PROPERTY( bool colorEnabled READ colorEnabled WRITE setColorEnabled NOTIFY + colorEnabledChanged ) + Q_PROPERTY( float colorOpacity READ colorOpacity WRITE setColorOpacity + NOTIFY colorOpacityChanged ) + Q_PROPERTY( float colorOpacityPerc READ colorOpacityPerc WRITE + setColorOpacityPerc NOTIFY colorOpacityPercChanged ) + Q_PROPERTY( + float colorRed READ colorRed WRITE setColorRed NOTIFY colorRedChanged ) + Q_PROPERTY( float colorGreen READ colorGreen WRITE setColorGreen NOTIFY + colorGreenChanged ) + Q_PROPERTY( float colorBlue READ colorBlue WRITE setColorBlue NOTIFY + colorBlueChanged ) private: // how far away the overlay is, any OVERLAY closer will not be dimmed. const float k_hmdDistance = -0.15f; - // how wide overlay is, Increase this value if edges of view are not dimmed. + // how wide overlay is, Increase this value if edges of view are not + // dimmed. const float k_overlayWidth = 1.0f; OverlayController* parent; QQuickWindow* widget; vr::VROverlayHandle_t m_brightnessOverlayHandle = vr::k_ulOverlayHandleInvalid; - float m_opacityValue = 0.0f; + + vr::VROverlayHandle_t m_colorOverlayHandle = vr::k_ulOverlayHandleInvalid; + + float m_brightnessOpacityValue = 0.0f; float m_brightnessValue = 1.0f; bool m_brightnessEnabled = false; + // color member vars + bool m_colorEnabled = false; + float m_colorOpacity = 1.0f; + float m_colorOpacityPerc = 0.0f; + float m_colorRed = 0.0f; + float m_colorBlue = 0.0f; + float m_colorGreen = 0.0f; + bool m_overlayInit = false; + void reloadVideoConfig(); void saveVideoConfig(); - void setOpacityValue(); + void setBrightnessOpacityValue(); + + void initBrightnessOverlay(); + void initColorOverlay(); + + void loadColorOverlay(); QString getSettingsName() { @@ -54,12 +85,25 @@ private: return m_brightnessOverlayHandle; } + vr::VROverlayHandle_t getColorOverlayHandle() + { + return m_colorOverlayHandle; + } + public: - float opacityValue() const; + float brightnessOpacityValue() const; // inverse of brightnessValue float brightnessValue() const; bool brightnessEnabled() const; + // Color overlay Getters + bool colorEnabled() const; + float colorOpacity() const; + float colorRed() const; + float colorGreen() const; + float colorBlue() const; + float colorOpacityPerc() const; + void initStage1(); void initStage2( OverlayController* var_parent, QQuickWindow* var_widget ); void eventLoopTick(); @@ -68,9 +112,24 @@ public slots: void setBrightnessEnabled( bool value, bool notify = true ); void setBrightnessValue( float percvalue, bool notify = true ); + // Color overlay Setters + void setColorEnabled( bool value, bool notify = true ); + void setColorOpacity( float value, bool notify = true ); + void setColorRed( float value, bool notify = true ); + void setColorGreen( float value, bool notify = true ); + void setColorBlue( float value, bool notify = true ); + void setColorOpacityPerc( float value, bool notify = true ); + signals: void brightnessEnabledChanged( bool value ); void brightnessValueChanged( float value ); + + void colorEnabledChanged( bool value ); + void colorOpacityChanged( float value ); + void colorRedChanged( float value ); + void colorGreenChanged( float value ); + void colorBlueChanged( float value ); + void colorOpacityPercChanged( float value ); }; -} // namespace advsettings \ No newline at end of file +} // namespace advsettings diff --git a/src/utils/setup.cpp b/src/utils/setup.cpp index 4b9b593..995c592 100644 --- a/src/utils/setup.cpp +++ b/src/utils/setup.cpp @@ -120,12 +120,8 @@ void installApplicationManifest( const std::string manifestPath ) if ( vr::VRApplications()->IsApplicationInstalled( application_strings::applicationKey ) ) { - LOG( ERROR ) << "Manifest Is already Installed for Key " - << application_strings::applicationKey; - LOG( ERROR ) << "You may have installed Advanced Settings in another " - "directory please remove it OR" - " manually delete the manifest install in in Steam " - "install at Steam\\config\\appconfig.json"; + LOG( INFO ) << "Manifest Is already Installed for Key " + << application_strings::applicationKey; } else {