mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2026-01-31 04:34:26 +01:00
Improve VirtualX360Code to ToViGEm mapping
This commit is contained in:
parent
36d0169119
commit
26171639eb
|
|
@ -13,24 +13,6 @@ namespace SteamController.Devices
|
|||
public const ushort VendorID = 0x045E;
|
||||
public const ushort ProductID = 0x028E;
|
||||
|
||||
public static readonly Dictionary<VirtualX360Code, Xbox360Button> codeToButton = new Dictionary<VirtualX360Code, Xbox360Button>()
|
||||
{
|
||||
{ VirtualX360Code.X360_UP, Xbox360Button.Up },
|
||||
{ VirtualX360Code.X360_DOWN, Xbox360Button.Down },
|
||||
{ VirtualX360Code.X360_LEFT, Xbox360Button.Left },
|
||||
{ VirtualX360Code.X360_RIGHT, Xbox360Button.Right },
|
||||
{ VirtualX360Code.X360_BACK, Xbox360Button.Back },
|
||||
{ VirtualX360Code.X360_START, Xbox360Button.Start },
|
||||
{ VirtualX360Code.X360_A, Xbox360Button.A },
|
||||
{ VirtualX360Code.X360_B, Xbox360Button.B },
|
||||
{ VirtualX360Code.X360_X, Xbox360Button.X },
|
||||
{ VirtualX360Code.X360_Y, Xbox360Button.Y },
|
||||
{ VirtualX360Code.X360_LB, Xbox360Button.LeftShoulder },
|
||||
{ VirtualX360Code.X360_RB, Xbox360Button.RightShoulder },
|
||||
{ VirtualX360Code.X360_LS, Xbox360Button.LeftThumb },
|
||||
{ VirtualX360Code.X360_RS, Xbox360Button.RightThumb }
|
||||
};
|
||||
|
||||
private ViGEmClient? client;
|
||||
private IXbox360Controller? device;
|
||||
private bool isConnected;
|
||||
|
|
@ -188,22 +170,11 @@ namespace SteamController.Devices
|
|||
public byte LedNumber { get; private set; }
|
||||
public DateTime? FeedbackReceived { get; private set; }
|
||||
|
||||
public bool this[VirtualX360Code code]
|
||||
public bool this[Xbox360Button? button]
|
||||
{
|
||||
set
|
||||
{
|
||||
if (codeToButton.TryGetValue(code, out var button))
|
||||
{
|
||||
this[button] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool this[Xbox360Button button]
|
||||
{
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
if (value && button is not null)
|
||||
device?.SetButtonState(button, value);
|
||||
submitReport = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using Nefarius.ViGEm.Client.Targets.Xbox360;
|
||||
using SteamController.ProfilesSettings;
|
||||
|
||||
namespace SteamController.Profiles
|
||||
{
|
||||
|
|
@ -69,10 +70,10 @@ namespace SteamController.Profiles
|
|||
|
||||
var settings = ProfilesSettings.X360BackPanelSettings.Default;
|
||||
|
||||
c.X360[settings.L4_X360] = c.Steam.BtnL4;
|
||||
c.X360[settings.L5_X360] = c.Steam.BtnL5;
|
||||
c.X360[settings.R4_X360] = c.Steam.BtnR4;
|
||||
c.X360[settings.R5_X360] = c.Steam.BtnR5;
|
||||
c.X360[settings.L4_X360.ToViGEm()] = c.Steam.BtnL4;
|
||||
c.X360[settings.L5_X360.ToViGEm()] = c.Steam.BtnL5;
|
||||
c.X360[settings.R4_X360.ToViGEm()] = c.Steam.BtnR4;
|
||||
c.X360[settings.R5_X360.ToViGEm()] = c.Steam.BtnR5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
using Nefarius.ViGEm.Client.Targets.Xbox360;
|
||||
|
||||
namespace SteamController.ProfilesSettings
|
||||
{
|
||||
public enum VirtualX360Code
|
||||
|
|
@ -21,4 +23,32 @@ namespace SteamController.ProfilesSettings
|
|||
X360_LS,
|
||||
X360_RS
|
||||
}
|
||||
|
||||
public static class VirtualX360CodeExtensions
|
||||
{
|
||||
private static readonly Dictionary<VirtualX360Code, Xbox360Button> codeToButton = new Dictionary<VirtualX360Code, Xbox360Button>()
|
||||
{
|
||||
{ VirtualX360Code.X360_UP, Xbox360Button.Up },
|
||||
{ VirtualX360Code.X360_DOWN, Xbox360Button.Down },
|
||||
{ VirtualX360Code.X360_LEFT, Xbox360Button.Left },
|
||||
{ VirtualX360Code.X360_RIGHT, Xbox360Button.Right },
|
||||
{ VirtualX360Code.X360_BACK, Xbox360Button.Back },
|
||||
{ VirtualX360Code.X360_START, Xbox360Button.Start },
|
||||
{ VirtualX360Code.X360_A, Xbox360Button.A },
|
||||
{ VirtualX360Code.X360_B, Xbox360Button.B },
|
||||
{ VirtualX360Code.X360_X, Xbox360Button.X },
|
||||
{ VirtualX360Code.X360_Y, Xbox360Button.Y },
|
||||
{ VirtualX360Code.X360_LB, Xbox360Button.LeftShoulder },
|
||||
{ VirtualX360Code.X360_RB, Xbox360Button.RightShoulder },
|
||||
{ VirtualX360Code.X360_LS, Xbox360Button.LeftThumb },
|
||||
{ VirtualX360Code.X360_RS, Xbox360Button.RightThumb }
|
||||
};
|
||||
|
||||
public static Xbox360Button? ToViGEm(this VirtualX360Code code)
|
||||
{
|
||||
if (codeToButton.TryGetValue(code, out var button))
|
||||
return button;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue