Skip to content

Commit

Permalink
Merge pull request #111 from calibx/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
calibx committed Oct 4, 2022
2 parents d3f098e + 1ae298e commit 6c47409
Show file tree
Hide file tree
Showing 15 changed files with 305 additions and 53 deletions.
10 changes: 2 additions & 8 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
{
"ExpandedNodes": [
"",
"\\MsfsPlugin\\MsfsPlugin",
"\\MsfsPlugin\\MsfsPlugin\\input",
"\\MsfsPlugin\\MsfsPlugin\\input\\light",
"\\MsfsPlugin\\MsfsPlugin\\input\\misc",
"\\MsfsPlugin\\MsfsPlugin\\input\\nav",
"\\MsfsPlugin\\MsfsPlugin\\msfs",
"\\MsfsPlugin\\MsfsPlugin\\Resources"
"\\MsfsPlugin"
],
"SelectedNode": "\\MsfsPlugin",
"SelectedNode": "\\MsfsPlugin\\MsfsPlugin.sln",
"PreviewInSolutionExplorer": false
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified .vs/msfsdeck/v17/.suo
Binary file not shown.
Binary file modified .vs/slnx.sqlite
Binary file not shown.
35 changes: 22 additions & 13 deletions MsfsPlugin/MsfsPlugin/MsfsPlugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\..\..\..\AppData\Local\Loupedeck\Plugins\</OutputPath>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand All @@ -36,6 +36,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x64</PlatformTarget>
<OutputPath>bin\Release\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<OutputPath>..\..\..\..\..\AppData\Local\Loupedeck\Plugins\</OutputPath>
Expand All @@ -44,9 +45,9 @@
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.FlightSimulator.SimConnect, Version=11.0.62651.3, Culture=neutral, PublicKeyToken=baf445ffb3a06b5c, processorArchitecture=AMD64">
<HintPath>..\..\..\..\..\..\..\MSFS SDK\SimConnect SDK\lib\managed\Microsoft.FlightSimulator.SimConnect.dll</HintPath>
<Reference Include="Microsoft.FlightSimulator.SimConnect, Version=10.0.61259.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\MSFS SDK\SimConnect SDK\lib\managed\Microsoft.FlightSimulator.SimConnect.dll</HintPath>
</Reference>
<Reference Include="PluginApi, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down Expand Up @@ -81,6 +82,7 @@
<Compile Include="folder\ATCDynamicFolder.cs" />
<Compile Include="folder\ComDynamicFolder.cs" />
<Compile Include="folder\LightsDynamicFolder.cs" />
<Compile Include="input\ap\APMultiInputs.cs" />
<Compile Include="input\debug\SimCnxStateInput.cs" />
<Compile Include="input\debug\DebugInput.cs" />
<Compile Include="input\debug\AircraftInput.cs" />
Expand Down Expand Up @@ -166,15 +168,22 @@
<PropertyGroup>
<PostBuildEvent>xcopy "C:\MSFS SDK\SimConnect SDK\lib\SimConnect.dll" "." /Y
if $(ConfigurationName) == Release (
powershell Remove-Item '$(OutDir)archive' -Recurse -Force
powershell New-Item -Path '$(OutDir)archive\bin\win' -ItemType Directory -Force
powershell Copy-Item '$(OutDir)MSFSPlugin.dll' -Destination '$(OutDir)archive\bin\win'
powershell Copy-Item '$(OutDir)Microsoft.FlightSimulator.SimConnect.dll' -Destination '$(OutDir)archive\bin\win'
powershell Copy-Item '$(OutDir)\SimConnect.dll' -Destination '$(OutDir)archive\bin\win'
powershell Copy-Item '$(OutDir)Resources\LoupedeckPackage.yaml' -Destination '$(OutDir)archive\'
powershell Compress-Archive -Path '$(OutDir)archive\*' -DestinationPath '$(OutDir)archive\MSFSPluginPackage.zip'
powershell Rename-Item -Path '$(OutDir)archive\MSFSPluginPackage.zip' -NewName MSFSPluginPackage.lplug4
)
</PostBuildEvent>
powershell Remove-Item 'archive' -Recurse -Force
powershell New-Item -Path 'archive\bin\win' -ItemType Directory -Force
powershell New-Item -Path 'archive\metadata' -ItemType Directory -Force
powershell Copy-Item 'MSFSPlugin.dll' -Destination 'archive\bin\win'
powershell Copy-Item 'Microsoft.FlightSimulator.SimConnect.dll' -Destination 'archive\bin\win'
powershell Copy-Item 'SimConnect.dll' -Destination 'archive\bin\win'
powershell Copy-Item 'Resources\LoupedeckPackage.yaml' -Destination 'archive\'
powershell Copy-Item 'Resources\LoupedeckPackage.yaml' -Destination 'archive\metadata\'
powershell Compress-Archive -Path 'archive\*' -DestinationPath 'archive\MSFSPluginPackage.zip'
powershell Rename-Item -Path 'archive\MSFSPluginPackage.zip' -NewName MSFSPluginPackage.lplug4
) else (
powershell Remove-Item '%25USERPROFILE%25\AppData\Local\Loupedeck\Plugins\MSFS' -Recurse -Force
powershell New-Item -Path '%25USERPROFILE%25\AppData\Local\Loupedeck\Plugins\MSFS' -ItemType Directory -Force
powershell Copy-Item 'MSFSPlugin.dll' -Destination '%25USERPROFILE%25\AppData\Local\Loupedeck\Plugins\MSFS'
powershell Copy-Item 'Microsoft.FlightSimulator.SimConnect.dll' -Destination '%25USERPROFILE%25\AppData\Local\Loupedeck\Plugins\MSFS'
powershell Copy-Item 'SimConnect.dll' -Destination '%25USERPROFILE%25\AppData\Local\Loupedeck\Plugins\MSFS'
)</PostBuildEvent>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion MsfsPlugin/MsfsPlugin/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("4.3.0.7478")]
[assembly: AssemblyVersion("1.0.3")]
[assembly: AssemblyVersion("1.0.4")]
4 changes: 2 additions & 2 deletions MsfsPlugin/MsfsPlugin/Resources/LoupedeckPackage.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
type: plugin4
name: MSFS
displayName: Microsoft Flight Simulator
version: 1.0.3
version: 1.0.4
author: CaliBx
copyright: CaliBx

