Convert m_flingStrength to new settings API

Casts inside the functions because it isn't feasible to change all
floats to double.
This commit is contained in:
Vasily
2019-12-10 08:28:41 +01:00
committed by username223
parent 4918ff2a37
commit 4be96344da
2 changed files with 9 additions and 15 deletions
+9 -14
View File
@@ -39,9 +39,6 @@ namespace advsettings
{ {
void MoveCenterTabController::initStage1() void MoveCenterTabController::initStage1()
{ {
m_flingStrength = static_cast<float>( settings::getSetting(
settings::DoubleSetting::PLAYSPACE_flingStrength ) );
reloadOffsetProfiles(); reloadOffsetProfiles();
m_k_moveCenterSettingsUpdateCounter m_k_moveCenterSettingsUpdateCounter
= utils::adjustUpdateRate( k_moveCenterSettingsUpdateCounter ); = utils::adjustUpdateRate( k_moveCenterSettingsUpdateCounter );
@@ -714,20 +711,18 @@ void MoveCenterTabController::setGravityStrength( float value, bool notify )
float MoveCenterTabController::flingStrength() const float MoveCenterTabController::flingStrength() const
{ {
return m_flingStrength; return static_cast<float>( settings::getSetting(
settings::DoubleSetting::PLAYSPACE_flingStrength ) );
} }
void MoveCenterTabController::setFlingStrength( float value, bool notify ) void MoveCenterTabController::setFlingStrength( float value, bool notify )
{ {
m_flingStrength = value; settings::setSetting( settings::DoubleSetting::PLAYSPACE_flingStrength,
auto settings = OverlayController::appSettings(); static_cast<double>( value ) );
settings->beginGroup( "playspaceSettings" );
settings->setValue( "flingStrength", m_flingStrength );
settings->endGroup();
settings->sync();
if ( notify ) if ( notify )
{ {
emit flingStrengthChanged( m_flingStrength ); emit flingStrengthChanged( value );
} }
} }
@@ -2281,11 +2276,11 @@ void MoveCenterTabController::updateHandDrag(
.count(); .count();
m_velocity[0] = ( diff[0] / secondsSinceLastDragUpdate ) m_velocity[0] = ( diff[0] / secondsSinceLastDragUpdate )
* static_cast<double>( m_flingStrength ); * static_cast<double>( flingStrength() );
m_velocity[1] = ( diff[1] / secondsSinceLastDragUpdate ) m_velocity[1] = ( diff[1] / secondsSinceLastDragUpdate )
* static_cast<double>( m_flingStrength ); * static_cast<double>( flingStrength() );
m_velocity[2] = ( diff[2] / secondsSinceLastDragUpdate ) m_velocity[2] = ( diff[2] / secondsSinceLastDragUpdate )
* static_cast<double>( m_flingStrength ); * static_cast<double>( flingStrength() );
} }
m_lastControllerPosition[0] = absoluteControllerPosition[0]; m_lastControllerPosition[0] = absoluteControllerPosition[0];
m_lastControllerPosition[1] = absoluteControllerPosition[1]; m_lastControllerPosition[1] = absoluteControllerPosition[1];
@@ -125,7 +125,6 @@ private:
float m_lastControllerPosition[3]; float m_lastControllerPosition[3];
bool m_heightToggle = false; bool m_heightToggle = false;
float m_gravityFloor = 0.0f; float m_gravityFloor = 0.0f;
float m_flingStrength = 1.0f;
// Set lastHandQuaternion.w to -1000.0 when last hand is invalid. // Set lastHandQuaternion.w to -1000.0 when last hand is invalid.
vr::HmdQuaternion_t m_lastHandQuaternion vr::HmdQuaternion_t m_lastHandQuaternion
= { k_quaternionInvalidValue, 0.0, 0.0, 0.0 }; = { k_quaternionInvalidValue, 0.0, 0.0, 0.0 };