Skip to content

Commit

Permalink
Merge pull request #196 from calibx/develop
Browse files Browse the repository at this point in the history
2.3.0
  • Loading branch information
calibx committed Dec 6, 2022
2 parents 8b7b27f + cf228c5 commit ad135a1
Show file tree
Hide file tree
Showing 15 changed files with 353 additions and 34 deletions.
3 changes: 3 additions & 0 deletions MsfsPlugin/MsfsPlugin/MsfsPlugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="encoder\SimRateEncoder.cs" />
<Compile Include="encoder\BarometerEncoder.cs" />
<Compile Include="encoder\VSpeedAPEncoder.cs" />
<Compile Include="encoder\SpeedAPEncoder.cs" />
Expand All @@ -80,6 +81,7 @@
<Compile Include="folder\AirlinerDynamicFolder.cs" />
<Compile Include="folder\APDynamicFolder.cs" />
<Compile Include="folder\ATCDynamicFolder.cs" />
<Compile Include="folder\ComDynamicSFolder.cs" />
<Compile Include="folder\ComDynamicFolder.cs" />
<Compile Include="folder\LightsDynamicFolder.cs" />
<Compile Include="input\ap\APMultiInputs.cs" />
Expand All @@ -94,6 +96,7 @@
<Compile Include="input\misc\ParkingBrakeInput.cs" />
<Compile Include="input\DefaultInput.cs" />
<Compile Include="input\misc\FuelDisplay.cs" />
<Compile Include="input\misc\SpoilerArmInput.cs" />
<Compile Include="input\misc\PushbackInput.cs" />
<Compile Include="input\misc\PauseInput.cs" />
<Compile Include="input\nav\APWPDisplay.cs" />
Expand Down
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("2.2.0")]
[assembly: AssemblyVersion("2.3.0")]
2 changes: 1 addition & 1 deletion 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: 2.2.0
version: 2.3.0
author: CaliBx
copyright: CaliBx

