Skip to content

Commit

Permalink
Upgraded to SDK 0.24.3.0 * Support for input events (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
TimianHeber authored Oct 14, 2024
1 parent 0898102 commit 32898a3
Show file tree
Hide file tree
Showing 26 changed files with 335 additions and 87 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A simple easy-to-use wrapper for the Flight Simulator 2020 SimConnect library. A
If, on the other hand, you just want to connect to Flight Simulator and read some information this may give you a quicker start.

FsConnect uses the _Microsoft.FlightSimulator.SimConnect_ .NET Framework library and the underlying native x64 _simconnect.dll_ library.
These files are distributed via the Flight Simulator 2020 SDK, currently version 0.10.0, but are included for easy use.
These files are distributed via the Flight Simulator 2020 SDK, currently version 0.24.3.0, but are included for easy use.

At the moment this project is intended as an easier to use wrapper than the current SimConnect for simple projects, creating a simpler C# programming model and reducing the need for repeated boiler plate code.

Expand All @@ -19,6 +19,8 @@ At the moment this project is intended as an easier to use wrapper than the curr
For more information about SimConnect and the Flight Simulator SDK see the [Microsoft Flight Simulator SDK site](
https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/SimConnect_SDK.htm) and the [SimConnect SDK section](https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/SimConnect_SDK.htm) in particular.

A useful tool for debugging SimConnect usage is the _SimConnect Inspector_ available from the Debug mode in Flight Simulator. See the [SDK documentation](https://docs.flightsimulator.com/html/Developer_Mode/Menus/Tools/SimConnect_Inspector.htm) for more information.

## Current features

* Supports connections from API, without direct use of SimConnect.cfg file
Expand Down Expand Up @@ -422,6 +424,12 @@ Supports:

## Change log

## 1.4.0

* Updated to SDK version 0.24.3.0.
* Support for registering input events.
* Updated to .NET Framework 4.6.1 to match SimConnect version.

## 1.3.3

* Added support for NAV frequencies, transponder and autopilot heading bug
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net472</TargetFramework>
<TargetFramework>net461</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand All @@ -19,7 +19,7 @@

<ItemGroup>
<Reference Include="Microsoft.FlightSimulator.SimConnect">
<HintPath>..\Dependencies\SimConnect\lib\net40\Microsoft.FlightSimulator.SimConnect.dll</HintPath>
<HintPath>..\Dependencies\SimConnect\lib\net461\Microsoft.FlightSimulator.SimConnect.dll</HintPath>
</Reference>
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net45</TargetFramework>
<TargetFramework>net461</TargetFramework>
</PropertyGroup>


Expand All @@ -13,9 +13,9 @@
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NUnit" Version="3.13.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="NUnit" />
<PackageReference Include="NUnit3TestAdapter" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
</ItemGroup>

<ItemGroup>
Expand Down
12 changes: 3 additions & 9 deletions src/CTrue.FsConnect.Managers/CTrue.FsConnect.Managers.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net45</TargetFramework>
<Company>C-True</Company>
<TargetFramework>net461</TargetFramework>
<Product>Flight Simulator Connect Managers</Product>
<Copyright />
<Description>
Expand All @@ -15,17 +14,12 @@
- Controlling transponder code
- Initial Autopilot manager
</Description>
<Authors>C-True</Authors>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<RepositoryUrl>https://github.com/c-true/FsConnect</RepositoryUrl>
<PackageTags>msfs flight-simulator simconnect</PackageTags>
<Version>1.3.3</Version>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageReleaseNotes>Added support for NAV frequencies, transponder and autopilot heading bug</PackageReleaseNotes>
<AssemblyVersion>1.3.3.0</AssemblyVersion>
<FileVersion>1.3.3.0</FileVersion>
<PackageReleaseNotes>Updated SDK version to 0.24.3.0</PackageReleaseNotes>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand All @@ -42,7 +36,7 @@

<ItemGroup>
<Reference Include="Microsoft.FlightSimulator.SimConnect">
<HintPath>..\Dependencies\SimConnect\lib\net40\Microsoft.FlightSimulator.SimConnect.dll</HintPath>
<HintPath>..\Dependencies\SimConnect\lib\net461\Microsoft.FlightSimulator.SimConnect.dll</HintPath>
</Reference>
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/CTrue.FsConnect.Managers/licenses/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2020-2021 C-True
Copyright 2020-2024 C-True

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:

Expand Down
10 changes: 5 additions & 5 deletions src/CTrue.FsConnect.Test/CTrue.FsConnect.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net45</TargetFramework>
<TargetFramework>net461</TargetFramework>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NUnit" Version="3.13.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="NUnit" />
<PackageReference Include="NUnit3TestAdapter" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
</ItemGroup>

<ItemGroup>
Expand All @@ -17,7 +17,7 @@

<ItemGroup>
<Reference Include="Microsoft.FlightSimulator.SimConnect">
<HintPath>..\Dependencies\SimConnect\lib\net40\Microsoft.FlightSimulator.SimConnect.dll</HintPath>
<HintPath>..\Dependencies\SimConnect\lib\net461\Microsoft.FlightSimulator.SimConnect.dll</HintPath>
</Reference>
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net472</TargetFramework>
<TargetFramework>net461</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand All @@ -14,9 +14,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.8.0" />
<PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="CommandLineParser" />
<PackageReference Include="Serilog" />
<PackageReference Include="Serilog.Sinks.Console" />
</ItemGroup>

<ItemGroup>
Expand All @@ -26,7 +26,7 @@

<ItemGroup>
<Reference Include="Microsoft.FlightSimulator.SimConnect">
<HintPath>..\Dependencies\SimConnect\lib\net40\Microsoft.FlightSimulator.SimConnect.dll</HintPath>
<HintPath>..\Dependencies\SimConnect\lib\net461\Microsoft.FlightSimulator.SimConnect.dll</HintPath>
</Reference>
</ItemGroup>

Expand Down
6 changes: 6 additions & 0 deletions src/CTrue.FsConnect.TestConsole/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,11 @@ public class Options

[Option('l', "loglevel", HelpText = "Specifies the log level.", Default = LogEventLevel.Warning)]
public LogEventLevel LogLevel { get; set; }

[Option('j', "joystick",
HelpText =
"Provide the joystick id, the index in list of joysticks, to handle joystick events. (Use Setup USB Game Controllers app)",
Required = false, Default = 0)]
public uint JoystickId { get; set; }
}
}
35 changes: 35 additions & 0 deletions src/CTrue.FsConnect.TestConsole/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ private static void Run(Options commandLineOptions)

