1
0
Fork 0
mirror of https://github.com/hawkeye-stan/msfs-popout-panel-manager.git synced 2024-11-21 21:30:12 +00:00

Added keyboard shortcut function for start pop out

This commit is contained in:
hawkeye 2023-08-14 15:51:28 -04:00
parent 859e68893e
commit 1f855f7de6
16 changed files with 206 additions and 53 deletions

View file

@ -1,4 +1,5 @@
using MSFSPopoutPanelManager.Shared;
using System;
namespace MSFSPopoutPanelManager.DomainModel.Setting
{
@ -14,8 +15,17 @@ namespace MSFSPopoutPanelManager.DomainModel.Setting
TrackIRSetting = new TrackIRSetting();
WindowedModeSetting = new WindowedModeSetting();
SystemSetting = new SystemSetting();
KeyboardShortcutSetting = new KeyboardShortcutSetting();
InitializeChildPropertyChangeBinding();
this.PropertyChanged += (sender, e) =>
{
var evtArg = e as PropertyChangedExtendedEventArgs;
if (evtArg.ObjectName == "MSFSPopoutPanelManager.DomainModel.Setting.KeyboardShortcutSetting" && evtArg.PropertyName == "IsEnabled")
IsUsedKeyboardShortcutChanged?.Invoke(this, KeyboardShortcutSetting.IsEnabled);
};
}
public GeneralSetting GeneralSetting { get; set; }
@ -33,5 +43,9 @@ namespace MSFSPopoutPanelManager.DomainModel.Setting
public WindowedModeSetting WindowedModeSetting { get; set; }
public SystemSetting SystemSetting { get; set; }
public KeyboardShortcutSetting KeyboardShortcutSetting { get; set; }
public event EventHandler<bool> IsUsedKeyboardShortcutChanged;
}
}

View file

@ -7,11 +7,8 @@ namespace MSFSPopoutPanelManager.DomainModel.Setting
public AutoPopOutSetting()
{
IsEnabled = true;
ReadyToFlyDelay = 3;
}
public bool IsEnabled { get; set; }
public int ReadyToFlyDelay { get; set; }
}
}

View file

@ -0,0 +1,17 @@
using MSFSPopoutPanelManager.Shared;
namespace MSFSPopoutPanelManager.DomainModel.Setting
{
public class KeyboardShortcutSetting : ObservableObject
{
public KeyboardShortcutSetting()
{
IsEnabled = true;
StartPopOutKeyBinding = "P";
}
public bool IsEnabled { get; set; }
public string StartPopOutKeyBinding { get; set; }
}
}

View file