Expand Down
2 changes: 2 additions & 0 deletions MsfsPlugin/MsfsPlugin/encoder/DefaultEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
{
using System;
using System.Collections.Generic;
using System.Diagnostics;


using Loupedeck.MsfsPlugin.tools;

Expand Down
29 changes: 29 additions & 0 deletions MsfsPlugin/MsfsPlugin/encoder/SimRateEncoder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace Loupedeck.MsfsPlugin
{
using System;

using Loupedeck.MsfsPlugin.encoder;
using Loupedeck.MsfsPlugin.tools;

class SimRateEncoder : DefaultEncoder
{
public SimRateEncoder() : base("Sim Rate", "Simulation rate encoder", "Misc", true, 0, 128, 1) => this._bindings.Add(MsfsData.Instance.Register(new Binding(BindingKeys.SIM_RATE)));
protected override void RunCommand(String actionParameter) => this.SetValue(0);
protected override Int64 GetValue() => this._bindings[0].ControllerValue;
protected override String GetDisplayValue() => this._bindings[0].ControllerValue.ToString();
protected override void SetValue(Int64 newValue) => this._bindings[0].SetControllerValue(newValue);
protected override void ApplyAdjustment(String actionParameter, Int32 ticks)
{
if (ticks > 0)
{
var newValue = this.GetValue() * 2;
this.SetValue(newValue > 128 ? 128 : newValue);
} else
{
this.SetValue(this.GetValue() / 2);
}
this.ActionImageChanged();
}

}
}
10 changes: 7 additions & 3 deletions MsfsPlugin/MsfsPlugin/encoder/SpoilerEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
using Loupedeck.MsfsPlugin.encoder;
class SpoilerEncoder : DefaultEncoder
{
public SpoilerEncoder() : base("Spoiler", "Spoiler position", "Nav", true, -1, 100, 1) => this._bindings.Add(MsfsData.Instance.Register(new Binding(BindingKeys.SPOILER)));
protected override void RunCommand(String actionParameter) => this.SetValue(0);
public SpoilerEncoder() : base("Spoiler", "Spoiler position", "Nav", true, 0, 100, 1)
{
this._bindings.Add(MsfsData.Instance.Register(new Binding(BindingKeys.SPOILER)));
this._bindings.Add(MsfsData.Instance.Register(new Binding(BindingKeys.SPOILERS_ARM)));
}
protected override void RunCommand(String actionParameter) => this._bindings[1].SetControllerValue((1+1)%2);
protected override Int64 GetValue() => this._bindings[0].ControllerValue;
protected override void SetValue(Int64 newValue) => this._bindings[0].SetControllerValue(newValue);
protected override String GetDisplayValue() => this.GetValue() == -1 ? "Arm" : this.GetValue().ToString();
protected override String GetDisplayValue() => this._bindings[1].ControllerValue == 1 ? "[" + this.GetValue().ToString() + "]" : this.GetValue().ToString();
}
}
5 changes: 5 additions & 0 deletions MsfsPlugin/MsfsPlugin/event/BindingKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public enum BindingKeys
AP_THROTTLE_SWITCH_AP_FOLDER,
AP_VSPEED_SWITCH_AP_FOLDER,
AP_YAW_DAMPER_AP_FOLDER,
AP_BC_AP_FOLDER,
AP_ALT_SWITCH,
AP_HEAD_SWITCH,
AP_NAV_SWITCH,
Expand All @@ -107,6 +108,7 @@ public enum BindingKeys
AP_THROTTLE_SWITCH,
AP_VSPEED_SWITCH,
AP_YAW_DAMPER_SWITCH,
AP_BC_SWITCH,
ATC_ATC_FOLDER,
ATC_0_ATC_FOLDER,
ATC_1_ATC_FOLDER,
Expand Down Expand Up @@ -138,6 +140,7 @@ public enum BindingKeys
AP_THROTTLE_SWITCH_AL_FOLDER,
AP_VSPEED_SWITCH_AL_FOLDER,
AP_YAW_DAMPER_AL_FOLDER,
AP_BC_AL_FOLDER,
AUTO_TAXI,
COM1_ACTIVE_FREQUENCY,
COM2_ACTIVE_FREQUENCY,
Expand All @@ -159,6 +162,8 @@ public enum BindingKeys
COM3_RADIO_SWAP,
FLASHLIGHT,
ICON_SIZE,
SIM_RATE,
SPOILERS_ARM,
}
}

8 changes: 8 additions & 0 deletions MsfsPlugin/MsfsPlugin/folder/APDynamicFolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public APDynamicFolder()
this._bindings.Add(MsfsData.Instance.Register(new Binding(BindingKeys.AP_THROTTLE_SWITCH_AP_FOLDER)));
this._bindings.Add(MsfsData.Instance.Register(new Binding(BindingKeys.AP_VSPEED_SWITCH_AP_FOLDER)));
this._bindings.Add(MsfsData.Instance.Register(new Binding(BindingKeys.AP_YAW_DAMPER_AP_FOLDER)));
this._bindings.Add(MsfsData.Instance.Register(new Binding(BindingKeys.AP_BC_AP_FOLDER)));

}