Console.WriteLine("Initializing data definitions");
InitializeDataDefinitions(_fsConnect);
InitializeInputEvents(_fsConnect, commandLineOptions.JoystickId);

_fsConnect.SetText("Test Console connected", 2);

Expand Down Expand Up @@ -136,6 +137,21 @@ private static void InitializeDataDefinitions(FsConnect fsConnect)
fsConnect.RegisterDataDefinition<PlanePosition>(Definitions.PlanePosition);
}

private static void InitializeInputEvents(FsConnect fsConnect, uint joystickId)
{
// Use Set Up USB Game controller app in windows to determine order of USB joystick devices. Use the Properties view to determine button ids.
// Note that there may be a constraint in SimConnect for the number of buttons supported, all buttons in complex devices may not be mappable.
InputEventInfo iei = new InputEventInfo(EventIds.JOYSTICK_BUTTON1, GroupIds.JOYSTICK_EVENT_KEY_GROUP, GroupIds.INPUT_KEY_GROUP, GetjoystickButtonInputEventDefinition(joystickId, 0),
(_) => { Log.Information("Joystick button 1 clicked"); });

fsConnect.RegisterInputEvent(iei);

iei = new InputEventInfo(EventIds.JOYSTICK_BUTTON2, GroupIds.JOYSTICK_EVENT_KEY_GROUP, GroupIds.INPUT_KEY_GROUP, GetjoystickButtonInputEventDefinition(joystickId, 1),
(_) => { Log.Information("Joystick button 2 clicked"); });

fsConnect.RegisterInputEvent(iei);
}

static void DisplayHelp<T>(ParserResult<T> result, IEnumerable<Error> errs)
{
HelpText helpText;
Expand All @@ -154,5 +170,24 @@ static void DisplayHelp<T>(ParserResult<T> result, IEnumerable<Error> errs)
}
Console.WriteLine(helpText);
}

private static string GetjoystickButtonInputEventDefinition(uint joystickId, uint buttonId)
{
return $"joystick:{joystickId}:button:{buttonId}";
}
}

public enum GroupIds : uint
{
JOYSTICK_EVENT_KEY_GROUP = 200,
INPUT_KEY_GROUP = 201,
JOYSTICK_EVENT_KEY_GROUP2 = 203,
INPUT_KEY_GROUP2 = 204
}

