2022-11-25 10:56:17 +01:00
|
|
|
using WindowsInput;
|
|
|
|
|
|
2022-12-08 20:57:20 +01:00
|
|
|
namespace SteamController.Profiles.Default
|
2022-11-25 10:56:17 +01:00
|
|
|
{
|
2022-12-08 20:57:20 +01:00
|
|
|
public abstract class ShortcutsProfile : Profile
|
2022-11-25 10:56:17 +01:00
|
|
|
{
|
|
|
|
|
public const String ShortcutConsumed = "ShortcutsProfile";
|
|
|
|
|
public readonly TimeSpan HoldForShorcuts = TimeSpan.FromMilliseconds(200);
|
|
|
|
|
private readonly TimeSpan HoldToSwitchProfile = TimeSpan.FromSeconds(1);
|
2022-11-29 00:12:55 +01:00
|
|
|
private readonly TimeSpan HoldToSwitchDesktop = TimeSpan.FromSeconds(2);
|
2022-11-25 10:56:17 +01:00
|
|
|
|
|
|
|
|
public override Status Run(Context c)
|
|
|
|
|
{
|
2022-11-27 19:54:37 +01:00
|
|
|
// Steam + 3 dots simulate CTRL+SHIFT+ESCAPE
|
2022-11-25 10:56:17 +01:00
|
|
|
if (c.Steam.BtnSteam.Hold(HoldForShorcuts, ShortcutConsumed) && c.Steam.BtnQuickAccess.HoldOnce(HoldForShorcuts, ShortcutConsumed))
|
|
|
|
|
{
|
2022-11-27 19:54:37 +01:00
|
|
|
// Simulate CTRL+ALT+DELETE behavior (not working)
|
|
|
|
|
// c.Keyboard.KeyPress(new VirtualKeyCode[] { VirtualKeyCode.LCONTROL, VirtualKeyCode.LMENU }, VirtualKeyCode.DELETE);
|
|
|
|
|
// We can send CTRL+SHIFT+ESCAPE to bring up Task Manager at least
|
|
|
|
|
c.Keyboard.KeyPress(new VirtualKeyCode[] { VirtualKeyCode.LCONTROL, VirtualKeyCode.SHIFT }, VirtualKeyCode.ESCAPE);
|
2022-11-25 10:56:17 +01:00
|
|
|
return Status.Done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Hold options for 1s to use next profile, or 3 seconds to switch between desktop-mode
|
|
|
|
|
if (c.Steam.BtnOptions.HoldOnce(HoldToSwitchProfile, ShortcutConsumed))
|
|
|
|
|
{
|
|
|
|
|
if (!c.SelectNext())
|
2022-11-28 23:43:46 +01:00
|
|
|
c.BackToDefault();
|
2022-11-25 10:56:17 +01:00
|
|
|
return Status.Done;
|
|
|
|
|
}
|
2022-11-27 09:19:34 +01:00
|
|
|
else if (c.Steam.BtnOptions.HoldChain(HoldToSwitchDesktop, ShortcutConsumed, "SwitchToDesktop"))
|
2022-11-25 10:56:17 +01:00
|
|
|
{
|
2022-11-28 23:43:46 +01:00
|
|
|
c.BackToDefault();
|
2022-11-25 10:56:17 +01:00
|
|
|
return Status.Done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Always consume 3 dots
|
|
|
|
|
if (c.Steam.BtnQuickAccess.Hold(HoldForShorcuts, ShortcutConsumed))
|
|
|
|
|
{
|
|
|
|
|
return Status.Done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (c.Steam.BtnSteam.Hold(HoldForShorcuts, ShortcutConsumed))
|
|
|
|
|
{
|
2023-01-10 16:42:00 +01:00
|
|
|
if (SteamShortcuts(c))
|
2022-11-25 10:56:17 +01:00
|
|
|
{
|
|
|
|
|
return Status.Done;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Status.Continue;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-10 16:42:00 +01:00
|
|
|
protected virtual bool SteamShortcuts(Context c)
|
2022-11-25 10:56:17 +01:00
|
|
|
{
|
2022-12-10 10:50:31 +01:00
|
|
|
if (c.Steam.BtnOptions.Pressed())
|
2022-11-25 10:56:17 +01:00
|
|
|
{
|
|
|
|
|
c.Keyboard.KeyPress(VirtualKeyCode.LWIN, VirtualKeyCode.TAB);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-10 10:50:31 +01:00
|
|
|
if (c.Steam.BtnMenu.Pressed())
|
2022-11-25 10:56:17 +01:00
|
|
|
{
|
|
|
|
|
c.Keyboard.KeyPress(VirtualKeyCode.F11);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|