@ -97,6 +97,10 @@
x:Name="CategoryGameRefocusSettings"
Margin="0,0,0,10"
Header="Game Refocus Settings" />
<TreeViewItem
x:Name="CategoryKeyboardShortcutSettings"
Margin="0,0,0,10"
Header="Keyboard Shortcut Settings" />
<TreeViewItem
x:Name="CategoryTouchSettings"
Margin="0,0,0,10"
@ -214,30 +218,6 @@
</TextBlock>
</StackPanel>
</WrapPanel>
<WrapPanel Margin="0,0,20,20" Orientation="Vertical">
<TextBlock Style="{StaticResource TextBlockHeading}">Ready to Fly Button Delay</TextBlock>
<Line
Stretch="Fill"
Stroke="Gray"
X2="1" />
<StackPanel Orientation="Horizontal">
<localcontrol:NumericUpDown
Width="90"
Height="24"
FontSize="12"
Increment="1"
MaxValue="10"
MinValue="0"
Value="{Binding AppSettingData.ApplicationSetting.AutoPopOutSetting.ReadyToFlyDelay, Mode=TwoWay}" />
<TextBlock
Width="640"
Margin="10,0,0,0"
Style="{StaticResource TextBlockLabel}"
TextWrapping="Wrap">
Amount of time in seconds to delay auto pop out panels from starting after ready to fly button has been pressed automatically. Extending this delay helps resolve auto pop out failure because cockpit has not been loaded completely yet depending on the speed of your PC.
</TextBlock>
</StackPanel>
</WrapPanel>
</WrapPanel>
<!-- Pop Out Settings -->
@ -486,6 +466,72 @@
</WrapPanel>
</WrapPanel>
<!-- Keyboard Shortcut Settings -->
<WrapPanel Orientation="Vertical" Visibility="{Binding ElementName=CategoryKeyboardShortcutSettings, Path=IsSelected, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}">
<WrapPanel Margin="0,0,20,0" Orientation="Vertical">
<WrapPanel Orientation="Vertical">
<TextBlock Style="{StaticResource TextBlockHeading}">Keyboard Shortcuts</TextBlock>
<Line
Stretch="Fill"
Stroke="Gray"
X2="1" />
<WrapPanel>
<ToggleButton IsChecked="{Binding AppSettingData.ApplicationSetting.KeyboardShortcutSetting.IsEnabled, Mode=TwoWay}" Style="{StaticResource ToggleButton}" />
<TextBlock Style="{StaticResource TextBlockLabel}">Enable using of keyboard shortcuts to control application.</TextBlock>
</WrapPanel>
</WrapPanel>
<WrapPanel Orientation="Vertical" Visibility="{Binding AppSettingData.ApplicationSetting.KeyboardShortcutSetting.IsEnabled, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}">
<StackPanel
Width="Auto"
Margin="44,15,0,0"
VerticalAlignment="Top"
Orientation="Horizontal">
<WrapPanel>
<Label Content="Ctrl-Shift-" FontSize="14" />
<ComboBox
Width="40"
VerticalAlignment="top"
SelectedValue="{Binding AppSettingData.ApplicationSetting.KeyboardShortcutSetting.StartPopOutKeyBinding, Mode=TwoWay}"
SelectedValuePath="Tag">
<ComboBoxItem Content="A" Tag="A" />
<ComboBoxItem Content="B" Tag="B" />
<ComboBoxItem Content="C" Tag="C" />
<ComboBoxItem Content="D" Tag="D" />
<ComboBoxItem Content="E" Tag="E" />
<ComboBoxItem Content="F" Tag="F" />
<ComboBoxItem Content="G" Tag="G" />
<ComboBoxItem Content="H" Tag="H" />
<ComboBoxItem Content="I" Tag="I" />
<ComboBoxItem Content="J" Tag="J" />
<ComboBoxItem Content="K" Tag="K" />
<ComboBoxItem Content="L" Tag="L" />
<ComboBoxItem Content="M" Tag="M" />
<ComboBoxItem Content="N" Tag="N" />
<ComboBoxItem Content="O" Tag="O" />
<ComboBoxItem Content="P" Tag="P" />
<ComboBoxItem Content="Q" Tag="Q" />
<ComboBoxItem Content="R" Tag="R" />
<ComboBoxItem Content="S" Tag="S" />
<ComboBoxItem Content="T" Tag="T" />
<ComboBoxItem Content="U" Tag="U" />
<ComboBoxItem Content="V" Tag="V" />
<ComboBoxItem Content="W" Tag="W" />
<ComboBoxItem Content="X" Tag="X" />
<ComboBoxItem Content="Y" Tag="Y" />
<ComboBoxItem Content="Z" Tag="Z" />
</ComboBox>
</WrapPanel>
<TextBlock
Width="600"
Margin="10,3,0,0"
Style="{StaticResource TextBlockLabel}">
Configure key binding to initiate start pop out.
</TextBlock>
</StackPanel>
</WrapPanel>
</WrapPanel>
</WrapPanel>
<!-- Touch Settings -->
<WrapPanel Orientation="Vertical" Visibility="{Binding ElementName=CategoryTouchSettings, Path=IsSelected, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}">
<WrapPanel Margin="0,0,20,20" Orientation="Vertical">

View file

