Skip to content

Commit

Permalink
Fix calibration page closing instantly when not connected
Browse files Browse the repository at this point in the history
Note: calibration was still taking place in the background,
but the calibration progress page would close instantly
and show the "calibration complete message" prematurely.

This was due to Con_Printf being called in IN_StartGyroCalibration
before updates_countdown was set. Con_Printf redraws the screen,
which means M_Calibration_Draw would see updates_countdown == 0
and consider that calibration must be done, immediately changing
the menu state to CALIBRATION_FINISHED.
  • Loading branch information
andrei-drexler committed Aug 6, 2024
1 parent 51bdbd3 commit b45d77f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Quake/in_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1385,13 +1385,18 @@ static void IN_DebugKeyEvent(SDL_Event *event)

void IN_StartGyroCalibration (void)
{
Con_Printf ("Calibrating, please wait...\n");

gyro_accum[0] = 0.0;
gyro_accum[1] = 0.0;
gyro_accum[2] = 0.0;

updates_countdown = GYRO_CALIBRATION_SAMPLES;

// Note: we modify updates_countdown first, before printing the message to the console,
// because Con_Printf triggers a redraw, which in turn calls M_Calibration_Draw,
// which would see that updates_countown is 0 and consider that calibration must be done.
// Alternatively, we could use Con_SafePrintf (which doesn't refresh the screen).

Con_Printf ("Calibrating, please wait...\n");
}

static qboolean IN_UpdateGyroCalibration (const float newsample[3])
Expand Down

0 comments on commit b45d77f

Please sign in to comment.