diff --git a/src/overlaycontroller.h b/src/overlaycontroller.h index 98b679c..4463158 100644 --- a/src/overlaycontroller.h +++ b/src/overlaycontroller.h @@ -55,6 +55,20 @@ public: static constexpr const char* applicationKey = "matzman666.AdvancedSettings"; static constexpr const char* applicationDisplayName = "Advanced Settings"; static constexpr const char* applicationVersionString = "v2.8.0-dev"; + // These counters set timing for refreshing settings changes in tab ui + // SettingsUpdateCounter values are set as prime numbers to reduce overlap + // of simultaneous settings updates. + // Actual rates of updates are counter * vsync (~11ms) + // Values chosen based on update speed priority + // Avoid setting values to the same numbers. + static constexpr int k_accessibilitySettingsUpdateCounter = 151; + static constexpr int k_audioSettingsUpdateCounter = 89; + static constexpr int k_chaperoneSettingsUpdateCounter = 101; + static constexpr int k_moveCenterSettingsUpdateCounter = 149; + static constexpr int k_reviveSettingsUpdateCounter = 139; + static constexpr int k_settingsTabSettingsUpdateCounter = 157; + static constexpr int k_steamVrSettingsUpdateCounter = 97; + static constexpr int k_utilitiesSettingsUpdateCounter = 19; private: vr::VROverlayHandle_t m_ulOverlayHandle = vr::k_ulOverlayHandleInvalid; diff --git a/src/package_files/action_manifest.json b/src/package_files/action_manifest.json index a3e13ff..9225ab1 100644 --- a/src/package_files/action_manifest.json +++ b/src/package_files/action_manifest.json @@ -75,7 +75,7 @@ ], "localization" : [ { - "language_tag": "en", + "language_tag": "en_US", "/actions/main" : "Advanced Settings Actions", diff --git a/src/tabcontrollers/AccessibilityTabController.cpp b/src/tabcontrollers/AccessibilityTabController.cpp index fafbc6f..21474de 100644 --- a/src/tabcontrollers/AccessibilityTabController.cpp +++ b/src/tabcontrollers/AccessibilityTabController.cpp @@ -117,19 +117,7 @@ void AccessibilityTabController::eventLoopTick( return; } - // 151 was chosen because it's a prime number (to reduce overlap of - // simultaneous settings updates). - // Actual rate of updates is 151 * vsync (~11ms) - // Values chosen based on update speed priority - // Values in other tabs are as follows (avoid using same values): - // AudioTabController: 89 - // ChaperoneTabController: 101 - // MoveCenterTabController: 149 - // ReviveTabController: 139 - // SettingsTabController: 157 - // SteamVRTabController: 97 - // UtilitiesTabController: 19 - if ( settingsUpdateCounter >= 151 ) + if ( settingsUpdateCounter >= parent->k_accessibilitySettingsUpdateCounter ) { if ( parent->isDashboardVisible() ) { diff --git a/src/tabcontrollers/AudioTabController.cpp b/src/tabcontrollers/AudioTabController.cpp index e8a7ac0..86c02fa 100644 --- a/src/tabcontrollers/AudioTabController.cpp +++ b/src/tabcontrollers/AudioTabController.cpp @@ -169,19 +169,7 @@ void AudioTabController::eventLoopTick() return; } - // 89 was chosen because it's a prime number (to reduce overlap of - // simultaneous settings updates). - // Actual rate of updates is 89 * vsync (~11ms) - // Values chosen based on update speed priority - // Values in other tabs are as follows (avoid using same values): - // AccessibiltyTabController: 151 - // ChaperoneTabController: 101 - // MoveCenterTabController: 149 - // ReviveTabController: 139 - // SettingsTabController: 157 - // SteamVRTabController: 97 - // UtilitiesTabController: 19 - if ( settingsUpdateCounter >= 89 ) + if ( settingsUpdateCounter >= parent->k_audioSettingsUpdateCounter ) { if ( m_micProximitySensorCanMute ) { diff --git a/src/tabcontrollers/ChaperoneTabController.cpp b/src/tabcontrollers/ChaperoneTabController.cpp index 8606ca7..00d6d8f 100644 --- a/src/tabcontrollers/ChaperoneTabController.cpp +++ b/src/tabcontrollers/ChaperoneTabController.cpp @@ -649,19 +649,7 @@ void ChaperoneTabController::eventLoopTick( } } - // 101 was chosen because it's a prime number (to reduce overlap of - // simultaneous settings updates). - // Actual rate of updates is 101 * vsync (~11ms) - // Values chosen based on update speed priority - // Values in other tabs are as follows (avoid using same values): - // AccessibiltyTabController: 151 - // AudioTabController: 89 - // MoveCenterTabController: 149 - // ReviveTabController: 139 - // SettingsTabController: 157 - // SteamVRTabController: 97 - // UtilitiesTabController: 19 - if ( settingsUpdateCounter >= 101 ) + if ( settingsUpdateCounter >= parent->k_chaperoneSettingsUpdateCounter ) { if ( parent->isDashboardVisible() ) { diff --git a/src/tabcontrollers/MoveCenterTabController.cpp b/src/tabcontrollers/MoveCenterTabController.cpp index 8f39121..c9a7f48 100644 --- a/src/tabcontrollers/MoveCenterTabController.cpp +++ b/src/tabcontrollers/MoveCenterTabController.cpp @@ -148,7 +148,7 @@ void MoveCenterTabController::setRotation( int value, bool notify ) { if ( m_rotation != value ) { - double angle = ( value - m_rotation ) * M_PI / 18000.0; + double angle = ( value - m_rotation ) * k_centidegreesToRadians; // Revert now because we don't commit in RotateUniverseCenter and // AddOffsetToUniverseCenter. We do this so rotation and offset can @@ -173,7 +173,7 @@ void MoveCenterTabController::setRotation( int value, bool notify ) = { oldHmdPos.m[0][3], oldHmdPos.m[1][3], oldHmdPos.m[2][3] }; // Convert oldHmdXyz into un-rotated coordinates. - double oldAngle = -m_rotation * M_PI / 18000.0; + double oldAngle = -m_rotation * k_centidegreesToRadians; rotateCoordinates( oldHmdXyz, oldAngle ); // Set newHmdXyz to have additional rotation from incoming angle change. @@ -201,7 +201,7 @@ void MoveCenterTabController::setRotation( int value, bool notify ) // We use rotated coordinates here because we have already applied // RotateUniverseCenter. This will be the final offset ready to apply, // so it must match the current universe axis rotation. - double finalAngle = m_rotation * M_PI / 18000.0; + double finalAngle = m_rotation * k_centidegreesToRadians; double finalHmdRotDiff[3] = { hmdRotDiff[0], 0, hmdRotDiff[2] }; rotateCoordinates( finalHmdRotDiff, finalAngle ); @@ -259,7 +259,7 @@ void MoveCenterTabController::setAdjustChaperone( bool value, bool notify ) m_adjustChaperone = value; if ( m_trackingUniverse == vr::TrackingUniverseStanding ) { - double angle = m_rotation * M_PI / 18000.0; + double angle = m_rotation * k_centidegreesToRadians; double offsetdir = m_adjustChaperone ? -1.0 : 1.0; double offset[3] = { offsetdir * m_offsetX, offsetdir * m_offsetY, @@ -406,7 +406,7 @@ void MoveCenterTabController::modOffsetX( float value, bool notify ) // TODO ? possible issue with locking position this way if ( !m_lockXToggle ) { - double angle = m_rotation * M_PI / 18000.0; + double angle = m_rotation * k_centidegreesToRadians; double offset[3] = { value, 0, 0 }; rotateCoordinates( offset, angle ); float offsetFloat[3] = { static_cast( offset[0] ), @@ -445,7 +445,7 @@ void MoveCenterTabController::modOffsetZ( float value, bool notify ) { if ( !m_lockZToggle ) { - double angle = m_rotation * M_PI / 18000.0; + double angle = m_rotation * k_centidegreesToRadians; double offset[3] = { 0, 0, value }; rotateCoordinates( offset, angle ); float offsetFloat[3] = { static_cast( offset[0] ), @@ -468,7 +468,7 @@ void MoveCenterTabController::reset() vr::VRChaperoneSetup()->RevertWorkingCopy(); parent->RotateUniverseCenter( vr::TrackingUniverseOrigin( m_trackingUniverse ), - static_cast( -m_rotation * M_PI / 18000.0 ), + static_cast( -m_rotation * k_centidegreesToRadians ), m_adjustChaperone, false ); float offset[3] = { -m_offsetX, -m_offsetY, -m_offsetZ }; @@ -862,19 +862,7 @@ void MoveCenterTabController::eventLoopTick( vr::ETrackingUniverseOrigin universe, vr::TrackedDevicePose_t* devicePoses ) { - // 149 was chosen because it's a prime number (to reduce overlap of - // simultaneous settings updates). - // Actual rate of updates is 149 * vsync (~11ms) - // Values chosen based on update speed priority - // Values in other tabs are as follows (avoid using same values): - // AccessibiltyTabController: 151 - // AudioTabController: 89 - // ChaperoneTabController: 101 - // ReviveTabController: 139 - // SettingsTabController: 157 - // SteamVRTabController: 97 - // UtilitiesTabController: 19 - if ( settingsUpdateCounter >= 149 ) + if ( settingsUpdateCounter >= parent->k_moveCenterSettingsUpdateCounter ) { if ( parent->isDashboardVisible() ) { @@ -887,7 +875,7 @@ void MoveCenterTabController::eventLoopTick( settingsUpdateCounter++; } - double angle = m_rotation * M_PI / 18000.0; + double angle = m_rotation * k_centidegreesToRadians; // START of hmd rotation stats tracking: // Check if hmd is tracking ok and do everything @@ -907,13 +895,13 @@ void MoveCenterTabController::eventLoopTick( utils::matMul33( hmdMatrixAbsolute, hmdMatrixRotMat, hmdMatrix ); // Convert pose matrix to quaternion - hmdQuaternion = utils::getQuaternion( hmdMatrixAbsolute ); + m_hmdQuaternion = utils::getQuaternion( hmdMatrixAbsolute ); // Get rotation change of hmd // Checking if set to -1000.0 placeholder for invalid hmd pose. - if ( lastHmdQuaternion.w < -900.0 ) + if ( m_lastHmdQuaternion.w < -900.0 ) { - lastHmdQuaternion = hmdQuaternion; + m_lastHmdQuaternion = m_hmdQuaternion; } else @@ -921,8 +909,8 @@ void MoveCenterTabController::eventLoopTick( // Construct a quaternion representing difference between old // hmd pose and new hmd pose. vr::HmdQuaternion_t hmdDiffQuaternion = utils::multiplyQuaternion( - hmdQuaternion, - utils::quaternionConjugate( lastHmdQuaternion ) ); + m_hmdQuaternion, + utils::quaternionConjugate( m_lastHmdQuaternion ) ); // Calculate yaw from quaternion. double hmdYawDiff = atan2( @@ -936,7 +924,7 @@ void MoveCenterTabController::eventLoopTick( // Apply yaw difference to m_hmdYawTotal. m_hmdYawTotal += hmdYawDiff; - lastHmdQuaternion = hmdQuaternion; + m_lastHmdQuaternion = m_hmdQuaternion; } // end check if hmdpose is ok @@ -944,7 +932,7 @@ void MoveCenterTabController::eventLoopTick( else { // set lastHmdQuaternion.w to placeholder -1000.0 for invalid - lastHmdQuaternion.w = -1000.0; + m_lastHmdQuaternion.w = -1000.0; } // END of hmd rotation stats tracking /* @@ -1077,7 +1065,7 @@ void MoveCenterTabController::eventLoopTick( { // Set lastHandQuaternion.w to placeholder value for invalid // (-1000.0) - lastHandQuaternion.w = -1000.0; + m_lastHandQuaternion.w = -1000.0; } m_lastRotateHand = m_activeTurnHand; } @@ -1108,15 +1096,15 @@ void MoveCenterTabController::eventLoopTick( utils::matMul33( handMatrixAbsolute, handMatrixRotMat, handMatrix ); // Convert pose matrix to quaternion - handQuaternion = utils::getQuaternion( handMatrixAbsolute ); + m_handQuaternion = utils::getQuaternion( handMatrixAbsolute ); if ( m_lastRotateHand == m_activeTurnHand ) { // Get rotation change of hand. // Checking if set to -1000.0 placeholder for invalid hand. - if ( lastHandQuaternion.w < -900.0 ) + if ( m_lastHandQuaternion.w < -900.0 ) { - lastHandQuaternion = handQuaternion; + m_lastHandQuaternion = m_handQuaternion; } else @@ -1125,8 +1113,9 @@ void MoveCenterTabController::eventLoopTick( // between old hand and new hand. vr::HmdQuaternion_t handDiffQuaternion = utils::multiplyQuaternion( - handQuaternion, - utils::quaternionConjugate( lastHandQuaternion ) ); + m_handQuaternion, + utils::quaternionConjugate( + m_lastHandQuaternion ) ); // Calculate yaw from quaternion. double handYawDiff = atan2( @@ -1141,9 +1130,10 @@ void MoveCenterTabController::eventLoopTick( * handDiffQuaternion.x ) ); int newRotationAngleDeg = static_cast( - round( handYawDiff * 18000.0 / M_PI ) + m_rotation ); + round( handYawDiff * k_radiansToCentidegrees ) + + m_rotation ); - // Keep angle within -18000 ~ 18000 + // Keep angle within -18000 ~ 18000 centidegrees if ( newRotationAngleDeg > 18000 ) { newRotationAngleDeg -= 36000; @@ -1156,7 +1146,7 @@ void MoveCenterTabController::eventLoopTick( setRotation( newRotationAngleDeg ); } } - lastHandQuaternion = handQuaternion; + m_lastHandQuaternion = m_handQuaternion; m_lastRotateHand = m_activeTurnHand; } } // END of hand rotation diff --git a/src/tabcontrollers/MoveCenterTabController.h b/src/tabcontrollers/MoveCenterTabController.h index 46edebc..a6e1282 100644 --- a/src/tabcontrollers/MoveCenterTabController.h +++ b/src/tabcontrollers/MoveCenterTabController.h @@ -4,6 +4,7 @@ #include #include #include +#include class QQuickWindow; // application namespace @@ -65,11 +66,11 @@ private: bool m_lockZToggle = false; std::chrono::system_clock::time_point lastMoveButtonClick[2]; // Set lastHandQuaternion.w to -1000.0 when last hand is invalid. - vr::HmdQuaternion_t lastHandQuaternion = { -1000.0, 0.0, 0.0, 0.0 }; - vr::HmdQuaternion_t handQuaternion; + vr::HmdQuaternion_t m_lastHandQuaternion = { -1000.0, 0.0, 0.0, 0.0 }; + vr::HmdQuaternion_t m_handQuaternion; // Set lastHmdQuaternion.w to -1000.0 when last hmd pose is invalid. - vr::HmdQuaternion_t lastHmdQuaternion = { -1000.0, 0.0, 0.0, 0.0 }; - vr::HmdQuaternion_t hmdQuaternion; + vr::HmdQuaternion_t m_lastHmdQuaternion = { -1000.0, 0.0, 0.0, 0.0 }; + vr::HmdQuaternion_t m_hmdQuaternion; double m_hmdYawTotal = 0.0; vr::ETrackedControllerRole m_activeDragHand = vr::TrackedControllerRole_Invalid; @@ -87,10 +88,9 @@ private: bool m_rightHandTurnPressed = false; bool m_overrideLeftHandTurnPressed = false; bool m_overrideRightHandTurnPressed = false; - unsigned settingsUpdateCounter = 0; - - // vr::ETrackedControllerRole getMoveShortcutHand(); + static constexpr double k_centidegreesToRadians = M_PI / 18000.0; + static constexpr double k_radiansToCentidegrees = 18000.0 / M_PI; public: void initStage1(); diff --git a/src/tabcontrollers/ReviveTabController.cpp b/src/tabcontrollers/ReviveTabController.cpp index 0ec3227..215ad53 100644 --- a/src/tabcontrollers/ReviveTabController.cpp +++ b/src/tabcontrollers/ReviveTabController.cpp @@ -309,19 +309,7 @@ void ReviveTabController::eventLoopTick() if ( m_isOverlayInstalled || parent->m_settingsTabController.forceRevivePage() ) { - // 139 was chosen because it's a prime number (to reduce overlap of - // simultaneous settings updates). - // Actual rate of updates is 139 * vsync (~11ms) - // Values chosen based on update speed priority - // Values in other tabs are as follows (avoid using same values): - // AccessibiltyTabController: 151 - // AudioTabController: 89 - // ChaperoneTabController: 101 - // MoveCenterTabController: 149 - // SettingsTabController: 157 - // SteamVRTabController: 97 - // UtilitiesTabController: 19 - if ( settingsUpdateCounter >= 139 ) + if ( settingsUpdateCounter >= parent->k_reviveSettingsUpdateCounter ) { if ( parent->isDashboardVisible() ) { diff --git a/src/tabcontrollers/SettingsTabController.cpp b/src/tabcontrollers/SettingsTabController.cpp index 68e0d63..aad2db3 100644 --- a/src/tabcontrollers/SettingsTabController.cpp +++ b/src/tabcontrollers/SettingsTabController.cpp @@ -28,19 +28,7 @@ void SettingsTabController::initStage2( OverlayController* var_parent, void SettingsTabController::eventLoopTick() { - // 157 was chosen because it's a prime number (to reduce overlap of - // simultaneous settings updates). - // Actual rate of updates is 157 * vsync (~11ms) - // Values chosen based on update speed priority - // Values in other tabs are as follows (avoid using same values): - // AccessibiltyTabController: 151 - // AudioTabController: 89 - // ChaperoneTabController: 101 - // MoveCenterTabController: 149 - // ReviveTabController: 139 - // SteamVRTabController: 97 - // UtilitiesTabController: 19 - if ( settingsUpdateCounter >= 157 ) + if ( settingsUpdateCounter >= parent->k_settingsTabSettingsUpdateCounter ) { if ( parent->isDashboardVisible() ) { diff --git a/src/tabcontrollers/SteamVRTabController.cpp b/src/tabcontrollers/SteamVRTabController.cpp index 202423a..95be83d 100644 --- a/src/tabcontrollers/SteamVRTabController.cpp +++ b/src/tabcontrollers/SteamVRTabController.cpp @@ -22,19 +22,7 @@ void SteamVRTabController::initStage2( OverlayController* var_parent, void SteamVRTabController::eventLoopTick() { - // 97 was chosen because it's a prime number (to reduce overlap of - // simultaneous settings updates). - // Actual rate of updates is 97 * vsync (~11ms) - // Values chosen based on update speed priority - // Values in other tabs are as follows (avoid using same values): - // AccessibiltyTabController: 151 - // AudioTabController: 89 - // ChaperoneTabController: 101 - // MoveCenterTabController: 149 - // ReviveTabController: 139 - // SettingsTabController: 157 - // UtilitiesTabController: 19 - if ( settingsUpdateCounter >= 97 ) + if ( settingsUpdateCounter >= parent->k_steamVrSettingsUpdateCounter ) { if ( parent->isDashboardVisible() ) { diff --git a/src/tabcontrollers/UtilitiesTabController.cpp b/src/tabcontrollers/UtilitiesTabController.cpp index 943cfeb..d28f9a1 100644 --- a/src/tabcontrollers/UtilitiesTabController.cpp +++ b/src/tabcontrollers/UtilitiesTabController.cpp @@ -321,19 +321,7 @@ vr::VROverlayHandle_t createBatteryOverlay( vr::TrackedDeviceIndex_t index ) void UtilitiesTabController::eventLoopTick() { - // 19 was chosen because it's a prime number (to reduce overlap of - // simultaneous settings updates). - // Actual rate of updates is 19 * vsync (~11ms) - // Values chosen based on update speed priority - // Values in other tabs are as follows (avoid using same values): - // AccessibiltyTabController: 151 - // AudioTabController: 89 - // ChaperoneTabController: 101 - // MoveCenterTabController: 149 - // ReviveTabController: 139 - // SettingsTabController: 157 - // SteamVRTabController: 97 - if ( settingsUpdateCounter >= 19 ) + if ( settingsUpdateCounter >= parent->k_utilitiesSettingsUpdateCounter ) { vr::VROverlayHandle_t pOverlayHandle; auto error = vr::VROverlay()->FindOverlay( steamDesktopOverlaykey,