public enum EventIds : uint
{
JOYSTICK_BUTTON1 = 300,
JOYSTICK_BUTTON2 = 301
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"FsConnectTestConsole": {
"commandName": "Project",
"commandLineArgs": "-h 192.168.1.174 -p 500 -l Debug"
"commandLineArgs": "-h 192.168.1.174 -p 500 -l Debug -j 0"
}
}
}
7 changes: 5 additions & 2 deletions src/CTrue.FsConnect.sln
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30011.22
# Visual Studio Version 17
VisualStudioVersion = 17.10.35004.147
MinimumVisualStudioVersion = 15.0.26124.0
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CTrue.FsConnect", "CTrue.FsConnect\CTrue.FsConnect.csproj", "{D507C538-CA5D-4162-93D2-C3C560F6648E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CTrue.FsConnect.TestConsole", "CTrue.FsConnect.TestConsole\CTrue.FsConnect.TestConsole.csproj", "{17BD0880-D516-472B-A615-92C8265CC8CC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{12C96830-77DE-4270-9FAF-56D356FA045C}"
ProjectSection(SolutionItems) = preProject
Directory.Build.props = Directory.Build.props
Directory.Build.targets = Directory.Build.targets
Directory.Packages.props = Directory.Packages.props
..\README.md = ..\README.md
EndProjectSection
EndProject
Expand Down
70 changes: 34 additions & 36 deletions src/CTrue.FsConnect/CTrue.FsConnect.csproj
Original file line number Diff line number Diff line change
@@ -1,44 +1,42 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net45</TargetFramework>
<Company>C-True</Company>
<Product>Flight Simulator Connect</Product>
<Copyright />
<Description>An easy to use wrapper for SimConnect, for connection to Flight Simulator 2020.
Contains SimConnect binaries, as distributed by the Flight Simulator 20202 SDK 0.10.0 release.</Description>
<Authors>C-True</Authors>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<RepositoryUrl>https://github.com/c-true/FsConnect</RepositoryUrl>
<PackageTags>msfs flight-simulator simconnect</PackageTags>
<Version>1.3.3</Version>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageReleaseNotes>Added and updated some method signatures. * Added event ids for setting COM and NAV frequencies.</PackageReleaseNotes>
<AssemblyVersion>1.3.3.0</AssemblyVersion>
<FileVersion>1.3.3.0</FileVersion>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<Product>Flight Simulator Connect</Product>
<Copyright />
<Description>
An easy to use wrapper for SimConnect, for connection to Flight Simulator 2020.
Contains SimConnect binaries, as distributed by the Flight Simulator 20202 SDK 0.10.0 release.
</Description>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageTags>msfs flight-simulator simconnect</PackageTags>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageReleaseNotes>Support for registering input events. * Updated SDK version to 0.24.3.0</PackageReleaseNotes>
</PropertyGroup>

<PropertyGroup>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<PropertyGroup>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>

<ItemGroup>
<Reference Include="Microsoft.FlightSimulator.SimConnect">
<HintPath>..\Dependencies\SimConnect\lib\net40\Microsoft.FlightSimulator.SimConnect.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.FlightSimulator.SimConnect">
<HintPath>..\Dependencies\SimConnect\lib\net461\Microsoft.FlightSimulator.SimConnect.dll</HintPath>
</Reference>
</ItemGroup>

<ItemGroup>
<None Include="..\Dependencies\SimConnect\build\simconnect.dll" Visible="false" Pack="true" PackagePath="build" />
<None Include="..\Dependencies\SimConnect\build\CTrue.FsConnect.targets" Visible="false" Pack="true" PackagePath="build" />
<None Include="..\Dependencies\SimConnect\lib\net40\Microsoft.FlightSimulator.SimConnect.dll" Visible="false" Pack="true" PackagePath="lib\net45" />
<None Include="licenses\LICENSE.txt" Pack="true" PackagePath="$(PackageLicenseFile)" />
</ItemGroup>
<ItemGroup>
<None Include="..\Dependencies\SimConnect\build\simconnect.dll" Visible="false" Pack="true" PackagePath="build" />
<None Include="..\Dependencies\SimConnect\build\CTrue.FsConnect.targets" Visible="false" Pack="true" PackagePath="build" />
<None Include="..\Dependencies\SimConnect\lib\net461\Microsoft.FlightSimulator.SimConnect.dll" Visible="false" Pack="true" PackagePath="lib\net461" />
<None Include="..\..\README.md" Pack="true" PackagePath="$(PackageReadmeFile)" />
<None Include="licenses\LICENSE.txt" Pack="true" PackagePath="$(PackageLicenseFile)" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Serilog" Version="2.10.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Serilog" />
</ItemGroup>

</Project>
Loading

0 comments on commit 32898a3

Please sign in to comment.