Skip to content

input_cali

Anthony Samms edited this page Jun 2, 2026 · 1 revision

The input calibration screen measures the player's input latency and writes the result back to config. It runs the gameplay engine on a fixed calibration chart with auto-play enabled, then records the timing difference between each don hit and the auto-play note hit time.

InputCaliScreen

Inherits from GameScreen. Uses the "game" skin assets.

Members

Member Type Description
latencies vector<double> Raw latency samples collected from each don hit, in milliseconds
average_latency double Median of all collected samples, updated after each hit
average_latency_text optional<OutlinedText> Text object displaying the current median latency, recreated after each hit

Lifecycle

void on_screen_start() override;

Sets session_data.selected_song to Songs/Calibration.tja and selected_difficulty to Hard (index 2), enables auto_play on the active player, then calls GameScreen::on_screen_start(). Resets the background object using the "TUTORIAL" theme at 150 BPM.

Screens on_screen_end(Screens next_screen) override;

Disables auto_play, writes average_latency * -1 to config->general.audio_offset, then delegates to GameScreen::on_screen_end.

Update

std::optional<Screens> update() override;

Pressing the back key returns immediately to Screens::SETTINGS. Otherwise delegates to GameScreen::update():

  • If the result is Screens::SONG_SELECT (song ended normally), swallows it and stays on screen so the calibration loop continues.
  • If the result is Screens::RESULT, returns Screens::SETTINGS instead — calibration is complete.

On each frame, if a left or right don is pressed, the latency is computed as players[0]->last_note_hit - current_ms (a negative value means the player hit early). The sample is appended to latencies and the median is recalculated. average_latency_text is rebuilt with the new value.

Draw

void draw() override;

Draws the game background rear layer, the note lane for P1 at the standard y-position, the average_latency_text centered near the bottom of the screen (if at least one sample has been recorded), and the game background front layer and overlay.

Clone this wiki locally