Skip to content

Commit 9bc78f1

Browse files
MrMinimalTom Langwaldt
andauthored
Update README (#37)
In order to make the msfs-rs project more accessible to beginners, I created a README. --------- Co-authored-by: Tom Langwaldt <mail@tomlangwaldt.com>
1 parent 8ec5537 commit 9bc78f1

File tree

3 files changed

+129
-2
lines changed

3 files changed

+129
-2
lines changed

README.md

Lines changed: 98 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,99 @@
1-
# msfs-rs
1+
![FlyByWire Simulations](https://raw.githubusercontent.com/flybywiresim/branding/1391fc003d8b5d439d01ad86e2778ae0bfc8b682/tails-with-text/FBW-Color-Light.svg#gh-dark-mode-only)
22

3-
See https://flybywiresim.github.io/msfs-rs/msfs/
3+
# ✈️ msfs-rs 🦀
4+
5+
**Use Rust to interact with Microsoft Flight Simulator**
6+
7+
[**As seen in the FlyByWire A32NX and A380X!**](https://flybywiresim.com/projects/)
8+
9+
* Write custom aircraft logic in Rust
10+
* Systems
11+
* Gauges
12+
* Instrument panels (NanoVG)
13+
* Replace aircraft code
14+
* RPL
15+
* C++
16+
* JavaScript
17+
* TypeScript
18+
* WASM
19+
* Interact with the Microsoft SDK
20+
* Create external applications that interact with MSFS using SimConnect
21+
22+
[![Discord](https://img.shields.io/discord/738864299392630914.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/flybywire)
23+
[![X](https://img.shields.io/badge/-@FlyByWireSim-e84393?label=&logo=X&logoColor=ffffff&color=6399AE&labelColor=00C2CB)](https://x.com/FlybywireSim)
24+
[![YouTube](https://img.shields.io/badge/-FlyByWireSimulations-e84393?label=&logo=youtube&logoColor=ffffff&color=6399AE&labelColor=00C2CB)](https://www.youtube.com/c/FlyByWire-Simulations)
25+
[![Facebook](https://img.shields.io/badge/-FlyByWireSimulations-e84393?label=&logo=facebook&logoColor=ffffff&color=6399AE&labelColor=00C2CB)](https://www.facebook.com/FlyByWireSimulations/)
26+
[![Instagram](https://img.shields.io/badge/-@FlyByWireSim-e84393?label=&logo=instagram&logoColor=ffffff&color=6399AE&labelColor=00C2CB)](https://instagram.com/flybywiresim)
27+
[![Bluesky](https://img.shields.io/badge/-@FlyByWireSim-e84393?label=&logo=Bluesky&logoColor=ffffff&color=6399AE&labelColor=00C2CB)](https://bsky.app/profile/flybywiresim.com)
28+
29+
---
30+
31+
## Example
32+
Drawing a red rectangle on a glass instrument panel inside an aircraft cockpit:
33+
34+
```rust
35+
// gauge_logic.rs
36+
use msfs::{nvg, MSFSEvent};
37+
38+
#[msfs::gauge(name=Demo)]
39+
async fn demo(mut gauge: msfs::Gauge) -> Result<(), Box<dyn std::error::Error>> {
40+
// Use NanoVG to draw
41+
let nvg = gauge.create_nanovg().unwrap();
42+
43+
let black = nvg::Style::default().fill(nvg::Color::from_rgb(0, 0, 0));
44+
let red = nvg::Style::default().fill(nvg::Color::from_rgb(255, 0, 0));
45+
46+
// Reacting to MSFS events
47+
while let Some(event) = gauge.next_event().await {
48+
match event {
49+
MSFSEvent::PreDraw(d) => {
50+
nvg.draw_frame(d.width(), d.height(), |f| {
51+
// Red rectangle
52+
f.draw_path(&red, |p| {
53+
p.rect(20.0, 20.0, 40.0, 40.0);
54+
println!("Hello rusty world!");
55+
56+
Ok(())
57+
})?;
58+
59+
Ok(())
60+
});
61+
}
62+
_ => {}
63+
}
64+
}
65+
Ok(())
66+
}
67+
```
68+
69+
```
70+
[VCockpit01]
71+
size_mm=1024,768
72+
pixel_size=1024,768
73+
texture=$SCREEN_1
74+
background_color=0,0,255
75+
htmlgauge00=WasmInstrument/WasmInstrument.html?wasm_module=gauge_logic.wasm&wasm_gauge=Demo, 0,0,1024,768
76+
```
77+
![Screenshot showing a Rust output in the ingame console](/img/proof.png)
78+
79+
80+
---
81+
82+
## Getting started
83+
```bash
84+
$ cd examples/nvg
85+
$ cargo build --target wasm32-wasip1
86+
```
87+
* [Check out the other examples](examples/)
88+
* [Download the MSFS SDK](https://docs.flightsimulator.com/html/Introduction/SDK_Overview.htm)
89+
90+
## Further reading
91+
* [Documentation](https://flybywiresim.github.io/msfs-rs/msfs/)
92+
* [Microsoft Flight Simulator SDK](https://docs.flightsimulator.com/html/Introduction/Introduction.htm)
93+
* [Creating an aircraft with custom logic](https://docs.flightsimulator.com/html/Samples_And_Tutorials/Samples/SimObjects_Aircraft/GaugeAircraft.htm)
94+
* [Programming APIs](https://docs.flightsimulator.com/html/Programming_Tools/Programming_APIs.htm)
95+
* [Microsoft's Samples and Examples](https://docs.flightsimulator.com/html/Samples_And_Tutorials/Samples_And_Tutorials.htm)
96+
* [External interaction with SimConnect](https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/SimConnect_SDK.htm)
97+
98+
## Help
99+
* Join the [Discord #rust-lang channel](https://discord.gg/flybywire)

examples/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
## Nvg
2+
NanoVG demo to show how to draw a custom Gauge in an aircraft.
3+
4+
* Compiles to WASM to be [loaded by MSFS](https://docs.flightsimulator.com/html/mergedProjects/How_To_Make_An_Aircraft/Contents/Instruments/Creating_WASM_Gauges.htm).
5+
* Similar to how the MSFS Sample [GaugeAircraft](https://docs.flightsimulator.com/html/Samples_And_Tutorials/Samples/SimObjects_Aircraft/GaugeAircraft.htm) works.
6+
7+
#### Building
8+
```bash
9+
$ cd examples/nvg
10+
$ cargo build --target wasm32-wasip1
11+
```
12+
#### Running
13+
To see it in action you have to load an aircraft into MSFS which uses the compiled wasm file.
14+
15+
[MrMinimal's Rust Aircraft Template](https://github.com/MrMinimal/msfs-rust-aircraft) shows how that can be done.
16+
17+
---
18+
19+
## Client Data
20+
SimConnect demo to show how a standalone application would interact with MSFS.
21+
22+
---
23+
24+
## Log
25+
SimConnect demo printing data from MSFS in a standalone application.
26+
27+
---
28+
29+
## Other Projects / Aircraft
30+
If you want to see msfs-rs fully integrated in working aircraft
31+
* [FlyByWire A32X and A380](https://github.com/flybywiresim/aircraft)

img/proof.png

1.15 MB
Loading

0 commit comments

Comments
 (0)