#pragma once //########################################################################## // RP412INPUTSCRIPT - scripted analog input, on the simulation's clock. // // A race cannot be called deterministic until somebody DRIVES it, and a // human cannot drive the same lap twice. This feeds the four analog // channels the controls mapper interprets - throttle, stick X/Y, pedals - // from a timeline file instead, evaluated against the mapper's own step // clock, so the same script produces the same race at any frame rate. // // The file named by RP412INPUTSCRIPT= holds one row per change: // // # t throttle stickX stickY pedals // 0.0 0.0 0 0 0 // 2.0 1.0 0 0 0 // 6.0 1.0 0.5 0 0 // // Times are seconds of SIMULATION time from the green light. Each row // HOLDS until the next row's time - a step function, no interpolation, // because interpolation would sample differently at different physics // rates and the whole point is that nothing does. // // Armed by the green-light anchor in Application::ExecuteForeground (the // same instant RP412PHYSTRACE stops the pod dead), so the script clock, // the trace clock and the vehicle's state all start together. // // Test harness: off unless the environment names a file, costs nothing // when off, and it would be a cheat in a real race. //########################################################################## class Time; // is a script named and readable? (parsed once, on first ask) int RPInputScript_Active(); // the green light: script time zero is this instant void RPInputScript_Arm(const Time &origin); // evaluate at 'now' (a simulation clock, normally GetLastPerformance()). // Returns 0 before Arm or with no script - callers leave their own // values alone. Outputs are clamped to the mapper's legal ranges. int RPInputScript_Sample( const Time &now, float *throttle_out, // 0..1 float *stick_x_out, // -1..1 float *stick_y_out, // -1..1 float *pedals_out // -1..1 );