Expand Down Expand Up @@ -69,6 +70,7 @@ public override IEnumerable<String> GetButtonPressActionNames(DeviceType deviceT
this.CreateCommandName("Throttle"),
this.CreateCommandName("VS Speed"),
this.CreateCommandName("Yaw Damper"),
this.CreateCommandName("Back Course"),
};
}
public override String GetAdjustmentDisplayName(String actionParameter, PluginImageSize imageSize)
Expand Down Expand Up @@ -120,6 +122,9 @@ public override BitmapImage GetCommandImage(String actionParameter, PluginImageS
case "Yaw Damper":
bitmapBuilder.SetBackgroundImage(ImageTool.GetOnOffImage(this._bindings[15].ControllerValue));
break;
case "Back Course":
bitmapBuilder.SetBackgroundImage(ImageTool.GetOnOffImage(this._bindings[16].ControllerValue));
break;
}
bitmapBuilder.DrawText(actionParameter);
return bitmapBuilder.ToImage();
Expand Down Expand Up @@ -171,6 +176,9 @@ public override void RunCommand(String actionParameter)
case "Yaw Damper":
this._bindings[15].SetControllerValue(1);
break;
case "Back Course":
this._bindings[16].SetControllerValue(1);
break;
case "Altitude Reset":
this._bindings[0].SetControllerValue((Int64)(Math.Round(this._bindings[1].ControllerValue / 100d, 0) * 100));
break;
Expand Down
8 changes: 8 additions & 0 deletions MsfsPlugin/MsfsPlugin/folder/AirlinerDynamicFolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public AirlinerDynamicFolder()
this._bindings.Add(MsfsData.Instance.Register(new Binding(BindingKeys.AP_THROTTLE_SWITCH_AL_FOLDER)));
this._bindings.Add(MsfsData.Instance.Register(new Binding(BindingKeys.AP_VSPEED_SWITCH_AL_FOLDER)));
this._bindings.Add(MsfsData.Instance.Register(new Binding(BindingKeys.AP_YAW_DAMPER_AL_FOLDER)));
this._bindings.Add(MsfsData.Instance.Register(new Binding(BindingKeys.AP_BC_AL_FOLDER)));

}

