Introduce X360 Haptic Profile (in DEBUG)

This commit is contained in:
Kamil Trzciński 2022-12-03 17:49:23 +01:00
parent a92a0661df
commit 8ffa5d967f
4 changed files with 82 additions and 9 deletions

View file

@ -22,7 +22,10 @@ namespace SteamController
new Profiles.SteamProfile() { Name = "Steam", Visible = false },
new Profiles.SteamWithShorcutsProfile() { Name = "Steam with Shortcuts", Visible = false },
new Profiles.X360Profile() { Name = "X360" },
new Profiles.X360RumbleProfile() { Name = "X360 with Rumble" }
new Profiles.X360RumbleProfile() { Name = "X360 with Rumble" },
#if DEBUG
new Profiles.X360HapticProfile() { Name = "X360 with Haptic" }
#endif
},
Managers = {
new Managers.ProcessManager(),
@ -305,6 +308,9 @@ namespace SteamController
Desktop = ProfilesSettings.BackPanelSettings.Desktop,
X360 = ProfilesSettings.BackPanelSettings.X360,
X360Rumble = ProfilesSettings.X360RumbleSettings.Default,
#if DEBUG
X360Haptic = ProfilesSettings.X360HapticSettings.Default,
#endif
Application = Settings.Default
}
};

View file

@ -0,0 +1,35 @@
using CommonHelpers;
using Nefarius.ViGEm.Client.Targets.Xbox360;
namespace SteamController.Profiles
{
public class X360HapticProfile : X360Profile
{
private ProfilesSettings.X360HapticSettings HapticSettings
{
get { return ProfilesSettings.X360HapticSettings.Default; }
}
public override Status Run(Context context)
{
if (base.Run(context).IsDone)
{
return Status.Done;
}
if (context.X360.FeedbackLargeMotor.GetValueOrDefault() > 0)
{
context.Steam.SendHaptic(1, 0);
}
if (context.X360.FeedbackSmallMotor.GetValueOrDefault() > 0)
{
context.Steam.SendHaptic(0, 0);
}
context.X360.ResetFeedback();
return Status.Continue;
}
}
}

View file

@ -0,0 +1,38 @@
using System.ComponentModel;
using System.Configuration;
using WindowsInput;
namespace SteamController.ProfilesSettings
{
[Category("Settings")]
internal sealed class X360HapticSettings : BaseSettings
{
public const sbyte MinIntensity = -2;
public const sbyte MaxIntensity = 10;
public static X360HapticSettings Default { get; } = (X360HapticSettings)ApplicationSettingsBase.Synchronized(
new X360HapticSettings("X360HapticSettings"));
public X360HapticSettings(String settingsKey) : base(settingsKey)
{
}
[UserScopedSettingAttribute()]
[DefaultSettingValueAttribute("0")]
[Description("Haptic intensity between -2dB and 10dB")]
public sbyte LeftIntensity
{
get { return ((sbyte)(this["LeftIntensity"])); }
set { this["LeftIntensity"] = Math.Clamp(value, MinIntensity, MaxIntensity); }
}
[UserScopedSettingAttribute()]
[DefaultSettingValueAttribute("0")]
[Description("Haptic intensity between -2dB and 10dB")]
public sbyte RightIntensity
{
get { return ((sbyte)(this["RightIntensity"])); }
set { this["RightIntensity"] = Math.Clamp(value, MinIntensity, MaxIntensity); }
}
}
}