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>
impl<'a> SimConnect<'a>
Sourcepub fn open<F>(name: &str, callback: F) -> Result<Pin<Box<SimConnect<'a>>>>
pub fn open<F>(name: &str, callback: F) -> Result<Pin<Box<SimConnect<'a>>>>
Send a request to the Microsoft Flight Simulator server to open up communications with a new client.
Sourcepub fn call_dispatch(&mut self) -> Result<()>
pub fn call_dispatch(&mut self) -> Result<()>
Used to process the next SimConnect message received. Only needed when not using the gauge API.
Sourcepub fn set_data_on_sim_object<T: DataDefinition>(
&mut self,
object_id: SIMCONNECT_OBJECT_ID,
data: &T,
) -> Result<()>
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.
Sourcepub fn request_data_on_sim_object_type<T: DataDefinition>(
&mut self,
request_id: SIMCONNECT_DATA_REQUEST_ID,
radius: DWORD,
type: SIMCONNECT_SIMOBJECT_TYPE,
) -> Result<()>
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.
Sourcepub fn request_data_on_sim_object<T: DataDefinition>(
&mut self,
request_id: SIMCONNECT_DATA_REQUEST_ID,
object_id: SIMCONNECT_OBJECT_ID,
period: Period,
) -> Result<()>
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
Sourcepub fn map_client_event_to_sim_event(
&mut self,
event_name: &str,
mask: bool,
) -> Result<DWORD>
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.
Sourcepub fn transmit_client_event(
&mut self,
object_id: SIMCONNECT_OBJECT_ID,
event_id: DWORD,
data: DWORD,
) -> Result<()>
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
pub fn transmit_client_event_ex1( &mut self, object_id: SIMCONNECT_OBJECT_ID, event_id: DWORD, data: [DWORD; 5], ) -> Result<()>
Sourcepub fn create_client_data<T: ClientDataDefinition>(
&mut self,
name: &str,
) -> Result<ClientDataArea<T>>
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.
Sourcepub fn get_client_area<T: ClientDataDefinition>(
&mut self,
name: &str,
) -> Result<ClientDataArea<T>>
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
.
Sourcepub fn request_client_data<T: ClientDataDefinition>(
&mut self,
request_id: SIMCONNECT_DATA_REQUEST_ID,
name: &str,
) -> Result<()>
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.
Sourcepub fn set_client_data<T: ClientDataDefinition>(
&mut self,
area: &ClientDataArea<T>,
data: &T,
) -> Result<()>
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
.
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<()>
pub fn ai_create_parked_atc_aircraft( &mut self, container_title: &str, tail_number: &str, icao: &str, request_id: SIMCONNECT_DATA_REQUEST_ID, ) -> Result<()>
pub fn ai_remove_object( &mut self, object_id: SIMCONNECT_OBJECT_ID, request_id: SIMCONNECT_DATA_REQUEST_ID, ) -> Result<()>
pub fn subscribe_to_system_event( &mut self, system_event_name: &str, ) -> Result<DWORD>
pub fn unsubscribe_from_system_event( &mut self, event_id: SIMCONNECT_CLIENT_EVENT_ID, ) -> Result<()>
pub fn set_system_event_state( &mut self, event_id: SIMCONNECT_CLIENT_EVENT_ID, on: bool, ) -> Result<()>
Sourcepub fn load_flight(&mut self, flight_file_path: &str) -> Result<()>
pub fn load_flight(&mut self, flight_file_path: &str) -> Result<()>
Load a .FLT file from disk
Sourcepub fn save_flight(
&mut self,
flight_file_path: &str,
title: Option<&str>,
description: Option<&str>,
) -> Result<()>
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
Sourcepub fn load_flight_plan(&mut self, flight_plan_file_path: &str) -> Result<()>
pub fn load_flight_plan(&mut self, flight_plan_file_path: &str) -> Result<()>
Load a .PLN file from disk