@ -17,10 +17,10 @@ namespace MSFSPopoutPanelManager.MainApp.ViewModel
{
Orchestrator = orchestrator;
Orchestrator.PanelPopOut.OnPopOutStarted += (sender, e) => IsDisabledAppInput = true;
Orchestrator.PanelPopOut.OnPopOutCompleted += (sender, e) => IsDisabledAppInput = false;
Orchestrator.PanelSource.OnPanelSourceSelectionStarted += (sender, e) => IsDisabledAppInput = true;
Orchestrator.PanelSource.OnPanelSourceSelectionCompleted += (sender, e) => IsDisabledAppInput = false;
Orchestrator.PanelPopOut.OnPopOutStarted += (sender, e) => Orchestrator.PanelPopOut.IsDisabledStartPopOut = true;
Orchestrator.PanelPopOut.OnPopOutCompleted += (sender, e) => Orchestrator.PanelPopOut.IsDisabledStartPopOut = false;
Orchestrator.PanelSource.OnPanelSourceSelectionStarted += (sender, e) => Orchestrator.PanelPopOut.IsDisabledStartPopOut = true;
Orchestrator.PanelSource.OnPanelSourceSelectionCompleted += (sender, e) => Orchestrator.PanelPopOut.IsDisabledStartPopOut = false;
}
public AppSettingData AppSettingData => Orchestrator.AppSettingData;
@ -29,8 +29,6 @@ namespace MSFSPopoutPanelManager.MainApp.ViewModel
public FlightSimData FlightSimData => Orchestrator.FlightSimData;
public bool IsDisabledAppInput { get; set; }
protected List<Run> FormatStatusMessages(List<StatusMessage> messages)
{
List<Run> runs = new List<Run>();

View file

@ -129,19 +129,25 @@ namespace MSFSPopoutPanelManager.MainApp.ViewModel
if (DataItem.IsEditingPanel)
{
ProfileData.ActiveProfile.CurrentMoveResizePanelId = DataItem.Id;
if (!AppSettingData.ApplicationSetting.KeyboardShortcutSetting.IsEnabled)
InputHookManager.StartKeyboardHook();
InputHookManager.OnKeyUp -= HandleKeyUpEvent;
InputHookManager.OnKeyUp += HandleKeyUpEvent;
}
else
{
ProfileData.ActiveProfile.CurrentMoveResizePanelId = Guid.Empty;
InputHookManager.OnKeyUp -= HandleKeyUpEvent;
if (!AppSettingData.ApplicationSetting.KeyboardShortcutSetting.IsEnabled)
InputHookManager.EndKeyboardHook();
InputHookManager.OnKeyUp -= HandleKeyUpEvent;
}
}
private void HandleKeyUpEvent(object? sender, KeyUpEventArgs e)
private void HandleKeyUpEvent(object sender, KeyUpEventArgs e)
{
PanelConfigPropertyName panelConfigPropertyName = PanelConfigPropertyName.None;

View file

@ -129,7 +129,7 @@ namespace MSFSPopoutPanelManager.MainApp.ViewModel
private void OnStartPopOut()
{
if (IsDisabledAppInput)
if (Orchestrator.PanelPopOut.IsDisabledStartPopOut || !FlightSimData.IsInCockpit)
return;
Orchestrator.PanelPopOut.ManualPopOut();
@ -212,7 +212,7 @@ namespace MSFSPopoutPanelManager.MainApp.ViewModel
if (monitor == null)
return;
if(!monitor.IsSelected)
if (!monitor.IsSelected)
{
ProfileData.ActiveProfile.PanelConfigs.RemoveAll(p => p.PanelName == arg && p.PanelType == PanelType.RefocusDisplay);
}

View file

@ -0,0 +1,51 @@
using MSFSPopoutPanelManager.Shared;
using MSFSPopoutPanelManager.WindowsAgent;
namespace MSFSPopoutPanelManager.Orchestration
{
public class KeyboardOrchestrator : ObservableObject
{
private AppSettingData _appSettingData;
private FlightSimData _flightSimData;
public KeyboardOrchestrator(AppSettingData appSettingData, FlightSimData flightSimData)
{
_appSettingData = appSettingData;
_flightSimData = flightSimData;
}
internal PanelPopOutOrchestrator PanelPopOutOrchestrator { get; set; }
public void Initialize()
{
if (_appSettingData.ApplicationSetting.KeyboardShortcutSetting.IsEnabled)
{
InputHookManager.StartKeyboardHook();
InputHookManager.OnKeyUp -= HandleKeyboardHookKeyUpEvent;
InputHookManager.OnKeyUp += HandleKeyboardHookKeyUpEvent;
}
_appSettingData.ApplicationSetting.IsUsedKeyboardShortcutChanged += (sender, e) =>
{
if (e)
{
InputHookManager.StartKeyboardHook();
InputHookManager.OnKeyUp -= HandleKeyboardHookKeyUpEvent;
InputHookManager.OnKeyUp += HandleKeyboardHookKeyUpEvent;
}
else
{
InputHookManager.EndKeyboardHook();
InputHookManager.OnKeyUp -= HandleKeyboardHookKeyUpEvent;
}
};
}
public void HandleKeyboardHookKeyUpEvent(object sender, KeyUpEventArgs e)
{
// Start pop out
if (e.IsHoldControl && e.IsHoldShift && e.KeyCode.ToUpper() == _appSettingData.ApplicationSetting.KeyboardShortcutSetting.StartPopOutKeyBinding)
PanelPopOutOrchestrator.ManualPopOut();
}
}
}

View file

@ -1,5 +1,6 @@
using AutoUpdaterDotNET;
using MSFSPopoutPanelManager.Shared;
using MSFSPopoutPanelManager.WindowsAgent;
using System;
using System.IO;
using System.Threading.Tasks;
@ -24,6 +25,7 @@ namespace MSFSPopoutPanelManager.Orchestration
PanelConfiguration = new PanelConfigurationOrchestrator(ProfileData, AppSettingData, FlightSimData);
FlightSim = new FlightSimOrchestrator(ProfileData, AppSettingData, FlightSimData);
Help = new HelpOrchestrator();
Keyboard = new KeyboardOrchestrator(AppSettingData, FlightSimData);
PanelSource.FlightSimOrchestrator = FlightSim;
@ -34,6 +36,8 @@ namespace MSFSPopoutPanelManager.Orchestration
FlightSim.PanelPopOutOrchestrator = PanelPopOut;
FlightSim.PanelConfigurationOrchestrator = PanelConfiguration;
FlightSim.OnSimulatorExited += (sender, e) => { ApplicationClose(); Environment.Exit(0); };
Keyboard.PanelPopOutOrchestrator = PanelPopOut;
}
public ProfileOrchestrator Profile { get; set; }
@ -54,6 +58,8 @@ namespace MSFSPopoutPanelManager.Orchestration
public HelpOrchestrator Help { get; set; }
public KeyboardOrchestrator Keyboard { get; set; }
public IntPtr ApplicationHandle { get; set; }
public Window ApplicationWindow { get; set; }
@ -71,6 +77,8 @@ namespace MSFSPopoutPanelManager.Orchestration
ProfileData.SetActiveProfile(AppSettingData.ApplicationSetting.SystemSetting.LastUsedProfileId); // Load last used profile
Task.Run(() => FlightSim.StartSimConnectServer()); // Start the SimConnect server
Keyboard.Initialize();
}
public void ApplicationClose()
@ -78,6 +86,8 @@ namespace MSFSPopoutPanelManager.Orchestration
// Force unhook all win events
PanelConfiguration.EndConfiguration();
PanelConfiguration.EndTouchHook();
InputHookManager.EndKeyboardHook();
FlightSim.EndSimConnectServer(true);
}

