Video and Steam VR Tab Re-work + keyboard binds (#289)

* changed color overlay to use gain values instead of overlay

* moved SS/Motion smoothing, and filter to video tab

* began refactor of steamVR qml page

* added misc toggles to steamvr tab

* added imu fallback and DND, and some qml formatting

* added Camera Settings to SteamVR page

* changed formatting to minimize height

* added video profiles cleaned up steamvr controller

* delta comparison change

* added profiles for video

* fixed display bug in colorgroupbox and removed frivoulous saves

* removed commented code

* added custom keybind buttons
This commit is contained in:
ykeara
2019-09-01 02:35:00 -05:00
committed by GitHub
parent 5452144157
commit 4b0be27ff6
24 changed files with 1750 additions and 1257 deletions
+279 -475
View File
@@ -7,10 +7,7 @@ namespace advsettings
{
void SteamVRTabController::initStage1()
{
initMotionSmoothing();
initSupersampleOverride();
dashboardLoopTick();
reloadSteamVRProfiles();
}
void SteamVRTabController::initStage2( OverlayController* var_parent )
@@ -23,78 +20,6 @@ void SteamVRTabController::dashboardLoopTick()
if ( settingsUpdateCounter >= k_steamVrSettingsUpdateCounter )
{
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<double>( 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 );
// Checks and synchs performance graph
auto pg = vr::VRSettings()->GetBool( vr::k_pch_Perf_Section,
@@ -110,6 +35,125 @@ void SteamVRTabController::dashboardLoopTick()
}
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 );
settingsUpdateCounter = 0;
}
else
@@ -118,341 +162,6 @@ void SteamVRTabController::dashboardLoopTick()
}
}
/* -----------------------------------------*/
/*------------------------------------------*/
/*Profile Logic Functions*/
void SteamVRTabController::addSteamVRProfile(
const QString name,
const bool includeSupersampling,
const bool includeSupersampleFiltering,
const bool includeMotionSmoothing )
{
SteamVRProfile* profile = nullptr;
for ( auto& p : steamvrProfiles )
{
if ( p.profileName.compare( name.toStdString() ) == 0 )
{
profile = &p;
break;
}
}
if ( !profile )
{
auto i = steamvrProfiles.size();
steamvrProfiles.emplace_back();
profile = &steamvrProfiles[i];
}
profile->profileName = name.toStdString();
profile->includesSupersampling = includeSupersampling;
if ( includeSupersampling )
{
profile->supersampleOverride = m_allowSupersampleOverride;
profile->supersampling = m_superSampling;
}
profile->includesSupersampleFiltering = includeSupersampleFiltering;
if ( includeSupersampleFiltering )
{
profile->supersampleFiltering = m_allowSupersampleFiltering;
}
profile->includesMotionSmoothing = includeMotionSmoothing;
if ( includeMotionSmoothing )
{
profile->motionSmooth = m_motionSmoothing;
}
saveSteamVRProfiles();
OverlayController::appSettings()->sync();
emit steamVRProfilesUpdated();
emit steamVRProfileAdded();
}
void SteamVRTabController::applySteamVRProfile( const unsigned index )
{
if ( index < steamvrProfiles.size() )
{
auto& profile = steamvrProfiles[index];
if ( profile.includesSupersampling )
{
setAllowSupersampleOverride( profile.supersampleOverride );
setSuperSampling( profile.supersampling );
}
if ( profile.includesSupersampleFiltering )
{
setAllowSupersampleFiltering( profile.supersampleFiltering );
}
if ( profile.includesMotionSmoothing )
{
setMotionSmoothing( profile.motionSmooth );
}
vr::VRSettings()->Sync( true );
}
}
void SteamVRTabController::deleteSteamVRProfile( const unsigned index )
{
if ( index < steamvrProfiles.size() )
{
auto pos = steamvrProfiles.begin() + index;
steamvrProfiles.erase( pos );
saveSteamVRProfiles();
OverlayController::appSettings()->sync();
emit steamVRProfilesUpdated();
}
}
void SteamVRTabController::reloadSteamVRProfiles()
{
steamvrProfiles.clear();
auto settings = OverlayController::appSettings();
settings->beginGroup( "steamVRSettings" );
auto profileCount = settings->beginReadArray( "steamVRProfiles" );
for ( int i = 0; i < profileCount; i++ )
{
settings->setArrayIndex( i );
steamvrProfiles.emplace_back();
auto& entry = steamvrProfiles[static_cast<size_t>( i )];
entry.profileName
= settings->value( "profileName" ).toString().toStdString();
entry.includesSupersampling
= settings->value( "includesSupersampling", false ).toBool();
if ( entry.includesSupersampling )
{
entry.supersampleOverride
= settings->value( "supersamplingOverride", false ).toBool();
entry.supersampling
= settings->value( "supersampling", 1.0f ).toFloat();
}
entry.includesSupersampleFiltering
= settings->value( "includesSupersampleFiltering", false ).toBool();
if ( entry.includesSupersampleFiltering )
{
entry.supersampleFiltering
= settings->value( "supersampleFiltering", true ).toBool();
}
entry.includesMotionSmoothing
= settings->value( "includesMotionSmoothing", false ).toBool();
if ( entry.includesMotionSmoothing )
{
entry.motionSmooth
= settings->value( "motionSmooth", true ).toBool();
}
}
settings->endArray();
settings->endGroup();
}
void SteamVRTabController::saveSteamVRProfiles()
{
auto settings = OverlayController::appSettings();
settings->beginGroup( "steamVRSettings" );
settings->beginWriteArray( "steamVRProfiles" );
unsigned i = 0;
for ( auto& p : steamvrProfiles )
{
settings->setArrayIndex( static_cast<int>( i ) );
settings->setValue( "profileName",
QString::fromStdString( p.profileName ) );
settings->setValue( "includesSupersampling", p.includesSupersampling );
if ( p.includesSupersampling )
{
settings->setValue( "supersamplingOverride",
p.supersampleOverride );
settings->setValue( "supersampling", p.supersampling );
}
settings->setValue( "includesSupersampleFiltering",
p.includesSupersampleFiltering );
if ( p.includesSupersampleFiltering )
{
settings->setValue( "supersampleFiltering",
p.supersampleFiltering );
}
settings->setValue( "includesMotionSmoothing",
p.includesMotionSmoothing );
if ( p.includesMotionSmoothing )
{
settings->setValue( "motionSmooth", p.motionSmooth );
}
i++;
}
settings->endArray();
settings->endGroup();
}
int SteamVRTabController::getSteamVRProfileCount()
{
return static_cast<int>( steamvrProfiles.size() );
}
QString SteamVRTabController::getSteamVRProfileName( const unsigned index )
{
if ( index >= steamvrProfiles.size() )
{
return QString();
}
else
{
return QString::fromStdString( steamvrProfiles[index].profileName );
}
}
/* -----------------------------------------*/
/*------------------------------------------*/
/*SuperSample (value) functions*/
void SteamVRTabController::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 || m_superSampling != value )
{
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 );
vr::VRSettings()->Sync();
if ( notify )
{
emit superSamplingChanged( m_superSampling );
}
}
}
float SteamVRTabController::superSampling() const
{
return m_superSampling;
}
/* -----------------------------------------*/
/*------------------------------------------*/
/*Motion Smoothing boolean/toggle functions*/
bool SteamVRTabController::motionSmoothing() const
{
return m_motionSmoothing;
}
void SteamVRTabController::setMotionSmoothing( const bool value,
const bool notify )
{
if ( m_motionSmoothing != value )
{
m_motionSmoothing = value;
vr::VRSettings()->SetBool( vr::k_pch_SteamVR_Section,
vr::k_pch_SteamVR_MotionSmoothing_Bool,
m_motionSmoothing );
vr::VRSettings()->Sync();
if ( notify )
{
emit motionSmoothingChanged( m_motionSmoothing );
}
}
}
void SteamVRTabController::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 );
}
vr::VRSettings()->Sync();
setMotionSmoothing( temporary, true );
}
/* -----------------------------------------*/
/*------------------------------------------*/
/*Supersample Filtering boolean/toggle functions*/
bool SteamVRTabController::allowSupersampleFiltering() const
{
return m_allowSupersampleFiltering;
}
void SteamVRTabController::setAllowSupersampleFiltering( const bool value,
const bool notify )
{
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()->Sync();
if ( notify )
{
emit allowSupersampleFilteringChanged(
m_allowSupersampleFiltering );
}
}
}
/* -----------------------------------------*/
/*------------------------------------------*/
/*SuperSampling Override boolean/toggle functions*/
bool SteamVRTabController::allowSupersampleOverride() const
{
return m_allowSupersampleOverride;
}
void SteamVRTabController::setAllowSupersampleOverride( const bool value,
const bool notify )
{
if ( m_allowSupersampleOverride != value )
{
m_allowSupersampleOverride = value;
vr::VRSettings()->SetBool(
vr::k_pch_SteamVR_Section,
vr::k_pch_SteamVR_SupersampleManualOverride_Bool,
m_allowSupersampleOverride );
vr::VRSettings()->Sync();
if ( notify )
{
emit allowSupersampleOverrideChanged( m_allowSupersampleOverride );
}
}
}
void SteamVRTabController::initSupersampleOverride()
{
bool temporary = false;
vr::EVRSettingsError vrSettingsError;
temporary = vr::VRSettings()->GetBool(
vr::k_pch_SteamVR_Section,
vr::k_pch_SteamVR_SupersampleManualOverride_Bool,
&vrSettingsError );
if ( vrSettingsError != vr::VRSettingsError_None )
{
LOG( WARNING ) << "Could not get SuperSampling Override State \""
<< vr::k_pch_SteamVR_SupersampleManualOverride_Bool
<< "\" setting: "
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
vrSettingsError );
}
vr::VRSettings()->Sync();
setAllowSupersampleOverride( temporary, true );
}
/*------------------------------------------*/
/* -----------------------------------------*/
bool SteamVRTabController::performanceGraph() const
{
return m_performanceGraphToggle;
@@ -475,91 +184,186 @@ void SteamVRTabController::setPerformanceGraph( const bool value,
}
}
/*------------------------------------------*/
/* -----------------------------------------*/
void SteamVRTabController::reset()
bool SteamVRTabController::multipleDriver() const
{
vr::EVRSettingsError vrSettingsError;
return m_multipleDriverToggle;
}
vr::VRSettings()->RemoveKeyInSection(
vr::k_pch_SteamVR_Section,
vr::k_pch_SteamVR_SupersampleScale_Float,
&vrSettingsError );
if ( vrSettingsError != vr::VRSettingsError_None )
void SteamVRTabController::setMultipleDriver( const bool value,
const bool notify )
{
if ( m_multipleDriverToggle != value )
{
LOG( WARNING ) << "Could not remove \""
<< vr::k_pch_SteamVR_SupersampleScale_Float
<< "\" setting: "
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
vrSettingsError );
m_multipleDriverToggle = value;
vr::VRSettings()->SetBool(
vr::k_pch_SteamVR_Section,
vr::k_pch_SteamVR_ActivateMultipleDrivers_Bool,
m_multipleDriverToggle );
vr::VRSettings()->Sync();
if ( notify )
{
emit multipleDriverChanged( m_multipleDriverToggle );
}
}
}
vr::VRSettings()->RemoveKeyInSection(
vr::k_pch_SteamVR_Section,
vr::k_pch_SteamVR_AllowSupersampleFiltering_Bool,
&vrSettingsError );
if ( vrSettingsError != vr::VRSettingsError_None )
bool SteamVRTabController::noFadeToGrid() const
{
return m_noFadeToGridToggle;
}
void SteamVRTabController::setNoFadeToGrid( const bool value,
const bool notify )
{
if ( m_noFadeToGridToggle != value )
{
LOG( WARNING ) << "Could not remove \""
<< vr::k_pch_SteamVR_AllowSupersampleFiltering_Bool
<< "\" setting: "
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
vrSettingsError );
m_noFadeToGridToggle = value;
vr::VRSettings()->SetBool( vr::k_pch_SteamVR_Section,
vr::k_pch_SteamVR_DoNotFadeToGrid,
m_noFadeToGridToggle );
vr::VRSettings()->Sync();
if ( notify )
{
emit noFadeToGridChanged( m_noFadeToGridToggle );
}
}
}
vr::VRSettings()->RemoveKeyInSection(
vr::k_pch_SteamVR_Section,
vr::k_pch_SteamVR_SupersampleManualOverride_Bool,
&vrSettingsError );
if ( vrSettingsError != vr::VRSettingsError_None )
bool SteamVRTabController::systemButton() const
{
return m_systemButtonToggle;
}
void SteamVRTabController::setSystemButton( const bool value,
const bool notify )
{
if ( m_systemButtonToggle != value )
{
LOG( WARNING ) << "Could not remove \""
<< vr::k_pch_SteamVR_SupersampleManualOverride_Bool
<< "\" setting: "
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
vrSettingsError );
m_systemButtonToggle = value;
vr::VRSettings()->SetBool(
vr::k_pch_SteamVR_Section,
vr::k_pch_SteamVR_SendSystemButtonToAllApps_Bool,
m_systemButtonToggle );
vr::VRSettings()->Sync();
if ( notify )
{
emit systemButtonChanged( m_systemButtonToggle );
}
}
}
vr::VRSettings()->RemoveKeyInSection(
vr::k_pch_SteamVR_Section,
vr::k_pch_SteamVR_SupersampleScale_Float,
&vrSettingsError );
if ( vrSettingsError != vr::VRSettingsError_None )
bool SteamVRTabController::dnd() const
{
return m_dnd;
}
void SteamVRTabController::setDND( const bool value, const bool notify )
{
if ( m_dnd != value )
{
LOG( WARNING ) << "Could not remove \""
<< vr::k_pch_SteamVR_SupersampleScale_Float
<< "\" setting: "
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
vrSettingsError );
m_dnd = value;
vr::VRSettings()->SetBool( vr::k_pch_Notifications_Section,
vr::k_pch_Notifications_DoNotDisturb_Bool,
m_dnd );
vr::VRSettings()->Sync();
if ( notify )
{
emit dNDChanged( m_dnd );
}
}
}
vr::VRSettings()->RemoveKeyInSection(
vr::k_pch_SteamVR_Section,
vr::k_pch_SteamVR_MotionSmoothing_Bool,
&vrSettingsError );
if ( vrSettingsError != vr::VRSettingsError_None )
/*------------------------------------------*/
/* -----------Camera Setting----------------*/
bool SteamVRTabController::cameraActive() const
{
return m_cameraActive;
}
void SteamVRTabController::setCameraActive( const bool value,
const bool notify )
{
if ( m_cameraActive != value )
{
LOG( WARNING ) << "Could not remove \""
<< vr::k_pch_SteamVR_MotionSmoothing_Bool
<< "\" setting: "
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
vrSettingsError );
m_cameraActive = value;
vr::VRSettings()->SetBool( vr::k_pch_Camera_Section,
vr::k_pch_Camera_EnableCamera_Bool,
m_cameraActive );
vr::VRSettings()->Sync();
if ( notify )
{
emit cameraActiveChanged( m_cameraActive );
}
}
}
vr::VRSettings()->RemoveKeyInSection( vr::k_pch_Perf_Section,
vr::k_pch_Perf_PerfGraphInHMD_Bool,
&vrSettingsError );
if ( vrSettingsError != vr::VRSettingsError_None )
bool SteamVRTabController::cameraBounds() const
{
return m_cameraBounds;
}
void SteamVRTabController::setCameraBounds( const bool value,
const bool notify )
{
if ( m_cameraBounds != value )
{
LOG( WARNING ) << "Could not remove \""
<< vr::k_pch_Perf_PerfGraphInHMD_Bool << "\" setting: "
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
vrSettingsError );
m_cameraBounds = value;
vr::VRSettings()->SetBool(
vr::k_pch_Camera_Section,
vr::k_pch_Camera_EnableCameraForCollisionBounds_Bool,
m_cameraBounds );
vr::VRSettings()->Sync();
if ( notify )
{
emit cameraBoundsChanged( m_cameraBounds );
}
}
}
vr::VRSettings()->Sync();
settingsUpdateCounter = 999; // Easiest way to get default values
bool SteamVRTabController::cameraRoom() const
{
return m_cameraRoom;
}
void SteamVRTabController::setCameraRoom( const bool value, const bool notify )
{
if ( m_cameraRoom != value )
{
m_cameraRoom = value;
vr::VRSettings()->SetBool(
vr::k_pch_Camera_Section,
vr::k_pch_Camera_EnableCameraForRoomView_Bool,
m_cameraRoom );
vr::VRSettings()->Sync();
if ( notify )
{
emit cameraRoomChanged( m_cameraRoom );
}
}
}
bool SteamVRTabController::cameraDashboard() const
{
return m_cameraDashboard;
}
void SteamVRTabController::setCameraDashboard( const bool value,
const bool notify )
{
if ( m_cameraDashboard != value )
{
m_cameraDashboard = value;
vr::VRSettings()->SetBool(
vr::k_pch_Camera_Section,
vr::k_pch_Camera_EnableCameraInDashboard_Bool,
m_cameraDashboard );
vr::VRSettings()->Sync();
if ( notify )
{
emit cameraDashboardChanged( m_cameraDashboard );
}
}
}
void SteamVRTabController::restartSteamVR()
+51 -59
View File
@@ -10,51 +10,43 @@ namespace advsettings
// forward declaration
class OverlayController;
struct SteamVRProfile
{
std::string profileName;
bool includesSupersampling = false;
float supersampling = 1.0f;
bool includesSupersampleFiltering = false;
bool supersampleFiltering = false;
bool motionSmooth = false;
bool includesMotionSmoothing = false;
bool supersampleOverride = false;
};
class SteamVRTabController : public QObject
{
Q_OBJECT
Q_PROPERTY( float superSampling READ superSampling WRITE setSuperSampling
NOTIFY superSamplingChanged )
Q_PROPERTY( bool systemButton READ systemButton WRITE setSystemButton NOTIFY
systemButtonChanged )
Q_PROPERTY( bool multipleDriver READ multipleDriver WRITE setMultipleDriver
NOTIFY multipleDriverChanged )
Q_PROPERTY( bool motionSmoothing READ motionSmoothing WRITE
setMotionSmoothing NOTIFY motionSmoothingChanged )
Q_PROPERTY( bool allowSupersampleFiltering READ allowSupersampleFiltering
WRITE setAllowSupersampleFiltering NOTIFY
allowSupersampleFilteringChanged )
Q_PROPERTY(
bool allowSupersampleOverride READ allowSupersampleOverride WRITE
setAllowSupersampleOverride NOTIFY allowSupersampleOverrideChanged )
Q_PROPERTY( bool noFadeToGrid READ noFadeToGrid WRITE setNoFadeToGrid NOTIFY
noFadeToGridChanged )
Q_PROPERTY( bool performanceGraph READ performanceGraph WRITE
setPerformanceGraph NOTIFY performanceGraphChanged )
Q_PROPERTY( bool dnd READ dnd WRITE setDND NOTIFY dNDChanged )
Q_PROPERTY( bool cameraActive READ cameraActive WRITE setCameraActive NOTIFY
cameraActiveChanged )
Q_PROPERTY( bool cameraBounds READ cameraBounds WRITE setCameraBounds NOTIFY
cameraBoundsChanged )
Q_PROPERTY( bool cameraRoom READ cameraRoom WRITE setCameraRoom NOTIFY
cameraRoomChanged )
Q_PROPERTY( bool cameraDashboard READ cameraDashboard WRITE
setCameraDashboard NOTIFY cameraDashboardChanged )
private:
OverlayController* parent;
float m_superSampling = 1.0;
bool m_motionSmoothing = true;
bool m_allowSupersampleFiltering = true;
bool m_allowSupersampleOverride = false;
bool m_performanceGraphToggle = false;
bool m_systemButtonToggle = false;
bool m_noFadeToGridToggle = false;
bool m_multipleDriverToggle = false;
bool m_dnd = false;
void initMotionSmoothing();
void initSupersampleOverride();
std::vector<SteamVRProfile> steamvrProfiles;
bool m_cameraActive = false;
bool m_cameraBounds = false;
bool m_cameraRoom = false;
bool m_cameraDashboard = false;
unsigned settingsUpdateCounter = 0;
@@ -65,44 +57,44 @@ public:
void eventLoopTick();
void dashboardLoopTick();
float superSampling() const;
bool motionSmoothing() const;
bool allowSupersampleFiltering() const;
bool allowSupersampleOverride() const;
bool performanceGraph() const;
bool noFadeToGrid() const;
bool multipleDriver() const;
bool systemButton() const;
bool dnd() const;
void reloadSteamVRProfiles();
void saveSteamVRProfiles();
Q_INVOKABLE int getSteamVRProfileCount();
Q_INVOKABLE QString getSteamVRProfileName( unsigned index );
bool cameraActive() const;
bool cameraBounds() const;
bool cameraRoom() const;
bool cameraDashboard() const;
public slots:
void setSuperSampling( float value, bool notify = true );
void setMotionSmoothing( bool value, bool notify = true );
void setAllowSupersampleFiltering( bool value, bool notify = true );
void setAllowSupersampleOverride( bool value, bool notify = true );
void setPerformanceGraph( bool value, bool notify = true );
void setSystemButton( bool value, bool notify = true );
void setNoFadeToGrid( bool value, bool notify = true );
void setMultipleDriver( bool value, bool notify = true );
void setDND( bool value, bool notify = true );
void addSteamVRProfile( QString name,
bool includeSupersampling,
bool includeSupersampleFiltering,
bool includeMotionSmoothing );
void applySteamVRProfile( unsigned index );
void deleteSteamVRProfile( unsigned index );
void setCameraActive( bool value, bool notify = true );
void setCameraBounds( bool value, bool notify = true );
void setCameraRoom( bool value, bool notify = true );
void setCameraDashboard( bool value, bool notify = true );
void reset();
void restartSteamVR();
signals:
void superSamplingChanged( float value );
void motionSmoothingChanged( bool value );
void allowSupersampleFilteringChanged( bool value );
void allowSupersampleOverrideChanged( bool value );
void performanceGraphChanged( bool value );
void steamVRProfilesUpdated();
void steamVRProfileAdded();
void performanceGraphChanged( bool value );
void multipleDriverChanged( bool value );
void systemButtonChanged( bool value );
void noFadeToGridChanged( bool value );
void dNDChanged( bool value );
void cameraActiveChanged( bool value );
void cameraBoundsChanged( bool value );
void cameraRoomChanged( bool value );
void cameraDashboardChanged( bool value );
};
} // namespace advsettings
@@ -2,6 +2,7 @@
#include <QQuickWindow>
#include <QApplication>
#include "../overlaycontroller.h"
#include "../keyboard_input/input_sender.h"
#include <chrono>
#include <thread>
@@ -79,6 +80,40 @@ void UtilitiesTabController::sendMediaStopSong()
keyboardinput::sendMediaStopSong();
}
void UtilitiesTabController::sendKeyboardOne()
{
m_parent->appSettings()->beginGroup( "keyboardShortcuts" );
const auto commands = m_parent->appSettings()
->value( "keyboardOne" )
.toString()
.toStdString();
m_parent->appSettings()->endGroup();
sendStringAsInput( commands );
}
void UtilitiesTabController::sendKeyboardTwo()
{
m_parent->appSettings()->beginGroup( "keyboardShortcuts" );
const auto commands = m_parent->appSettings()
->value( "keyboardTwo" )
.toString()
.toStdString();
m_parent->appSettings()->endGroup();
sendStringAsInput( commands );
}
void UtilitiesTabController::sendKeyboardThree()
{
m_parent->appSettings()->beginGroup( "keyboardShortcuts" );
const auto commands = m_parent->appSettings()
->value( "keyboardThree" )
.toString()
.toStdString();
m_parent->appSettings()->endGroup();
sendStringAsInput( commands );
}
bool UtilitiesTabController::alarmEnabled() const
{
return m_alarmEnabled;
@@ -65,6 +65,9 @@ public slots:
void sendMediaPreviousSong();
void sendMediaPausePlay();
void sendMediaStopSong();
Q_INVOKABLE void sendKeyboardOne();
Q_INVOKABLE void sendKeyboardTwo();
Q_INVOKABLE void sendKeyboardThree();
void setAlarmEnabled( bool enabled, bool notify = true );
void setAlarmIsModal( bool modal, bool notify = true );
+476 -178
View File
@@ -9,9 +9,12 @@ namespace advsettings
void VideoTabController::initStage1()
{
initBrightnessOverlay();
initColorOverlay();
initColorGain();
initMotionSmoothing();
initSupersampleOverride();
m_overlayInit = true;
reloadVideoConfig();
reloadVideoProfiles();
}
void VideoTabController::initBrightnessOverlay()
@@ -53,50 +56,99 @@ void VideoTabController::initBrightnessOverlay()
overlayError );
}
}
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 )
void VideoTabController::eventLoopTick() {}
void VideoTabController::dashboardLoopTick()
{
// TODO different key
if ( settingsUpdateCounter >= k_steamVrSettingsUpdateCounter )
{
const auto notifIconPath = paths::binaryDirectoryFindFile(
video_keys::k_colorOverlayFilename );
if ( notifIconPath.has_value() )
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 )
{
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 );
LOG( WARNING ) << "Could not read \""
<< vr::k_pch_SteamVR_SupersampleManualOverride_Bool
<< "\" setting: "
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
vrSettingsError );
}
else
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( ERROR ) << "Could not find Base color overlay: \""
<< video_keys::k_colorOverlayFilename << "\"";
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<double>( 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 );
settingsUpdateCounter = 0;
}
else
{
LOG( ERROR ) << "Could not create color overlay: "
<< vr::VROverlay()->GetOverlayErrorNameFromEnum(
overlayError );
settingsUpdateCounter++;
}
}
void VideoTabController::eventLoopTick() {}
void VideoTabController::reloadVideoConfig()
{
auto settings = OverlayController::appSettings();
@@ -106,15 +158,9 @@ void VideoTabController::reloadVideoConfig()
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();
setBrightnessOpacityValue();
loadColorOverlay();
settings->sync();
}
@@ -125,12 +171,7 @@ void VideoTabController::saveVideoConfig()
settings->setValue( "brightnessEnabled", brightnessEnabled() );
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();
}
@@ -187,7 +228,8 @@ void VideoTabController::setBrightnessValue( float percvalue, bool notify )
float realvalue = static_cast<float>(
std::pow( static_cast<double>( 1.0f - percvalue ), 1 / 3. ) );
if ( realvalue != m_brightnessOpacityValue )
if ( fabs( static_cast<double>( realvalue - m_brightnessOpacityValue ) )
> .005 )
{
m_brightnessValue = percvalue;
if ( realvalue <= 1.0f && realvalue >= 0.0f )
@@ -237,20 +279,6 @@ void VideoTabController::setBrightnessOpacityValue()
*/
// 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
{
@@ -268,71 +296,27 @@ float VideoTabController::colorBlue() const
}
// 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 )
if ( fabs( static_cast<double>( value - m_colorRed ) ) > .005 )
{
m_colorRed = value;
vr::VROverlayError overlayError = vr::VROverlay()->SetOverlayColor(
m_colorOverlayHandle, m_colorRed, m_colorGreen, m_colorBlue );
if ( overlayError != vr::VROverlayError_None )
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 for color overlay: "
<< vr::VROverlay()->GetOverlayErrorNameFromEnum(
overlayError );
LOG( ERROR ) << "could not set Red Gain Value, Error: "
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
vrSettingsError );
}
saveVideoConfig();
LOG( DEBUG ) << "Changed Red Gain to: " << m_colorRed;
vr::VRSettings()->Sync();
if ( notify )
{
emit colorRedChanged( m_colorRed );
@@ -342,18 +326,24 @@ void VideoTabController::setColorRed( float value, bool notify )
void VideoTabController::setColorGreen( float value, bool notify )
{
if ( value != m_colorGreen )
if ( fabs( static_cast<double>( value - m_colorGreen ) ) > .005 )
{
m_colorGreen = value;
vr::VROverlayError overlayError = vr::VROverlay()->SetOverlayColor(
m_colorOverlayHandle, m_colorRed, m_colorGreen, m_colorBlue );
if ( overlayError != vr::VROverlayError_None )
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 for color overlay: "
<< vr::VROverlay()->GetOverlayErrorNameFromEnum(
overlayError );
LOG( ERROR ) << "could not set Green Gain Value, Error: "
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
vrSettingsError );
}
saveVideoConfig();
LOG( DEBUG ) << "Changed Green Gain to: " << m_colorGreen;
vr::VRSettings()->Sync();
if ( notify )
{
emit colorGreenChanged( m_colorGreen );
@@ -363,18 +353,24 @@ void VideoTabController::setColorGreen( float value, bool notify )
void VideoTabController::setColorBlue( float value, bool notify )
{
if ( value != m_colorBlue )
if ( fabs( static_cast<double>( value - m_colorBlue ) ) > .005 )
{
m_colorBlue = value;
vr::VROverlayError overlayError = vr::VROverlay()->SetOverlayColor(
m_colorOverlayHandle, m_colorRed, m_colorGreen, m_colorBlue );
if ( overlayError != vr::VROverlayError_None )
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 for color overlay: "
<< vr::VROverlay()->GetOverlayErrorNameFromEnum(
overlayError );
LOG( ERROR ) << "could not set Blue Gain Value, Error: "
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
vrSettingsError );
}
saveVideoConfig();
LOG( DEBUG ) << "Changed Blue Gain to: " << m_colorBlue;
vr::VRSettings()->Sync();
if ( notify )
{
emit colorBlueChanged( m_colorBlue );
@@ -382,68 +378,370 @@ void VideoTabController::setColorBlue( float value, bool notify )
}
}
void VideoTabController::loadColorOverlay()
void VideoTabController::initColorGain()
{
vr::VROverlayError overlayError = vr::VROverlay()->SetOverlayColor(
m_colorOverlayHandle, m_colorRed, m_colorGreen, m_colorBlue );
if ( overlayError != vr::VROverlayError_None )
float temporary = 0.0f;
vr::EVRSettingsError vrSettingsError;
temporary = vr::VRSettings()->GetFloat(
vr::k_pch_SteamVR_Section,
vr::k_pch_SteamVR_HmdDisplayColorGainR_Float,
&vrSettingsError );
if ( vrSettingsError != vr::VRSettingsError_None )
{
LOG( ERROR ) << "Could not set Colors for color overlay: "
<< vr::VROverlay()->GetOverlayErrorNameFromEnum(
overlayError );
LOG( ERROR ) << "Could not get Red Gain Value ERROR: "
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
vrSettingsError );
}
else
{
m_colorRed = temporary;
setColorRed( temporary );
}
overlayError = vr::VROverlay()->SetOverlayAlpha( m_colorOverlayHandle,
m_colorOpacity );
if ( overlayError != vr::VROverlayError_None )
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 set alpha: "
<< vr::VROverlay()->GetOverlayErrorNameFromEnum(
overlayError );
LOG( ERROR ) << "Could not get 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 );
if ( vrSettingsError != vr::VRSettingsError_None )
{
LOG( ERROR ) << "Could not get Blue Gain Value ERROR: "
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
vrSettingsError );
}
else
{
m_colorBlue = temporary;
setColorBlue( temporary );
}
}
void VideoTabController::setColorOpacityPerc( float percvalue, bool notify )
/*
* -------------------------
* SuperSampling
* -------------------------
*/
// Getters
float VideoTabController::superSampling() const
{
// This takes the Perceived value, and converts it to allow more accurate
// linear positioning. (human perception logarithmic)
return m_superSampling;
}
// clamp the "percieved" value to 50% this is to ensure useability.
if ( percvalue <= 0.5f )
bool VideoTabController::allowSupersampleOverride() const
{
return m_allowSupersampleOverride;
}
void VideoTabController::initSupersampleOverride()
{
bool temporary = false;
vr::EVRSettingsError vrSettingsError;
temporary = vr::VRSettings()->GetBool(
vr::k_pch_SteamVR_Section,
vr::k_pch_SteamVR_SupersampleManualOverride_Bool,
&vrSettingsError );
if ( vrSettingsError != vr::VRSettingsError_None )
{
percvalue = 0.5f;
LOG( WARNING ) << "Could not get SuperSampling Override State \""
<< vr::k_pch_SteamVR_SupersampleManualOverride_Bool
<< "\" setting: "
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
vrSettingsError );
}
float realvalue = static_cast<float>(
std::pow( static_cast<double>( 1.0f - percvalue ), 0.5555f ) );
vr::VRSettings()->Sync();
setAllowSupersampleOverride( temporary, true );
}
if ( realvalue != m_colorOpacity )
void VideoTabController::setSuperSampling( float value, const bool notify )
{
bool override = false;
// Mirrors Desktop Clamp
if ( value < 0.2f )
{
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;
}
LOG( WARNING ) << "Encountered a supersampling value <= 0.2, setting "
"supersampling to 1.0";
value = 1.0f;
override = true;
}
if ( override
|| fabs( static_cast<double>( m_superSampling - value ) ) > .005 )
{
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 );
vr::VRSettings()->Sync();
if ( notify )
{
emit brightnessValueChanged( percvalue );
emit superSamplingChanged( m_superSampling );
}
}
}
void VideoTabController::setAllowSupersampleOverride( const bool value,
const bool notify )
{
if ( m_allowSupersampleOverride != value )
{
m_allowSupersampleOverride = value;
vr::VRSettings()->SetBool(
vr::k_pch_SteamVR_Section,
vr::k_pch_SteamVR_SupersampleManualOverride_Bool,
m_allowSupersampleOverride );
vr::VRSettings()->Sync();
if ( notify )
{
emit allowSupersampleOverrideChanged( m_allowSupersampleOverride );
}
}
}
/*
* -------------------------
* motion smoothing/antistropic (misc)
* -------------------------
*/
bool VideoTabController::motionSmoothing() const
{
return m_motionSmoothing;
}
void VideoTabController::setMotionSmoothing( const bool value,
const bool notify )
{
if ( m_motionSmoothing != value )
{
m_motionSmoothing = value;
vr::VRSettings()->SetBool( vr::k_pch_SteamVR_Section,
vr::k_pch_SteamVR_MotionSmoothing_Bool,
m_motionSmoothing );
vr::VRSettings()->Sync();
if ( notify )
{
emit motionSmoothingChanged( m_motionSmoothing );
}
}
}
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 );
}
vr::VRSettings()->Sync();
setMotionSmoothing( temporary, true );
}
bool VideoTabController::allowSupersampleFiltering() const
{
return m_allowSupersampleFiltering;
}
void VideoTabController::setAllowSupersampleFiltering( const bool value,
const bool notify )
{
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()->Sync();
if ( notify )
{
emit allowSupersampleFilteringChanged(
m_allowSupersampleFiltering );
}
}
}
/* -----------------------------------------*/
/*------------------------------------------*/
/*Profile Logic Functions*/
void VideoTabController::addVideoProfile( const QString name )
{
VideoProfile* profile = nullptr;
for ( auto& p : videoProfiles )
{
if ( p.profileName.compare( name.toStdString() ) == 0 )
{
profile = &p;
break;
}
}
if ( !profile )
{
auto i = videoProfiles.size();
videoProfiles.emplace_back();
profile = &videoProfiles[i];
}
profile->profileName = name.toStdString();
profile->supersampleOverride = m_allowSupersampleOverride;
profile->supersampling = m_superSampling;
profile->anisotropicFiltering = m_allowSupersampleFiltering;
profile->motionSmooth = m_motionSmoothing;
profile->colorRed = m_colorRed;
profile->colorGreen = m_colorGreen;
profile->colorBlue = m_colorBlue;
profile->brightnessToggle = m_brightnessEnabled;
profile->brightnessValue = m_brightnessValue;
saveVideoProfiles();
OverlayController::appSettings()->sync();
emit videoProfilesUpdated();
emit videoProfileAdded();
}
void VideoTabController::applyVideoProfile( const unsigned index )
{
if ( index < videoProfiles.size() )
{
auto& profile = videoProfiles[index];
setAllowSupersampleOverride( profile.supersampleOverride );
setSuperSampling( profile.supersampling );
setAllowSupersampleFiltering( profile.anisotropicFiltering );
setMotionSmoothing( profile.motionSmooth );
setColorRed( profile.colorRed );
setColorBlue( profile.colorBlue );
setColorGreen( profile.colorGreen );
setBrightnessEnabled( profile.brightnessToggle );
setBrightnessValue( profile.brightnessValue );
vr::VRSettings()->Sync( true );
}
}
void VideoTabController::deleteVideoProfile( const unsigned index )
{
if ( index < videoProfiles.size() )
{
auto pos = videoProfiles.begin() + index;
videoProfiles.erase( pos );
saveVideoProfiles();
OverlayController::appSettings()->sync();
emit videoProfilesUpdated();
}
}
void VideoTabController::reloadVideoProfiles()
{
videoProfiles.clear();
auto settings = OverlayController::appSettings();
settings->beginGroup( "steamVRSettings" );
auto profileCount = settings->beginReadArray( "steamVRProfiles" );
for ( int i = 0; i < profileCount; i++ )
{
settings->setArrayIndex( i );
videoProfiles.emplace_back();
auto& entry = videoProfiles[static_cast<size_t>( i )];
entry.profileName
= settings->value( "profileName" ).toString().toStdString();
entry.supersampleOverride
= settings->value( "supersamplingOverride", false ).toBool();
entry.supersampling
= settings->value( "supersampling", 1.0f ).toFloat();
entry.anisotropicFiltering
= settings->value( "anisotropicFiltering", true ).toBool();
entry.motionSmooth = settings->value( "motionSmooth", true ).toBool();
entry.colorRed = settings->value( "colorRed", 1.0f ).toFloat();
entry.colorBlue = settings->value( "colorBlue", 1.0f ).toFloat();
entry.colorGreen = settings->value( "colorGreen", 1.0f ).toFloat();
entry.brightnessToggle
= settings->value( "brightnessToggle", false ).toBool();
entry.brightnessValue
= settings->value( "brightnessValue", 1.0f ).toFloat();
}
settings->endArray();
settings->endGroup();
}
void VideoTabController::saveVideoProfiles()
{
auto settings = OverlayController::appSettings();
settings->beginGroup( "VideoSettings" );
settings->beginWriteArray( "videoProfiles" );
unsigned i = 0;
for ( auto& p : videoProfiles )
{
settings->setArrayIndex( static_cast<int>( i ) );
settings->setValue( "profileName",
QString::fromStdString( p.profileName ) );
settings->setValue( "supersamplingOverride", p.supersampleOverride );
settings->setValue( "supersampling", p.supersampling );
settings->setValue( "anisotropicFiltering", p.anisotropicFiltering );
settings->setValue( "motionSmooth", p.motionSmooth );
settings->setValue( "colorRed", p.colorRed );
settings->setValue( "colorBlue", p.colorBlue );
settings->setValue( "colorGreen", p.colorGreen );
settings->setValue( "brightnessToggle", p.brightnessToggle );
settings->setValue( "brightnessValue", p.brightnessValue );
i++;
}
settings->endArray();
settings->endGroup();
}
int VideoTabController::getVideoProfileCount()
{
return static_cast<int>( videoProfiles.size() );
}
QString VideoTabController::getVideoProfileName( const unsigned index )
{
if ( index >= videoProfiles.size() )
{
return QString();
}
else
{
return QString::fromStdString( videoProfiles[index].profileName );
}
}
/*------------------------------------------*/
/* -----------------------------------------*/
} // namespace advsettings
+67 -27
View File
@@ -10,7 +10,6 @@ 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
@@ -19,6 +18,21 @@ namespace advsettings
// forward declaration
class OverlayController;
struct VideoProfile
{
std::string profileName;
float supersampling = 1.0f;
bool anisotropicFiltering = false;
bool motionSmooth = false;
bool supersampleOverride = false;
float colorRed = 1.0f;
float colorGreen = 1.0f;
float colorBlue = 1.0f;
bool brightnessToggle = false;
float brightnessValue = 1.0f;
};
class VideoTabController : public QObject
{
Q_OBJECT
@@ -26,20 +40,26 @@ 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 )
Q_PROPERTY( float superSampling READ superSampling WRITE setSuperSampling
NOTIFY superSamplingChanged )
Q_PROPERTY(
bool allowSupersampleOverride READ allowSupersampleOverride WRITE
setAllowSupersampleOverride NOTIFY allowSupersampleOverrideChanged )
Q_PROPERTY( bool motionSmoothing READ motionSmoothing WRITE
setMotionSmoothing NOTIFY motionSmoothingChanged )
Q_PROPERTY( bool allowSupersampleFiltering READ allowSupersampleFiltering
WRITE setAllowSupersampleFiltering NOTIFY
allowSupersampleFilteringChanged )
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
@@ -55,23 +75,27 @@ private:
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;
float m_superSampling = 1.0;
bool m_allowSupersampleOverride = false;
bool m_motionSmoothing = true;
bool m_allowSupersampleFiltering = true;
void initColorGain();
void initSupersampleOverride();
void initMotionSmoothing();
void reloadVideoConfig();
void saveVideoConfig();
void setBrightnessOpacityValue();
void initBrightnessOverlay();
void initColorOverlay();
void loadColorOverlay();
std::vector<VideoProfile> videoProfiles;
QString getSettingsName()
{
@@ -83,11 +107,6 @@ private:
return m_brightnessOverlayHandle;
}
vr::VROverlayHandle_t getColorOverlayHandle()
{
return m_colorOverlayHandle;
}
public:
float brightnessOpacityValue() const;
// inverse of brightnessValue
@@ -96,37 +115,58 @@ public:
// Color overlay Getters
bool colorEnabled() const;
float colorOpacity() const;
float colorRed() const;
float colorGreen() const;
float colorBlue() const;
float colorOpacityPerc() const;
bool allowSupersampleOverride() const;
float superSampling() const;
bool motionSmoothing() const;
bool allowSupersampleFiltering() const;
void initStage1();
void eventLoopTick();
void dashboardLoopTick();
void reloadVideoProfiles();
void saveVideoProfiles();
Q_INVOKABLE int getVideoProfileCount();
Q_INVOKABLE QString getVideoProfileName( unsigned index );
public slots:
void setBrightnessEnabled( bool value, bool notify = true );
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 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 );
void setMotionSmoothing( bool value, bool notify = true );
void setAllowSupersampleFiltering( bool value, bool notify = true );
void addVideoProfile( QString name );
void applyVideoProfile( unsigned index );
void deleteVideoProfile( unsigned index );
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 );
void superSamplingChanged( float value );
void allowSupersampleOverrideChanged( bool value );
void motionSmoothingChanged( bool value );
void allowSupersampleFilteringChanged( bool value );
void videoProfilesUpdated();
void videoProfileAdded();
};
} // namespace advsettings