All Projects → Sequal32 → simconnect-rust

Sequal32 / simconnect-rust

Licence: MIT license
SimConnect bindings for rust.

Programming Languages

C++
36643 projects - #6 most used programming language
rust
11053 projects

Projects that are alternatives of or similar to simconnect-rust

EFBConnect
A utility that shares Microsoft Flight Simulator position, attitude, and traffic information with ForeFlight.
Stars: ✭ 18 (-25%)
Mutual labels:  fsx, p3d, simconnect
FSJumpStarter2020
Starts Microsoft Flight Simulator without intros and shows a splash screen.
Stars: ✭ 24 (+0%)
Mutual labels:  flightsimulator, flightsim, msfs2020
VAOS
Virtual Aviation Operations System
Stars: ✭ 44 (+83.33%)
Mutual labels:  fsx, p3d
BushtalkClient
Bushtalk Radio is a community driven project with the aim to fill the empty world of MSFS2020 with thousands of additional landmarks and POIs.
Stars: ✭ 31 (+29.17%)
Mutual labels:  simconnect, msfs2020
QSimPlanner
A tool for fuel planning and take-off/landing performance calculations.
Stars: ✭ 56 (+133.33%)
Mutual labels:  fsx, p3d
MSFSTouchPortalPlugin
The goal of this repository is to create a connection between Touch Portal and MSFS through SimConnect in order to allow users to create buttons to control or view data for your aircraft. While this is for MSFS, in theory it could be used with other SimConnect compatible games.
Stars: ✭ 60 (+150%)
Mutual labels:  simconnect, msfs2020
MSFS-Mobile-Companion-App
Mobile Companion App for MSFS 2020
Stars: ✭ 320 (+1233.33%)
Mutual labels:  simconnect, msfs2020
msfs2020-google-map
Replace MSFS2020's bing map to google map
Stars: ✭ 272 (+1033.33%)
Mutual labels:  msfs2020
aws-fsx-csi-driver
CSI Driver of Amazon FSx for Lustre https://aws.amazon.com/fsx/lustre/
Stars: ✭ 102 (+325%)
Mutual labels:  fsx
MSFS2020-Real-Time-Weather
A work in progress to update a custom Microsoft Flight Simulator 2020 weather preset with the current conditions of a given airport.
Stars: ✭ 22 (-8.33%)
Mutual labels:  msfs2020
vscode-save-and-run
Visual Studio Code extension to run commands whenever a file is saved https://marketplace.visualstudio.com/items?itemName=wk-j.save-and-run
Stars: ✭ 31 (+29.17%)
Mutual labels:  fsx
navdatareader
Navdatareader is a command line tool that uses the atools fs/bgl and fs/writer to store a full flight simulator scenery database into a relational database like Sqlite or MySql.
Stars: ✭ 35 (+45.83%)
Mutual labels:  fsx
pseudo-3d-pytorch
No description or website provided.
Stars: ✭ 29 (+20.83%)
Mutual labels:  p3d
P3D-Debinarizer-Arma-3
P3DDebinarizer converts binarized p3d models (ODOL format) to editable MLOD format
Stars: ✭ 31 (+29.17%)
Mutual labels:  p3d
LittleNavmapOFMTheme
Open Flightmaps VFR Map Theme for Little Navmap
Stars: ✭ 34 (+41.67%)
Mutual labels:  flightsimulator
A32nx
The A32NX Project is a community driven open source project to create a free Airbus A320neo in Microsoft Flight Simulator that is as close to reality as possible.
Stars: ✭ 3,847 (+15929.17%)
Mutual labels:  msfs2020
Flight-Recorder
Record and replay flights in Microsoft Flight Simulator
Stars: ✭ 148 (+516.67%)
Mutual labels:  msfs2020
MFS2020 zh-CN
微软模拟飞行民间汉化
Stars: ✭ 49 (+104.17%)
Mutual labels:  msfs2020

SimConnect Bindings for Rust

Using

Add this to your Cargo.toml

[dependencies]
simconnect = "0.1.3"

Note: This crate is in its early stages and API breaking changes can be pushed at any moment. In this case, it's recommended to use the exact version "0.X.X".

Building

The SimConnect binaries are included within this repository, but they may not be up to date.

  1. Install CLang. More information available at the Rust Bindgen Documentation.
  2. run cargo build
  3. use simconnect

Sample Program

Note: You must have SimConnect.dll in your current working directory or in the exe directory to be able to successfully use SimConnect

use simconnect;
use std::time::Duration;
use std::thread::sleep;
use std::mem::transmute_copy;

struct DataStruct {
  lat: f64,
  lon: f64,
  alt: f64,
}

let mut conn = simconnect::SimConnector::new();
conn.connect("Simple Program"); // Intialize connection with SimConnect
conn.add_data_definition(0, "PLANE LATITUDE", "Degrees", simconnect::SIMCONNECT_DATATYPE_SIMCONNECT_DATATYPE_FLOAT64, u32::MAX); // Assign a sim variable to a client defined id
conn.add_data_definition(0, "PLANE LONGITUDE", "Degrees", simconnect::SIMCONNECT_DATATYPE_SIMCONNECT_DATATYPE_FLOAT64, u32::MAX);
conn.add_data_definition(0, "PLANE ALTITUDE", "Feet", simconnect::SIMCONNECT_DATATYPE_SIMCONNECT_DATATYPE_FLOAT64, u32::MAX); //define_id, units, data_type, datum_id
conn.request_data_on_sim_object(0, 0, 0, simconnect::SIMCONNECT_PERIOD_SIMCONNECT_PERIOD_SIM_FRAME, 0, 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

loop {
  match conn.get_next_message() {
    Ok(simconnect::DispatchResult::SimobjectData(data)) => {
      unsafe {
        match data.dwDefineID {
          0 => {
            let sim_data: DataStruct = transmute_copy(&data.dwData);
            println!("{:?} {:?} {:?}", sim_data.lat, sim_data.lon, sim_data.alt);
          },
          _ => ()
        }
      }
    },
    _ => ()
  }
  
  sleep(Duration::from_millis(16)); // Will use up lots of CPU if this is not included, as get_next_message() is non-blocking
}

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].