Add chaperone autoprofiles, crash recovery, and space fix revert
This commit is contained in:
@@ -644,60 +644,7 @@ void ChaperoneTabController::eventLoopTick(
|
||||
{
|
||||
if ( parent->isDashboardVisible() )
|
||||
{
|
||||
vr::EVRSettingsError vrSettingsError;
|
||||
float vis = static_cast<float>( vr::VRSettings()->GetInt32(
|
||||
vr::k_pch_CollisionBounds_Section,
|
||||
vr::k_pch_CollisionBounds_ColorGammaA_Int32,
|
||||
&vrSettingsError ) );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING )
|
||||
<< "Could not read \""
|
||||
<< vr::k_pch_CollisionBounds_ColorGammaA_Int32
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
setBoundsVisibility( vis / 255.0f );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING )
|
||||
<< "Could not read \""
|
||||
<< vr::k_pch_CollisionBounds_FadeDistance_Float
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
|
||||
auto cm = vr::VRSettings()->GetBool(
|
||||
vr::k_pch_CollisionBounds_Section,
|
||||
vr::k_pch_CollisionBounds_CenterMarkerOn_Bool,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING )
|
||||
<< "Could not read \""
|
||||
<< vr::k_pch_CollisionBounds_CenterMarkerOn_Bool
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
setCenterMarker( cm );
|
||||
auto ps = vr::VRSettings()->GetBool(
|
||||
vr::k_pch_CollisionBounds_Section,
|
||||
vr::k_pch_CollisionBounds_PlaySpaceOn_Bool,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING )
|
||||
<< "Could not read \""
|
||||
<< vr::k_pch_CollisionBounds_PlaySpaceOn_Bool
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
setPlaySpaceMarker( ps );
|
||||
updateHeight( getBoundsMaxY() );
|
||||
updateChaperoneSettings();
|
||||
}
|
||||
settingsUpdateCounter = 0;
|
||||
}
|
||||
@@ -707,6 +654,60 @@ void ChaperoneTabController::eventLoopTick(
|
||||
}
|
||||
}
|
||||
|
||||
void ChaperoneTabController::updateChaperoneSettings()
|
||||
{
|
||||
vr::EVRSettingsError vrSettingsError;
|
||||
float vis = static_cast<float>(
|
||||
vr::VRSettings()->GetInt32( vr::k_pch_CollisionBounds_Section,
|
||||
vr::k_pch_CollisionBounds_ColorGammaA_Int32,
|
||||
&vrSettingsError ) );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_CollisionBounds_ColorGammaA_Int32
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
setBoundsVisibility( vis / 255.0f );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_CollisionBounds_FadeDistance_Float
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
|
||||
auto cm = vr::VRSettings()->GetBool(
|
||||
vr::k_pch_CollisionBounds_Section,
|
||||
vr::k_pch_CollisionBounds_CenterMarkerOn_Bool,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_CollisionBounds_CenterMarkerOn_Bool
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
setCenterMarker( cm );
|
||||
auto ps
|
||||
= vr::VRSettings()->GetBool( vr::k_pch_CollisionBounds_Section,
|
||||
vr::k_pch_CollisionBounds_PlaySpaceOn_Bool,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
<< vr::k_pch_CollisionBounds_PlaySpaceOn_Bool
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
setPlaySpaceMarker( ps );
|
||||
updateHeight( getBoundsMaxY() );
|
||||
}
|
||||
|
||||
float ChaperoneTabController::boundsVisibility() const
|
||||
{
|
||||
return m_visibility;
|
||||
@@ -1520,6 +1521,91 @@ void ChaperoneTabController::deleteChaperoneProfile( unsigned index )
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<bool, unsigned>
|
||||
ChaperoneTabController::getChaperoneProfileIndexFromName( std::string name )
|
||||
{
|
||||
std::pair<bool, unsigned> result = { false, 0 };
|
||||
unsigned profileIndex = 0;
|
||||
for ( auto& p : chaperoneProfiles )
|
||||
{
|
||||
if ( name == p.profileName )
|
||||
{
|
||||
result.first = true;
|
||||
result.second = profileIndex;
|
||||
break;
|
||||
}
|
||||
profileIndex++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void ChaperoneTabController::createNewAutosaveProfile()
|
||||
{
|
||||
// update settings to live chaperone
|
||||
updateChaperoneSettings();
|
||||
|
||||
// lookup the index for old autosave and delete it
|
||||
std::pair<bool, unsigned> previousAutosaveIndexLookup
|
||||
= getChaperoneProfileIndexFromName( "«Autosaved Profile (previous)»" );
|
||||
if ( previousAutosaveIndexLookup.first )
|
||||
{
|
||||
deleteChaperoneProfile( previousAutosaveIndexLookup.second );
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG( INFO )
|
||||
<< "[Chaperone Autosave] «Autosaved Profile (previous)» not found";
|
||||
}
|
||||
|
||||
// lookup the index for current autosave and rename to old
|
||||
std::pair<bool, unsigned> currentAutosaveIndexLookup
|
||||
= getChaperoneProfileIndexFromName( "«Autosaved Profile»" );
|
||||
if ( currentAutosaveIndexLookup.first )
|
||||
{
|
||||
chaperoneProfiles[currentAutosaveIndexLookup.second].profileName
|
||||
= "«Autosaved Profile (previous)»";
|
||||
saveChaperoneProfiles();
|
||||
OverlayController::appSettings()->sync();
|
||||
emit chaperoneProfilesUpdated();
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG( INFO ) << "[Chaperone Autosave] «Autosaved Profile» not found";
|
||||
}
|
||||
|
||||
// create a new autosave from current chaperone (all options set true)
|
||||
addChaperoneProfile( "«Autosaved Profile»",
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true );
|
||||
}
|
||||
|
||||
void ChaperoneTabController::applyAutosavedProfile()
|
||||
{
|
||||
// lookup index of autosave
|
||||
std::pair<bool, unsigned> autosaveIndexLookup
|
||||
= getChaperoneProfileIndexFromName( "«Autosaved Profile»" );
|
||||
|
||||
// check if it exists
|
||||
if ( autosaveIndexLookup.first )
|
||||
{
|
||||
// apply if it exists
|
||||
applyChaperoneProfile( autosaveIndexLookup.second );
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG( WARNING ) << "Failed to apply chaperone Autosaved Profile "
|
||||
"(autosave doesn't exist)";
|
||||
}
|
||||
}
|
||||
|
||||
float ChaperoneTabController::getBoundsMaxY()
|
||||
{
|
||||
unsigned collisionBoundsCount = 0;
|
||||
|
||||
@@ -157,6 +157,7 @@ private:
|
||||
bool m_chaperoneShowDashboardActive = false;
|
||||
|
||||
unsigned settingsUpdateCounter = 0;
|
||||
void updateChaperoneSettings();
|
||||
|
||||
bool m_isHapticGood = true;
|
||||
bool m_isHMDActive = false;
|
||||
@@ -165,6 +166,8 @@ private:
|
||||
bool m_leftHapticClickActivated = false;
|
||||
bool m_rightHapticClickActivated = false;
|
||||
|
||||
bool m_autosaveComplete = false;
|
||||
|
||||
int m_updateTicksChaperoneReload = 0;
|
||||
|
||||
vr::VRActionHandle_t m_rightActionHandle;
|
||||
@@ -219,6 +222,9 @@ public:
|
||||
Q_INVOKABLE QString getChaperoneProfileName( unsigned index );
|
||||
|
||||
float getBoundsMaxY();
|
||||
std::pair<bool, unsigned>
|
||||
getChaperoneProfileIndexFromName( std::string name );
|
||||
void createNewAutosaveProfile();
|
||||
|
||||
// actions
|
||||
void addLeftHapticClick( bool leftHapticClickPressed );
|
||||
@@ -265,6 +271,7 @@ public slots:
|
||||
bool includesProximityWarningSettings );
|
||||
void applyChaperoneProfile( unsigned index );
|
||||
void deleteChaperoneProfile( unsigned index );
|
||||
void applyAutosavedProfile();
|
||||
|
||||
void reset();
|
||||
|
||||
|
||||
@@ -1215,6 +1215,11 @@ void MoveCenterTabController::setEnableSeatedOffsetsRecenter( bool value,
|
||||
<< m_enableSeatedOffsetsRecenter;
|
||||
}
|
||||
|
||||
bool MoveCenterTabController::isInitComplete() const
|
||||
{
|
||||
return m_initComplete;
|
||||
}
|
||||
|
||||
bool MoveCenterTabController::disableSeatedMotion() const
|
||||
{
|
||||
return m_disableSeatedMotion;
|
||||
@@ -1414,7 +1419,30 @@ void MoveCenterTabController::zeroOffsets()
|
||||
if ( !m_initComplete )
|
||||
{
|
||||
setTrackingUniverse( vr::VRCompositor()->GetTrackingSpace() );
|
||||
m_initComplete = true;
|
||||
if ( parent->isPreviousShutdownSafe() )
|
||||
{
|
||||
// all init complete, safe to autosave chaperone profile
|
||||
parent->m_chaperoneTabController.createNewAutosaveProfile();
|
||||
m_initComplete = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// shutdown was unsafe last session!
|
||||
LOG( WARNING )
|
||||
<< "DETECTED UNSAFE SHUTDOWN FROM LAST SESSION";
|
||||
m_initComplete = true;
|
||||
if ( !parent->crashRecoveryDisabled() )
|
||||
{
|
||||
parent->m_chaperoneTabController
|
||||
.applyAutosavedProfile();
|
||||
LOG( INFO )
|
||||
<< "Applying last good chaperone profile autosave";
|
||||
}
|
||||
}
|
||||
// Now mark previous shutdown as unsafe in case we crash some
|
||||
// time during this session. Previous shutdown will be marked as
|
||||
// being safe once more just before our app shuts down properly.
|
||||
parent->setPreviousShutdownSafe( false );
|
||||
}
|
||||
}
|
||||
if ( m_roomSetupModeDetected )
|
||||
|
||||
@@ -259,6 +259,7 @@ public:
|
||||
bool universeCenteredRotation() const;
|
||||
bool enableSeatedOffsetsRecenter() const;
|
||||
bool disableSeatedMotion() const;
|
||||
bool isInitComplete() const;
|
||||
double getHmdYawTotal();
|
||||
void resetHmdYawTotal();
|
||||
void incomingSeatedReset();
|
||||
|
||||
Reference in New Issue
Block a user