Module xplm::flight_loop

source ·
Expand description

Flight loop callbacks

§Flight loop callbacks

X-Plane can call plugin code at timed intervals or when it runs its flight model.

A FlightLoop object must persist for callbacks to occur. When the FlightLoop is dropped, its callbacks will stop.

§Examples

Closure handler:

use xplm::flight_loop::{FlightLoop, LoopState};

let handler = |loop_state: &mut LoopState| {
    println!("Flight loop callback running");
};

let mut flight_loop = FlightLoop::new(handler);
flight_loop.schedule_immediate();

Struct handler:

use xplm::flight_loop::{FlightLoop, FlightLoopCallback, LoopState};

struct LoopHandler;

impl FlightLoopCallback for LoopHandler {
    fn flight_loop(&mut self, state: &mut LoopState) {
        println!("Flight loop callback running");
    }
}

let mut flight_loop = FlightLoop::new(LoopHandler);
flight_loop.schedule_immediate();

Structs§

  • Tracks a flight loop callback, which can be called by X-Plane periodically for calculations
  • Information available during a flight loop callback

Traits§