Implemented vsync tick for event loops
This commit is contained in:
+33
-24
@@ -495,7 +495,7 @@ void OverlayController::SetWidget( QQuickItem* quickItem,
|
||||
SLOT( OnTimeoutPumpEvents() ) );
|
||||
|
||||
// was m_pPumpEventsTimer->setInterval( 20 );
|
||||
m_pPumpEventsTimer->setInterval( 5 );
|
||||
m_pPumpEventsTimer->setInterval( 1 );
|
||||
|
||||
m_pPumpEventsTimer->start();
|
||||
|
||||
@@ -580,6 +580,10 @@ QPoint OverlayController::getMousePositionForEvent( vr::VREvent_Mouse_t mouse )
|
||||
|
||||
void OverlayController::OnTimeoutPumpEvents()
|
||||
{
|
||||
vr::VRSystem()->GetTimeSinceLastVsync( nullptr, &m_currentFrame );
|
||||
|
||||
if ( m_currentFrame > m_lastFrame )
|
||||
{
|
||||
if ( !vr::VRSystem() )
|
||||
return;
|
||||
|
||||
@@ -591,10 +595,12 @@ void OverlayController::OnTimeoutPumpEvents()
|
||||
{
|
||||
case vr::VREvent_MouseMove:
|
||||
{
|
||||
QPoint ptNewMouse = getMousePositionForEvent( vrEvent.data.mouse );
|
||||
QPoint ptNewMouse
|
||||
= getMousePositionForEvent( vrEvent.data.mouse );
|
||||
if ( ptNewMouse != m_ptLastMouse )
|
||||
{
|
||||
QMouseEvent mouseEvent( QEvent::MouseMove,
|
||||
QMouseEvent mouseEvent(
|
||||
QEvent::MouseMove,
|
||||
ptNewMouse,
|
||||
m_pWindow->mapToGlobal( ptNewMouse ),
|
||||
Qt::NoButton,
|
||||
@@ -609,7 +615,8 @@ void OverlayController::OnTimeoutPumpEvents()
|
||||
|
||||
case vr::VREvent_MouseButtonDown:
|
||||
{
|
||||
QPoint ptNewMouse = getMousePositionForEvent( vrEvent.data.mouse );
|
||||
QPoint ptNewMouse
|
||||
= getMousePositionForEvent( vrEvent.data.mouse );
|
||||
Qt::MouseButton button
|
||||
= vrEvent.data.mouse.button == vr::VRMouseButton_Right
|
||||
? Qt::RightButton
|
||||
@@ -627,7 +634,8 @@ void OverlayController::OnTimeoutPumpEvents()
|
||||
|
||||
case vr::VREvent_MouseButtonUp:
|
||||
{
|
||||
QPoint ptNewMouse = getMousePositionForEvent( vrEvent.data.mouse );
|
||||
QPoint ptNewMouse
|
||||
= getMousePositionForEvent( vrEvent.data.mouse );
|
||||
Qt::MouseButton button
|
||||
= vrEvent.data.mouse.button == vr::VRMouseButton_Right
|
||||
? Qt::RightButton
|
||||
@@ -669,8 +677,8 @@ void OverlayController::OnTimeoutPumpEvents()
|
||||
case vr::VREvent_Quit:
|
||||
{
|
||||
LOG( INFO ) << "Received quit request.";
|
||||
vr::VRSystem()->AcknowledgeQuit_Exiting(); // Let us buy some time
|
||||
// just in case
|
||||
vr::VRSystem()->AcknowledgeQuit_Exiting(); // Let us buy some
|
||||
// time just in case
|
||||
m_moveCenterTabController.reset();
|
||||
m_chaperoneTabController.shutdown();
|
||||
Shutdown();
|
||||
@@ -702,12 +710,11 @@ void OverlayController::OnTimeoutPumpEvents()
|
||||
}
|
||||
break;
|
||||
|
||||
// Multiple ChaperoneUniverseHasChanged are often emitted at the same
|
||||
// time (some with a little bit of delay) There is no sure way to
|
||||
// recognize redundant events, we can only exclude redundant events
|
||||
// during the same call of OnTimeoutPumpEvents()
|
||||
// INFO Removed logging on play space mover for possible crashing
|
||||
// issues.
|
||||
// Multiple ChaperoneUniverseHasChanged are often emitted at the
|
||||
// same time (some with a little bit of delay) There is no sure way
|
||||
// to recognize redundant events, we can only exclude redundant
|
||||
// events during the same call of OnTimeoutPumpEvents() INFO Removed
|
||||
// logging on play space mover for possible crashing issues.
|
||||
case vr::VREvent_ChaperoneUniverseHasChanged:
|
||||
case vr::VREvent_ChaperoneDataHasChanged:
|
||||
{
|
||||
@@ -715,8 +722,8 @@ void OverlayController::OnTimeoutPumpEvents()
|
||||
{
|
||||
// LOG(INFO) << "Re-loading chaperone data ...";
|
||||
m_chaperoneUtils.loadChaperoneData();
|
||||
// LOG(INFO) << "Found " << m_chaperoneUtils.quadsCount() << "
|
||||
// chaperone quads."; if
|
||||
// LOG(INFO) << "Found " << m_chaperoneUtils.quadsCount() <<
|
||||
// " chaperone quads."; if
|
||||
// (m_chaperoneUtils.isChaperoneWellFormed()) { LOG(INFO) <<
|
||||
// "Chaperone data seems to be well-formed.";
|
||||
//} else {
|
||||
@@ -746,8 +753,8 @@ void OverlayController::OnTimeoutPumpEvents()
|
||||
== vr::TrackingResult_Running_OK )
|
||||
{
|
||||
auto& vel = devicePoses[leftId].vVelocity.v;
|
||||
leftSpeed
|
||||
= std::sqrt( vel[0] * vel[0] + vel[1] * vel[1] + vel[2] * vel[2] );
|
||||
leftSpeed = std::sqrt( vel[0] * vel[0] + vel[1] * vel[1]
|
||||
+ vel[2] * vel[2] );
|
||||
}
|
||||
auto rightId = vr::VRSystem()->GetTrackedDeviceIndexForControllerRole(
|
||||
vr::TrackedControllerRole_RightHand );
|
||||
@@ -758,8 +765,8 @@ void OverlayController::OnTimeoutPumpEvents()
|
||||
== vr::TrackingResult_Running_OK )
|
||||
{
|
||||
auto& vel = devicePoses[rightId].vVelocity.v;
|
||||
rightSpeed
|
||||
= std::sqrt( vel[0] * vel[0] + vel[1] * vel[1] + vel[2] * vel[2] );
|
||||
rightSpeed = std::sqrt( vel[0] * vel[0] + vel[1] * vel[1]
|
||||
+ vel[2] * vel[2] );
|
||||
}
|
||||
auto hmdSpeed = 0.0f;
|
||||
if ( devicePoses[vr::k_unTrackedDeviceIndex_Hmd].bPoseIsValid
|
||||
@@ -767,22 +774,22 @@ void OverlayController::OnTimeoutPumpEvents()
|
||||
== vr::TrackingResult_Running_OK )
|
||||
{
|
||||
auto& vel = devicePoses[vr::k_unTrackedDeviceIndex_Hmd].vVelocity.v;
|
||||
hmdSpeed
|
||||
= std::sqrt( vel[0] * vel[0] + vel[1] * vel[1] + vel[2] * vel[2] );
|
||||
hmdSpeed = std::sqrt( vel[0] * vel[0] + vel[1] * vel[1]
|
||||
+ vel[2] * vel[2] );
|
||||
}
|
||||
|
||||
m_moveCenterTabController.eventLoopTick(
|
||||
vr::VRCompositor()->GetTrackingSpace(), devicePoses );
|
||||
m_utilitiesTabController.eventLoopTick();
|
||||
m_fixFloorTabController.eventLoopTick( devicePoses );
|
||||
m_statisticsTabController.eventLoopTick(
|
||||
devicePoses, leftSpeed, rightSpeed );
|
||||
m_moveCenterTabController.eventLoopTick(
|
||||
vr::VRCompositor()->GetTrackingSpace(), devicePoses );
|
||||
m_steamVRTabController.eventLoopTick();
|
||||
m_chaperoneTabController.eventLoopTick(
|
||||
devicePoses, leftSpeed, rightSpeed, hmdSpeed );
|
||||
m_settingsTabController.eventLoopTick();
|
||||
m_reviveTabController.eventLoopTick();
|
||||
m_audioTabController.eventLoopTick();
|
||||
m_utilitiesTabController.eventLoopTick();
|
||||
m_accessibilityTabController.eventLoopTick(
|
||||
vr::VRCompositor()->GetTrackingSpace() );
|
||||
|
||||
@@ -801,6 +808,8 @@ void OverlayController::OnTimeoutPumpEvents()
|
||||
}
|
||||
}
|
||||
}
|
||||
m_lastFrame = m_currentFrame;
|
||||
}
|
||||
}
|
||||
|
||||
void OverlayController::AddOffsetToUniverseCenter(
|
||||
|
||||
@@ -80,6 +80,9 @@ private:
|
||||
QSoundEffect m_focusChangedSoundEffect;
|
||||
QSoundEffect m_alarm01SoundEffect;
|
||||
|
||||
uint64_t m_currentFrame = 0;
|
||||
uint64_t m_lastFrame = 0;
|
||||
|
||||
public: // I know it's an ugly hack to make them public to enable external
|
||||
// access, but I am too lazy to implement getters.
|
||||
SteamVRTabController m_steamVRTabController;
|
||||
|
||||
@@ -415,7 +415,11 @@ MyStackViewPage {
|
||||
reloadChaperoneProfiles()
|
||||
reloadSteamVRProfiles()
|
||||
reloadPttProfiles()
|
||||
summaryVersionText.text = applicationVersion
|
||||
|
||||
// REVERT TO THIS LATER: summaryVersionText.text = applicationVersion
|
||||
// TEMP VERSION:
|
||||
summaryVersionText.text = "Alpha-Kung v1.3"
|
||||
|
||||
if (MoveCenterTabController.trackingUniverse === 0) {
|
||||
summaryPlaySpaceModeText.text = "Sitting"
|
||||
} else if (MoveCenterTabController.trackingUniverse === 1) {
|
||||
|
||||
@@ -116,9 +116,12 @@ void AccessibilityTabController::eventLoopTick(
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ( settingsUpdateCounter >= 50 )
|
||||
if ( settingsUpdateCounter >= 151 )
|
||||
{
|
||||
if ( parent->isDashboardVisible() )
|
||||
{
|
||||
setTrackingUniverse( ( int ) universe );
|
||||
}
|
||||
settingsUpdateCounter = 0;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -167,7 +167,7 @@ void AudioTabController::eventLoopTick()
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ( settingsUpdateCounter >= 50 )
|
||||
if ( settingsUpdateCounter >= 89 )
|
||||
{
|
||||
if ( m_micProximitySensorCanMute )
|
||||
{
|
||||
|
||||
@@ -649,7 +649,9 @@ void ChaperoneTabController::eventLoopTick(
|
||||
}
|
||||
}
|
||||
|
||||
if ( settingsUpdateCounter >= 50 )
|
||||
if ( settingsUpdateCounter >= 101 )
|
||||
{
|
||||
if ( parent->isDashboardVisible() )
|
||||
{
|
||||
vr::EVRSettingsError vrSettingsError;
|
||||
float vis = vr::VRSettings()->GetInt32(
|
||||
@@ -658,7 +660,8 @@ void ChaperoneTabController::eventLoopTick(
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
LOG( WARNING )
|
||||
<< "Could not read \""
|
||||
<< vr::k_pch_CollisionBounds_ColorGammaA_Int32
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
@@ -688,7 +691,8 @@ void ChaperoneTabController::eventLoopTick(
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
LOG( WARNING )
|
||||
<< "Could not read \""
|
||||
<< vr::k_pch_CollisionBounds_CenterMarkerOn_Bool
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
@@ -701,7 +705,8 @@ void ChaperoneTabController::eventLoopTick(
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
LOG( WARNING )
|
||||
<< "Could not read \""
|
||||
<< vr::k_pch_CollisionBounds_PlaySpaceOn_Bool
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
@@ -709,6 +714,7 @@ void ChaperoneTabController::eventLoopTick(
|
||||
}
|
||||
setPlaySpaceMarker( ps );
|
||||
updateHeight( getBoundsMaxY() );
|
||||
}
|
||||
settingsUpdateCounter = 0;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -604,9 +604,12 @@ void MoveCenterTabController::eventLoopTick(
|
||||
vr::ETrackingUniverseOrigin universe,
|
||||
vr::TrackedDevicePose_t* devicePoses )
|
||||
{
|
||||
if ( settingsUpdateCounter >= 100 )
|
||||
if ( settingsUpdateCounter >= 149 )
|
||||
{
|
||||
if ( parent->isDashboardVisible() )
|
||||
{
|
||||
setTrackingUniverse( int( universe ) );
|
||||
}
|
||||
settingsUpdateCounter = 0;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -309,13 +309,16 @@ void ReviveTabController::eventLoopTick()
|
||||
if ( m_isOverlayInstalled
|
||||
|| parent->m_settingsTabController.forceRevivePage() )
|
||||
{
|
||||
if ( settingsUpdateCounter >= 50 )
|
||||
if ( settingsUpdateCounter >= 139 )
|
||||
{
|
||||
if ( parent->isDashboardVisible() )
|
||||
{
|
||||
settingsUpdateCounter = 0;
|
||||
vr::EVRSettingsError vrSettingsError;
|
||||
|
||||
float valuef = vr::VRSettings()->GetFloat(
|
||||
section_revive, key_pixelsPerDisplayPixel, &vrSettingsError );
|
||||
float valuef
|
||||
= vr::VRSettings()->GetFloat( section_revive,
|
||||
key_pixelsPerDisplayPixel,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError == vr::VRSettingsError_None )
|
||||
{
|
||||
if ( valuef == 0.0 )
|
||||
@@ -421,25 +424,35 @@ void ReviveTabController::eventLoopTick()
|
||||
}
|
||||
|
||||
char buffer[1024];
|
||||
vr::VRSettings()->GetString(
|
||||
section_revive, key_piUser, buffer, 1024, &vrSettingsError );
|
||||
vr::VRSettings()->GetString( section_revive,
|
||||
key_piUser,
|
||||
buffer,
|
||||
1024,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError == vr::VRSettingsError_None )
|
||||
{
|
||||
setPiUsername( buffer );
|
||||
}
|
||||
|
||||
vr::VRSettings()->GetString(
|
||||
section_revive, key_piName, buffer, 1024, &vrSettingsError );
|
||||
vr::VRSettings()->GetString( section_revive,
|
||||
key_piName,
|
||||
buffer,
|
||||
1024,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError == vr::VRSettingsError_None )
|
||||
{
|
||||
setPiName( buffer );
|
||||
}
|
||||
|
||||
vr::VRSettings()->GetString(
|
||||
section_revive, key_piGender, buffer, 1024, &vrSettingsError );
|
||||
vr::VRSettings()->GetString( section_revive,
|
||||
key_piGender,
|
||||
buffer,
|
||||
1024,
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError == vr::VRSettingsError_None )
|
||||
{
|
||||
if ( QString( buffer ).compare( "male", Qt::CaseInsensitive )
|
||||
if ( QString( buffer ).compare( "male",
|
||||
Qt::CaseInsensitive )
|
||||
== 0 )
|
||||
{
|
||||
valuei = 1;
|
||||
@@ -457,6 +470,8 @@ void ReviveTabController::eventLoopTick()
|
||||
setPiGender( valuei );
|
||||
}
|
||||
}
|
||||
settingsUpdateCounter = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
settingsUpdateCounter++;
|
||||
|
||||
@@ -28,10 +28,13 @@ void SettingsTabController::initStage2( OverlayController* var_parent,
|
||||
|
||||
void SettingsTabController::eventLoopTick()
|
||||
{
|
||||
if ( settingsUpdateCounter >= 50 )
|
||||
if ( settingsUpdateCounter >= 157 )
|
||||
{
|
||||
if ( parent->isDashboardVisible() )
|
||||
{
|
||||
setAutoStartEnabled( vr::VRApplications()->GetApplicationAutoLaunch(
|
||||
OverlayController::applicationKey ) );
|
||||
}
|
||||
settingsUpdateCounter = 0;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -22,7 +22,9 @@ void SteamVRTabController::initStage2( OverlayController* var_parent,
|
||||
|
||||
void SteamVRTabController::eventLoopTick()
|
||||
{
|
||||
if ( settingsUpdateCounter >= 50 )
|
||||
if ( settingsUpdateCounter >= 97 )
|
||||
{
|
||||
if ( parent->isDashboardVisible() )
|
||||
{
|
||||
vr::EVRSettingsError vrSettingsError;
|
||||
// checks supersampling override and resynchs if necessry
|
||||
@@ -33,7 +35,8 @@ void SteamVRTabController::eventLoopTick()
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
LOG( WARNING )
|
||||
<< "Could not read \""
|
||||
<< vr::k_pch_SteamVR_SupersampleManualOverride_Bool
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
@@ -47,14 +50,16 @@ void SteamVRTabController::eventLoopTick()
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
LOG( WARNING )
|
||||
<< "Could not read \""
|
||||
<< vr::k_pch_SteamVR_SupersampleScale_Float
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
if ( m_superSampling != 1.0 )
|
||||
{
|
||||
LOG( DEBUG ) << "OpenVR returns an error and we have a custom "
|
||||
LOG( DEBUG )
|
||||
<< "OpenVR returns an error and we have a custom "
|
||||
"supersampling value: "
|
||||
<< m_superSampling;
|
||||
setSuperSampling( 1.0 );
|
||||
@@ -74,7 +79,8 @@ void SteamVRTabController::eventLoopTick()
|
||||
&vrSettingsError );
|
||||
if ( vrSettingsError != vr::VRSettingsError_None )
|
||||
{
|
||||
LOG( WARNING ) << "Could not read \""
|
||||
LOG( WARNING )
|
||||
<< "Could not read \""
|
||||
<< vr::k_pch_SteamVR_AllowSupersampleFiltering_Bool
|
||||
<< "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
@@ -84,20 +90,20 @@ void SteamVRTabController::eventLoopTick()
|
||||
|
||||
// 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,
|
||||
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: "
|
||||
LOG( WARNING )
|
||||
<< "Could not read \""
|
||||
<< vr::k_pch_SteamVR_MotionSmoothing_Bool << "\" setting: "
|
||||
<< vr::VRSettings()->GetSettingsErrorNameFromEnum(
|
||||
vrSettingsError );
|
||||
}
|
||||
setMotionSmoothing( ms );
|
||||
|
||||
}
|
||||
settingsUpdateCounter = 0;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -316,7 +316,7 @@ vr::VROverlayHandle_t createBatteryOverlay( vr::TrackedDeviceIndex_t index )
|
||||
|
||||
void UtilitiesTabController::eventLoopTick()
|
||||
{
|
||||
if ( settingsUpdateCounter >= 10 )
|
||||
if ( settingsUpdateCounter >= 19 )
|
||||
{
|
||||
vr::VROverlayHandle_t pOverlayHandle;
|
||||
auto error = vr::VROverlay()->FindOverlay( steamDesktopOverlaykey,
|
||||
|
||||
Reference in New Issue
Block a user