Expand All @@ -10,4 +10,4 @@ supportedDevices:
- LoupedeckLive

pluginFileName: MSFSPlugin.dll
pluginFolderWin: bin\win\
pluginFolderWin: ./bin/win/
7 changes: 7 additions & 0 deletions MsfsPlugin/MsfsPlugin/event/BindingKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ public enum BindingKeys
AP_MASTER_SWITCH_AP_FOLDER,
AP_THROTTLE_SWITCH_AP_FOLDER,
AP_VSPEED_SWITCH_AP_FOLDER,
AP_ALT_SWITCH,
AP_HEAD_SWITCH,
AP_NAV_SWITCH,
AP_SPEED_SWITCH,
AP_MASTER_SWITCH,
AP_THROTTLE_SWITCH,
AP_VSPEED_SWITCH,
ATC_ATC_FOLDER,
ATC_0_ATC_FOLDER,
ATC_1_ATC_FOLDER,
Expand Down
12 changes: 11 additions & 1 deletion MsfsPlugin/MsfsPlugin/folder/APDynamicFolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public override void ApplyAdjustment(String actionParameter, Int32 ticks)
this._bindings[0].SetControllerValue(this.ApplyAdjustment(this._bindings[0].ControllerValue, -10000, 99900, 100, ticks));
break;
case "Heading Encoder":
this._bindings[2].SetControllerValue(this.ApplyAdjustment(this._bindings[2].ControllerValue, 0, 360, 1, ticks));
this._bindings[2].SetControllerValue(this.ApplyAdjustmentForHeading(this._bindings[2].ControllerValue, 1, 360, 1, ticks));
break;
case "Speed Encoder":
this._bindings[4].SetControllerValue(this.ApplyAdjustment(this._bindings[4].ControllerValue, 0, 2000, 1, ticks));
Expand Down Expand Up @@ -187,6 +187,16 @@ private Int64 ApplyAdjustment(Int64 value, Int32 min, Int32 max, Int32 steps, In
{ value = max; }
return value;
}

private Int64 ApplyAdjustmentForHeading(Int64 value, Int32 min, Int32 max, Int32 steps, Int32 ticks)
{
value += ticks * steps;
if (value < min)
{ value = max; }
else if (value > max)
{ value = min; }
return value;
}

