mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2026-04-06 23:03:59 +00:00
Split Profiles into Profiles/Default and Profiles/Predefined
This commit is contained in:
parent
86b73001a2
commit
bdcb70d685
9 changed files with 19 additions and 26 deletions
|
|
@ -0,0 +1,31 @@
|
|||
using SteamController.ProfilesSettings;
|
||||
|
||||
namespace SteamController.Profiles.Default
|
||||
{
|
||||
public abstract class BackPanelShortcutsProfile : GuideShortcutsProfile
|
||||
{
|
||||
internal abstract ProfilesSettings.BackPanelSettings BackPanelSettings { get; }
|
||||
|
||||
public override Status Run(Context c)
|
||||
{
|
||||
if (base.Run(c).IsDone)
|
||||
{
|
||||
return Status.Done;
|
||||
}
|
||||
|
||||
BackPanelShortcuts(c);
|
||||
|
||||
return Status.Continue;
|
||||
}
|
||||
|
||||
protected virtual void BackPanelShortcuts(Context c)
|
||||
{
|
||||
var settings = BackPanelSettings;
|
||||
|
||||
c.Keyboard[settings.L4_KEY.ToWindowsInput()] = c.Steam.BtnL4;
|
||||
c.Keyboard[settings.L5_KEY.ToWindowsInput()] = c.Steam.BtnL5;
|
||||
c.Keyboard[settings.R4_KEY.ToWindowsInput()] = c.Steam.BtnR4;
|
||||
c.Keyboard[settings.R5_KEY.ToWindowsInput()] = c.Steam.BtnR5;
|
||||
}
|
||||
}
|
||||
}
|
||||
177
SteamController/Profiles/Default/GuideShortcutsProfile.cs
Normal file
177
SteamController/Profiles/Default/GuideShortcutsProfile.cs
Normal file
|
|
@ -0,0 +1,177 @@
|
|||
using System.Diagnostics;
|
||||
using ExternalHelpers;
|
||||
using PowerControl.Helpers;
|
||||
using WindowsInput;
|
||||
|
||||
namespace SteamController.Profiles.Default
|
||||
{
|
||||
public abstract class GuideShortcutsProfile : ShortcutsProfile
|
||||
{
|
||||
public readonly TimeSpan HoldForKill = TimeSpan.FromSeconds(3);
|
||||
public readonly TimeSpan HoldForClose = TimeSpan.FromSeconds(1);
|
||||
|
||||
public override Status Run(Context c)
|
||||
{
|
||||
if (base.Run(c).IsDone)
|
||||
{
|
||||
return Status.Done;
|
||||
}
|
||||
|
||||
if (c.Steam.BtnSteam.Hold(HoldForShorcuts, ShortcutConsumed))
|
||||
{
|
||||
SteamShortcuts(c);
|
||||
return Status.Done;
|
||||
}
|
||||
|
||||
return Status.Continue;
|
||||
}
|
||||
|
||||
private void SteamShortcuts(Context c)
|
||||
{
|
||||
c.Steam.LizardButtons = SettingsDebug.Default.LizardButtons;
|
||||
c.Steam.LizardMouse = SettingsDebug.Default.LizardMouse;
|
||||
|
||||
EmulateScrollOnLPad(c);
|
||||
EmulateMouseOnRPad(c);
|
||||
EmulateMouseOnRStick(c);
|
||||
|
||||
if (c.Steam.BtnA.Pressed())
|
||||
{
|
||||
c.Keyboard.KeyPress(VirtualKeyCode.RETURN);
|
||||
}
|
||||
|
||||
if (c.Steam.BtnB.HoldOnce(HoldForClose, ShortcutConsumed))
|
||||
{
|
||||
Helpers.ForegroundProcess.Store();
|
||||
|
||||
// close application
|
||||
c.Keyboard.KeyPress(VirtualKeyCode.LMENU, VirtualKeyCode.F4);
|
||||
}
|
||||
else if (c.Steam.BtnB.HoldChain(HoldForKill, ShortcutConsumed, "KillProcess"))
|
||||
{
|
||||
// We want to KILL only the process that
|
||||
// was foreground last time
|
||||
Helpers.ForegroundProcess.Kill(true);
|
||||
}
|
||||
|
||||
if (c.Steam.BtnX.Pressed())
|
||||
{
|
||||
switch (Settings.Default.KeyboardStyle)
|
||||
{
|
||||
case Settings.KeyboardStyles.CTRL_WIN_O:
|
||||
c.Keyboard.KeyPress(new VirtualKeyCode[] { VirtualKeyCode.LCONTROL, VirtualKeyCode.LWIN }, VirtualKeyCode.VK_O);
|
||||
break;
|
||||
|
||||
case Settings.KeyboardStyles.WindowsTouch:
|
||||
OnScreenKeyboard.Toggle();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (c.Steam.BtnL1.Pressed())
|
||||
{
|
||||
if (Process.GetProcessesByName("Magnify").Any())
|
||||
{
|
||||
// close magnifier
|
||||
c.Keyboard.KeyPress(VirtualKeyCode.LWIN, VirtualKeyCode.ESCAPE);
|
||||
}
|
||||
else
|
||||
{
|
||||
// enable magnifier
|
||||
c.Keyboard.KeyPress(VirtualKeyCode.LWIN, VirtualKeyCode.OEM_PLUS);
|
||||
}
|
||||
}
|
||||
|
||||
if (c.Steam.BtnR1.Pressed())
|
||||
{
|
||||
// take screenshot
|
||||
c.Keyboard.KeyPress(VirtualKeyCode.LWIN, VirtualKeyCode.SNAPSHOT);
|
||||
}
|
||||
|
||||
if (c.Steam.BtnVirtualLeftThumbUp.JustPressed() || c.Steam.BtnVirtualLeftThumbUp.HoldRepeat(ShortcutConsumed))
|
||||
{
|
||||
WindowsSettingsBrightnessController.Increase(5);
|
||||
}
|
||||
|
||||
if (c.Steam.BtnVirtualLeftThumbDown.JustPressed() || c.Steam.BtnVirtualLeftThumbDown.HoldRepeat(ShortcutConsumed))
|
||||
{
|
||||
WindowsSettingsBrightnessController.Increase(-5);
|
||||
}
|
||||
|
||||
if (c.Steam.BtnDpadRight.Pressed())
|
||||
{
|
||||
c.Keyboard.KeyPress(VirtualKeyCode.RETURN);
|
||||
}
|
||||
|
||||
if (c.Steam.BtnDpadDown.Pressed())
|
||||
{
|
||||
c.Keyboard.KeyPress(VirtualKeyCode.TAB);
|
||||
}
|
||||
|
||||
if (c.Steam.BtnDpadLeft.Pressed())
|
||||
{
|
||||
c.Keyboard.KeyPress(VirtualKeyCode.ESCAPE);
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool AdditionalShortcuts(Context c)
|
||||
{
|
||||
if (base.AdditionalShortcuts(c))
|
||||
return true;
|
||||
|
||||
// Additional binding for tool hotkeys (Lossless Fullscreen is nice)
|
||||
if (c.Steam.BtnDpadUp.Pressed())
|
||||
{
|
||||
c.Keyboard.KeyPress(new VirtualKeyCode[] { VirtualKeyCode.LCONTROL, VirtualKeyCode.LMENU }, VirtualKeyCode.VK_U);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void EmulateScrollOnLPad(Context c)
|
||||
{
|
||||
if (c.Steam.LPadX)
|
||||
{
|
||||
c.Mouse.HorizontalScroll(c.Steam.LPadX.DeltaValue * Context.PadToWhellSensitivity);
|
||||
}
|
||||
if (c.Steam.LPadY)
|
||||
{
|
||||
c.Mouse.VerticalScroll(c.Steam.LPadY.DeltaValue * Context.PadToWhellSensitivity * (double)Settings.Default.ScrollDirection);
|
||||
}
|
||||
}
|
||||
|
||||
protected void EmulateMouseOnRStick(Context c)
|
||||
{
|
||||
if (c.Steam.RightThumbX || c.Steam.RightThumbY)
|
||||
{
|
||||
c.Mouse.MoveBy(
|
||||
c.Steam.RightThumbX.DeltaValue * Context.JoystickToMouseSensitivity,
|
||||
-c.Steam.RightThumbY.DeltaValue * Context.JoystickToMouseSensitivity
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
protected void EmulateMouseOnRPad(Context c, bool useButtonTriggers = true)
|
||||
{
|
||||
if (useButtonTriggers)
|
||||
{
|
||||
c.Mouse[Devices.MouseController.Button.Right] = c.Steam.BtnL2 || c.Steam.BtnLPadPress;
|
||||
c.Mouse[Devices.MouseController.Button.Left] = c.Steam.BtnR2 || c.Steam.BtnRPadPress;
|
||||
}
|
||||
else
|
||||
{
|
||||
c.Mouse[Devices.MouseController.Button.Right] = c.Steam.BtnLPadPress;
|
||||
c.Mouse[Devices.MouseController.Button.Left] = c.Steam.BtnRPadPress;
|
||||
}
|
||||
|
||||
if (c.Steam.RPadX || c.Steam.RPadY)
|
||||
{
|
||||
c.Mouse.MoveBy(
|
||||
c.Steam.RPadX.DeltaValue * Context.PadToMouseSensitivity,
|
||||
-c.Steam.RPadY.DeltaValue * Context.PadToMouseSensitivity
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
71
SteamController/Profiles/Default/ShortcutsProfile.cs
Normal file
71
SteamController/Profiles/Default/ShortcutsProfile.cs
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
using WindowsInput;
|
||||
|
||||
namespace SteamController.Profiles.Default
|
||||
{
|
||||
public abstract class ShortcutsProfile : Profile
|
||||
{
|
||||
public const String ShortcutConsumed = "ShortcutsProfile";
|
||||
public readonly TimeSpan HoldForShorcuts = TimeSpan.FromMilliseconds(200);
|
||||
private readonly TimeSpan HoldToSwitchProfile = TimeSpan.FromSeconds(1);
|
||||
private readonly TimeSpan HoldToSwitchDesktop = TimeSpan.FromSeconds(2);
|
||||
|
||||
public override Status Run(Context c)
|
||||
{
|
||||
// Steam + 3 dots simulate CTRL+SHIFT+ESCAPE
|
||||
if (c.Steam.BtnSteam.Hold(HoldForShorcuts, ShortcutConsumed) && c.Steam.BtnQuickAccess.HoldOnce(HoldForShorcuts, ShortcutConsumed))
|
||||
{
|
||||
// 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);
|
||||
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())
|
||||
c.BackToDefault();
|
||||
return Status.Done;
|
||||
}
|
||||
else if (c.Steam.BtnOptions.HoldChain(HoldToSwitchDesktop, ShortcutConsumed, "SwitchToDesktop"))
|
||||
{
|
||||
c.BackToDefault();
|
||||
return Status.Done;
|
||||
}
|
||||
|
||||
// Always consume 3 dots
|
||||
if (c.Steam.BtnQuickAccess.Hold(HoldForShorcuts, ShortcutConsumed))
|
||||
{
|
||||
return Status.Done;
|
||||
}
|
||||
|
||||
if (c.Steam.BtnSteam.Hold(HoldForShorcuts, ShortcutConsumed))
|
||||
{
|
||||
if (AdditionalShortcuts(c))
|
||||
{
|
||||
return Status.Done;
|
||||
}
|
||||
}
|
||||
|
||||
return Status.Continue;
|
||||
}
|
||||
|
||||
protected virtual bool AdditionalShortcuts(Context c)
|
||||
{
|
||||
if (c.Steam.BtnOptions.Pressed())
|
||||
{
|
||||
c.Keyboard.KeyPress(VirtualKeyCode.LWIN, VirtualKeyCode.TAB);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (c.Steam.BtnMenu.Pressed())
|
||||
{
|
||||
c.Keyboard.KeyPress(VirtualKeyCode.F11);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue