Re-Add color overlay (#311)

* fixed Chaperone toggle, toggle state on launch

* made update rates based on variable frame rate assuming 90 default

* added overlay color back in

* fixed opacity value not synching

* updated to ovr 1.8.19

* fixed license issue

* rolled back ovr update

* fixed overlay toggle state, formatting, and clamped max opacity to .85%
This commit is contained in:
ykeara
2019-11-08 14:45:26 -06:00
committed by GitHub
parent b148a3d6de
commit 05c12cd4a0
24 changed files with 866 additions and 105 deletions
+3 -1
View File
@@ -20,6 +20,8 @@ void AudioTabController::initStage1()
audioManager.reset( new AudioManagerDummy() );
#endif
audioManager->init( this );
m_k_audioSettingsUpdateCounter
= utils::adjustUpdateRate( k_audioSettingsUpdateCounter );
m_playbackDevices = audioManager->getPlaybackDevices();
m_recordingDevices = audioManager->getRecordingDevices();
findPlaybackDeviceIndex( audioManager->getPlaybackDevId(), false );
@@ -165,7 +167,7 @@ void AudioTabController::eventLoopTick()
return;
}
if ( settingsUpdateCounter >= k_audioSettingsUpdateCounter )
if ( settingsUpdateCounter >= m_k_audioSettingsUpdateCounter )
{
vr::EVRSettingsError vrSettingsError;
char mirrorDeviceId[1024];
+3
View File
@@ -4,6 +4,7 @@
#include "AudioManager.h"
#include "PttController.h"
#include <memory>
#include "../utils/FrameRateUtils.h"
class QQuickWindow;
// application namespace
@@ -73,6 +74,8 @@ private:
bool m_micReversePtt = false;
bool m_isDefaultAudioProfile = false;
unsigned int m_k_audioSettingsUpdateCounter = 90;
int m_defaultProfileIndex = -1;
unsigned settingsUpdateCounter = 0;
@@ -35,8 +35,15 @@ void ChaperoneTabController::initStage1()
m_fadeDistanceRemembered
= settings->value( "fadeDistanceRemembered", 0.5f ).toFloat();
settings->endGroup();
reloadChaperoneProfiles();
if ( m_disableChaperone )
{
setFadeDistance( 0.0f, true );
}
reloadChaperoneProfiles();
m_k_chaperoneSettingsUpdateCounter
= utils::adjustUpdateRate( k_chaperoneSettingsUpdateCounter );
eventLoopTick( nullptr );
}
@@ -638,7 +645,7 @@ void ChaperoneTabController::eventLoopTick(
}
}
if ( settingsUpdateCounter >= k_chaperoneSettingsUpdateCounter )
if ( settingsUpdateCounter >= m_k_chaperoneSettingsUpdateCounter )
{
if ( parent->isDashboardVisible() )
{
@@ -7,6 +7,7 @@
#include <thread>
#include <openvr.h>
#include <cmath>
#include "../utils/FrameRateUtils.h"
class QQuickWindow;
// application namespace
@@ -170,6 +171,8 @@ private:
int m_updateTicksChaperoneReload = 0;
unsigned int m_k_chaperoneSettingsUpdateCounter = 101;
vr::VRActionHandle_t m_rightActionHandle;
vr::VRActionHandle_t m_leftActionHandle;
vr::VRInputValueHandle_t m_leftInputHandle;
@@ -165,6 +165,8 @@ void MoveCenterTabController::initStage1()
}
settings->endGroup();
reloadOffsetProfiles();
m_k_moveCenterSettingsUpdateCounter
= utils::adjustUpdateRate( k_moveCenterSettingsUpdateCounter );
m_lastDragUpdateTimePoint = std::chrono::steady_clock::now();
m_lastGravityUpdateTimePoint = std::chrono::steady_clock::now();
}
@@ -5,6 +5,7 @@
#include <openvr.h>
#include <chrono>
#include <qmath.h>
#include "../utils/FrameRateUtils.h"
class QQuickWindow;
// application namespace
@@ -190,6 +191,9 @@ private:
int m_hmdRotationStatsUpdateCounter = 0;
unsigned m_dragComfortFrameSkipCounter = 0;
unsigned m_turnComfortFrameSkipCounter = 0;
unsigned int m_k_moveCenterSettingsUpdateCounter = 83;
double m_velocity[3] = { 0.0, 0.0, 0.0 };
std::chrono::steady_clock::time_point m_lastGravityUpdateTimePoint;
std::chrono::steady_clock::time_point m_lastDragUpdateTimePoint;
+3 -1
View File
@@ -9,6 +9,8 @@ void SettingsTabController::initStage1()
{
m_autoStartEnabled = vr::VRApplications()->GetApplicationAutoLaunch(
application_strings::applicationKey );
m_k_settingsTabSettingsUpdateCounter
= utils::adjustUpdateRate( k_settingsTabSettingsUpdateCounter );
}
void SettingsTabController::initStage2( OverlayController* var_parent )
@@ -18,7 +20,7 @@ void SettingsTabController::initStage2( OverlayController* var_parent )
void SettingsTabController::dashboardLoopTick()
{
if ( settingsUpdateCounter >= k_settingsTabSettingsUpdateCounter )
if ( settingsUpdateCounter >= m_k_settingsTabSettingsUpdateCounter )
{
setAutoStartEnabled( vr::VRApplications()->GetApplicationAutoLaunch(
application_strings::applicationKey ) );
@@ -2,6 +2,7 @@
#pragma once
#include <QObject>
#include "../utils/FrameRateUtils.h"
class QQuickWindow;
// application namespace
@@ -23,6 +24,8 @@ private:
bool m_autoStartEnabled = false;
unsigned int m_k_settingsTabSettingsUpdateCounter = 157;
public:
void initStage1();
void initStage2( OverlayController* parent );
+3 -1
View File
@@ -7,6 +7,8 @@ namespace advsettings
{
void SteamVRTabController::initStage1()
{
m_k_steamVrSettingsUpdateCounter
= utils::adjustUpdateRate( k_steamVrSettingsUpdateCounter );
dashboardLoopTick();
}
@@ -17,7 +19,7 @@ void SteamVRTabController::initStage2( OverlayController* var_parent )
void SteamVRTabController::dashboardLoopTick()
{
if ( settingsUpdateCounter >= k_steamVrSettingsUpdateCounter )
if ( settingsUpdateCounter >= m_k_steamVrSettingsUpdateCounter )
{
vr::EVRSettingsError vrSettingsError;
@@ -2,6 +2,7 @@
#pragma once
#include <QObject>
#include "../utils/FrameRateUtils.h"
class QQuickWindow;
// application namespace
@@ -50,6 +51,8 @@ private:
unsigned settingsUpdateCounter = 0;
unsigned int m_k_steamVrSettingsUpdateCounter = 97;
public:
void initStage1();
void initStage2( OverlayController* parent );
@@ -23,6 +23,9 @@ void UtilitiesTabController::initStage1()
m_alarmIsModal = qAlarmIsModal.toBool();
m_vrcDebug = qVrcDebug.toBool();
m_alarmTime = QTime( qAlarmHour.toInt(), qAlarmMinute.toInt() );
m_k_utilitiesSettingsUpdateCounter
= utils::adjustUpdateRate( k_utilitiesSettingsUpdateCounter );
}
void UtilitiesTabController::initStage2( OverlayController* var_parent )
@@ -461,7 +464,7 @@ vr::VROverlayHandle_t createBatteryOverlay( vr::TrackedDeviceIndex_t index )
void UtilitiesTabController::eventLoopTick()
{
if ( settingsUpdateCounter >= k_utilitiesSettingsUpdateCounter )
if ( settingsUpdateCounter >= m_k_utilitiesSettingsUpdateCounter )
{
if ( m_alarmEnabled && m_alarmTime.isValid() )
{
@@ -7,6 +7,7 @@
#include <memory>
#include "src/keyboard_input/keyboard_input.h"
#include "src/media_keys/media_keys.h"
#include "../utils/FrameRateUtils.h"
class QQuickWindow;
// application namespace
@@ -45,6 +46,8 @@ private:
int m_batteryState[vr::k_unMaxTrackedDeviceCount];
bool m_batteryVisible[vr::k_unMaxTrackedDeviceCount];
unsigned int m_k_utilitiesSettingsUpdateCounter = 19;
public:
void initStage1();
void initStage2( OverlayController* var_parent );
+343 -82
View File
@@ -8,8 +8,12 @@ namespace advsettings
{
void VideoTabController::initStage1()
{
// In order to ensure gain is "normal" before applying to either overlay or
// gain.
resetGain();
initBrightnessOverlay();
initColorGain();
initColorOverlay();
initMotionSmoothing();
initSupersampleOverride();
m_overlayInit = true;
@@ -57,6 +61,70 @@ void VideoTabController::initBrightnessOverlay()
}
}
void VideoTabController::initColorOverlay()
{
std::string notifKey
= std::string( application_strings::applicationKey ) + ".coloroverlay";
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,
&notificationTransform );
}
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::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_colorOverlayOpacity );
if ( overlayError != vr::VROverlayError_None )
{
LOG( ERROR ) << "Could not set alpha: "
<< vr::VROverlay()->GetOverlayErrorNameFromEnum(
overlayError );
}
emit colorOverlayOpacityChanged( true );
}
void VideoTabController::eventLoopTick() {}
void VideoTabController::dashboardLoopTick()
@@ -158,9 +226,19 @@ void VideoTabController::reloadVideoConfig()
m_brightnessOpacityValue
= settings->value( "brightnessOpacityValue", 0.0f ).toFloat();
m_brightnessValue = settings->value( "brightnessValue", 1.0f ).toFloat();
setColorOverlayEnabled(
settings->value( "colorOverlayEnabled", false ).toBool(), true );
setColorOverlayOpacity(
settings->value( "colorOverlayOpacity", 0.0f ).toFloat(), true );
setIsOverlayMethodActive(
settings->value( "isOverlayMethodActive", false ).toBool(), true );
setColorRed( settings->value( "colorRed", 1.0f ).toFloat() );
setColorGreen( settings->value( "colorGreen", 1.0f ).toFloat() );
setColorBlue( settings->value( "colorBlue", 1.0f ).toFloat() );
settings->endGroup();
setBrightnessOpacityValue();
loadColorOverlay();
settings->sync();
}
@@ -171,6 +249,12 @@ void VideoTabController::saveVideoConfig()
settings->setValue( "brightnessEnabled", brightnessEnabled() );
settings->setValue( "brightnessOpacityValue", brightnessOpacityValue() );
settings->setValue( "brightnessValue", brightnessValue() );
settings->setValue( "colorOverlayEnabled", colorOverlayEnabled() );
settings->setValue( "colorOverlayOpacity", colorOverlayOpacity() );
settings->setValue( "colorRed", colorRed() );
settings->setValue( "colorGreen", colorGreen() );
settings->setValue( "colorBlue", colorBlue() );
settings->setValue( "isOverlayMethodActive", isOverlayMethodActive() );
settings->endGroup();
settings->sync();
@@ -191,11 +275,16 @@ bool VideoTabController::brightnessEnabled() const
return m_brightnessEnabled;
}
void VideoTabController::setBrightnessEnabled( bool value, bool notify )
void VideoTabController::setBrightnessEnabled( bool value,
bool notify,
bool keepValue )
{
if ( value != m_brightnessEnabled )
if ( value != m_brightnessEnabled || keepValue )
{
m_brightnessEnabled = value;
if ( !keepValue )
{
m_brightnessEnabled = value;
}
auto overlayHandle = getBrightnessOverlayHandle();
if ( value )
{
@@ -280,6 +369,16 @@ void VideoTabController::setBrightnessOpacityValue()
// getters
bool VideoTabController::colorOverlayEnabled() const
{
return m_colorOverlayEnabled;
}
float VideoTabController::colorOverlayOpacity() const
{
return m_colorOverlayOpacity;
}
float VideoTabController::colorRed() const
{
return m_colorRed;
@@ -295,27 +394,138 @@ float VideoTabController::colorBlue() const
return m_colorBlue;
}
bool VideoTabController::isOverlayMethodActive() const
{
return m_isOverlayMethodActive;
}
// setters
void VideoTabController::setColorRed( float value, bool notify )
void VideoTabController::setIsOverlayMethodActive( bool value, bool notify )
{
if ( fabs( static_cast<double>( value - m_colorRed ) ) > .005 )
resetGain();
m_isOverlayMethodActive = value;
if ( value )
{
m_colorRed = value;
vr::EVRSettingsError vrSettingsError;
vr::VRSettings()->SetFloat(
vr::k_pch_SteamVR_Section,
vr::k_pch_SteamVR_HmdDisplayColorGainR_Float,
m_colorRed,
&vrSettingsError );
setColorOverlayEnabled( colorOverlayEnabled(), true, false );
}
else
{
setColorOverlayEnabled( false, true, false );
}
setColor( colorRed(), colorGreen(), colorBlue(), true, true );
if ( vrSettingsError != vr::VRSettingsError_None )
saveVideoConfig();
if ( notify )
{
emit isOverlayMethodActiveChanged( value );
}
}
void VideoTabController::setColorOverlayEnabled( bool value,
bool notify,
bool keepValue )
{
if ( value != m_colorOverlayEnabled || keepValue )
{
if ( !keepValue )
{
LOG( ERROR ) << "could not set Red Gain Value, Error: "
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
vrSettingsError );
m_colorOverlayEnabled = value;
}
LOG( DEBUG ) << "Changed Red Gain to: " << m_colorRed;
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 colorOverlayEnabledChanged( value );
}
}
}
void VideoTabController::setColorOverlayOpacity( float value, bool notify )
{
if ( fabs( static_cast<double>( value - m_colorOverlayOpacity ) ) > .005 )
{
vr::VROverlayError overlayError = vr::VROverlay()->SetOverlayAlpha(
m_colorOverlayHandle, m_colorOverlayOpacity );
if ( value > .85f )
{
m_colorOverlayOpacity = 0.85f;
}
else
{
m_colorOverlayOpacity = value;
}
if ( overlayError != vr::VROverlayError_None )
{
LOG( ERROR ) << "Could not set alpha for color overlay: "
<< vr::VROverlay()->GetOverlayErrorNameFromEnum(
overlayError );
}
saveVideoConfig();
if ( notify )
{
emit colorOverlayOpacityChanged( m_colorOverlayOpacity );
}
}
}
void VideoTabController::setColorRed( float value, bool notify, bool keepValue )
{
if ( ( fabs( static_cast<double>( value - m_colorRed ) ) > .005 )
|| keepValue )
{
if ( !keepValue )
{
m_colorRed = value;
}
if ( isOverlayMethodActive() )
{
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 );
}
}
else
{
vr::EVRSettingsError vrSettingsError;
vr::VRSettings()->SetFloat(
vr::k_pch_SteamVR_Section,
vr::k_pch_SteamVR_HmdDisplayColorGainR_Float,
m_colorRed,
&vrSettingsError );
if ( vrSettingsError != vr::VRSettingsError_None )
{
LOG( ERROR ) << "could not set Red Gain Value, Error: "
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
vrSettingsError );
}
}
LOG( DEBUG ) << "Changed Red Value to: " << m_colorRed;
saveVideoConfig();
vr::VRSettings()->Sync();
if ( notify )
{
@@ -324,25 +534,48 @@ void VideoTabController::setColorRed( float value, bool notify )
}
}
void VideoTabController::setColorGreen( float value, bool notify )
void VideoTabController::setColorGreen( float value,
bool notify,
bool keepValue )
{
if ( fabs( static_cast<double>( value - m_colorGreen ) ) > .005 )
if ( ( fabs( static_cast<double>( value - m_colorGreen ) ) > .005 )
|| keepValue )
{
m_colorGreen = value;
vr::EVRSettingsError vrSettingsError;
vr::VRSettings()->SetFloat(
vr::k_pch_SteamVR_Section,
vr::k_pch_SteamVR_HmdDisplayColorGainG_Float,
m_colorGreen,
&vrSettingsError );
if ( vrSettingsError != vr::VRSettingsError_None )
if ( !keepValue )
{
LOG( ERROR ) << "could not set Green Gain Value, Error: "
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
vrSettingsError );
m_colorGreen = value;
}
LOG( DEBUG ) << "Changed Green Gain to: " << m_colorGreen;
if ( isOverlayMethodActive() )
{
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 );
}
}
else
{
vr::EVRSettingsError vrSettingsError;
vr::VRSettings()->SetFloat(
vr::k_pch_SteamVR_Section,
vr::k_pch_SteamVR_HmdDisplayColorGainG_Float,
m_colorGreen,
&vrSettingsError );
if ( vrSettingsError != vr::VRSettingsError_None )
{
LOG( ERROR ) << "could not set Green Gain Value, Error: "
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
vrSettingsError );
}
}
LOG( DEBUG ) << "Changed Green Value to: " << m_colorGreen;
saveVideoConfig();
vr::VRSettings()->Sync();
if ( notify )
{
@@ -351,25 +584,47 @@ void VideoTabController::setColorGreen( float value, bool notify )
}
}
void VideoTabController::setColorBlue( float value, bool notify )
void VideoTabController::setColorBlue( float value,
bool notify,
bool keepValue )
{
if ( fabs( static_cast<double>( value - m_colorBlue ) ) > .005 )
if ( ( fabs( static_cast<double>( value - m_colorBlue ) ) > .005 )
|| keepValue )
{
m_colorBlue = value;
vr::EVRSettingsError vrSettingsError;
vr::VRSettings()->SetFloat(
vr::k_pch_SteamVR_Section,
vr::k_pch_SteamVR_HmdDisplayColorGainB_Float,
m_colorBlue,
&vrSettingsError );
if ( vrSettingsError != vr::VRSettingsError_None )
if ( !keepValue )
{
LOG( ERROR ) << "could not set Blue Gain Value, Error: "
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
vrSettingsError );
m_colorBlue = value;
}
LOG( DEBUG ) << "Changed Blue Gain to: " << m_colorBlue;
if ( isOverlayMethodActive() )
{
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 );
}
}
else
{
vr::EVRSettingsError vrSettingsError;
vr::VRSettings()->SetFloat(
vr::k_pch_SteamVR_Section,
vr::k_pch_SteamVR_HmdDisplayColorGainB_Float,
m_colorBlue,
&vrSettingsError );
if ( vrSettingsError != vr::VRSettingsError_None )
{
LOG( ERROR ) << "could not set Blue Gain Value, Error: "
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
vrSettingsError );
}
}
LOG( DEBUG ) << "Changed Blue Value to: " << m_colorBlue;
saveVideoConfig();
vr::VRSettings()->Sync();
if ( notify )
{
@@ -378,58 +633,54 @@ void VideoTabController::setColorBlue( float value, bool notify )
}
}
void VideoTabController::initColorGain()
void VideoTabController::resetGain()
{
float temporary = 0.0f;
vr::EVRSettingsError vrSettingsError;
temporary = vr::VRSettings()->GetFloat(
vr::k_pch_SteamVR_Section,
vr::k_pch_SteamVR_HmdDisplayColorGainR_Float,
&vrSettingsError );
vr::VRSettings()->SetFloat( vr::k_pch_SteamVR_Section,
vr::k_pch_SteamVR_HmdDisplayColorGainR_Float,
1.0f,
&vrSettingsError );
if ( vrSettingsError != vr::VRSettingsError_None )
{
LOG( ERROR ) << "Could not get Red Gain Value ERROR: "
LOG( ERROR ) << "could not set Red Gain Value, Error: "
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
vrSettingsError );
}
else
{
m_colorRed = temporary;
setColorRed( temporary );
}
vr::VRSettings()->SetFloat( vr::k_pch_SteamVR_Section,
vr::k_pch_SteamVR_HmdDisplayColorGainG_Float,
1.0f,
&vrSettingsError );
temporary = vr::VRSettings()->GetFloat(
vr::k_pch_SteamVR_Section,
vr::k_pch_SteamVR_HmdDisplayColorGainG_Float,
&vrSettingsError );
if ( vrSettingsError != vr::VRSettingsError_None )
{
LOG( ERROR ) << "Could not get Green Gain Value ERROR: "
LOG( ERROR ) << "could not set Green Gain Value, Error: "
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
vrSettingsError );
}
else
{
m_colorGreen = temporary;
setColorGreen( temporary );
}
temporary = vr::VRSettings()->GetFloat(
vr::k_pch_SteamVR_Section,
vr::k_pch_SteamVR_HmdDisplayColorGainB_Float,
&vrSettingsError );
vr::VRSettings()->SetFloat( vr::k_pch_SteamVR_Section,
vr::k_pch_SteamVR_HmdDisplayColorGainB_Float,
1.0f,
&vrSettingsError );
if ( vrSettingsError != vr::VRSettingsError_None )
{
LOG( ERROR ) << "Could not get Blue Gain Value ERROR: "
LOG( ERROR ) << "could not set Blue Gain Value, Error: "
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
vrSettingsError );
}
else
{
m_colorBlue = temporary;
setColorBlue( temporary );
}
}
void VideoTabController::setColor( float R,
float G,
float B,
bool notify,
bool keepValue )
{
setColorRed( R, notify, keepValue );
setColorGreen( G, notify, keepValue );
setColorBlue( B, notify, keepValue );
}
/*
@@ -621,6 +872,8 @@ void VideoTabController::addVideoProfile( const QString name )
profile->colorBlue = m_colorBlue;
profile->brightnessToggle = m_brightnessEnabled;
profile->brightnessValue = m_brightnessValue;
profile->opacity = m_colorOverlayOpacity;
profile->overlayMethodState = m_isOverlayMethodActive;
saveVideoProfiles();
OverlayController::appSettings()->sync();
@@ -638,11 +891,13 @@ void VideoTabController::applyVideoProfile( const unsigned index )
setSuperSampling( profile.supersampling );
setAllowSupersampleFiltering( profile.anisotropicFiltering );
setMotionSmoothing( profile.motionSmooth );
setIsOverlayMethodActive( profile.overlayMethodState );
setColorRed( profile.colorRed );
setColorBlue( profile.colorBlue );
setColorGreen( profile.colorGreen );
setBrightnessEnabled( profile.brightnessToggle );
setBrightnessValue( profile.brightnessValue );
setColorOverlayOpacity( profile.opacity );
vr::VRSettings()->Sync( true );
}
}
@@ -663,8 +918,8 @@ void VideoTabController::reloadVideoProfiles()
{
videoProfiles.clear();
auto settings = OverlayController::appSettings();
settings->beginGroup( "steamVRSettings" );
auto profileCount = settings->beginReadArray( "steamVRProfiles" );
settings->beginGroup( "VideoSettings" );
auto profileCount = settings->beginReadArray( "videoProfiles" );
for ( int i = 0; i < profileCount; i++ )
{
settings->setArrayIndex( i );
@@ -689,6 +944,9 @@ void VideoTabController::reloadVideoProfiles()
= settings->value( "brightnessToggle", false ).toBool();
entry.brightnessValue
= settings->value( "brightnessValue", 1.0f ).toFloat();
entry.opacity = settings->value( "opacity", 0.0f ).toFloat();
entry.overlayMethodState
= settings->value( "overlayMethodState", false ).toBool();
}
settings->endArray();
settings->endGroup();
@@ -718,6 +976,9 @@ void VideoTabController::saveVideoProfiles()
settings->setValue( "brightnessToggle", p.brightnessToggle );
settings->setValue( "brightnessValue", p.brightnessValue );
settings->setValue( "opacity", p.opacity );
settings->setValue( "overlayMethodState", p.overlayMethodState );
i++;
}
settings->endArray();
+54 -6
View File
@@ -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
@@ -31,6 +32,8 @@ struct VideoProfile
float colorBlue = 1.0f;
bool brightnessToggle = false;
float brightnessValue = 1.0f;
bool overlayMethodState = false;
float opacity = 0.0f;
};
class VideoTabController : public QObject
@@ -56,12 +59,20 @@ class VideoTabController : public QObject
Q_PROPERTY( bool allowSupersampleFiltering READ allowSupersampleFiltering
WRITE setAllowSupersampleFiltering NOTIFY
allowSupersampleFilteringChanged )
Q_PROPERTY(
bool isOverlayMethodActive READ isOverlayMethodActive WRITE
setIsOverlayMethodActive NOTIFY isOverlayMethodActiveChanged )
Q_PROPERTY( bool colorOverlayEnabled READ colorOverlayEnabled WRITE
setColorOverlayEnabled NOTIFY colorOverlayEnabledChanged )
Q_PROPERTY( float colorOverlayOpacity READ colorOverlayOpacity WRITE
setColorOverlayOpacity NOTIFY colorOverlayOpacityChanged )
private:
unsigned settingsUpdateCounter = 0;
// 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.
const float k_overlayWidth = 1.0f;
@@ -79,16 +90,29 @@ private:
float m_colorBlue = 0.0f;
float m_colorGreen = 0.0f;
bool m_overlayInit = false;
bool m_isOverlayMethodActive = false;
bool m_colorOverlayEnabled = false;
float m_colorOverlayOpacity = 0.0f;
float m_superSampling = 1.0;
bool m_allowSupersampleOverride = false;
bool m_motionSmoothing = true;
bool m_allowSupersampleFiltering = true;
void initColorGain();
void setColor( float R,
float G,
float B,
bool notify = true,
bool keepValue = false );
void resetGain();
void initSupersampleOverride();
void initMotionSmoothing();
void initColorOverlay();
void loadColorOverlay();
void reloadVideoConfig();
void saveVideoConfig();
void setBrightnessOpacityValue();
@@ -107,6 +131,11 @@ private:
return m_brightnessOverlayHandle;
}
vr::VROverlayHandle_t getColorOverlayHandle()
{
return m_colorOverlayHandle;
}
public:
float brightnessOpacityValue() const;
// inverse of brightnessValue
@@ -114,15 +143,18 @@ public:
bool brightnessEnabled() const;
// Color overlay Getters
bool colorEnabled() const;
bool colorOverlayEnabled() const;
float colorRed() const;
float colorGreen() const;
float colorBlue() const;
float colorOverlayOpacity() const;
bool allowSupersampleOverride() const;
float superSampling() const;
bool motionSmoothing() const;
bool allowSupersampleFiltering() const;
bool isOverlayMethodActive() const;
void initStage1();
void eventLoopTick();
@@ -135,19 +167,31 @@ public:
Q_INVOKABLE QString getVideoProfileName( unsigned index );
public slots:
void setBrightnessEnabled( bool value, bool notify = true );
void setBrightnessEnabled( bool value,
bool notify = true,
bool keepValue = false );
void setBrightnessValue( float percvalue, bool notify = true );
void setSuperSampling( float value, bool notify = true );
void setAllowSupersampleOverride( bool value, bool notify = true );
// Color overlay Setters
void setColorRed( float value, bool notify = true );
void setColorGreen( float value, bool notify = true );
void setColorBlue( float value, bool notify = true );
void setColorRed( float value, bool notify = true, bool keepValue = false );
void setColorGreen( float value,
bool notify = true,
bool keepValue = false );
void
setColorBlue( float value, bool notify = true, bool keepValue = false );
void setColorOverlayEnabled( bool value,
bool notify = true,
bool keepValue = false );
void setColorOverlayOpacity( float value, bool notify = true );
void setMotionSmoothing( bool value, bool notify = true );
void setAllowSupersampleFiltering( bool value, bool notify = true );
void setIsOverlayMethodActive( bool value, bool notify = true );
void addVideoProfile( QString name );
void applyVideoProfile( unsigned index );
void deleteVideoProfile( unsigned index );
@@ -158,6 +202,10 @@ signals:
void colorRedChanged( float value );
void colorGreenChanged( float value );
void colorBlueChanged( float value );
void isOverlayMethodActiveChanged( bool value );
void colorOverlayEnabledChanged( bool value );
void colorOverlayOpacityChanged( float value );
void superSamplingChanged( float value );
void allowSupersampleOverrideChanged( bool value );