public void Notify()
{
Expand Down
94 changes: 76 additions & 18 deletions MsfsPlugin/MsfsPlugin/folder/ComDynamicFolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,31 +42,26 @@ public override IEnumerable<String> GetButtonPressActionNames()
{
return new[]
{
/* this.CreateCommandName("COM1 Active"),
this.CreateCommandName("COM1 Standby"),
this.CreateCommandName("COM1 Status"),
*/ this.CreateCommandName("COM1 Active Int"),
this.CreateCommandName("COM1 Active Int"),
this.CreateCommandName("COM1 Active Float"),
this.CreateCommandName("COM1 Standby Int"),
this.CreateCommandName("COM1 Standby Float"),
this.CreateCommandName("COM2 Active Int"),
this.CreateCommandName("COM2 Active Float"),
this.CreateCommandName("COM2 Standby Int"),
this.CreateCommandName("COM2 Standby Float"),
PluginDynamicFolder.NavigateUpActionName,

/* this.CreateCommandName("COM2 Active"),
this.CreateCommandName("COM2 Standby"),
this.CreateCommandName("COM3 Active"),
this.CreateCommandName("COM3 Standby"),*/
};
}
public override IEnumerable<String> GetEncoderRotateActionNames()
{
return new[]
{
this.CreateAdjustmentName ("COM1 Int Encoder"),
this.CreateAdjustmentName (""),
this.CreateAdjustmentName ("COM2 Int Encoder"),
this.CreateAdjustmentName (""),
this.CreateAdjustmentName ("COM1 Float Encoder"),
/* this.CreateAdjustmentName ("COM1 Float Encoder"),
*/ //this.CreateAdjustmentName ("COM3 Float Encoder"),
this.CreateAdjustmentName ("COM2 Float Encoder"),
};
}

Expand All @@ -75,10 +70,10 @@ public override IEnumerable<String> GetEncoderPressActionNames()
return new[]
{
this.CreateCommandName("COM1 Int Reset"),
//this.CreateCommandName("COM2 Int Reset"),
this.CreateCommandName("COM2 Int Reset"),
//this.CreateCommandName("COM3 Int Reset"),
this.CreateCommandName("COM1 Float Reset"),
//this.CreateCommandName("COM1 Float Reset"),
this.CreateCommandName("COM2 Float Reset"),
//this.CreateCommandName("COM3 Float Reset"),
};
}
Expand All @@ -94,6 +89,13 @@ public override String GetAdjustmentDisplayName(String actionParameter, PluginIm
var com1dbl = Math.Round(this._bindings[12].ControllerValue / 1000000f - Math.Truncate(this._bindings[12].ControllerValue / 1000000f), 3).ToString();
ret = "COM1\n" + (com1dbl.Length > 2 ? com1dbl.Substring(2) : com1dbl).PadRight(3, '0');
break;
case "COM2 Int Encoder":
ret = "COM2\n" + Math.Truncate(this._bindings[13].ControllerValue / 1000000f) + ".";
break;
case "COM2 Float Encoder":
var com2dbl = Math.Round(this._bindings[13].ControllerValue / 1000000f - Math.Truncate(this._bindings[13].ControllerValue / 1000000f), 3).ToString();
ret = "COM2\n" + (com2dbl.Length > 2 ? com2dbl.Substring(2) : com2dbl).PadRight(3, '0');
break;
}
return ret;
}
Expand All @@ -116,19 +118,47 @@ public override BitmapImage GetCommandImage(String actionParameter, PluginImageS
break;
case "COM1 Active Int":
this.SetBackground(bitmapBuilder, this._bindings[9]);
bitmapBuilder.DrawText(this._bindings[0].ControllerValue.ToString().Substring(0,3) +".", new BitmapColor(0, 255, 0), 40);
bitmapBuilder.DrawText((this._bindings[0].ControllerValue == 0 ? "0" : this._bindings[0].ControllerValue.ToString().Substring(0,3)) +".", new BitmapColor(0, 255, 0), 40);
break;
case "COM1 Active Float":
this.SetBackground(bitmapBuilder, this._bindings[9]);
bitmapBuilder.DrawText(this._bindings[0].ControllerValue.ToString().Substring(3, 3), new BitmapColor(0, 255, 0), 40);
bitmapBuilder.DrawText(this._bindings[0].ControllerValue == 0 ? "0" : this._bindings[0].ControllerValue.ToString().Substring(3, 3), new BitmapColor(0, 255, 0), 40);
break;
case "COM1 Standby Int":
this.SetBackground(bitmapBuilder, this._bindings[9]);
bitmapBuilder.DrawText(this._bindings[12].ControllerValue.ToString().Substring(0, 3) + ".", new BitmapColor(255, 255, 0), 40);
bitmapBuilder.DrawText((this._bindings[12].ControllerValue == 0 ? "0" : this._bindings[12].ControllerValue.ToString().Substring(0, 3)) + ".", new BitmapColor(255, 255, 0), 40);
break;
case "COM1 Standby Float":
this.SetBackground(bitmapBuilder, this._bindings[9]);
bitmapBuilder.DrawText(this._bindings[12].ControllerValue.ToString().Substring(3, 3), new BitmapColor(255, 255, 0), 40);
bitmapBuilder.DrawText(this._bindings[12].ControllerValue == 0 ? "0" : this._bindings[12].ControllerValue.ToString().Substring(3, 3), new BitmapColor(255, 255, 0), 40);
break;
case "COM2 Active":
this.SetBackground(bitmapBuilder, this._bindings[10]);
bitmapBuilder.DrawText("COM 2\n" + (this._bindings[1].ControllerValue / 1000000f).ToString("F3", CultureInfo.InvariantCulture));
break;
case "COM2 Standby":
this.SetBackground(bitmapBuilder, this._bindings[10]);
bitmapBuilder.DrawText("Standby\n" + (this._bindings[13].ControllerValue / 1000000f).ToString("F3", CultureInfo.InvariantCulture));
break;
case "COM2 Status":
this.SetBackground(bitmapBuilder, this._bindings[10]);
bitmapBuilder.DrawText("Status\n" + this.IntToCOMStatus(this._bindings[7].ControllerValue) + "\nType\n" + this.IntToCOMType(this._bindings[3].ControllerValue));
break;
case "COM2 Active Int":
this.SetBackground(bitmapBuilder, this._bindings[10]);
bitmapBuilder.DrawText((this._bindings[1].ControllerValue == 0 ? "0" : this._bindings[1].ControllerValue.ToString().Substring(0, 3)) + ".", new BitmapColor(0, 255, 0), 40);
break;
case "COM2 Active Float":
this.SetBackground(bitmapBuilder, this._bindings[10]);
bitmapBuilder.DrawText(this._bindings[1].ControllerValue == 0 ? "0" : this._bindings[1].ControllerValue.ToString().Substring(3, 3), new BitmapColor(0, 255, 0), 40);
break;
case "COM2 Standby Int":
this.SetBackground(bitmapBuilder, this._bindings[10]);
bitmapBuilder.DrawText((this._bindings[13].ControllerValue == 0 ? "0" : this._bindings[13].ControllerValue.ToString().Substring(0, 3)) + ".", new BitmapColor(255, 255, 0), 40);
break;
case "COM2 Standby Float":
this.SetBackground(bitmapBuilder, this._bindings[10]);
bitmapBuilder.DrawText(this._bindings[13].ControllerValue == 0 ? "0" : this._bindings[13].ControllerValue.ToString().Substring(3, 3), new BitmapColor(255, 255, 0), 40);
break;

}
Expand Down Expand Up @@ -161,6 +191,17 @@ public override void RunCommand(String actionParameter)
case "COM1 Float Reset":
this._bindings[15].SetControllerValue(1);
break;
case "COM2 Active":
case "COM2 Active Int":
case "COM2 Active Float":
case "COM2 Standby":
case "COM2 Standby Int":
case "COM2 Standby Float":
case "COM2 Int Reset":
case "COM2 Float Reset":
this._bindings[16].SetControllerValue(1);
break;

}
}

