diff --git a/DomainModel/Setting/ApplicationSetting.cs b/DomainModel/Setting/ApplicationSetting.cs index c2640c4..8277695 100644 --- a/DomainModel/Setting/ApplicationSetting.cs +++ b/DomainModel/Setting/ApplicationSetting.cs @@ -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 IsUsedKeyboardShortcutChanged; } } diff --git a/DomainModel/Setting/AutoPopOutSetting.cs b/DomainModel/Setting/AutoPopOutSetting.cs index 3877d89..3f26116 100644 --- a/DomainModel/Setting/AutoPopOutSetting.cs +++ b/DomainModel/Setting/AutoPopOutSetting.cs @@ -7,11 +7,8 @@ namespace MSFSPopoutPanelManager.DomainModel.Setting public AutoPopOutSetting() { IsEnabled = true; - ReadyToFlyDelay = 3; } public bool IsEnabled { get; set; } - - public int ReadyToFlyDelay { get; set; } } } diff --git a/DomainModel/Setting/KeyboardShortcutSetting.cs b/DomainModel/Setting/KeyboardShortcutSetting.cs new file mode 100644 index 0000000..3d95a26 --- /dev/null +++ b/DomainModel/Setting/KeyboardShortcutSetting.cs @@ -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; } + } +} diff --git a/MainApp/UserControl/PreferenceDrawer.xaml b/MainApp/UserControl/PreferenceDrawer.xaml index f773551..a306b64 100644 --- a/MainApp/UserControl/PreferenceDrawer.xaml +++ b/MainApp/UserControl/PreferenceDrawer.xaml @@ -97,6 +97,10 @@ x:Name="CategoryGameRefocusSettings" Margin="0,0,0,10" Header="Game Refocus Settings" /> + - - Ready to Fly Button Delay - - - - - 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. - - - @@ -486,6 +466,72 @@ + + + + + Keyboard Shortcuts + + + + Enable using of keyboard shortcuts to control application. + + + + + + + + Configure key binding to initiate start pop out. + + + + + + diff --git a/MainApp/ViewModel/BaseViewModel.cs b/MainApp/ViewModel/BaseViewModel.cs index 9910581..8668e79 100644 --- a/MainApp/ViewModel/BaseViewModel.cs +++ b/MainApp/ViewModel/BaseViewModel.cs @@ -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 FormatStatusMessages(List messages) { List runs = new List(); diff --git a/MainApp/ViewModel/PopOutPanelCardViewModel.cs b/MainApp/ViewModel/PopOutPanelCardViewModel.cs index bb9acbd..a8500a3 100644 --- a/MainApp/ViewModel/PopOutPanelCardViewModel.cs +++ b/MainApp/ViewModel/PopOutPanelCardViewModel.cs @@ -129,19 +129,25 @@ namespace MSFSPopoutPanelManager.MainApp.ViewModel if (DataItem.IsEditingPanel) { ProfileData.ActiveProfile.CurrentMoveResizePanelId = DataItem.Id; - InputHookManager.StartKeyboardHook(); + + if (!AppSettingData.ApplicationSetting.KeyboardShortcutSetting.IsEnabled) + InputHookManager.StartKeyboardHook(); + InputHookManager.OnKeyUp -= HandleKeyUpEvent; InputHookManager.OnKeyUp += HandleKeyUpEvent; } else { ProfileData.ActiveProfile.CurrentMoveResizePanelId = Guid.Empty; + + if (!AppSettingData.ApplicationSetting.KeyboardShortcutSetting.IsEnabled) + InputHookManager.EndKeyboardHook(); + InputHookManager.OnKeyUp -= HandleKeyUpEvent; - InputHookManager.EndKeyboardHook(); } } - private void HandleKeyUpEvent(object? sender, KeyUpEventArgs e) + private void HandleKeyUpEvent(object sender, KeyUpEventArgs e) { PanelConfigPropertyName panelConfigPropertyName = PanelConfigPropertyName.None; diff --git a/MainApp/ViewModel/ProfileCardViewModel.cs b/MainApp/ViewModel/ProfileCardViewModel.cs index 9c055d8..6f35b23 100644 --- a/MainApp/ViewModel/ProfileCardViewModel.cs +++ b/MainApp/ViewModel/ProfileCardViewModel.cs @@ -129,7 +129,7 @@ namespace MSFSPopoutPanelManager.MainApp.ViewModel private void OnStartPopOut() { - if (IsDisabledAppInput) + if (Orchestrator.PanelPopOut.IsDisabledStartPopOut || !FlightSimData.IsInCockpit) return; Orchestrator.PanelPopOut.ManualPopOut(); @@ -162,8 +162,8 @@ namespace MSFSPopoutPanelManager.MainApp.ViewModel AutoGameRefocus = false }); } - else - { + else + { ProfileData.ActiveProfile.PanelConfigs.RemoveAll(p => p.PanelType == PanelType.HudBarWindow); } } @@ -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); } @@ -226,7 +226,7 @@ namespace MSFSPopoutPanelManager.MainApp.ViewModel Top = monitor.Y, Width = monitor.Width, Height = monitor.Height, - TouchEnabled = true + TouchEnabled = true }); } } diff --git a/Orchestration/KeyboardOrchestrator.cs b/Orchestration/KeyboardOrchestrator.cs new file mode 100644 index 0000000..5e0bf78 --- /dev/null +++ b/Orchestration/KeyboardOrchestrator.cs @@ -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(); + } + } +} diff --git a/Orchestration/MainOrchestrator.cs b/Orchestration/MainOrchestrator.cs index 6635272..bf17a3b 100644 --- a/Orchestration/MainOrchestrator.cs +++ b/Orchestration/MainOrchestrator.cs @@ -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); } diff --git a/Orchestration/PanelPopOutOrchestrator.cs b/Orchestration/PanelPopOutOrchestrator.cs index fe0c7cc..c358f0c 100644 --- a/Orchestration/PanelPopOutOrchestrator.cs +++ b/Orchestration/PanelPopOutOrchestrator.cs @@ -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 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 diff --git a/Orchestration/PanelSourceOrchestrator.cs b/Orchestration/PanelSourceOrchestrator.cs index e1bc130..75f61dc 100644 --- a/Orchestration/PanelSourceOrchestrator.cs +++ b/Orchestration/PanelSourceOrchestrator.cs @@ -175,7 +175,7 @@ namespace MSFSPopoutPanelManager.Orchestration { // Disable hooks if active InputHookManager.EndMouseHook(); - InputHookManager.EndKeyboardHook(); + //InputHookManager.EndKeyboardHook(); _profileData.ActiveProfile.CurrentMoveResizePanelId = Guid.Empty; diff --git a/Orchestration/ProfileData.cs b/Orchestration/ProfileData.cs index c21a43e..cadd814 100644 --- a/Orchestration/ProfileData.cs +++ b/Orchestration/ProfileData.cs @@ -242,7 +242,7 @@ namespace MSFSPopoutPanelManager.Orchestration public void ResetActiveProfile() { InputHookManager.EndMouseHook(); - InputHookManager.EndKeyboardHook(); + //InputHookManager.EndKeyboardHook(); if (ActiveProfile == null) return; diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 14bdc2f..90bfc0b 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -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. -* 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. +* 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. \ No newline at end of file diff --git a/Shared/ObservableObject.cs b/Shared/ObservableObject.cs index 903b369..5d5fa65 100644 --- a/Shared/ObservableObject.cs +++ b/Shared/ObservableObject.cs @@ -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; } } } diff --git a/VERSION.md b/VERSION.md index 239fe62..7c5968f 100644 --- a/VERSION.md +++ b/VERSION.md @@ -2,13 +2,17 @@
## 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. diff --git a/assets/Community/zzz-ready-to-fly-button-skipper/html_ui/pages/MissionStartup/MissionStartup.html b/assets/Community/zzz-ready-to-fly-button-skipper/html_ui/pages/MissionStartup/MissionStartup.html index d9da99b..02e3d4d 100644 --- a/assets/Community/zzz-ready-to-fly-button-skipper/html_ui/pages/MissionStartup/MissionStartup.html +++ b/assets/Community/zzz-ready-to-fly-button-skipper/html_ui/pages/MissionStartup/MissionStartup.html @@ -32,7 +32,7 @@