Skip to content

Commit

Permalink
qol
Browse files Browse the repository at this point in the history
  • Loading branch information
Valkirie committed Nov 3, 2022
1 parent f88a831 commit eb0673a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 26 deletions.
12 changes: 2 additions & 10 deletions HandheldCompanion/Managers/HotkeysManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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":
{
Expand Down
8 changes: 4 additions & 4 deletions HandheldCompanion/Managers/InputsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -211,7 +211,7 @@ private static void CheckForSequence(bool IsKeyDown, bool IsKeyUp)
break;
}

TriggerRaised?.Invoke(key, chord, IsKeyDown);
TriggerRaised?.Invoke(key, chord, IsKeyDown, IsKeyUp);
}
}
}
Expand Down Expand Up @@ -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);
}
}
}
15 changes: 4 additions & 11 deletions HandheldCompanion/Views/Windows/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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)
{
Expand All @@ -364,6 +354,9 @@ private void InputsManager_TriggerRaised(string listener, InputsChord input, boo
case "overlayTrackpads":
overlayTrackpad.UpdateVisibility();
break;
case "shortcutMainwindow":
SwapWindowState();
break;
}
}

Expand Down
2 changes: 1 addition & 1 deletion HandheldCompanion/Views/Windows/OverlayQuickTools.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit eb0673a

Please sign in to comment.