diff --git a/HandheldCompanion/Managers/HotkeysManager.cs b/HandheldCompanion/Managers/HotkeysManager.cs index 5c8d05e70..ad3eb543e 100644 --- a/HandheldCompanion/Managers/HotkeysManager.cs +++ b/HandheldCompanion/Managers/HotkeysManager.cs @@ -187,7 +187,7 @@ public static void SerializeHotkey(Hotkey hotkey, bool overwrite = false) } } - public static void TriggerRaised(string listener, InputsChord input, bool IsKeyDown) + public static void TriggerRaised(string listener, InputsChord input, bool IsKeyDown, bool IsKeyUp) { var fProcess = ProcessManager.GetForegroundProcess(); @@ -238,15 +238,7 @@ public static void TriggerRaised(string listener, InputsChord input, bool IsKeyD InputsManager.KeyPress(new VirtualKeyCode[] { VirtualKeyCode.LCONTROL, VirtualKeyCode.LSHIFT, VirtualKeyCode.ESCAPE }); break; case "shortcutGuide": - switch(IsKeyDown) - { - case true: - MainWindow.pipeClient.SendMessage(new PipeClientInput() { sButtons = (ushort)0x0400 }); - break; - case false: - MainWindow.pipeClient.SendMessage(new PipeClientInput() { sButtons = (ushort)0x000 }); - break; - } + MainWindow.pipeClient.SendMessage(new PipeClientInput() { sButtons = (ushort)(IsKeyDown ? 0x0400 : 0x000) }); break; case "suspendResumeTask": { diff --git a/HandheldCompanion/Managers/InputsManager.cs b/HandheldCompanion/Managers/InputsManager.cs index b718b24a3..2987b2678 100644 --- a/HandheldCompanion/Managers/InputsManager.cs +++ b/HandheldCompanion/Managers/InputsManager.cs @@ -70,7 +70,7 @@ public static class InputsManager public delegate void UpdatedEventHandler(Gamepad gamepad); public static event TriggerRaisedEventHandler TriggerRaised; - public delegate void TriggerRaisedEventHandler(string listener, InputsChord inputs, bool IsKeyDown); + public delegate void TriggerRaisedEventHandler(string listener, InputsChord inputs, bool IsKeyDown, bool IsKeyUp); public static event TriggerUpdatedEventHandler TriggerUpdated; public delegate void TriggerUpdatedEventHandler(string listener, InputsChord inputs, bool IsCombo); @@ -211,7 +211,7 @@ private static void CheckForSequence(bool IsKeyDown, bool IsKeyUp) break; } - TriggerRaised?.Invoke(key, chord, IsKeyDown); + TriggerRaised?.Invoke(key, chord, IsKeyDown, IsKeyUp); } } } @@ -697,10 +697,10 @@ private static void TriggerCreated(Hotkey hotkey) internal static void InvokeTrigger(Hotkey hotkey) { if (hotkey.inputsHotkey.OnKeyDown) - TriggerRaised?.Invoke(hotkey.inputsHotkey.Listener, hotkey.inputsChord, true); + TriggerRaised?.Invoke(hotkey.inputsHotkey.Listener, hotkey.inputsChord, true, false); if (hotkey.inputsHotkey.OnKeyUp) - TriggerRaised?.Invoke(hotkey.inputsHotkey.Listener, hotkey.inputsChord, false); + TriggerRaised?.Invoke(hotkey.inputsHotkey.Listener, hotkey.inputsChord, false, true); } } } \ No newline at end of file diff --git a/HandheldCompanion/Views/Windows/MainWindow.xaml.cs b/HandheldCompanion/Views/Windows/MainWindow.xaml.cs index f47de04bf..45d0efea9 100644 --- a/HandheldCompanion/Views/Windows/MainWindow.xaml.cs +++ b/HandheldCompanion/Views/Windows/MainWindow.xaml.cs @@ -329,16 +329,6 @@ private void loadManagers() } }; - InputsManager.TriggerRaised += (listener, input, iskeydown) => - { - switch (listener) - { - case "shortcutMainwindow": - SwapWindowState(); - break; - } - }; - stopwatch.Stop(); LogManager.LogDebug("Loaded in {0}", stopwatch.Elapsed); } @@ -351,7 +341,7 @@ private void SystemManager_Updated(PnPDevice device) settingsPage.UpdateDevice(device); } - private void InputsManager_TriggerRaised(string listener, InputsChord input, bool IsKeyDown) + private void InputsManager_TriggerRaised(string listener, InputsChord input, bool IsKeyDown, bool IsKeyUp) { switch (listener) { @@ -364,6 +354,9 @@ private void InputsManager_TriggerRaised(string listener, InputsChord input, boo case "overlayTrackpads": overlayTrackpad.UpdateVisibility(); break; + case "shortcutMainwindow": + SwapWindowState(); + break; } } diff --git a/HandheldCompanion/Views/Windows/OverlayQuickTools.xaml.cs b/HandheldCompanion/Views/Windows/OverlayQuickTools.xaml.cs index 34d986d37..1e8df2d98 100644 --- a/HandheldCompanion/Views/Windows/OverlayQuickTools.xaml.cs +++ b/HandheldCompanion/Views/Windows/OverlayQuickTools.xaml.cs @@ -100,7 +100,7 @@ private void navView_ItemInvoked(NavigationView sender, NavigationViewItemInvoke case "shortcutDesktop": case "shortcutESC": case "shortcutExpand": - HotkeysManager.TriggerRaised(navItemTag, null, false); + HotkeysManager.TriggerRaised(navItemTag, null, false, true); break; }