Merge X360 with Haptic into X360 profile

This commit is contained in:
Kamil Trzciński 2022-12-05 18:39:50 +01:00
parent d4b8a09395
commit 5066f3a0cb
4 changed files with 2 additions and 105 deletions

View file

@ -28,3 +28,4 @@ It does help this project on being supported.
- Fix haptics not being fired both sides
- Scale haptic intensity
- Add haptic style setting (disabled, weak, strong)
- Merge `X360 with Haptic` into `X360` profile

View file

@ -21,12 +21,7 @@ namespace SteamController
new Profiles.DesktopProfile() { Name = "Desktop" },
new Profiles.SteamProfile() { Name = "Steam", Visible = false },
new Profiles.SteamWithShorcutsProfile() { Name = "Steam with Shortcuts", Visible = false },
new Profiles.X360Profile() { Name = "X360" },
#if !DEBUG
new Profiles.X360RumbleProfile() { Name = "X360 with Rumble" },
#else
new Profiles.X360HapticProfile() { Name = "X360 with Haptic" }
#endif
new Profiles.X360HapticProfile() { Name = "X360" }
},
Managers = {
new Managers.ProcessManager(),
@ -315,11 +310,7 @@ namespace SteamController
{
Desktop = ProfilesSettings.BackPanelSettings.Desktop,
X360 = ProfilesSettings.BackPanelSettings.X360,
#if !DEBUG
X360Rumble = ProfilesSettings.X360RumbleSettings.Default,
#else
X360Haptic = ProfilesSettings.X360HapticSettings.Default,
#endif
Application = Settings.Default
}
};

View file

@ -1,51 +0,0 @@
using CommonHelpers;
using Nefarius.ViGEm.Client.Targets.Xbox360;
namespace SteamController.Profiles
{
public class X360RumbleProfile : X360Profile
{
public const ushort FeedbackMaxAmplitude = 255;
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)
{
return Status.Done;
}
if (context.X360.FeedbackLargeMotor.HasValue)
{
context.Steam.SetFeedback(
1, GetHapticAmplitude(context.X360.FeedbackLargeMotor), RumbleSettings.Period, FeedbackCount);
}
if (context.X360.FeedbackSmallMotor.HasValue)
{
context.Steam.SetFeedback(
0, GetHapticAmplitude(context.X360.FeedbackSmallMotor), RumbleSettings.Period, FeedbackCount);
}
context.X360.ResetFeedback();
return Status.Continue;
}
private ushort GetHapticAmplitude(byte? value)
{
if (value == 0)
return 0;
else if (RumbleSettings.FixedAmplitude > 0)
return value is not null ? (ushort)RumbleSettings.FixedAmplitude : (ushort)0;
else
return (ushort)(RumbleSettings.MaxAmplitude * (value ?? 0) / byte.MaxValue);
}
}
}

View file

@ -1,44 +0,0 @@
using System.ComponentModel;
using System.Configuration;
using WindowsInput;
namespace SteamController.ProfilesSettings
{
[Category("Settings")]
internal sealed class X360RumbleSettings : BaseSettings
{
public static X360RumbleSettings Default { get; } = (X360RumbleSettings)ApplicationSettingsBase.Synchronized(
new X360RumbleSettings("X360RumbleSettings"));
public X360RumbleSettings(String settingsKey) : base(settingsKey)
{
}
[UserScopedSettingAttribute()]
[DefaultSettingValueAttribute("0")]
[Description("Use Fixed Amplitude when configured. Set to 0 to disable")]
public byte FixedAmplitude
{
get { return ((byte)(this["FixedAmplitude"])); }
set { this["FixedAmplitude"] = value; }
}
[UserScopedSettingAttribute()]
[DefaultSettingValueAttribute("255")]
[Description("Scale rumble intensity up to Maximum Amplitude based on feedback request received")]
public byte MaxAmplitude
{
get { return ((byte)(this["MaxAmplitude"])); }
set { this["MaxAmplitude"] = value; }
}
[UserScopedSettingAttribute()]
[DefaultSettingValueAttribute("10")]
[Description("Rumble feedback period")]
public byte Period
{
get { return ((byte)(this["Period"])); }
set { this["Period"] = value; }
}
}
}