Fix the docs.rs build and improve the documentation
This commit is contained in:
13
.github/workflows/publish.yml
vendored
13
.github/workflows/publish.yml
vendored
@@ -18,10 +18,17 @@ jobs:
|
|||||||
override: true
|
override: true
|
||||||
- name: Run build
|
- name: Run build
|
||||||
run: cargo build --release --verbose
|
run: cargo build --release --verbose
|
||||||
|
- name: Run cargo login
|
||||||
|
shell: pwsh
|
||||||
|
run: cargo login $Env:CRATES_IO_TOKEN
|
||||||
|
env:
|
||||||
|
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
|
||||||
- name: Run publish simconnect-sdk-derive
|
- name: Run publish simconnect-sdk-derive
|
||||||
run: cargo publish -p simconnect-sdk-derive --token ${{ secrets.CRATES_IO_TOKEN }}
|
shell: pwsh
|
||||||
|
run: cargo make simconnect-sdk-publish-derive
|
||||||
- name: Sleep for 30 seconds
|
- name: Sleep for 30 seconds
|
||||||
|
shell: pwsh
|
||||||
run: Start-Sleep -s 30
|
run: Start-Sleep -s 30
|
||||||
shell: powershell
|
|
||||||
- name: Run publish simconnect-sdk
|
- name: Run publish simconnect-sdk
|
||||||
run: cargo publish -p simconnect-sdk --token ${{ secrets.CRATES_IO_TOKEN }}
|
shell: pwsh
|
||||||
|
run: cargo make simconnect-sdk-publish
|
||||||
|
@@ -6,6 +6,14 @@ file. This change log follows the conventions of
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Docs.rs build should now pass.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- The docs and README files have been improved.
|
||||||
|
|
||||||
## [v0.1.0] - 2022-10-22
|
## [v0.1.0] - 2022-10-22
|
||||||
|
|
||||||
### Initial Release of simconnect-sdk
|
### Initial Release of simconnect-sdk
|
||||||
|
@@ -1,98 +1,6 @@
|
|||||||
# SimConnect SDK in Rust
|
# Features
|
||||||
|
|
||||||
[![Crates][crates_badge]][crates]
|
## General
|
||||||
[![Documentation][documentation_badge]][documentation]
|
|
||||||
[![CI][ci_badge]][ci]
|
|
||||||
[![license][license_badge]][license]
|
|
||||||
[![Crates.io][crates_downloads_badge]][crates]\
|
|
||||||
An opinionated SimConnect SDK that encapsulates the C API fully and optimizes for developer experience.
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```toml
|
|
||||||
[dependencies]
|
|
||||||
simconnect-sdk = { version = "0.1", features = ["derive"] }
|
|
||||||
```
|
|
||||||
|
|
||||||
```rust
|
|
||||||
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)]
|
|
||||||
struct AirplaneData {
|
|
||||||
#[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,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
||||||
let client = SimConnect::new("Receiving data example");
|
|
||||||
|
|
||||||
match client {
|
|
||||||
Ok(mut client) => {
|
|
||||||
let mut 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)) => {
|
|
||||||
if let Ok(airplane_data) = AirplaneData::try_from(&data) {
|
|
||||||
println!("{airplane_data:?}");
|
|
||||||
|
|
||||||
notifications_received += 1;
|
|
||||||
|
|
||||||
// After we have received 10 notifications, we unregister the struct
|
|
||||||
if 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(())
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
See [more examples][examples].
|
|
||||||
|
|
||||||
## Contributing
|
|
||||||
|
|
||||||
Contributions are welcome and encouraged! See [/CONTRIBUTING.md][contributing].
|
|
||||||
|
|
||||||
## Feature table
|
|
||||||
|
|
||||||
### General
|
|
||||||
|
|
||||||
| Feature | Status | Comment |
|
| Feature | Status | Comment |
|
||||||
| --------------------------------------- | ------- | ----------- |
|
| --------------------------------------- | ------- | ----------- |
|
||||||
@@ -108,7 +16,7 @@ Contributions are welcome and encouraged! See [/CONTRIBUTING.md][contributing].
|
|||||||
| SimConnect_UnsubscribeFromSystemEvent | | |
|
| SimConnect_UnsubscribeFromSystemEvent | | |
|
||||||
| SimConnect_SetNotificationGroupPriority | - | Coming soon |
|
| SimConnect_SetNotificationGroupPriority | - | Coming soon |
|
||||||
|
|
||||||
### Events And Data
|
## Events And Data
|
||||||
|
|
||||||
| Feature | Status | Comment |
|
| Feature | Status | Comment |
|
||||||
| -------------------------------------------- | ------- | ----------------------------------- |
|
| -------------------------------------------- | ------- | ----------------------------------- |
|
||||||
@@ -136,7 +44,7 @@ Contributions are welcome and encouraged! See [/CONTRIBUTING.md][contributing].
|
|||||||
| SimConnect_SetInputGroupState | | |
|
| SimConnect_SetInputGroupState | | |
|
||||||
| SimConnect_RemoveInputEvent | | |
|
| SimConnect_RemoveInputEvent | | |
|
||||||
|
|
||||||
### AI Objects
|
## AI Objects
|
||||||
|
|
||||||
| Feature | Status | Comment |
|
| Feature | Status | Comment |
|
||||||
| ------------------------------------- | ------ | ------- |
|
| ------------------------------------- | ------ | ------- |
|
||||||
@@ -148,7 +56,7 @@ Contributions are welcome and encouraged! See [/CONTRIBUTING.md][contributing].
|
|||||||
| SimConnect_AIRemoveObject | | |
|
| SimConnect_AIRemoveObject | | |
|
||||||
| SimConnect_AISetAircraftFlightPlan | | |
|
| SimConnect_AISetAircraftFlightPlan | | |
|
||||||
|
|
||||||
### Flights
|
## Flights
|
||||||
|
|
||||||
| Feature | Status | Comment |
|
| Feature | Status | Comment |
|
||||||
| ------------------------- | ------ | ------- |
|
| ------------------------- | ------ | ------- |
|
||||||
@@ -156,7 +64,7 @@ Contributions are welcome and encouraged! See [/CONTRIBUTING.md][contributing].
|
|||||||
| SimConnect_FlightSave | | |
|
| SimConnect_FlightSave | | |
|
||||||
| SimConnect_FlightPlanLoad | | |
|
| SimConnect_FlightPlanLoad | | |
|
||||||
|
|
||||||
### Debug
|
## Debug
|
||||||
|
|
||||||
| Feature | Status | Comment |
|
| Feature | Status | Comment |
|
||||||
| ------------------------------- | ------ | ------- |
|
| ------------------------------- | ------ | ------- |
|
||||||
@@ -165,7 +73,7 @@ Contributions are welcome and encouraged! See [/CONTRIBUTING.md][contributing].
|
|||||||
| SimConnect_InsertString | | |
|
| SimConnect_InsertString | | |
|
||||||
| SimConnect_RetrieveString | | |
|
| SimConnect_RetrieveString | | |
|
||||||
|
|
||||||
### Facilities
|
## Facilities
|
||||||
|
|
||||||
| Feature | Status | Comment |
|
| Feature | Status | Comment |
|
||||||
| -------------------------------------- | ------- | ------- |
|
| -------------------------------------- | ------- | ------- |
|
||||||
@@ -178,26 +86,9 @@ Contributions are welcome and encouraged! See [/CONTRIBUTING.md][contributing].
|
|||||||
| SimConnect_UnsubscribeToFacilities | ✓ | |
|
| SimConnect_UnsubscribeToFacilities | ✓ | |
|
||||||
| SimConnect_UnsubscribeToFacilities_EX1 | | |
|
| SimConnect_UnsubscribeToFacilities_EX1 | | |
|
||||||
|
|
||||||
### Missions
|
## Missions
|
||||||
|
|
||||||
| Feature | Status | Comment |
|
| Feature | Status | Comment |
|
||||||
| -------------------------------------- | ------ | ------- |
|
| -------------------------------------- | ------ | ------- |
|
||||||
| SimConnect_CompleteCustomMissionAction | | |
|
| SimConnect_CompleteCustomMissionAction | | |
|
||||||
| SimConnect_ExecuteMissionAction | | |
|
| SimConnect_ExecuteMissionAction | | |
|
||||||
|
|
||||||
## Credits
|
|
||||||
|
|
||||||
Inspired by [Sequal32/simconnect-rust][inspired_by].
|
|
||||||
|
|
||||||
[crates_badge]: https://img.shields.io/crates/v/simconnect-sdk.svg
|
|
||||||
[crates]: https://crates.io/crates/simconnect-sdk
|
|
||||||
[documentation_badge]: https://docs.rs/simconnect-sdk/badge.svg
|
|
||||||
[documentation]: https://docs.rs/simconnect-sdk
|
|
||||||
[ci_badge]: https://github.com/mihai-dinculescu/simconnect-sdk/workflows/CI/badge.svg?branch=main
|
|
||||||
[ci]: https://github.com/mihai-dinculescu/simconnect-sdk/actions
|
|
||||||
[license_badge]: https://img.shields.io/crates/l/simconnect-sdk.svg
|
|
||||||
[license]: https://github.com/mihai-dinculescu/simconnect-sdk/blob/main/LICENSE
|
|
||||||
[crates_downloads_badge]: https://img.shields.io/crates/d/simconnect-sdk?label=downloads
|
|
||||||
[examples]: https://github.com/mihai-dinculescu/simconnect-sdk/tree/main/examples
|
|
||||||
[contributing]: https://github.com/mihai-dinculescu/simconnect-sdk/blob/main/CONTRIBUTING.md
|
|
||||||
[inspired_by]: https://github.com/Sequal32/simconnect-rust
|
|
19
Makefile.toml
Normal file
19
Makefile.toml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
[tasks.simconnect-sdk-publish-derive]
|
||||||
|
workspace = false
|
||||||
|
script = [
|
||||||
|
'''
|
||||||
|
copy LICENSE simconnect-sdk-derive\LICENSE
|
||||||
|
copy README.md simconnect-sdk-derive\README.md
|
||||||
|
cargo publish -p simconnect-sdk-derive --allow-dirty
|
||||||
|
'''
|
||||||
|
]
|
||||||
|
|
||||||
|
[tasks.simconnect-sdk-publish]
|
||||||
|
workspace = false
|
||||||
|
script = [
|
||||||
|
'''
|
||||||
|
copy LICENSE simconnect-sdk\LICENSE
|
||||||
|
copy README.md simconnect-sdk\README.md
|
||||||
|
cargo publish -p simconnect-sdk --allow-dirty
|
||||||
|
'''
|
||||||
|
]
|
102
README.md
102
README.md
@@ -1,11 +1,11 @@
|
|||||||
# SimConnect SDK in Rust
|
# SimConnect SDK
|
||||||
|
|
||||||
[![Crates][crates_badge]][crates]
|
[![Crates][crates_badge]][crates]
|
||||||
[![Documentation][documentation_badge]][documentation]
|
[![Documentation][documentation_badge]][documentation]
|
||||||
[![CI][ci_badge]][ci]
|
[![CI][ci_badge]][ci]
|
||||||
[![license][license_badge]][license]
|
[![license][license_badge]][license]
|
||||||
[![Crates.io][crates_downloads_badge]][crates]\
|
[![Crates.io][crates_downloads_badge]][crates]\
|
||||||
An opinionated SimConnect SDK that encapsulates the C API fully and optimizes for developer experience.
|
An opinionated SimConnect Client that encapsulates the C API fully and optimizes for developer experience.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@@ -88,102 +88,11 @@ See [more examples][examples].
|
|||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
Contributions are welcome and encouraged! See [/CONTRIBUTING.md][contributing].
|
Contributions are welcome and encouraged! See [CONTRIBUTING.md][contributing].
|
||||||
|
|
||||||
## Feature table
|
## Supported Features
|
||||||
|
|
||||||
### General
|
See [FEATURES.md][features].
|
||||||
|
|
||||||
| Feature | Status | Comment |
|
|
||||||
| --------------------------------------- | ------- | ----------- |
|
|
||||||
| DispatchProc | | |
|
|
||||||
| SimConnect_Open | ✓ | |
|
|
||||||
| SimConnect_Close | ✓ | |
|
|
||||||
| SimConnect_CallDispatch | | |
|
|
||||||
| SimConnect_GetNextDispatch | ✓ | |
|
|
||||||
| SimConnect_RequestSystemState | | |
|
|
||||||
| SimConnect_MapClientEventToSimEvent | - | Coming soon |
|
|
||||||
| SimConnect_SubscribeToSystemEvent | | |
|
|
||||||
| SimConnect_SetSystemEventState | | |
|
|
||||||
| SimConnect_UnsubscribeFromSystemEvent | | |
|
|
||||||
| SimConnect_SetNotificationGroupPriority | - | Coming soon |
|
|
||||||
|
|
||||||
### Events And Data
|
|
||||||
|
|
||||||
| Feature | Status | Comment |
|
|
||||||
| -------------------------------------------- | ------- | ----------------------------------- |
|
|
||||||
| SimConnect_RequestDataOnSimObject | ✓ | Only for SIMCONNECT_OBJECT_ID_USER |
|
|
||||||
| SimConnect_RequestDataOnSimObjectType | - | Coming soon |
|
|
||||||
| SimConnect_AddClientEventToNotificationGroup | - | Coming soon |
|
|
||||||
| SimConnect_RemoveClientEvent | | |
|
|
||||||
| SimConnect_TransmitClientEvent | | |
|
|
||||||
| SimConnect_TransmitClientEvent_EX1 | | |
|
|
||||||
| SimConnect_MapClientDataNameToID | | |
|
|
||||||
| SimConnect_RequestClientData | | |
|
|
||||||
| SimConnect_CreateClientData | | |
|
|
||||||
| SimConnect_AddToClientDataDefinition | | |
|
|
||||||
| SimConnect_AddToDataDefinition | ✓ | Supports `f64`, `bool` and `String` |
|
|
||||||
| SimConnect_SetClientData | | |
|
|
||||||
| SimConnect_SetDataOnSimObject | | |
|
|
||||||
| SimConnect_ClearClientDataDefinition | | |
|
|
||||||
| SimConnect_ClearDataDefinition | ✓ | |
|
|
||||||
| SimConnect_MapInputEventToClientEvent | | |
|
|
||||||
| SimConnect_RequestNotificationGroup | | |
|
|
||||||
| SimConnect_ClearInputGroup | | |
|
|
||||||
| SimConnect_ClearNotificationGroup | | |
|
|
||||||
| SimConnect_RequestReservedKey | | |
|
|
||||||
| SimConnect_SetInputGroupPriority | | |
|
|
||||||
| SimConnect_SetInputGroupState | | |
|
|
||||||
| SimConnect_RemoveInputEvent | | |
|
|
||||||
|
|
||||||
### AI Objects
|
|
||||||
|
|
||||||
| Feature | Status | Comment |
|
|
||||||
| ------------------------------------- | ------ | ------- |
|
|
||||||
| SimConnect_AICreateEnrouteATCAircraft | | |
|
|
||||||
| SimConnect_AICreateNonATCAircraft | | |
|
|
||||||
| SimConnect_AICreateParkedATCAircraft | | |
|
|
||||||
| SimConnect_AICreateSimulatedObject | | |
|
|
||||||
| SimConnect_AIReleaseControl | | |
|
|
||||||
| SimConnect_AIRemoveObject | | |
|
|
||||||
| SimConnect_AISetAircraftFlightPlan | | |
|
|
||||||
|
|
||||||
### Flights
|
|
||||||
|
|
||||||
| Feature | Status | Comment |
|
|
||||||
| ------------------------- | ------ | ------- |
|
|
||||||
| SimConnect_FlightLoad | | |
|
|
||||||
| SimConnect_FlightSave | | |
|
|
||||||
| SimConnect_FlightPlanLoad | | |
|
|
||||||
|
|
||||||
### Debug
|
|
||||||
|
|
||||||
| Feature | Status | Comment |
|
|
||||||
| ------------------------------- | ------ | ------- |
|
|
||||||
| SimConnect_GetLastSentPacketID | | |
|
|
||||||
| SimConnect_RequestResponseTimes | | |
|
|
||||||
| SimConnect_InsertString | | |
|
|
||||||
| SimConnect_RetrieveString | | |
|
|
||||||
|
|
||||||
### Facilities
|
|
||||||
|
|
||||||
| Feature | Status | Comment |
|
|
||||||
| -------------------------------------- | ------- | ------- |
|
|
||||||
| SimConnect_AddToFacilityDefinition | | |
|
|
||||||
| SimConnect_RequestFacilitesList | ✓ | |
|
|
||||||
| SimConnect_RequestFacilitiesList_EX1 | | |
|
|
||||||
| SimConnect_RequestFacilityData | | |
|
|
||||||
| SimConnect_SubscribeToFacilities | ✓ | |
|
|
||||||
| SimConnect_SubscribeToFacilities_EX1 | | |
|
|
||||||
| SimConnect_UnsubscribeToFacilities | ✓ | |
|
|
||||||
| SimConnect_UnsubscribeToFacilities_EX1 | | |
|
|
||||||
|
|
||||||
### Missions
|
|
||||||
|
|
||||||
| Feature | Status | Comment |
|
|
||||||
| -------------------------------------- | ------ | ------- |
|
|
||||||
| SimConnect_CompleteCustomMissionAction | | |
|
|
||||||
| SimConnect_ExecuteMissionAction | | |
|
|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
|
|
||||||
@@ -200,4 +109,5 @@ Inspired by [Sequal32/simconnect-rust][inspired_by].
|
|||||||
[crates_downloads_badge]: https://img.shields.io/crates/d/simconnect-sdk?label=downloads
|
[crates_downloads_badge]: https://img.shields.io/crates/d/simconnect-sdk?label=downloads
|
||||||
[examples]: https://github.com/mihai-dinculescu/simconnect-sdk/tree/main/examples
|
[examples]: https://github.com/mihai-dinculescu/simconnect-sdk/tree/main/examples
|
||||||
[contributing]: https://github.com/mihai-dinculescu/simconnect-sdk/blob/main/CONTRIBUTING.md
|
[contributing]: https://github.com/mihai-dinculescu/simconnect-sdk/blob/main/CONTRIBUTING.md
|
||||||
|
[features]: https://github.com/mihai-dinculescu/simconnect-sdk/blob/main/FEATURES.md
|
||||||
[inspired_by]: https://github.com/Sequal32/simconnect-rust
|
[inspired_by]: https://github.com/Sequal32/simconnect-rust
|
||||||
|
@@ -4,7 +4,7 @@ version = "0.1.0"
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Mihai Dinculescu <mihai.dinculescu@outlook.com>"]
|
authors = ["Mihai Dinculescu <mihai.dinculescu@outlook.com>"]
|
||||||
description = "Macros implementation for SimConnect SDK"
|
description = "Macros implementation for SimConnect SDK. An opinionated SimConnect Client that encapsulates the C API fully and optimizes for developer experience."
|
||||||
keywords = ["simconnect", "MSFS-2020", "simulation", "aerospace"]
|
keywords = ["simconnect", "MSFS-2020", "simulation", "aerospace"]
|
||||||
categories = ["aerospace", "simulation", "aerospace::simulation", "games"]
|
categories = ["aerospace", "simulation", "aerospace::simulation", "games"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
@@ -28,3 +28,6 @@ once_cell = "1.7"
|
|||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
simconnect-sdk = { path = "../simconnect-sdk" }
|
simconnect-sdk = { path = "../simconnect-sdk" }
|
||||||
trybuild = { version = "1.0", features = ["diff"] }
|
trybuild = { version = "1.0", features = ["diff"] }
|
||||||
|
|
||||||
|
[package.metadata.docs.rs]
|
||||||
|
targets = ["x86_64-pc-windows-msvc"]
|
||||||
|
@@ -1,21 +0,0 @@
|
|||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2022 Mihai Dinculescu
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
@@ -1,3 +1,5 @@
|
|||||||
|
//! This crate provides the [`crate::SimConnectObject`] derive macro of simconnect-sdk.
|
||||||
|
|
||||||
extern crate proc_macro;
|
extern crate proc_macro;
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
@@ -4,7 +4,7 @@ version = "0.1.0"
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Mihai Dinculescu <mihai.dinculescu@outlook.com>"]
|
authors = ["Mihai Dinculescu <mihai.dinculescu@outlook.com>"]
|
||||||
description = "SimConnect SDK"
|
description = "SimConnect SDK. An opinionated SimConnect Client that encapsulates the C API fully and optimizes for developer experience."
|
||||||
keywords = ["simconnect", "MSFS-2020", "simulation", "aerospace"]
|
keywords = ["simconnect", "MSFS-2020", "simulation", "aerospace"]
|
||||||
categories = ["aerospace", "simulation", "aerospace::simulation", "games"]
|
categories = ["aerospace", "simulation", "aerospace::simulation", "games"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
@@ -24,9 +24,7 @@ tracing = "0.1"
|
|||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
simconnect-sdk-derive = { version = "=0.1.0", path = "../simconnect-sdk-derive", optional = true }
|
simconnect-sdk-derive = { version = "=0.1.0", path = "../simconnect-sdk-derive", optional = true }
|
||||||
|
|
||||||
# docs.rs-specific configuration
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
# document all features
|
|
||||||
all-features = true
|
all-features = true
|
||||||
# defines the configuration attribute `docsrs`
|
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
targets = ["x86_64-pc-windows-msvc"]
|
||||||
|
@@ -1,21 +0,0 @@
|
|||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2022 Mihai Dinculescu
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
@@ -1,203 +0,0 @@
|
|||||||
# SimConnect SDK in Rust
|
|
||||||
|
|
||||||
[![Crates][crates_badge]][crates]
|
|
||||||
[![Documentation][documentation_badge]][documentation]
|
|
||||||
[![CI][ci_badge]][ci]
|
|
||||||
[![license][license_badge]][license]
|
|
||||||
[![Crates.io][crates_downloads_badge]][crates]\
|
|
||||||
An opinionated SimConnect SDK that encapsulates the C API fully and optimizes for developer experience.
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```toml
|
|
||||||
[dependencies]
|
|
||||||
simconnect-sdk = { version = "0.1", features = ["derive"] }
|
|
||||||
```
|
|
||||||
|
|
||||||
```rust
|
|
||||||
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)]
|
|
||||||
struct AirplaneData {
|
|
||||||
#[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,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
||||||
let client = SimConnect::new("Receiving data example");
|
|
||||||
|
|
||||||
match client {
|
|
||||||
Ok(mut client) => {
|
|
||||||
let mut 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)) => {
|
|
||||||
if let Ok(airplane_data) = AirplaneData::try_from(&data) {
|
|
||||||
println!("{airplane_data:?}");
|
|
||||||
|
|
||||||
notifications_received += 1;
|
|
||||||
|
|
||||||
// After we have received 10 notifications, we unregister the struct
|
|
||||||
if 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(())
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
See [more examples][examples].
|
|
||||||
|
|
||||||
## Contributing
|
|
||||||
|
|
||||||
Contributions are welcome and encouraged! See [/CONTRIBUTING.md][contributing].
|
|
||||||
|
|
||||||
## Feature table
|
|
||||||
|
|
||||||
### General
|
|
||||||
|
|
||||||
| Feature | Status | Comment |
|
|
||||||
| --------------------------------------- | ------- | ----------- |
|
|
||||||
| DispatchProc | | |
|
|
||||||
| SimConnect_Open | ✓ | |
|
|
||||||
| SimConnect_Close | ✓ | |
|
|
||||||
| SimConnect_CallDispatch | | |
|
|
||||||
| SimConnect_GetNextDispatch | ✓ | |
|
|
||||||
| SimConnect_RequestSystemState | | |
|
|
||||||
| SimConnect_MapClientEventToSimEvent | - | Coming soon |
|
|
||||||
| SimConnect_SubscribeToSystemEvent | | |
|
|
||||||
| SimConnect_SetSystemEventState | | |
|
|
||||||
| SimConnect_UnsubscribeFromSystemEvent | | |
|
|
||||||
| SimConnect_SetNotificationGroupPriority | - | Coming soon |
|
|
||||||
|
|
||||||
### Events And Data
|
|
||||||
|
|
||||||
| Feature | Status | Comment |
|
|
||||||
| -------------------------------------------- | ------- | ----------------------------------- |
|
|
||||||
| SimConnect_RequestDataOnSimObject | ✓ | Only for SIMCONNECT_OBJECT_ID_USER |
|
|
||||||
| SimConnect_RequestDataOnSimObjectType | - | Coming soon |
|
|
||||||
| SimConnect_AddClientEventToNotificationGroup | - | Coming soon |
|
|
||||||
| SimConnect_RemoveClientEvent | | |
|
|
||||||
| SimConnect_TransmitClientEvent | | |
|
|
||||||
| SimConnect_TransmitClientEvent_EX1 | | |
|
|
||||||
| SimConnect_MapClientDataNameToID | | |
|
|
||||||
| SimConnect_RequestClientData | | |
|
|
||||||
| SimConnect_CreateClientData | | |
|
|
||||||
| SimConnect_AddToClientDataDefinition | | |
|
|
||||||
| SimConnect_AddToDataDefinition | ✓ | Supports `f64`, `bool` and `String` |
|
|
||||||
| SimConnect_SetClientData | | |
|
|
||||||
| SimConnect_SetDataOnSimObject | | |
|
|
||||||
| SimConnect_ClearClientDataDefinition | | |
|
|
||||||
| SimConnect_ClearDataDefinition | ✓ | |
|
|
||||||
| SimConnect_MapInputEventToClientEvent | | |
|
|
||||||
| SimConnect_RequestNotificationGroup | | |
|
|
||||||
| SimConnect_ClearInputGroup | | |
|
|
||||||
| SimConnect_ClearNotificationGroup | | |
|
|
||||||
| SimConnect_RequestReservedKey | | |
|
|
||||||
| SimConnect_SetInputGroupPriority | | |
|
|
||||||
| SimConnect_SetInputGroupState | | |
|
|
||||||
| SimConnect_RemoveInputEvent | | |
|
|
||||||
|
|
||||||
### AI Objects
|
|
||||||
|
|
||||||
| Feature | Status | Comment |
|
|
||||||
| ------------------------------------- | ------ | ------- |
|
|
||||||
| SimConnect_AICreateEnrouteATCAircraft | | |
|
|
||||||
| SimConnect_AICreateNonATCAircraft | | |
|
|
||||||
| SimConnect_AICreateParkedATCAircraft | | |
|
|
||||||
| SimConnect_AICreateSimulatedObject | | |
|
|
||||||
| SimConnect_AIReleaseControl | | |
|
|
||||||
| SimConnect_AIRemoveObject | | |
|
|
||||||
| SimConnect_AISetAircraftFlightPlan | | |
|
|
||||||
|
|
||||||
### Flights
|
|
||||||
|
|
||||||
| Feature | Status | Comment |
|
|
||||||
| ------------------------- | ------ | ------- |
|
|
||||||
| SimConnect_FlightLoad | | |
|
|
||||||
| SimConnect_FlightSave | | |
|
|
||||||
| SimConnect_FlightPlanLoad | | |
|
|
||||||
|
|
||||||
### Debug
|
|
||||||
|
|
||||||
| Feature | Status | Comment |
|
|
||||||
| ------------------------------- | ------ | ------- |
|
|
||||||
| SimConnect_GetLastSentPacketID | | |
|
|
||||||
| SimConnect_RequestResponseTimes | | |
|
|
||||||
| SimConnect_InsertString | | |
|
|
||||||
| SimConnect_RetrieveString | | |
|
|
||||||
|
|
||||||
### Facilities
|
|
||||||
|
|
||||||
| Feature | Status | Comment |
|
|
||||||
| -------------------------------------- | ------- | ------- |
|
|
||||||
| SimConnect_AddToFacilityDefinition | | |
|
|
||||||
| SimConnect_RequestFacilitesList | ✓ | |
|
|
||||||
| SimConnect_RequestFacilitiesList_EX1 | | |
|
|
||||||
| SimConnect_RequestFacilityData | | |
|
|
||||||
| SimConnect_SubscribeToFacilities | ✓ | |
|
|
||||||
| SimConnect_SubscribeToFacilities_EX1 | | |
|
|
||||||
| SimConnect_UnsubscribeToFacilities | ✓ | |
|
|
||||||
| SimConnect_UnsubscribeToFacilities_EX1 | | |
|
|
||||||
|
|
||||||
### Missions
|
|
||||||
|
|
||||||
| Feature | Status | Comment |
|
|
||||||
| -------------------------------------- | ------ | ------- |
|
|
||||||
| SimConnect_CompleteCustomMissionAction | | |
|
|
||||||
| SimConnect_ExecuteMissionAction | | |
|
|
||||||
|
|
||||||
## Credits
|
|
||||||
|
|
||||||
Inspired by [Sequal32/simconnect-rust][inspired_by].
|
|
||||||
|
|
||||||
[crates_badge]: https://img.shields.io/crates/v/simconnect-sdk.svg
|
|
||||||
[crates]: https://crates.io/crates/simconnect-sdk
|
|
||||||
[documentation_badge]: https://docs.rs/simconnect-sdk/badge.svg
|
|
||||||
[documentation]: https://docs.rs/simconnect-sdk
|
|
||||||
[ci_badge]: https://github.com/mihai-dinculescu/simconnect-sdk/workflows/CI/badge.svg?branch=main
|
|
||||||
[ci]: https://github.com/mihai-dinculescu/simconnect-sdk/actions
|
|
||||||
[license_badge]: https://img.shields.io/crates/l/simconnect-sdk.svg
|
|
||||||
[license]: https://github.com/mihai-dinculescu/simconnect-sdk/blob/main/LICENSE
|
|
||||||
[crates_downloads_badge]: https://img.shields.io/crates/d/simconnect-sdk?label=downloads
|
|
||||||
[examples]: https://github.com/mihai-dinculescu/simconnect-sdk/tree/main/examples
|
|
||||||
[contributing]: https://github.com/mihai-dinculescu/simconnect-sdk/blob/main/CONTRIBUTING.md
|
|
||||||
[inspired_by]: https://github.com/Sequal32/simconnect-rust
|
|
Reference in New Issue
Block a user