Brightness Opacity Refactor + Gain behavior (#355)
* added loop update tick for Synchronizeing while dashboard up * fixed gain to allow better synching w/ external apps. * removed extra setting brighnessValue fixed toggle error for brightness Overlay fixed gain synch error * fixed compiler warning implicit conversion
This commit is contained in:
@@ -11,8 +11,13 @@ void VideoTabController::initStage1()
|
||||
{
|
||||
// In order to ensure gain is "normal" before applying to either overlay or
|
||||
// gain.
|
||||
|
||||
synchGain( true );
|
||||
resetGain();
|
||||
|
||||
m_videoDashboardUpdateCounter
|
||||
= utils::adjustUpdateRate( k_videoDashboardUpdateCounter );
|
||||
|
||||
initBrightnessOverlay();
|
||||
initColorOverlay();
|
||||
initMotionSmoothing();
|
||||
@@ -20,6 +25,11 @@ void VideoTabController::initStage1()
|
||||
m_overlayInit = true;
|
||||
reloadVideoConfig();
|
||||
reloadVideoProfiles();
|
||||
|
||||
if ( brightnessEnabled() )
|
||||
{
|
||||
setBrightnessEnabled( true, false, true );
|
||||
}
|
||||
}
|
||||
|
||||
void VideoTabController::initBrightnessOverlay()
|
||||
@@ -130,8 +140,7 @@ void VideoTabController::eventLoopTick() {}
|
||||
|
||||
void VideoTabController::dashboardLoopTick()
|
||||
{
|
||||
// TODO different key
|
||||
if ( settingsUpdateCounter >= k_steamVrSettingsUpdateCounter )
|
||||
if ( settingsUpdateCounter >= m_videoDashboardUpdateCounter )
|
||||
{
|
||||
vr::EVRSettingsError vrSettingsError;
|
||||
|
||||
@@ -210,6 +219,16 @@ void VideoTabController::dashboardLoopTick()
|
||||
}
|
||||
setMotionSmoothing( ms );
|
||||
|
||||
// Synch's our saved Values of gain to the SteamVR's version
|
||||
// This will allow other apps to modify Gain.
|
||||
|
||||
bool valueAdjust = true;
|
||||
if ( isOverlayMethodActive() )
|
||||
{
|
||||
valueAdjust = false;
|
||||
}
|
||||
synchGain( valueAdjust );
|
||||
|
||||
settingsUpdateCounter = 0;
|
||||
}
|
||||
else
|
||||
@@ -230,7 +249,14 @@ void VideoTabController::reloadVideoConfig()
|
||||
setColorBlue( colorBlue() );
|
||||
|
||||
settings->endGroup();
|
||||
setBrightnessOpacityValue();
|
||||
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 );
|
||||
}
|
||||
loadColorOverlay();
|
||||
settings->sync();
|
||||
}
|
||||
@@ -241,12 +267,6 @@ float VideoTabController::brightnessOpacityValue() const
|
||||
settings::DoubleSetting::VIDEO_brightnessOpacityValue ) );
|
||||
}
|
||||
|
||||
float VideoTabController::brightnessValue() const
|
||||
{
|
||||
return static_cast<float>( settings::getSetting(
|
||||
settings::DoubleSetting::VIDEO_brightnessValue ) );
|
||||
}
|
||||
|
||||
bool VideoTabController::brightnessEnabled() const
|
||||
{
|
||||
return settings::getSetting(
|
||||
@@ -290,30 +310,28 @@ void VideoTabController::setBrightnessEnabled( bool value,
|
||||
}
|
||||
}
|
||||
|
||||
void VideoTabController::setBrightnessValue( float percvalue, bool notify )
|
||||
void VideoTabController::setBrightnessOpacityValue( float percvalue,
|
||||
bool notify )
|
||||
{
|
||||
// This takes the Perceived value, and converts it to allow more accurate
|
||||
// linear positioning. (human perception logarithmic)
|
||||
float realvalue = static_cast<float>(
|
||||
std::pow( static_cast<double>( 1.0f - percvalue ), 1 / 3. ) );
|
||||
|
||||
if ( fabs( static_cast<double>( realvalue - brightnessOpacityValue() ) )
|
||||
if ( fabs( static_cast<double>( percvalue - brightnessOpacityValue() ) )
|
||||
> .005 )
|
||||
{
|
||||
settings::setSetting( settings::DoubleSetting::VIDEO_brightnessValue,
|
||||
static_cast<double>( percvalue ) );
|
||||
settings::setSetting(
|
||||
settings::DoubleSetting::VIDEO_brightnessOpacityValue,
|
||||
static_cast<double>( percvalue ) );
|
||||
|
||||
if ( realvalue <= 1.0f && realvalue >= 0.0f )
|
||||
if ( realvalue <= 1.0f && realvalue >= 0.00f )
|
||||
{
|
||||
settings::setSetting(
|
||||
settings::DoubleSetting::VIDEO_brightnessOpacityValue,
|
||||
static_cast<double>( realvalue ) );
|
||||
|
||||
vr::VROverlayError overlayError = vr::VROverlay()->SetOverlayAlpha(
|
||||
m_brightnessOverlayHandle, realvalue );
|
||||
if ( overlayError != vr::VROverlayError_None )
|
||||
{
|
||||
LOG( ERROR ) << "Could not set alpha: "
|
||||
LOG( ERROR ) << "Could not set alpha for brightness overlay: "
|
||||
<< vr::VROverlay()->GetOverlayErrorNameFromEnum(
|
||||
overlayError );
|
||||
}
|
||||
@@ -327,24 +345,11 @@ void VideoTabController::setBrightnessValue( float percvalue, bool notify )
|
||||
|
||||
if ( notify )
|
||||
{
|
||||
emit brightnessValueChanged( percvalue );
|
||||
emit brightnessOpacityValueChanged( percvalue );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VideoTabController::setBrightnessOpacityValue()
|
||||
{
|
||||
vr::VROverlayError overlayError = vr::VROverlay()->SetOverlayAlpha(
|
||||
m_brightnessOverlayHandle, brightnessOpacityValue() );
|
||||
if ( overlayError != vr::VROverlayError_None )
|
||||
{
|
||||
LOG( ERROR ) << "Could not set alpha: "
|
||||
<< vr::VROverlay()->GetOverlayErrorNameFromEnum(
|
||||
overlayError );
|
||||
}
|
||||
emit brightnessValueChanged( brightnessValue() );
|
||||
}
|
||||
|
||||
/*
|
||||
* -------------------------
|
||||
* Color Overlay
|
||||
@@ -478,6 +483,75 @@ void VideoTabController::setColorOverlayOpacity( float value, bool notify )
|
||||
}
|
||||
}
|
||||
|
||||
void VideoTabController::synchGain( bool setValue )
|
||||
{
|
||||
vr::EVRSettingsError vrSettingsError;
|
||||
|
||||
auto red = vr::VRSettings()->GetFloat(
|
||||
vr::k_pch_SteamVR_Section,
|
||||
vr::k_pch_SteamVR_HmdDisplayColorGainR_Float,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_SteamVR_HmdDisplayColorGainR_Float
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( fabs( static_cast<double>( red - colorRed() ) ) > 0.005
|
||||
&& setValue )
|
||||
{
|
||||
settings::setSetting( settings::DoubleSetting::VIDEO_colorRed,
|
||||
static_cast<double>( red ) );
|
||||
}
|
||||
}
|
||||
auto blue = vr::VRSettings()->GetFloat(
|
||||
vr::k_pch_SteamVR_Section,
|
||||
vr::k_pch_SteamVR_HmdDisplayColorGainB_Float,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_SteamVR_HmdDisplayColorGainB_Float
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( fabs( static_cast<double>( blue - colorBlue() ) ) > 0.005
|
||||
&& setValue )
|
||||
{
|
||||
settings::setSetting( settings::DoubleSetting::VIDEO_colorBlue,
|
||||
static_cast<double>( blue ) );
|
||||
}
|
||||
}
|
||||
auto green = vr::VRSettings()->GetFloat(
|
||||
vr::k_pch_SteamVR_Section,
|
||||
vr::k_pch_SteamVR_HmdDisplayColorGainG_Float,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_SteamVR_HmdDisplayColorGainG_Float
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( fabs( static_cast<double>( green - colorGreen() ) ) > 0.005
|
||||
&& setValue )
|
||||
{
|
||||
settings::setSetting( settings::DoubleSetting::VIDEO_colorGreen,
|
||||
static_cast<double>( green ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VideoTabController::setColorRed( float value, bool notify, bool keepValue )
|
||||
{
|
||||
if ( ( fabs( static_cast<double>( value - colorRed() ) ) > .005 )
|
||||
@@ -857,7 +931,7 @@ void VideoTabController::addVideoProfile( const QString name )
|
||||
profile->colorGreen = colorGreen();
|
||||
profile->colorBlue = colorBlue();
|
||||
profile->brightnessToggle = brightnessEnabled();
|
||||
profile->brightnessValue = brightnessValue();
|
||||
profile->brightnessOpacityValue = brightnessOpacityValue();
|
||||
profile->opacity = colorOverlayOpacity();
|
||||
profile->overlayMethodState = isOverlayMethodActive();
|
||||
|
||||
@@ -882,7 +956,7 @@ void VideoTabController::applyVideoProfile( const unsigned index )
|
||||
setColorBlue( profile.colorBlue );
|
||||
setColorGreen( profile.colorGreen );
|
||||
setBrightnessEnabled( profile.brightnessToggle );
|
||||
setBrightnessValue( profile.brightnessValue );
|
||||
setBrightnessOpacityValue( profile.brightnessOpacityValue );
|
||||
setColorOverlayOpacity( profile.opacity );
|
||||
}
|
||||
}
|
||||
@@ -927,8 +1001,8 @@ void VideoTabController::reloadVideoProfiles()
|
||||
|
||||
entry.brightnessToggle
|
||||
= settings->value( "brightnessToggle", false ).toBool();
|
||||
entry.brightnessValue
|
||||
= settings->value( "brightnessValue", 1.0f ).toFloat();
|
||||
entry.brightnessOpacityValue
|
||||
= settings->value( "brightnessOpacityValue", 1.0f ).toFloat();
|
||||
entry.opacity = settings->value( "opacity", 0.0f ).toFloat();
|
||||
entry.overlayMethodState
|
||||
= settings->value( "overlayMethodState", false ).toBool();
|
||||
@@ -959,7 +1033,8 @@ void VideoTabController::saveVideoProfiles()
|
||||
settings->setValue( "colorGreenNew", p.colorGreen );
|
||||
|
||||
settings->setValue( "brightnessToggle", p.brightnessToggle );
|
||||
settings->setValue( "brightnessValue", p.brightnessValue );
|
||||
settings->setValue( "brightnessOpacityValue",
|
||||
p.brightnessOpacityValue );
|
||||
|
||||
settings->setValue( "opacity", p.opacity );
|
||||
settings->setValue( "overlayMethodState", p.overlayMethodState );
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
#include <openvr.h>
|
||||
#include "../utils/FrameRateUtils.h"
|
||||
|
||||
class QQuickWindow;
|
||||
|
||||
@@ -31,9 +32,9 @@ struct VideoProfile
|
||||
float colorGreen = 1.0f;
|
||||
float colorBlue = 1.0f;
|
||||
bool brightnessToggle = false;
|
||||
float brightnessValue = 1.0f;
|
||||
float brightnessOpacityValue = 1.0f;
|
||||
bool overlayMethodState = false;
|
||||
float opacity = 0.0f;
|
||||
float opacity = 0.0f; // TODO check
|
||||
};
|
||||
|
||||
class VideoTabController : public QObject
|
||||
@@ -41,8 +42,9 @@ class VideoTabController : public QObject
|
||||
Q_OBJECT
|
||||
Q_PROPERTY( bool brightnessEnabled READ brightnessEnabled WRITE
|
||||
setBrightnessEnabled NOTIFY brightnessEnabledChanged )
|
||||
Q_PROPERTY( float brightnessValue READ brightnessValue WRITE
|
||||
setBrightnessValue NOTIFY brightnessValueChanged )
|
||||
Q_PROPERTY(
|
||||
float brightnessOpacityValue READ brightnessOpacityValue WRITE
|
||||
setBrightnessOpacityValue NOTIFY brightnessOpacityValueChanged )
|
||||
Q_PROPERTY(
|
||||
float colorRed READ colorRed WRITE setColorRed NOTIFY colorRedChanged )
|
||||
Q_PROPERTY( float colorGreen READ colorGreen WRITE setColorGreen NOTIFY
|
||||
@@ -89,6 +91,8 @@ private:
|
||||
bool m_motionSmoothing = true;
|
||||
bool m_allowSupersampleFiltering = true;
|
||||
|
||||
unsigned int m_videoDashboardUpdateCounter = 47;
|
||||
|
||||
void setColor( float R,
|
||||
float G,
|
||||
float B,
|
||||
@@ -103,10 +107,11 @@ private:
|
||||
void loadColorOverlay();
|
||||
|
||||
void reloadVideoConfig();
|
||||
void setBrightnessOpacityValue();
|
||||
|
||||
void initBrightnessOverlay();
|
||||
|
||||
void synchGain( bool setValue = false );
|
||||
|
||||
std::vector<VideoProfile> videoProfiles;
|
||||
|
||||
QString getSettingsName()
|
||||
@@ -126,8 +131,6 @@ private:
|
||||
|
||||
public:
|
||||
float brightnessOpacityValue() const;
|
||||
// inverse of brightnessValue
|
||||
float brightnessValue() const;
|
||||
bool brightnessEnabled() const;
|
||||
|
||||
// Color overlay Getters
|
||||
@@ -158,7 +161,7 @@ public slots:
|
||||
void setBrightnessEnabled( bool value,
|
||||
bool notify = true,
|
||||
bool keepValue = false );
|
||||
void setBrightnessValue( float percvalue, bool notify = true );
|
||||
void setBrightnessOpacityValue( float percvalue, bool notify = true );
|
||||
|
||||
void setSuperSampling( float value, bool notify = true );
|
||||
void setAllowSupersampleOverride( bool value, bool notify = true );
|
||||
@@ -186,7 +189,7 @@ public slots:
|
||||
|
||||
signals:
|
||||
void brightnessEnabledChanged( bool value );
|
||||
void brightnessValueChanged( float value );
|
||||
void brightnessOpacityValueChanged( float value );
|
||||
void colorRedChanged( float value );
|
||||
void colorGreenChanged( float value );
|
||||
void colorBlueChanged( float value );
|
||||
|
||||
Reference in New Issue
Block a user