Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.1.18] - 2025-12-29

### Added

- Subscribe to simulator system events via `SimConnectClient.SubscribeToEventAsync` and handle notifications through `SystemEventReceived`, enabling callbacks for SimConnect system events like `4sec` and pause state changes.
- Typed system event dispatch and events: `FrameEventReceived`, `FilenameEventReceived`, `ObjectAddRemoveEventReceived`, and `SystemEventEx1Received` now surface frame-rate, filename, object add/remove, and EX1 payloads instead of dropping them.
- Helpers to control and clean up subscriptions: `SetSystemEventStateAsync` and `UnsubscribeFromEventAsync` wrap the native APIs for toggling and stopping system event notifications.
- Test runner now includes a system-event subscription test and a state toggle test to exercise the full subscribe/on/off/unsubscribe flow.
- Bundled `SimConnect.dll` updated to the latest SDK build to align with current simulator versions.

### Performance

- Message processing loop no longer spins up a worker task per dispatch; `SimConnect_GetNextDispatch` is polled synchronously to reduce context switches and lower idle CPU.
- SimVar setters use pooled pinned buffers instead of per-call unmanaged allocations and extra `Task.Run` hops, and request timeouts now rely on linked cancellation sources instead of `Task.Delay`, cutting allocations on hot paths.

## [0.1.17] - 2025-11-14

### Added
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>0.1.17</Version>
<Version>0.1.18</Version>
<Authors>BARS</Authors>
<Company>BARS</Company>
<Product>SimConnect.NET</Product>
Expand Down
50 changes: 50 additions & 0 deletions src/SimConnect.NET/Events/SimSystemEventEx1ReceivedEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// <copyright file="SimSystemEventEx1ReceivedEventArgs.cs" company="BARS">
// Copyright (c) BARS. All rights reserved.
// </copyright>

using System;

namespace SimConnect.NET.Events
{
/// <summary>
/// Provides data for extended EX1 system events that carry multiple data parameters.
/// </summary>
/// <param name="eventId">The identifier of the event.</param>
/// <param name="data0">First data parameter.</param>
/// <param name="data1">Second data parameter.</param>
/// <param name="data2">Third data parameter.</param>
/// <param name="data3">Fourth data parameter.</param>
/// <param name="data4">Fifth data parameter.</param>
public class SimSystemEventEx1ReceivedEventArgs(uint eventId, uint data0, uint data1, uint data2, uint data3, uint data4) : EventArgs
{
/// <summary>
/// Gets the event identifier.
/// </summary>
public uint EventId { get; } = eventId;

/// <summary>
/// Gets the first data parameter.
/// </summary>
public uint Data0 { get; } = data0;

/// <summary>
/// Gets the second data parameter.
/// </summary>
public uint Data1 { get; } = data1;

/// <summary>
/// Gets the third data parameter.
/// </summary>
public uint Data2 { get; } = data2;

/// <summary>
/// Gets the fourth data parameter.
/// </summary>
public uint Data3 { get; } = data3;

/// <summary>
/// Gets the fifth data parameter.
/// </summary>
public uint Data4 { get; } = data4;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// <copyright file="SimSystemEventFilenameReceivedEventArgs.cs" company="BARS">
// Copyright (c) BARS. All rights reserved.
// </copyright>

using System;

namespace SimConnect.NET.Events
{
/// <summary>
/// Provides data for filename-based system events such as flight load/save notifications.
/// </summary>
/// <param name="fileName">The filename reported by the simulator.</param>
/// <param name="flags">Optional flags returned by the simulator.</param>
public class SimSystemEventFilenameReceivedEventArgs(string fileName, uint flags) : EventArgs
{
/// <summary>
/// Gets the filename reported by the simulator.
/// </summary>
public string FileName { get; } = fileName;

/// <summary>
/// Gets the flags returned alongside the filename.
/// </summary>
public uint Flags { get; } = flags;
}
}
26 changes: 26 additions & 0 deletions src/SimConnect.NET/Events/SimSystemEventFrameEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// <copyright file="SimSystemEventFrameEventArgs.cs" company="BARS">
// Copyright (c) BARS. All rights reserved.
// </copyright>

using System;

namespace SimConnect.NET.Events
{
/// <summary>
/// Provides data for a frame-based system event that includes frame rate and simulation speed.
/// </summary>
/// <param name="frameRate">The reported frame rate in frames per second.</param>
/// <param name="simulationSpeed">The reported simulation speed multiplier.</param>
public class SimSystemEventFrameEventArgs(float frameRate, float simulationSpeed) : EventArgs
{
/// <summary>
/// Gets the reported frame rate in frames per second.
/// </summary>
public float FrameRate { get; } = frameRate;

/// <summary>
/// Gets the reported simulation speed multiplier.
/// </summary>
public float SimulationSpeed { get; } = simulationSpeed;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// <copyright file="SimSystemEventObjectAddRemoveEventArgs.cs" company="BARS">
// Copyright (c) BARS. All rights reserved.
// </copyright>

using System;
using SimConnect.NET;

namespace SimConnect.NET.Events
{
/// <summary>
/// Provides data for system events that report AI object creation or removal.
/// </summary>
/// <param name="objectType">The type of the object that was added or removed.</param>
public class SimSystemEventObjectAddRemoveEventArgs(SimConnectSimObjectType objectType) : EventArgs
{
/// <summary>
/// Gets the type of the object that was added or removed.
/// </summary>
public SimConnectSimObjectType ObjectType { get; } = objectType;
}
}
28 changes: 28 additions & 0 deletions src/SimConnect.NET/Events/SimSystemEventReceivedEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// <copyright file="SimSystemEventReceivedEventArgs.cs" company="BARS">
// Copyright (c) BARS. All rights reserved.
// </copyright>

namespace SimConnect.NET.Events
{
/// <summary>
/// Provides data for an event that is raised when a Simconnect system event is raised.
/// </summary>
/// <remarks>
/// Initializes a new instance of the <see cref="SimSystemEventReceivedEventArgs"/> class with the specified event identifier and
/// associated data.
/// </remarks>
/// <param name="eventId">The unique identifier for the system event.</param>
/// <param name="data">The data associated with the system event.</param>
public class SimSystemEventReceivedEventArgs(uint eventId, uint data) : EventArgs
{
/// <summary>
/// Gets the unique identifier for the event.
/// </summary>
public uint EventId { get; } = eventId;

/// <summary>
/// Gets the data associated with the event.
/// </summary>
public uint Data { get; } = data;
}
}
Loading
Loading