diff --git a/Readme.md b/Readme.md index c960e92..70d97c7 100644 --- a/Readme.md +++ b/Readme.md @@ -2,10 +2,18 @@ # SimConnect Bindings for Rust +Send and receive information through SimConnect, for Microsoft Flight Simulator (2020). + +Documentation can be found at: [MSFS 2020 SDK](https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/SimConnect_SDK.htm) + + ## Requirements -- [CLang](https://clang.llvm.org/get_started.html) (See the [Rust Bindgen Documentation](https://rust-lang.github.io/rust-bindgen/requirements.html)) -- MSVC x64 Rust build (`x86_64-pc-windows-msvc`, see [The rustup book](https://rust-lang.github.io/rustup/installation/windows.html)) +- [Rust](https://rust-lang.org/learn/get-started) +- [LLVM/Clang](https://clang.llvm.org/get_started.html) + +See the [Rust Bindgen Documentation](https://rust-lang.github.io/rust-bindgen/introduction.html) + ## Using @@ -16,14 +24,18 @@ Add this to your `Cargo.toml` simconnect = "0.4" ``` +_You must have SimConnect.dll in the same directory as your executable._ + + ## Building _The SimConnect binaries are included within this repository, but they may not be up-to-date._ -1. run `cargo build` -2. Add `use simconnect` at the top of your file +1. Run `cargo build` +2. Add import `use simconnect` at the top of your file + -## Example +## Examples Read float position data @@ -31,14 +43,13 @@ Read float position data cargo run --example aircraft_updates ``` -Requests tagged data with thresholds from SimConnect and reads floats/strings +Requests tagged data with thresholds from SimConnect, and reads floats/strings ``` cargo run --example aircraft_updates_on_change ``` -_You must have SimConnect.dll in the same directory as the compiled exe for it to run (e.g. in )_ -### Remarks +## Remarks -I have not tested every single function from the api. If you find an error, feel free to make an issue or a pull request. +I have not tested every function of the API. If you find an error, feel free to make an issue or pull request. diff --git a/SimConnect.dll b/SimConnect.dll index 2aa284c..8f0fe28 100644 Binary files a/SimConnect.dll and b/SimConnect.dll differ diff --git a/examples/aircraft_updates/main.rs b/examples/aircraft_updates/main.rs index 5e6eedf..44ae0ce 100644 --- a/examples/aircraft_updates/main.rs +++ b/examples/aircraft_updates/main.rs @@ -1,6 +1,5 @@ use std::thread::sleep; use std::time::Duration; - use simconnect::DispatchResult; struct DataStruct { @@ -8,9 +7,10 @@ struct DataStruct { lon: f64, alt: f64, } + fn main() { let mut conn = simconnect::SimConnector::new(); - conn.connect("Simple Program"); // Intialize connection with SimConnect + conn.connect("Simple Program"); // Initialize connection with SimConnect conn.add_data_definition( 0, "PLANE LATITUDE", @@ -34,7 +34,7 @@ fn main() { simconnect::SIMCONNECT_DATATYPE_SIMCONNECT_DATATYPE_FLOAT64, u32::MAX, 1.0, - ); //define_id, units, data_type, datum_id, epsilon (update threshold) + ); // define_id, units, data_type, datum_id, epsilon (update threshold) conn.request_data_on_sim_object( 0, 0, @@ -44,7 +44,7 @@ fn main() { 0, 0, 0, - ); //request_id, define_id, object_id (user), period, falgs, origin, interval, limit - tells simconnect to send data for the defined id and on the user aircraft + ); // request_id, define_id, object_id (user), period, flags, origin, interval, limit - tells simconnect to send data for the defined id and on the user aircraft loop { match conn.get_next_message() { diff --git a/examples/aircraft_updates_on_change/main.rs b/examples/aircraft_updates_on_change/main.rs index f4211a0..4e51592 100644 --- a/examples/aircraft_updates_on_change/main.rs +++ b/examples/aircraft_updates_on_change/main.rs @@ -1,9 +1,9 @@ -use simconnect::{DispatchResult, DWORD}; use std::ptr::read_unaligned; use std::thread::sleep; use std::time::Duration; +use simconnect::{DispatchResult, DWORD}; -// To allign the memory we have to set a fixed max size to the returned variables from the game +// To align the memory we have to set a fixed max size to the returned variables from the game const MAX_RETURNED_ITEMS: usize = 255; // Rust will add padding to the inner parts of a struct if it isn't marked as packed @@ -54,7 +54,7 @@ fn main() { simconnect::SIMCONNECT_DATATYPE_SIMCONNECT_DATATYPE_FLOAT64, 3, 100.0, - ); //define_id, units, data_type, datum_id, epsilon (update threshold) + ); // define_id, units, data_type, datum_id, epsilon (update threshold) // Here we define all our variabes that get returned as Strings // Notice how the define_id differs from the float values @@ -82,7 +82,7 @@ fn main() { 0, 0, 0, - ); //request_id, define_id, object_id (user), period, falgs, origin, interval, limit - tells simconnect to send data for the defined id and on the user aircraft + ); // request_id, define_id, object_id (user), period, flags, origin, interval, limit - tells simconnect to send data for the defined id and on the user aircraft // Request the data from our define_id 1 (strings) // The request_id has to differ from the float request. Or else it will overwrite the previous request conn.request_data_on_sim_object( @@ -95,7 +95,7 @@ fn main() { 0, 0, 0, - ); //request_id, define_id, object_id (user), period, falgs, origin, interval, limit - tells simconnect to send data for the defined id and on the user aircraft + ); // request_id, define_id, object_id (user), period, flags, origin, interval, limit - tells simconnect to send data for the defined id and on the user aircraft loop { match conn.get_next_message() {