Expand All @@ -180,6 +221,19 @@ public override void ApplyAdjustment(String actionParameter, Int32 ticks)
var newFloat = this.ApplyAdjustment(com1dbl1, 0, 995, 5, ticks);
this._bindings[12].SetControllerValue(com1int1 * 1000000 + newFloat * 1000);
break;
case "COM2 Int Encoder":
var com2int = Int32.Parse(this._bindings[13].ControllerValue.ToString().Substring(0, 3));
var com2dbl = Int32.Parse(this._bindings[13].ControllerValue.ToString().Substring(3, 3));
var newInt2 = this.ApplyAdjustment(com2int, 118, 136, 1, ticks);
this._bindings[13].SetControllerValue(newInt2 * 1000000 + com2dbl * 1000);
break;
case "COM2 Float Encoder":
var com2dbl2 = Int32.Parse(this._bindings[13].ControllerValue.ToString().Substring(3, 3));
var com2int2 = Int32.Parse(this._bindings[13].ControllerValue.ToString().Substring(0, 3));
var newFloat2 = this.ApplyAdjustment(com2dbl2, 0, 995, 5, ticks);
this._bindings[13].SetControllerValue(com2int2 * 1000000 + newFloat2 * 1000);
break;

}
this.EncoderActionNamesChanged();
this.ButtonActionNamesChanged();
Expand All @@ -198,6 +252,10 @@ public void Notify()
this.AdjustmentValueChanged("COM1 Int Encoder");
this.AdjustmentValueChanged("COM1 Float Encoder");
break;
case BindingKeys.COM2_ACTIVE_FREQUENCY:
this.AdjustmentValueChanged("COM2 Int Encoder");
this.AdjustmentValueChanged("COM2 Float Encoder");
break;
default:
break;
}
Expand Down
Loading

0 comments on commit 6c47409

Please sign in to comment.