View file

@ -23,6 +23,7 @@ namespace MSFSPopoutPanelManager.Orchestration
_profileData = profileData;
_appSettingData = appSettingData;
_flightSimData = flightSimData;
IsDisabledStartPopOut = false;
}
internal FlightSimOrchestrator FlightSimOrchestrator { private get; set; }
@ -35,12 +36,17 @@ namespace MSFSPopoutPanelManager.Orchestration
private ApplicationSetting AppSetting { get { return _appSettingData == null ? null : _appSettingData.ApplicationSetting; } }
public bool IsDisabledStartPopOut { get; set; }
public event EventHandler OnPopOutStarted;
public event EventHandler OnPopOutCompleted;
public event EventHandler<PanelConfig> OnHudBarOpened;
public async void ManualPopOut()
{
if (IsDisabledStartPopOut || !_flightSimData.IsInCockpit)
return;
await CoreSteps(false);
}
@ -490,8 +496,6 @@ namespace MSFSPopoutPanelManager.Orchestration
int retry = 10;
for (var i = 0; i < retry; i++)
{
System.Diagnostics.Debug.WriteLine($"zoom {i}");
FlightSimOrchestrator.SetCockpitCameraZoomLevel(zoom);
Thread.Sleep(500); // wait for flightsimdata to be updated

View file

@ -175,7 +175,7 @@ namespace MSFSPopoutPanelManager.Orchestration
{
// Disable hooks if active
InputHookManager.EndMouseHook();
InputHookManager.EndKeyboardHook();
//InputHookManager.EndKeyboardHook();
_profileData.ActiveProfile.CurrentMoveResizePanelId = Guid.Empty;

View file

@ -242,7 +242,7 @@ namespace MSFSPopoutPanelManager.Orchestration
public void ResetActiveProfile()
{
InputHookManager.EndMouseHook();
InputHookManager.EndKeyboardHook();
//InputHookManager.EndKeyboardHook();
if (ActiveProfile == null)
return;

View file

@ -1,9 +1,12 @@
## Version 4.0.2
* Added new logic to detect when flight session is ready to initiate pop out process. Ready to Fly delay setting is no longer needed. Please install the updated "ready-to-fly-button-skipper" community plugin to your community folder to shorten the time when pop out process starts. The old version waits 2 seconds before ready to fly button is deactivated and the new version is immediate.
* Updated logic to load custom camera view when performing pop out. It is now more reliable and reduces unnecessary shifting of camera angle before starting pop out process.
* Added workaround for CJ4 CDU panel not popping out because of MSFS bug.
* Added workaround fix when using camera zoom setting with value other than 50 in MSFS general options will cause Pop Out Panel Manager pop out to fail. This is an existing MSFS bug where saving and loading of custom camera view is currently broken for zoom level other than 50.
* Add configurable keyboard shortcut to initiate pop out process (default is Ctrl-Shift-P). This keyboard shortcut can be configured in preference setting. This setting can be disabled to improve computing resource needed to constantly detect keyboard inputs.
* Fixed issue where full screen mode for pop out panel does not work on certain aircraft configuration.
* Updated logic to verify custom camera view has been loaded before starting pop out process.

View file

@ -25,7 +25,7 @@ namespace MSFSPopoutPanelManager.Shared
hasJsonIgnoreAttribute = Attribute.IsDefined(propertyInfo, typeof(JsonIgnoreAttribute));
}
PropertyChanged?.Invoke(this, new PropertyChangedExtendedEventArgs(e?.PropertyName, hasJsonIgnoreAttribute));
PropertyChanged?.Invoke(this, new PropertyChangedExtendedEventArgs(e?.PropertyName, sender.ToString(), hasJsonIgnoreAttribute));
}
protected void InitializeChildPropertyChangeBinding()
@ -55,9 +55,12 @@ namespace MSFSPopoutPanelManager.Shared
{
public virtual bool DisableSave { get; private set; }
public PropertyChangedExtendedEventArgs(string propertyName, bool disableSave) : base(propertyName)
public virtual string ObjectName { get; private set; }
public PropertyChangedExtendedEventArgs(string propertyName, string objectName, bool disableSave) : base(propertyName)
{
DisableSave = disableSave;
ObjectName = objectName;
}
}
}

