Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

SimConnect SDK in Rust. An opinionated SimConnect Client that encapsulates the C API fully and optimizes for developer experience.

License

NotificationsYou must be signed in to change notification settings

mihai-dinculescu/simconnect-sdk-rs

Repository files navigation

CratesDocumentationCIlicenseCrates.io
An opinionated SimConnect Client that encapsulates the C API fully and optimizes for developer experience.

Usage

[dependencies]simconnect-sdk = {version ="0.2",features = ["derive"] }
use simconnect_sdk::{Notification,SimConnect,SimConnectObject};/// A data structure that will be used to receive data from SimConnect./// See the documentation of `SimConnectObject` for more information on the arguments of the `simconnect` attribute.#[derive(Debug,Clone,SimConnectObject)]#[simconnect(period ="second")]#[allow(dead_code)]structAirplaneData{#[simconnect(name ="TITLE")]title:String,#[simconnect(name ="CATEGORY")]category:String,#[simconnect(name ="PLANE LATITUDE", unit ="degrees")]lat:f64,#[simconnect(name ="PLANE LONGITUDE", unit ="degrees")]lon:f64,#[simconnect(name ="PLANE ALTITUDE", unit ="feet")]alt:f64,#[simconnect(name ="SIM ON GROUND")]sim_on_ground:bool,}fnmain() ->Result<(),Box<dyn std::error::Error>>{let client =SimConnect::new("Receiving data example");match client{Ok(mut client) =>{letmut notifications_received =0;loop{let notification = client.get_next_dispatch()?;match notification{Some(Notification::Open) =>{println!("Connection opened.");// After the connection is successfully open, we register the struct                        client.register_object::<AirplaneData>()?;}Some(Notification::Object(data)) =>{ifletOk(airplane_data) =AirplaneData::try_from(&data){println!("{airplane_data:?}");                            notifications_received +=1;// After we have received 10 notifications, we unregister the structif notifications_received >10{                                client.unregister_object::<AirplaneData>()?;println!("Subscription stopped.");break;}}}                    _ =>(),}// sleep for about a frame to reduce CPU usage                std::thread::sleep(std::time::Duration::from_millis(16));}}Err(e) =>{println!("Error: {e:?}")}}Ok(())}

Seemore examples.

Contributing

Contributions are welcome and encouraged! SeeCONTRIBUTING.md.

Supported features

SeeFEATURES.md.

Credits

Inspired byrylev/msfs2020 andSequal32/simconnect-rust.

About

SimConnect SDK in Rust. An opinionated SimConnect Client that encapsulates the C API fully and optimizes for developer experience.

Topics

Resources

License

Stars

Watchers

Forks

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp