\
An opinionated SimConnect SDK that encapsulates the C API fully and optimizes for developer experience.
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.
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")] simonground: bool, }
fn main() -> Result<(), Box
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.
Contributions are welcome and encouraged! See /CONTRIBUTING.md.
| Feature | Status | Comment | | --------------------------------------- | ------- | ----------- | | DispatchProc | | | | SimConnectOpen | ✓ | | | SimConnectClose | ✓ | | | SimConnectCallDispatch | | | | SimConnectGetNextDispatch | ✓ | | | SimConnectRequestSystemState | | | | SimConnectMapClientEventToSimEvent | - | Coming soon | | SimConnectSubscribeToSystemEvent | | | | SimConnectSetSystemEventState | | | | SimConnectUnsubscribeFromSystemEvent | | | | SimConnectSetNotificationGroupPriority | - | Coming soon |
| Feature | Status | Comment |
| -------------------------------------------- | ------- | ----------------------------------- |
| SimConnectRequestDataOnSimObject | ✓ | Only for SIMCONNECTOBJECTIDUSER |
| SimConnectRequestDataOnSimObjectType | - | Coming soon |
| SimConnectAddClientEventToNotificationGroup | - | Coming soon |
| SimConnectRemoveClientEvent | | |
| SimConnectTransmitClientEvent | | |
| SimConnectTransmitClientEventEX1 | | |
| SimConnectMapClientDataNameToID | | |
| SimConnectRequestClientData | | |
| SimConnectCreateClientData | | |
| SimConnectAddToClientDataDefinition | | |
| SimConnectAddToDataDefinition | ✓ | Supports f64
, bool
and String
|
| SimConnectSetClientData | | |
| SimConnectSetDataOnSimObject | | |
| SimConnectClearClientDataDefinition | | |
| SimConnectClearDataDefinition | ✓ | |
| SimConnectMapInputEventToClientEvent | | |
| SimConnectRequestNotificationGroup | | |
| SimConnectClearInputGroup | | |
| SimConnectClearNotificationGroup | | |
| SimConnectRequestReservedKey | | |
| SimConnectSetInputGroupPriority | | |
| SimConnectSetInputGroupState | | |
| SimConnect_RemoveInputEvent | | |
| Feature | Status | Comment | | ------------------------------------- | ------ | ------- | | SimConnectAICreateEnrouteATCAircraft | | | | SimConnectAICreateNonATCAircraft | | | | SimConnectAICreateParkedATCAircraft | | | | SimConnectAICreateSimulatedObject | | | | SimConnectAIReleaseControl | | | | SimConnectAIRemoveObject | | | | SimConnect_AISetAircraftFlightPlan | | |
| Feature | Status | Comment | | ------------------------- | ------ | ------- | | SimConnectFlightLoad | | | | SimConnectFlightSave | | | | SimConnect_FlightPlanLoad | | |
| Feature | Status | Comment | | ------------------------------- | ------ | ------- | | SimConnectGetLastSentPacketID | | | | SimConnectRequestResponseTimes | | | | SimConnectInsertString | | | | SimConnectRetrieveString | | |
| Feature | Status | Comment | | -------------------------------------- | ------- | ------- | | SimConnectAddToFacilityDefinition | | | | SimConnectRequestFacilitesList | ✓ | | | SimConnectRequestFacilitiesListEX1 | | | | SimConnectRequestFacilityData | | | | SimConnectSubscribeToFacilities | ✓ | | | SimConnectSubscribeToFacilitiesEX1 | | | | SimConnectUnsubscribeToFacilities | ✓ | | | SimConnectUnsubscribeToFacilities_EX1 | | |
| Feature | Status | Comment | | -------------------------------------- | ------ | ------- | | SimConnectCompleteCustomMissionAction | | | | SimConnectExecuteMissionAction | | |
Inspired by Sequal32/simconnect-rust.