msfs::sim_connect

Struct SimConnect

Source
pub struct SimConnect<'a> { /* private fields */ }
Expand description

A SimConnect session. This provides access to data within the MSFS sim.

Implementations§

Source§

impl<'a> SimConnect<'a>

Source

pub fn open<F>(name: &str, callback: F) -> Result<Pin<Box<SimConnect<'a>>>>
where F: FnMut(&mut SimConnect<'_>, SimConnectRecv<'_>) + 'a,

Send a request to the Microsoft Flight Simulator server to open up communications with a new client.

Source

pub fn call_dispatch(&mut self) -> Result<()>

Used to process the next SimConnect message received. Only needed when not using the gauge API.

Source

pub fn set_data_on_sim_object<T: DataDefinition>( &mut self, object_id: SIMCONNECT_OBJECT_ID, data: &T, ) -> Result<()>

Make changes to the data properties of an object.

Source

pub fn request_data_on_sim_object_type<T: DataDefinition>( &mut self, request_id: SIMCONNECT_DATA_REQUEST_ID, radius: DWORD, type: SIMCONNECT_SIMOBJECT_TYPE, ) -> Result<()>

Retrieve information about simulation objects of a given type that are within a specified radius of the user’s aircraft.

Source

pub fn request_data_on_sim_object<T: DataDefinition>( &mut self, request_id: SIMCONNECT_DATA_REQUEST_ID, object_id: SIMCONNECT_OBJECT_ID, period: Period, ) -> Result<()>

Request when the SimConnect client is to receive data values for a specific object

Source

pub fn map_client_event_to_sim_event( &mut self, event_name: &str, mask: bool, ) -> Result<DWORD>

Map a Prepar3D event to a specific ID. If mask is true, the sim itself will ignore the event, and only this SimConnect instance will receive it.

Source

pub fn transmit_client_event( &mut self, object_id: SIMCONNECT_OBJECT_ID, event_id: DWORD, data: DWORD, ) -> Result<()>

Trigger an event, previously mapped with map_client_event_to_sim_event

Source

pub fn transmit_client_event_ex1( &mut self, object_id: SIMCONNECT_OBJECT_ID, event_id: DWORD, data: [DWORD; 5], ) -> Result<()>

Source

pub fn create_client_data<T: ClientDataDefinition>( &mut self, name: &str, ) -> Result<ClientDataArea<T>>

Allocate a region of memory in the sim with the given name. Other SimConnect modules can use the name to read data from this memory using request_client_data. This memory cannot be deallocated.

Source

pub fn get_client_area<T: ClientDataDefinition>( &mut self, name: &str, ) -> Result<ClientDataArea<T>>

Create a handle to a region of memory allocated by another module with the given name.

Source

pub fn request_client_data<T: ClientDataDefinition>( &mut self, request_id: SIMCONNECT_DATA_REQUEST_ID, name: &str, ) -> Result<()>

Request a pre-allocated region of memory from the sim with the given name. A module must have already used create_client_data to allocate this memory.

Source

pub fn set_client_data<T: ClientDataDefinition>( &mut self, area: &ClientDataArea<T>, data: &T, ) -> Result<()>

Set the data of an area acquired by create_client_data or get_client_data.

Source

pub fn ai_create_non_atc_aircraft( &mut self, container_title: &str, tail_number: &str, init_position: SIMCONNECT_DATA_INITPOSITION, request_id: SIMCONNECT_DATA_REQUEST_ID, ) -> Result<()>

Source

pub fn ai_create_parked_atc_aircraft( &mut self, container_title: &str, tail_number: &str, icao: &str, request_id: SIMCONNECT_DATA_REQUEST_ID, ) -> Result<()>

Source

pub fn ai_remove_object( &mut self, object_id: SIMCONNECT_OBJECT_ID, request_id: SIMCONNECT_DATA_REQUEST_ID, ) -> Result<()>

Source

pub fn subscribe_to_system_event( &mut self, system_event_name: &str, ) -> Result<DWORD>

Source

pub fn unsubscribe_from_system_event( &mut self, event_id: SIMCONNECT_CLIENT_EVENT_ID, ) -> Result<()>

Source

pub fn set_system_event_state( &mut self, event_id: SIMCONNECT_CLIENT_EVENT_ID, on: bool, ) -> Result<()>

Source

pub fn load_flight(&mut self, flight_file_path: &str) -> Result<()>

Load a .FLT file from disk

Source

pub fn save_flight( &mut self, flight_file_path: &str, title: Option<&str>, description: Option<&str>, ) -> Result<()>

Save the current sim state to a .FLT file

Source

pub fn load_flight_plan(&mut self, flight_plan_file_path: &str) -> Result<()>

Load a .PLN file from disk

Trait Implementations§

Source§

impl Debug for SimConnect<'_>

Source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for SimConnect<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for SimConnect<'a>

§

impl<'a> !RefUnwindSafe for SimConnect<'a>

§

impl<'a> !Send for SimConnect<'a>

§

impl<'a> !Sync for SimConnect<'a>

§

impl<'a> Unpin for SimConnect<'a>

§

impl<'a> !UnwindSafe for SimConnect<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.