Expand Down Expand Up @@ -76,6 +77,7 @@ public override IEnumerable<String> GetButtonPressActionNames(DeviceType deviceT
this.CreateCommandName("Throttle"),
this.CreateCommandName("VS Speed"),
this.CreateCommandName("Yaw Damper"),
this.CreateCommandName("Back Course"),
};
}
public override String GetAdjustmentDisplayName(String actionParameter, PluginImageSize imageSize)
Expand Down Expand Up @@ -139,6 +141,9 @@ public override BitmapImage GetCommandImage(String actionParameter, PluginImageS
case "Yaw Damper":
bitmapBuilder.SetBackgroundImage(ImageTool.GetOnOffImage(this._bindings[19].ControllerValue));
break;
case "Back Course":
bitmapBuilder.SetBackgroundImage(ImageTool.GetOnOffImage(this._bindings[20].ControllerValue));
break;
}
bitmapBuilder.DrawText(actionParameter);
return bitmapBuilder.ToImage();
Expand Down Expand Up @@ -202,6 +207,9 @@ public override void RunCommand(String actionParameter)
case "Yaw Damper":
this._bindings[19].SetControllerValue(1);
break;
case "Back Course":
this._bindings[20].SetControllerValue(1);
break;
case "Altitude Reset":
//this._bindings[18].SetControllerValue(1);
break;
Expand Down
32 changes: 4 additions & 28 deletions MsfsPlugin/MsfsPlugin/folder/ComDynamicFolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,6 @@ public override BitmapImage GetCommandImage(String actionParameter, PluginImageS
var bitmapBuilder = new BitmapBuilder(imageSize);
switch (actionParameter)
{
case "COM1 Active":
bitmapBuilder.SetBackgroundImage(ImageTool.GetAvailableDisableImage(this._bindings[9].MsfsValue));
bitmapBuilder.DrawText("COM 1\n" + (this._bindings[0].ControllerValue / 1000000f).ToString("F3", CultureInfo.InvariantCulture));
break;
case "COM1 Standby":
bitmapBuilder.SetBackgroundImage(ImageTool.GetAvailableDisableImage(this._bindings[9].MsfsValue));
bitmapBuilder.DrawText("Standby\n" + (this._bindings[12].ControllerValue / 1000000f).ToString("F3", CultureInfo.InvariantCulture));
break;
case "COM1 Status":
bitmapBuilder.SetBackgroundImage(ImageTool.GetAvailableDisableImage(this._bindings[9].MsfsValue));
bitmapBuilder.DrawText("Status\n" + ConvertTool.IntToCOMStatus(this._bindings[6].ControllerValue) + "\nType\n" + ConvertTool.IntToCOMType(this._bindings[3].ControllerValue));
break;
case "COM1 Active Int":
bitmapBuilder.SetBackgroundImage(ImageTool.GetAvailableDisableImage(this._bindings[9].MsfsValue));
bitmapBuilder.DrawText((this._bindings[0].ControllerValue == 0 ? "0" : this._bindings[0].ControllerValue.ToString().Substring(0, 3)) + ".", new BitmapColor(0, 255, 0), 40);
Expand All @@ -131,18 +119,6 @@ public override BitmapImage GetCommandImage(String actionParameter, PluginImageS
bitmapBuilder.SetBackgroundImage(ImageTool.GetAvailableDisableImage(this._bindings[9].MsfsValue));
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":
bitmapBuilder.SetBackgroundImage(ImageTool.GetAvailableDisableImage(this._bindings[10].MsfsValue));
bitmapBuilder.DrawText("COM 2\n" + (this._bindings[1].ControllerValue / 1000000f).ToString("F3", CultureInfo.InvariantCulture));
break;
case "COM2 Standby":
bitmapBuilder.SetBackgroundImage(ImageTool.GetAvailableDisableImage(this._bindings[10].MsfsValue));
bitmapBuilder.DrawText("Standby\n" + (this._bindings[13].ControllerValue / 1000000f).ToString("F3", CultureInfo.InvariantCulture));
break;
case "COM2 Status":
bitmapBuilder.SetBackgroundImage(ImageTool.GetAvailableDisableImage(this._bindings[10].MsfsValue));
bitmapBuilder.DrawText("Status\n" + ConvertTool.IntToCOMStatus(this._bindings[7].ControllerValue) + "\nType\n" + ConvertTool.IntToCOMType(this._bindings[3].ControllerValue));
break;
case "COM2 Active Int":
bitmapBuilder.SetBackgroundImage(ImageTool.GetAvailableDisableImage(this._bindings[10].MsfsValue));
bitmapBuilder.DrawText((this._bindings[1].ControllerValue == 0 ? "0" : this._bindings[1].ControllerValue.ToString().Substring(0, 3)) + ".", new BitmapColor(0, 255, 0), 40);
Expand Down Expand Up @@ -199,25 +175,25 @@ public override void ApplyAdjustment(String actionParameter, Int32 ticks)
case "COM1 Int Encoder":
var com1int = Int32.Parse(this._bindings[12].ControllerValue.ToString().Substring(0, 3));
var com1dbl = Int32.Parse(this._bindings[12].ControllerValue.ToString().Substring(3, 3));
var newInt = ConvertTool.ApplyAdjustment(com1int, ticks, 118, 136, 1);
var newInt = ConvertTool.ApplyAdjustment(com1int, ticks, 118, 136, 1, true);
this._bindings[12].SetControllerValue(newInt * 1000000 + com1dbl * 1000);
break;
case "COM1 Float Encoder":
var com1dbl1 = Int32.Parse(this._bindings[12].ControllerValue.ToString().Substring(3, 3));
var com1int1 = Int32.Parse(this._bindings[12].ControllerValue.ToString().Substring(0, 3));
var newFloat = ConvertTool.ApplyAdjustment(com1dbl1, ticks, 0, 995, 5);
var newFloat = ConvertTool.ApplyAdjustment(com1dbl1, ticks, 0, 995, 5, true);
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 = ConvertTool.ApplyAdjustment(com2int, ticks, 118, 136, 1);
var newInt2 = ConvertTool.ApplyAdjustment(com2int, ticks, 118, 136, 1, true);
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 = ConvertTool.ApplyAdjustment(com2dbl2, ticks, 0, 995, 5);
var newFloat2 = ConvertTool.ApplyAdjustment(com2dbl2, ticks, 0, 995, 5, true);
this._bindings[13].SetControllerValue(com2int2 * 1000000 + newFloat2 * 1000);
break;

Expand Down
Loading

0 comments on commit ad135a1

Please sign in to comment.