Struct msfs::sim_connect::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>
impl<'a> SimConnect<'a>
sourcepub fn open<F>(name: &str, callback: F) -> Result<Pin<Box<SimConnect<'a>>>>where
F: FnMut(&mut SimConnect<'_>, SimConnectRecv<'_>) + 'a,
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.
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
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
.