Add configurable BackPanel keys (allowed mappings are subject to change)

This commit is contained in:
Kamil Trzciński 2022-11-28 09:34:17 +01:00
parent 8c26efa334
commit 68f51ff4f0
10 changed files with 214 additions and 6 deletions

View file

@ -0,0 +1,29 @@
namespace SteamController.Profiles
{
public abstract class DefaultBackPanelShortcutsProfile : DefaultGuideShortcutsProfile
{
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;
}
private void BackPanelShortcuts(Context c)
{
var settings = BackPanelSettings;
c.Keyboard[settings.L4] = c.Steam.BtnL4;
c.Keyboard[settings.L5] = c.Steam.BtnL5;
c.Keyboard[settings.R4] = c.Steam.BtnR4;
c.Keyboard[settings.R5] = c.Steam.BtnR5;
}
}
}

View file

@ -2,7 +2,7 @@ using WindowsInput;
namespace SteamController.Profiles
{
public sealed class DesktopProfile : DefaultGuideShortcutsProfile
public sealed class DesktopProfile : DefaultBackPanelShortcutsProfile
{
private const String Consumed = "DesktopProfileOwner";
@ -11,6 +11,11 @@ namespace SteamController.Profiles
IsDesktop = true;
}
internal override ProfilesSettings.BackPanelSettings BackPanelSettings
{
get { return ProfilesSettings.BackPanelSettings.Desktop; }
}
public override bool Selected(Context context)
{
return context.Enabled && context.DesktopMode;

View file

@ -2,13 +2,18 @@ using Nefarius.ViGEm.Client.Targets.Xbox360;
namespace SteamController.Profiles
{
public class X360Profile : DefaultGuideShortcutsProfile
public class X360Profile : DefaultBackPanelShortcutsProfile
{
public override bool Selected(Context context)
{
return context.Enabled && !context.DesktopMode && !context.SteamUsesSteamInput;
}
internal override ProfilesSettings.BackPanelSettings BackPanelSettings
{
get { return ProfilesSettings.BackPanelSettings.Desktop; }
}
public override Status Run(Context context)
{
context.Steam.LizardButtons = false;

View file

@ -9,6 +9,11 @@ namespace SteamController.Profiles
public const ushort FeedbackPeriod = 10;
public const ushort FeedbackCount = 1;
private ProfilesSettings.X360RumbleSettings RumbleSettings
{
get { return ProfilesSettings.X360RumbleSettings.Default; }
}
public override Status Run(Context context)
{
if (base.Run(context).IsDone)
@ -20,14 +25,14 @@ namespace SteamController.Profiles
{
Log.TraceLine("X360: Feedback Large: {0}", context.X360.FeedbackLargeMotor.Value);
context.Steam.SetHaptic(
1, GetHapticAmplitude(context.X360.FeedbackLargeMotor), FeedbackPeriod, FeedbackCount);
1, GetHapticAmplitude(context.X360.FeedbackLargeMotor), RumbleSettings.Period, FeedbackCount);
}
if (context.X360.FeedbackSmallMotor.HasValue)
{
Log.TraceLine("X360: Feedback Small: {0}", context.X360.FeedbackSmallMotor.Value);
context.Steam.SetHaptic(
0, GetHapticAmplitude(context.X360.FeedbackSmallMotor), FeedbackPeriod, FeedbackCount);
0, GetHapticAmplitude(context.X360.FeedbackSmallMotor), RumbleSettings.Period, FeedbackCount);
}
context.X360.ResetFeedback();
@ -37,7 +42,10 @@ namespace SteamController.Profiles
private ushort GetHapticAmplitude(byte? value)
{
return (ushort)(FeedbackMaxAmplitude * (value ?? 0) / byte.MaxValue);
if (RumbleSettings.FixedAmplitude > 0)
return value is not null ? (ushort)RumbleSettings.FixedAmplitude : (ushort)0;
else
return (ushort)(RumbleSettings.MaxAmplitude * (value ?? 0) / byte.MaxValue);
}
}
}