@@ -1786,8 +1786,7 @@ void RenderGyroDriftCalibrationButton(GyroDisplay *ctx, GamepadDisplay *gamepad_
1786
1786
SetGamepadButtonArea (start_calibration_button , & recalibrate_button_area );
1787
1787
RenderGamepadButton (start_calibration_button );
1788
1788
1789
- const float flAbsoluteMaxAccelerationG = 0.125f ;
1790
- bool bExtremeNoise = ctx -> accelerometer_noise_sq > (flAbsoluteMaxAccelerationG * flAbsoluteMaxAccelerationG );
1789
+ bool bExtremeNoise = ctx -> accelerometer_noise_sq > ACCELEROMETER_MAX_NOISE_G_SQ ;
1791
1790
/* Explicit warning message if we detect too much movement */
1792
1791
if (ctx -> current_calibration_phase == GYRO_CALIBRATION_PHASE_OFF ) {
1793
1792
@@ -1803,10 +1802,9 @@ void RenderGyroDriftCalibrationButton(GyroDisplay *ctx, GamepadDisplay *gamepad_
1803
1802
if (ctx -> current_calibration_phase == GYRO_CALIBRATION_PHASE_NOISE_PROFILING
1804
1803
|| ctx -> current_calibration_phase == GYRO_CALIBRATION_PHASE_DRIFT_PROFILING )
1805
1804
{
1806
- float flAbsoluteNoiseFraction = SDL_clamp (ctx -> accelerometer_noise_sq / ( flAbsoluteMaxAccelerationG * flAbsoluteMaxAccelerationG ) , 0.0f , 1.0f );
1807
- float flAbsoluteToleranceFraction = SDL_clamp (ctx -> accelerometer_noise_tolerance_sq / ( flAbsoluteMaxAccelerationG * flAbsoluteMaxAccelerationG ) , 0.0f , 1.0f );
1805
+ float flAbsoluteNoiseFraction = SDL_clamp (ctx -> accelerometer_noise_sq / ACCELEROMETER_MAX_NOISE_G_SQ , 0.0f , 1.0f );
1806
+ float flAbsoluteToleranceFraction = SDL_clamp (ctx -> accelerometer_noise_tolerance_sq / ACCELEROMETER_MAX_NOISE_G_SQ , 0.0f , 1.0f );
1808
1807
float flRelativeNoiseFraction = SDL_clamp (ctx -> accelerometer_noise_sq / ctx -> accelerometer_noise_tolerance_sq , 0.0f , 1.0f );
1809
- bool bTooMuchNoise = (flAbsoluteNoiseFraction == 1.0f );
1810
1808
1811
1809
float noise_bar_height = gamepad_display -> button_height ;
1812
1810
SDL_FRect noise_bar_rect ;
@@ -1815,12 +1813,10 @@ void RenderGyroDriftCalibrationButton(GyroDisplay *ctx, GamepadDisplay *gamepad_
1815
1813
noise_bar_rect .w = recalibrate_button_area .w ;
1816
1814
noise_bar_rect .h = noise_bar_height ;
1817
1815
1818
- //SDL_strlcpy(label_text, "Place GamePad On Table", sizeof(label_text));
1819
1816
SDL_snprintf (label_text , sizeof (label_text ), "Noise Tolerance: %3.3fG " , SDL_sqrtf (ctx -> accelerometer_noise_tolerance_sq ) );
1820
1817
SDLTest_DrawString (ctx -> renderer , recalibrate_button_area .x , recalibrate_button_area .y + recalibrate_button_area .h + new_line_height * 2 , label_text );
1821
1818
1822
1819
/* Adjust the noise bar rectangle based on the accelerometer noise value */
1823
-
1824
1820
float noise_bar_fill_width = flAbsoluteNoiseFraction * noise_bar_rect .w ; /* Scale the width based on the noise value */
1825
1821
SDL_FRect noise_bar_fill_rect ;
1826
1822
noise_bar_fill_rect .x = noise_bar_rect .x + (noise_bar_rect .w - noise_bar_fill_width ) * 0.5f ;
@@ -1848,6 +1844,7 @@ void RenderGyroDriftCalibrationButton(GyroDisplay *ctx, GamepadDisplay *gamepad_
1848
1844
SDL_RenderRect (ctx -> renderer , & noise_bar_rect ); /* draw the outline rectangle */
1849
1845
1850
1846
/* Explicit warning message if we detect too much movement */
1847
+ bool bTooMuchNoise = (flAbsoluteNoiseFraction == 1.0f );
1851
1848
if (bTooMuchNoise ) {
1852
1849
SDL_strlcpy (label_text , "Place GamePad Down!" , sizeof (label_text ));
1853
1850
SDLTest_DrawString (ctx -> renderer , recalibrate_button_area .x , noise_bar_rect .y + noise_bar_rect .h + new_line_height , label_text );
0 commit comments