2022-11-24 22:37:24 +01:00
|
|
|
using System.Diagnostics;
|
|
|
|
|
using ExternalHelpers;
|
|
|
|
|
using PowerControl.Helpers;
|
|
|
|
|
using WindowsInput;
|
|
|
|
|
|
2022-12-08 20:57:20 +01:00
|
|
|
namespace SteamController.Profiles.Default
|
2022-11-24 22:37:24 +01:00
|
|
|
{
|
2022-12-08 20:57:20 +01:00
|
|
|
public abstract class GuideShortcutsProfile : ShortcutsProfile
|
2022-11-24 22:37:24 +01:00
|
|
|
{
|
|
|
|
|
public readonly TimeSpan HoldForKill = TimeSpan.FromSeconds(3);
|
|
|
|
|
public readonly TimeSpan HoldForClose = TimeSpan.FromSeconds(1);
|
|
|
|
|
|
2023-01-10 16:42:00 +01:00
|
|
|
protected override bool SteamShortcuts(Context c)
|
2022-11-24 22:37:24 +01:00
|
|
|
{
|
2023-01-10 16:42:00 +01:00
|
|
|
if (base.SteamShortcuts(c))
|
|
|
|
|
return true;
|
2022-11-24 22:37:24 +01:00
|
|
|
|
2022-12-10 10:29:37 +01:00
|
|
|
c.Steam.LizardButtons = SettingsDebug.Default.LizardButtons;
|
|
|
|
|
c.Steam.LizardMouse = SettingsDebug.Default.LizardMouse;
|
2022-11-25 10:56:17 +01:00
|
|
|
|
|
|
|
|
EmulateScrollOnLPad(c);
|
|
|
|
|
EmulateMouseOnRPad(c);
|
|
|
|
|
EmulateMouseOnRStick(c);
|
2022-11-24 22:37:24 +01:00
|
|
|
|
|
|
|
|
if (c.Steam.BtnA.Pressed())
|
|
|
|
|
{
|
|
|
|
|
c.Keyboard.KeyPress(VirtualKeyCode.RETURN);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-29 00:12:20 +01:00
|
|
|
if (c.Steam.BtnB.HoldOnce(HoldForClose, ShortcutConsumed))
|
2022-11-24 22:37:24 +01:00
|
|
|
{
|
2022-11-27 14:34:44 +01:00
|
|
|
Helpers.ForegroundProcess.Store();
|
|
|
|
|
|
2022-11-24 22:37:24 +01:00
|
|
|
// close application
|
|
|
|
|
c.Keyboard.KeyPress(VirtualKeyCode.LMENU, VirtualKeyCode.F4);
|
|
|
|
|
}
|
2022-11-29 00:12:20 +01:00
|
|
|
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);
|
|
|
|
|
}
|
2022-11-24 22:37:24 +01:00
|
|
|
|
|
|
|
|
if (c.Steam.BtnX.Pressed())
|
|
|
|
|
{
|
2022-12-10 11:05:34 +01:00
|
|
|
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:
|
2022-12-16 10:47:55 +01:00
|
|
|
if (!OnScreenKeyboard.Toggle())
|
|
|
|
|
{
|
|
|
|
|
// Fallback to CTRL+WIN+O
|
|
|
|
|
c.Keyboard.KeyPress(new VirtualKeyCode[] { VirtualKeyCode.LCONTROL, VirtualKeyCode.LWIN }, VirtualKeyCode.VK_O);
|
|
|
|
|
}
|
2022-12-10 11:05:34 +01:00
|
|
|
break;
|
|
|
|
|
}
|
2022-11-24 22:37:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-27 15:32:23 +01:00
|
|
|
if (c.Steam.BtnVirtualLeftThumbUp.JustPressed() || c.Steam.BtnVirtualLeftThumbUp.HoldRepeat(ShortcutConsumed))
|
2022-11-24 22:37:24 +01:00
|
|
|
{
|
|
|
|
|
WindowsSettingsBrightnessController.Increase(5);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-27 15:32:23 +01:00
|
|
|
if (c.Steam.BtnVirtualLeftThumbDown.JustPressed() || c.Steam.BtnVirtualLeftThumbDown.HoldRepeat(ShortcutConsumed))
|
2022-11-24 22:37:24 +01:00
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
2022-11-27 09:49:07 +01:00
|
|
|
|
2022-11-27 10:26:43 +01:00
|
|
|
// Additional binding for tool hotkeys (Lossless Fullscreen is nice)
|
2022-11-27 14:21:46 +01:00
|
|
|
if (c.Steam.BtnDpadUp.Pressed())
|
2022-11-27 09:49:07 +01:00
|
|
|
{
|
|
|
|
|
c.Keyboard.KeyPress(new VirtualKeyCode[] { VirtualKeyCode.LCONTROL, VirtualKeyCode.LMENU }, VirtualKeyCode.VK_U);
|
2022-11-27 10:26:43 +01:00
|
|
|
}
|
2022-11-27 14:21:46 +01:00
|
|
|
|
2023-01-10 16:42:00 +01:00
|
|
|
return true;
|
2022-11-24 22:37:24 +01:00
|
|
|
}
|
|
|
|
|
|
2022-11-25 10:56:17 +01:00
|
|
|
protected void EmulateScrollOnLPad(Context c)
|
2022-11-24 22:37:24 +01:00
|
|
|
{
|
2022-11-25 10:56:17 +01:00
|
|
|
if (c.Steam.LPadX)
|
2022-11-24 22:37:24 +01:00
|
|
|
{
|
2022-11-27 10:01:27 +01:00
|
|
|
c.Mouse.HorizontalScroll(c.Steam.LPadX.DeltaValue * Context.PadToWhellSensitivity);
|
2022-11-25 10:56:17 +01:00
|
|
|
}
|
|
|
|
|
if (c.Steam.LPadY)
|
|
|
|
|
{
|
2022-12-04 20:39:00 +01:00
|
|
|
c.Mouse.VerticalScroll(c.Steam.LPadY.DeltaValue * Context.PadToWhellSensitivity * (double)Settings.Default.ScrollDirection);
|
2022-11-24 22:37:24 +01:00
|
|
|
}
|
2022-11-25 10:56:17 +01:00
|
|
|
}
|
2022-11-24 22:37:24 +01:00
|
|
|
|
2022-11-25 10:56:17 +01:00
|
|
|
protected void EmulateMouseOnRStick(Context c)
|
|
|
|
|
{
|
|
|
|
|
if (c.Steam.RightThumbX || c.Steam.RightThumbY)
|
2022-11-24 22:37:24 +01:00
|
|
|
{
|
2022-11-25 10:56:17 +01:00
|
|
|
c.Mouse.MoveBy(
|
2022-11-27 10:01:27 +01:00
|
|
|
c.Steam.RightThumbX.DeltaValue * Context.JoystickToMouseSensitivity,
|
|
|
|
|
-c.Steam.RightThumbY.DeltaValue * Context.JoystickToMouseSensitivity
|
2022-11-25 10:56:17 +01:00
|
|
|
);
|
2022-11-24 22:37:24 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-25 10:56:17 +01:00
|
|
|
protected void EmulateMouseOnRPad(Context c, bool useButtonTriggers = true)
|
2022-11-24 22:37:24 +01:00
|
|
|
{
|
2022-11-25 10:56:17 +01:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 22:37:24 +01:00
|
|
|
if (c.Steam.RPadX || c.Steam.RPadY)
|
|
|
|
|
{
|
|
|
|
|
c.Mouse.MoveBy(
|
2022-11-27 10:01:27 +01:00
|
|
|
c.Steam.RPadX.DeltaValue * Context.PadToMouseSensitivity,
|
|
|
|
|
-c.Steam.RPadY.DeltaValue * Context.PadToMouseSensitivity
|
2022-11-24 22:37:24 +01:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|