2022-11-24 22:37:24 +01:00
|
|
|
using System.Diagnostics;
|
2022-11-25 10:56:17 +01:00
|
|
|
using System.Runtime.InteropServices;
|
2022-11-24 22:37:24 +01:00
|
|
|
using ExternalHelpers;
|
|
|
|
|
using PowerControl.Helpers;
|
|
|
|
|
using WindowsInput;
|
|
|
|
|
|
|
|
|
|
namespace SteamController.Profiles
|
|
|
|
|
{
|
2022-11-25 21:28:43 +01:00
|
|
|
public abstract class DefaultGuideShortcutsProfile : DefaultShortcutsProfile
|
2022-11-24 22:37:24 +01:00
|
|
|
{
|
2022-11-25 10:56:17 +01:00
|
|
|
public static bool SteamModeLizardButtons = false;
|
|
|
|
|
public static bool SteamModeLizardMouse = true;
|
2022-11-24 22:37:24 +01:00
|
|
|
|
|
|
|
|
public readonly TimeSpan HoldForKill = TimeSpan.FromSeconds(3);
|
|
|
|
|
public readonly TimeSpan HoldForClose = TimeSpan.FromSeconds(1);
|
|
|
|
|
|
|
|
|
|
public override Status Run(Context c)
|
|
|
|
|
{
|
2022-11-25 10:56:17 +01:00
|
|
|
if (base.Run(c).IsDone)
|
2022-11-24 22:37:24 +01:00
|
|
|
{
|
2022-11-25 10:56:17 +01:00
|
|
|
return Status.Done;
|
2022-11-24 22:37:24 +01:00
|
|
|
}
|
|
|
|
|
|
2022-11-25 10:56:17 +01:00
|
|
|
if (c.Steam.BtnSteam.Hold(HoldForShorcuts, ShortcutConsumed))
|
2022-11-24 22:37:24 +01:00
|
|
|
{
|
|
|
|
|
SteamShortcuts(c);
|
2022-11-25 10:56:17 +01:00
|
|
|
return Status.Done;
|
2022-11-24 22:37:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Status.Continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SteamShortcuts(Context c)
|
|
|
|
|
{
|
2022-11-25 10:56:17 +01:00
|
|
|
c.Steam.LizardButtons = SteamModeLizardButtons;
|
|
|
|
|
c.Steam.LizardMouse = SteamModeLizardMouse;
|
|
|
|
|
|
|
|
|
|
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-25 10:56:17 +01:00
|
|
|
if (c.Steam.BtnB.HoldOnce(HoldForKill, ShortcutConsumed))
|
2022-11-24 22:37:24 +01:00
|
|
|
{
|
|
|
|
|
// kill application
|
|
|
|
|
}
|
2022-11-25 10:56:17 +01:00
|
|
|
else if (c.Steam.BtnB.HoldOnce(HoldForClose, ShortcutConsumed))
|
2022-11-24 22:37:24 +01:00
|
|
|
{
|
|
|
|
|
// close application
|
|
|
|
|
c.Keyboard.KeyPress(VirtualKeyCode.LMENU, VirtualKeyCode.F4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (c.Steam.BtnX.Pressed())
|
|
|
|
|
{
|
|
|
|
|
OnScreenKeyboard.Toggle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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-25 10:56:17 +01:00
|
|
|
if (c.Steam.BtnVirtualLeftThumbUp.HoldRepeat(ShortcutConsumed))
|
2022-11-24 22:37:24 +01:00
|
|
|
{
|
|
|
|
|
WindowsSettingsBrightnessController.Increase(5);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-25 10:56:17 +01:00
|
|
|
if (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-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-25 10:56:17 +01:00
|
|
|
c.Mouse.HorizontalScroll(c.Steam.LPadX.Scaled(Context.PadToWhellSensitivity, Devices.SteamController.SteamAxis.ScaledMode.Delta));
|
|
|
|
|
}
|
|
|
|
|
if (c.Steam.LPadY)
|
|
|
|
|
{
|
|
|
|
|
c.Mouse.VerticalScroll(c.Steam.LPadY.Scaled(Context.PadToWhellSensitivity, Devices.SteamController.SteamAxis.ScaledMode.Delta));
|
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(
|
|
|
|
|
c.Steam.RightThumbX.Scaled(Context.JoystickToMouseSensitivity, Devices.SteamController.SteamAxis.ScaledMode.AbsoluteTime),
|
|
|
|
|
-c.Steam.RightThumbY.Scaled(Context.JoystickToMouseSensitivity, Devices.SteamController.SteamAxis.ScaledMode.AbsoluteTime)
|
|
|
|
|
);
|
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(
|
|
|
|
|
c.Steam.RPadX.Scaled(Context.PadToMouseSensitivity, Devices.SteamController.SteamAxis.ScaledMode.Delta),
|
|
|
|
|
-c.Steam.RPadY.Scaled(Context.PadToMouseSensitivity, Devices.SteamController.SteamAxis.ScaledMode.Delta)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|