diff --git a/src/overlaycontroller.cpp b/src/overlaycontroller.cpp index 8c22518..3e69478 100644 --- a/src/overlaycontroller.cpp +++ b/src/overlaycontroller.cpp @@ -337,6 +337,16 @@ OverlayController::OverlayController( bool desktopMode, { m_crashRecoveryDisabled = value.toBool(); } + value = appSettings()->value( "enableDebug", m_enableDebug ); + if ( value.isValid() && !value.isNull() ) + { + m_enableDebug = value.toBool(); + } + value = appSettings()->value( "debugState", m_debugState ); + if ( value.isValid() && !value.isNull() ) + { + m_debugState = value.toInt(); + } appSettings()->endGroup(); } @@ -481,7 +491,7 @@ void OverlayController::SetWidget( QQuickItem* quickItem, this, SLOT( OnTimeoutPumpEvents() ) ); - // Every 1ms we check if the current frame has advanced (for vysnc) + // Every 1ms we check if the current frame has advanced (for vsync) m_pPumpEventsTimer->setInterval( 1 ); m_pPumpEventsTimer->start(); @@ -776,6 +786,50 @@ void OverlayController::setVsyncDisabled( bool value, bool notify ) } } +bool OverlayController::enableDebug() const +{ + return m_enableDebug; +} + +void OverlayController::setEnableDebug( bool value, bool notify ) +{ + if ( m_enableDebug == value ) + { + return; + } + m_enableDebug = value; + appSettings()->beginGroup( "applicationSettings" ); + appSettings()->setValue( "enableDebug", m_enableDebug ); + appSettings()->endGroup(); + appSettings()->sync(); + if ( notify ) + { + emit enableDebugChanged( m_enableDebug ); + } +} + +int OverlayController::debugState() const +{ + return m_debugState; +} + +void OverlayController::setDebugState( int value, bool notify ) +{ + if ( m_debugState == value ) + { + return; + } + m_debugState = value; + appSettings()->beginGroup( "applicationSettings" ); + appSettings()->setValue( "debugState", m_debugState ); + appSettings()->endGroup(); + appSettings()->sync(); + if ( notify ) + { + emit debugStateChanged( m_debugState ); + } +} + void OverlayController::setPreviousShutdownSafe( bool value ) { if ( m_previousShutdownSafe == value ) diff --git a/src/overlaycontroller.h b/src/overlaycontroller.h index 26b3bd3..89fdb3a 100644 --- a/src/overlaycontroller.h +++ b/src/overlaycontroller.h @@ -82,8 +82,12 @@ class OverlayController : public QObject setCrashRecoveryDisabled NOTIFY crashRecoveryDisabledChanged ) Q_PROPERTY( bool vsyncDisabled READ vsyncDisabled WRITE setVsyncDisabled NOTIFY vsyncDisabledChanged ) + Q_PROPERTY( bool enableDebug READ enableDebug WRITE setEnableDebug NOTIFY + enableDebugChanged ) Q_PROPERTY( int customTickRateMs READ customTickRateMs WRITE setCustomTickRateMs NOTIFY customTickRateMsChanged ) + Q_PROPERTY( int debugState READ debugState WRITE setDebugState NOTIFY + debugStateChanged ) private: vr::VROverlayHandle_t m_ulOverlayHandle = vr::k_ulOverlayHandleInvalid; @@ -108,7 +112,9 @@ private: bool m_noSound; bool m_crashRecoveryDisabled = false; bool m_vsyncDisabled = false; + bool m_enableDebug = false; int m_customTickRateMs = 20; + int m_debugState = 0; QUrl m_runtimePathUrl; @@ -211,8 +217,10 @@ public: void mainEventLoop(); bool crashRecoveryDisabled() const; + bool enableDebug() const; bool vsyncDisabled() const; int customTickRateMs() const; + int debugState() const; public slots: void renderOverlay(); @@ -228,14 +236,18 @@ public slots: void cancelAlarm01Sound(); void setCrashRecoveryDisabled( bool value, bool notify = true ); + void setEnableDebug( bool value, bool notify = true ); void setVsyncDisabled( bool value, bool notify = true ); void setCustomTickRateMs( int value, bool notify = true ); + void setDebugState( int value, bool notify = true ); signals: void keyBoardInputSignal( QString input, unsigned long userValue = 0 ); void crashRecoveryDisabledChanged( bool value ); + void enableDebugChanged( bool value ); void vsyncDisabledChanged( bool value ); void customTickRateMsChanged( int value ); + void debugStateChanged( int value ); private: static QSettings* _appSettings; diff --git a/src/res/qml/PlayspacePage.qml b/src/res/qml/PlayspacePage.qml index a1e0b33..90242a1 100644 --- a/src/res/qml/PlayspacePage.qml +++ b/src/res/qml/PlayspacePage.qml @@ -528,10 +528,10 @@ MyStackViewPage { if (MoveCenterTabController.trackingUniverse === 0) { spaceModeText.text = "Sitting" spaceSeatedRecenter.visible = true - offsetsGroupBox.visible = !MoveCenterTabController.disableSeatedMotion - rotationGroupBox.visible = !MoveCenterTabController.disableSeatedMotion - resetButtonRow.visible = !MoveCenterTabController.disableSeatedMotion - seatedDisableWarningText.visible = MoveCenterTabController.disableSeatedMotion + offsetsGroupBox.visible = MoveCenterTabController.enableSeatedMotion + rotationGroupBox.visible = MoveCenterTabController.enableSeatedMotion + resetButtonRow.visible = MoveCenterTabController.enableSeatedMotion + seatedDisableWarningText.visible = !MoveCenterTabController.enableSeatedMotion } else if (MoveCenterTabController.trackingUniverse === 1) { spaceModeText.text = "Standing" @@ -580,24 +580,24 @@ MyStackViewPage { onLockZToggleChanged: { lockZToggle.checked = MoveCenterTabController.lockZToggle } - onDisableSeatedMotionChanged: { + onEnableSeatedMotionChanged: { if (MoveCenterTabController.trackingUniverse === 0) { spaceModeText.text = "Sitting" spaceSeatedRecenter.visible = true - offsetsGroupBox.visible = !MoveCenterTabController.disableSeatedMotion - rotationGroupBox.visible = !MoveCenterTabController.disableSeatedMotion - resetButtonRow.visible = !MoveCenterTabController.disableSeatedMotion - seatedDisableWarningText.visible = MoveCenterTabController.disableSeatedMotion + offsetsGroupBox.visible = MoveCenterTabController.enableSeatedMotion + rotationGroupBox.visible = MoveCenterTabController.enableSeatedMotion + resetButtonRow.visible = MoveCenterTabController.enableSeatedMotion + seatedDisableWarningText.visible = !MoveCenterTabController.enableSeatedMotion } } onTrackingUniverseChanged: { if (MoveCenterTabController.trackingUniverse === 0) { spaceModeText.text = "Sitting" spaceSeatedRecenter.visible = true - offsetsGroupBox.visible = !MoveCenterTabController.disableSeatedMotion - rotationGroupBox.visible = !MoveCenterTabController.disableSeatedMotion - resetButtonRow.visible = !MoveCenterTabController.disableSeatedMotion - seatedDisableWarningText.visible = MoveCenterTabController.disableSeatedMotion + offsetsGroupBox.visible = MoveCenterTabController.enableSeatedMotion + rotationGroupBox.visible = MoveCenterTabController.enableSeatedMotion + resetButtonRow.visible = MoveCenterTabController.enableSeatedMotion + seatedDisableWarningText.visible = !MoveCenterTabController.enableSeatedMotion } else if (MoveCenterTabController.trackingUniverse === 1) { spaceModeText.text = "Standing" spaceSeatedRecenter.visible = false diff --git a/src/res/qml/SettingsPage.qml b/src/res/qml/SettingsPage.qml index ad4b1ab..740bfca 100644 --- a/src/res/qml/SettingsPage.qml +++ b/src/res/qml/SettingsPage.qml @@ -43,19 +43,30 @@ MyStackViewPage { } MyToggleButton { - id: enableSeatedOffsetsRecenterToggle - text: "Enable Auto-set Seated Offsets During Seated Recenter" + id: enableSeatedMotionToggle + text: "Enable Motion Features When in Seated Mode (Experimental)" onCheckedChanged: { - MoveCenterTabController.setEnableSeatedOffsetsRecenter(checked, true) + MoveCenterTabController.setEnableSeatedMotion(checked, true) + seatedOffsetsRecenterRow.visible = checked } } - MyToggleButton { - id: disableSeatedMotionToggle - text: "Disable All Motion Features When in Seated Mode" - onCheckedChanged: { - MoveCenterTabController.setDisableSeatedMotion(checked, true) + RowLayout { + Layout.fillWidth: true + id: seatedOffsetsRecenterRow + + Item { + Layout.preferredWidth: 50 } + + MyToggleButton { + id: enableSeatedOffsetsRecenterToggle + text: "Enable Auto-set Seated Offsets During Seated Recenter" + onCheckedChanged: { + MoveCenterTabController.setEnableSeatedOffsetsRecenter(checked, true) + } + } + } MyToggleButton { @@ -119,6 +130,41 @@ MyStackViewPage { } } + RowLayout { + id: debugStateRow + Layout.fillWidth: true + + MyText { + id: debugStateLabel + text: "Debug State: " + horizontalAlignment: Text.AlignRight + Layout.leftMargin: 20 + Layout.rightMargin: 2 + } + + MyTextField { + id: debugStateText + text: "0" + keyBoardUID: 1002 + Layout.preferredWidth: 140 + Layout.leftMargin: 10 + Layout.rightMargin: 1 + horizontalAlignment: Text.AlignHCenter + function onInputEvent(input) { + var val = parseInt(input, 10) + if (!isNaN(val)) { + OverlayController.debugState = val + text = OverlayController.debugState + } else { + text = OverlayController.debugState + } + } + } + Item { + Layout.fillWidth: true + } + } + Item { Layout.fillHeight: true } @@ -131,7 +177,8 @@ MyStackViewPage { oldStyleMotionToggle.checked = MoveCenterTabController.oldStyleMotion universeCenteredRotationToggle.checked = MoveCenterTabController.universeCenteredRotation enableSeatedOffsetsRecenterToggle.checked = MoveCenterTabController.enableSeatedOffsetsRecenter - disableSeatedMotionToggle.checked = MoveCenterTabController.disableSeatedMotion + enableSeatedMotionToggle.checked = MoveCenterTabController.enableSeatedMotion + seatedOffsetsRecenterRow.visible = MoveCenterTabController.enableSeatedMotion disableCrashRecoveryToggle.checked = OverlayController.crashRecoveryDisabled customTickRateText.text = OverlayController.customTickRateMs @@ -139,6 +186,7 @@ MyStackViewPage { customTickRateText.visible = vsyncDisabledToggle.checked customTickRateLabel.visible = vsyncDisabledToggle.checked customTickRateMsLabel.visible = vsyncDisabledToggle.checked + debugStateRow.visible = OverlayController.enableDebug } Connections { @@ -162,8 +210,9 @@ MyStackViewPage { onEnableSeatedOffsetsRecenterChanged: { enableSeatedOffsetsRecenterToggle.checked = MoveCenterTabController.enableSeatedOffsetsRecenter } - onDisableSeatedMotionChanged: { - disableSeatedMotionToggle.checked = MoveCenterTabController.disableSeatedMotion + onEnableSeatedMotionChanged: { + enableSeatedMotionToggle.checked = MoveCenterTabController.enableSeatedMotion + seatedOffsetsRecenterRow.visible = MoveCenterTabController.enableSeatedMotion } } @@ -182,6 +231,10 @@ MyStackViewPage { onCustomTickRateMsChanged: { customTickRateText.text = OverlayController.customTickRateMs } + + onEnableDebugChanged: { + debugStateRow.visible = OverlayController.enableDebug + } } } } diff --git a/src/tabcontrollers/MoveCenterTabController.cpp b/src/tabcontrollers/MoveCenterTabController.cpp index 535b3bc..bf9eee1 100644 --- a/src/tabcontrollers/MoveCenterTabController.cpp +++ b/src/tabcontrollers/MoveCenterTabController.cpp @@ -159,10 +159,10 @@ void MoveCenterTabController::initStage1() { m_enableSeatedOffsetsRecenter = value.toBool(); } - value = settings->value( "disableSeatedMotion", m_disableSeatedMotion ); + value = settings->value( "enableSeatedMotion", m_enableSeatedMotion ); if ( value.isValid() && !value.isNull() ) { - m_disableSeatedMotion = value.toBool(); + m_enableSeatedMotion = value.toBool(); } settings->endGroup(); reloadOffsetProfiles(); @@ -357,9 +357,9 @@ void MoveCenterTabController::outputLogSettings() { LOG( INFO ) << "LOADED SETTINGS: Seated Offsets Recenter Enabled"; } - if ( m_disableSeatedMotion ) + if ( m_enableSeatedMotion ) { - LOG( INFO ) << "LOADED SETTINGS: Seated Motion Disabled"; + LOG( INFO ) << "LOADED SETTINGS: Seated Motion Enabled"; } if ( m_dragBounds ) { @@ -1220,25 +1220,25 @@ bool MoveCenterTabController::isInitComplete() const return m_initComplete; } -bool MoveCenterTabController::disableSeatedMotion() const +bool MoveCenterTabController::enableSeatedMotion() const { - return m_disableSeatedMotion; + return m_enableSeatedMotion; } -void MoveCenterTabController::setDisableSeatedMotion( bool value, bool notify ) +void MoveCenterTabController::setEnableSeatedMotion( bool value, bool notify ) { - m_disableSeatedMotion = value; + m_enableSeatedMotion = value; auto settings = OverlayController::appSettings(); settings->beginGroup( "playspaceSettings" ); - settings->setValue( "disableSeatedMotion", m_disableSeatedMotion ); + settings->setValue( "enableSeatedMotion", m_enableSeatedMotion ); settings->endGroup(); settings->sync(); if ( notify ) { - emit disableSeatedMotionChanged( m_disableSeatedMotion ); + emit enableSeatedMotionChanged( m_enableSeatedMotion ); } - LOG( INFO ) << "CHANGED SETTINGS: Disable Seated Motion Set: " - << m_disableSeatedMotion; + LOG( INFO ) << "CHANGED SETTINGS: Enable Seated Motion Set: " + << m_enableSeatedMotion; } void MoveCenterTabController::modOffsetX( float value, bool notify ) @@ -1285,7 +1285,12 @@ void MoveCenterTabController::shutdown() void MoveCenterTabController::incomingSeatedReset() { - if ( !m_disableSeatedMotion ) + if ( parent->enableDebug() && parent->debugState() == 2 ) + { + return; + } + + if ( m_enableSeatedMotion ) { updateSeatedResetData(); } @@ -1487,7 +1492,10 @@ void MoveCenterTabController::clampVelocity( double* velocity ) void MoveCenterTabController::updateSeatedResetData() { - reset(); + if ( !( parent->enableDebug() && parent->debugState() == 1 ) ) + { + reset(); + } vr::VRChaperoneSetup()->RevertWorkingCopy(); vr::TrackedDevicePose_t devicePosesStanding[vr::k_unMaxTrackedDeviceCount]; vr::VRSystem()->GetDeviceToAbsoluteTrackingPose( @@ -1527,6 +1535,38 @@ void MoveCenterTabController::updateSeatedResetData() emit rotationChanged( m_rotation ); } + if ( parent->enableDebug() ) + { + switch ( parent->debugState() ) + { + case 3: + { + vr::VRChaperoneSetup()->GetWorkingStandingZeroPoseToRawTrackingPose( + &m_seatedCenterForReset ); + } + break; + case 4: + { + vr::VRChaperoneSetup()->GetWorkingSeatedZeroPoseToRawTrackingPose( + &m_seatedCenterForReset ); + } + break; + case 5: + { + vr::VRChaperoneSetup()->GetLiveSeatedZeroPoseToRawTrackingPose( + &m_seatedCenterForReset ); + } + break; + case 6: + { + m_seatedCenterForReset + = vr::VRSystem() + ->GetSeatedZeroPoseToStandingAbsoluteTrackingPose(); + } + break; + } + } + unsigned checkQuadCount = 0; vr::VRChaperoneSetup()->GetWorkingCollisionBoundsInfo( nullptr, &checkQuadCount ); @@ -3030,10 +3070,6 @@ void MoveCenterTabController::eventLoopTick( // m_roomSetupModeDetected is set to false in zeroOffsets() if it's // successful. } - else if ( m_seatedModeDetected && m_disableSeatedMotion ) - { - return; - } else { setTrackingUniverse( int( universe ) ); @@ -3054,6 +3090,13 @@ void MoveCenterTabController::eventLoopTick( m_hmdRotationStatsUpdateCounter++; } + // stop everything before processing motion if we're in seated mode and + // don't have seated motion enabled + if ( m_seatedModeDetected && !m_enableSeatedMotion ) + { + return; + } + // only update dynamic motion if the dash is closed if ( !parent->isDashboardVisible() ) { diff --git a/src/tabcontrollers/MoveCenterTabController.h b/src/tabcontrollers/MoveCenterTabController.h index d3b7499..075c03f 100644 --- a/src/tabcontrollers/MoveCenterTabController.h +++ b/src/tabcontrollers/MoveCenterTabController.h @@ -102,8 +102,8 @@ class MoveCenterTabController : public QObject bool enableSeatedOffsetsRecenter READ enableSeatedOffsetsRecenter WRITE setEnableSeatedOffsetsRecenter NOTIFY enableSeatedOffsetsRecenterChanged ) - Q_PROPERTY( bool disableSeatedMotion READ disableSeatedMotion WRITE - setDisableSeatedMotion NOTIFY disableSeatedMotionChanged ) + Q_PROPERTY( bool enableSeatedMotion READ enableSeatedMotion WRITE + setEnableSeatedMotion NOTIFY enableSeatedMotionChanged ) private: OverlayController* parent; @@ -186,7 +186,7 @@ private: bool m_oldStyleMotion = false; bool m_universeCenteredRotation = false; bool m_enableSeatedOffsetsRecenter = false; - bool m_disableSeatedMotion = false; + bool m_enableSeatedMotion = false; unsigned settingsUpdateCounter = 0; int m_hmdRotationStatsUpdateCounter = 0; unsigned m_dragComfortFrameSkipCounter = 0; @@ -258,7 +258,7 @@ public: bool oldStyleMotion() const; bool universeCenteredRotation() const; bool enableSeatedOffsetsRecenter() const; - bool disableSeatedMotion() const; + bool enableSeatedMotion() const; bool isInitComplete() const; double getHmdYawTotal(); void resetHmdYawTotal(); @@ -333,7 +333,7 @@ public slots: void setOldStyleMotion( bool value, bool notify = true ); void setUniverseCenteredRotation( bool value, bool notify = true ); void setEnableSeatedOffsetsRecenter( bool value, bool notify = true ); - void setDisableSeatedMotion( bool value, bool notify = true ); + void setEnableSeatedMotion( bool value, bool notify = true ); void shutdown(); void reset(); @@ -377,7 +377,7 @@ signals: void oldStyleMotionChanged( bool value ); void universeCenteredRotationChanged( bool value ); void enableSeatedOffsetsRecenterChanged( bool value ); - void disableSeatedMotionChanged( bool value ); + void enableSeatedMotionChanged( bool value ); void offsetProfilesUpdated(); };