steam-deck-tools/SteamController/Profiles/X360Profile.cs
Kamil Trzciński ecbd0407c0 Add SteamController implementation
This adds a Steam Shortcuts, Desktop Mode, and X360 Emulation
- Supports all Steam Shortcuts (including on-screen keyboard, and brightness)
- Supports Desktop mode (with a scroll on left pad and left stick), and trackpoint (on right stick)
- Supports X360 mode: hold Options for 1s to switch between Desktop and X360
- Holding Steam button enables Desktop like controls and stops passing all inputs to X360
2022-11-26 10:19:50 +01:00

67 lines
2.5 KiB
C#

using Nefarius.ViGEm.Client.Targets.Xbox360;
namespace SteamController.Profiles
{
public sealed class X360Profile : Profile
{
public override void Skipped(Context context)
{
if (!context.DesktopMode)
{
context.X360.Connected = true;
ControlButtons(context);
}
}
public override Status Run(Context context)
{
if (context.DesktopMode)
{
context.X360.Connected = false;
return Status.Continue;
}
context.Steam.LizardButtons = false;
context.Steam.LizardMouse = true;
context.X360.Connected = true;
// DPad
context.X360[Xbox360Button.Up] = context.Steam.BtnDpadUp;
context.X360[Xbox360Button.Down] = context.Steam.BtnDpadDown;
context.X360[Xbox360Button.Left] = context.Steam.BtnDpadLeft;
context.X360[Xbox360Button.Right] = context.Steam.BtnDpadRight;
// Buttons
context.X360[Xbox360Button.A] = context.Steam.BtnA;
context.X360[Xbox360Button.B] = context.Steam.BtnB;
context.X360[Xbox360Button.X] = context.Steam.BtnX;
context.X360[Xbox360Button.Y] = context.Steam.BtnY;
// Sticks
context.X360[Xbox360Axis.LeftThumbX] = context.Steam.LeftThumbX;
context.X360[Xbox360Axis.LeftThumbY] = context.Steam.LeftThumbY;
context.X360[Xbox360Axis.RightThumbX] = context.Steam.RightThumbX;
context.X360[Xbox360Axis.RightThumbY] = context.Steam.RightThumbY;
context.X360[Xbox360Button.LeftThumb] = context.Steam.BtnLeftStickPress;
context.X360[Xbox360Button.RightThumb] = context.Steam.BtnRightStickPress;
// Triggers
context.X360[Xbox360Slider.LeftTrigger] = context.Steam.LeftTrigger;
context.X360[Xbox360Slider.RightTrigger] = context.Steam.RightTrigger;
context.X360[Xbox360Button.LeftShoulder] = context.Steam.BtnL1;
context.X360[Xbox360Button.RightShoulder] = context.Steam.BtnR1;
ControlButtons(context);
return Status.Continue;
}
private void ControlButtons(Context context)
{
// Controls
context.X360[Xbox360Button.Guide] = context.Steam.BtnSteam.Pressed();
context.X360[Xbox360Button.Back] = context.Steam.BtnMenu;
context.X360[Xbox360Button.Start] = context.Steam.BtnOptions;
}
}
}