View file

@ -2,13 +2,17 @@
<hr/>
## Version 4.0.2
* Added new logic to detect when flight session is ready to initiate pop out process. Ready to Fly delay setting is no longer needed. Please install the updated "ready-to-fly-button-skipper" community plugin to your community folder to shorten the time when pop out process starts. The old version waits 2 seconds before ready to fly button is deactivated and the new version is immediate.
* Updated logic to load custom camera view when performing pop out. It is now more reliable and reduces unnecessary shifting of camera angle before starting pop out process.
* Added workaround for CJ4 CDU panel not popping out because of MSFS bug.
* Added workaround fix when using camera zoom setting with value other than 50 in MSFS general options will cause Pop Out Panel Manager pop out to fail. This is an existing MSFS bug where saving and loading of custom camera view is currently broken for zoom level other than 50.
* Fixed issue where full screen mode for pop out panel does not work on certain aircraft configuration.
* Add configurable keyboard shortcut to initiate pop out process (default is Ctrl-Shift-P). This keyboard shortcut can be configured in preference setting. This setting can be disabled to improve computing resource needed to constantly detect keyboard inputs.
* Updated logic to verify custom camera view has been loaded before starting pop out process.
* Fixed issue where full screen mode for pop out panel does not work on certain aircraft configuration.
## Version 4.0.1.2
* Hotfix - Fixed issue where using touch panel feature may freeze computer and the application.

View file

@ -32,7 +32,7 @@
<script>
// Define ready to fly button skip delay in seconds
const READY_TO_FLY_BUTTON_SKIP_DELAY = 2;
const READY_TO_FLY_BUTTON_SKIP_DELAY = 0;
// Click ready to fly button
Coherent.on("MissionStartup_Step", (step) => {