All SteamController settings are stored in .ini file in root folder

This commit is contained in:
Kamil Trzciński 2022-12-08 10:24:40 +01:00
parent 9adb25be21
commit 658898d632
10 changed files with 160 additions and 145 deletions

View file

@ -39,7 +39,7 @@ namespace SteamController.Managers
Settings.Default.SettingChanging -= UnlockControllerFiles;
}
private void UnlockControllerFiles(object sender, System.Configuration.SettingChangingEventArgs e)
private void UnlockControllerFiles(string key)
{
SetSteamControllerFilesLock(false);
}

View file

@ -4,7 +4,7 @@ using System.Configuration;
namespace SteamController.ProfilesSettings
{
[Category("Mappings")]
internal abstract class BackPanelSettings : BaseSettings
internal abstract class BackPanelSettings : CommonHelpers.BaseSettings
{
private const String MappingsDescription = @"Only some of those keys do work. Allowed mappings are to be changed in future release.";
@ -12,40 +12,32 @@ namespace SteamController.ProfilesSettings
{
}
[UserScopedSettingAttribute()]
[DefaultSettingValueAttribute("None")]
[Description(MappingsDescription)]
public VirtualKeyCode L4_KEY
{
get { return ((VirtualKeyCode)(this["L4_KEY"])); }
set { this["L4_KEY"] = value; }
get { return Get<VirtualKeyCode>("L4_KEY", VirtualKeyCode.None); }
set { Set("L4_KEY", value); }
}
[UserScopedSettingAttribute()]
[DefaultSettingValueAttribute("None")]
[Description(MappingsDescription)]
public VirtualKeyCode L5_KEY
{
get { return ((VirtualKeyCode)(this["L5_KEY"])); }
set { this["L5_KEY"] = value; }
get { return Get<VirtualKeyCode>("L5_KEY", VirtualKeyCode.None); }
set { Set("L5_KEY", value); }
}
[UserScopedSettingAttribute()]
[DefaultSettingValueAttribute("None")]
[Description(MappingsDescription)]
public VirtualKeyCode R4_KEY
{
get { return ((VirtualKeyCode)(this["R4_KEY"])); }
set { this["R4_KEY"] = value; }
get { return Get<VirtualKeyCode>("R4_KEY", VirtualKeyCode.None); }
set { Set("R4_KEY", value); }
}
[UserScopedSettingAttribute()]
[DefaultSettingValueAttribute("None")]
[Description(MappingsDescription)]
public VirtualKeyCode R5_KEY
{
get { return ((VirtualKeyCode)(this["R5_KEY"])); }
set { this["R5_KEY"] = value; }
get { return Get<VirtualKeyCode>("R5_KEY", VirtualKeyCode.None); }
set { Set("R5_KEY", value); }
}
}
}

View file

@ -1,23 +0,0 @@
using System.ComponentModel;
using System.Configuration;
using WindowsInput;
namespace SteamController.ProfilesSettings
{
[TypeConverter(typeof(ExpandableObjectConverter))]
internal abstract class BaseSettings : ApplicationSettingsBase
{
public BaseSettings(String settingsKey) : base(settingsKey)
{
PropertyChanged += delegate
{
Save();
};
}
public override string ToString()
{
return "";
}
}
}

View file

@ -5,10 +5,9 @@ namespace SteamController.ProfilesSettings
{
internal class DesktopPanelSettings : BackPanelSettings
{
public static DesktopPanelSettings Default { get; } = (DesktopPanelSettings)ApplicationSettingsBase.Synchronized(
new DesktopPanelSettings("DesktopPanelSettings"));
public static DesktopPanelSettings Default { get; } = new DesktopPanelSettings();
public DesktopPanelSettings(String settingsKey) : base(settingsKey)
public DesktopPanelSettings() : base("DesktopPanelSettings")
{
}
}

View file

@ -7,47 +7,38 @@ namespace SteamController.ProfilesSettings
{
private const String MappingsDescription = @"Mappings are to be changed in future release.";
public static X360BackPanelSettings Default { get; } = (X360BackPanelSettings)ApplicationSettingsBase.Synchronized(
new X360BackPanelSettings("X360BackPanelSettings"));
public static X360BackPanelSettings Default { get; } = new X360BackPanelSettings();
public X360BackPanelSettings(String settingsKey) : base(settingsKey)
public X360BackPanelSettings() : base("X360BackPanelSettings")
{
}
[UserScopedSettingAttribute()]
[DefaultSettingValueAttribute("None")]
[Description(MappingsDescription)]
public VirtualX360Code L4_X360
{
get { return ((VirtualX360Code)(this["L4_X360"])); }
set { this["L4_X360"] = value; }
get { return Get<VirtualX360Code>("L4_X360", VirtualX360Code.None); }
set { Set("L4_X360", value); }
}
[UserScopedSettingAttribute()]
[DefaultSettingValueAttribute("None")]
[Description(MappingsDescription)]
public VirtualX360Code L5_X360
{
get { return ((VirtualX360Code)(this["L5_X360"])); }
set { this["L5_X360"] = value; }
get { return Get<VirtualX360Code>("L5_X360", VirtualX360Code.None); }
set { Set("L5_X360", value); }
}
[UserScopedSettingAttribute()]
[DefaultSettingValueAttribute("None")]
[Description(MappingsDescription)]
public VirtualX360Code R4_X360
{
get { return ((VirtualX360Code)(this["R4_X360"])); }
set { this["R4_X360"] = value; }
get { return Get<VirtualX360Code>("R4_X360", VirtualX360Code.None); }
set { Set("R4_X360", value); }
}
[UserScopedSettingAttribute()]
[DefaultSettingValueAttribute("None")]
[Description(MappingsDescription)]
public VirtualX360Code R5_X360
{
get { return ((VirtualX360Code)(this["R5_X360"])); }
set { this["R5_X360"] = value; }
get { return Get<VirtualX360Code>("R5_X360", VirtualX360Code.None); }
set { Set("R5_X360", value); }
}
}
}

View file

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

View file

@ -5,35 +5,28 @@ namespace SteamController
{
[Category("Settings")]
[TypeConverter(typeof(ExpandableObjectConverter))]
internal sealed partial class Settings : ApplicationSettingsBase
internal sealed partial class Settings : CommonHelpers.BaseSettings
{
public static readonly Settings Default = (Settings)Synchronized(new Settings());
public static readonly Settings Default = new Settings();
private static readonly ProfilesSettings.Helpers.ProfileName DefaultProfileDefault = new ProfilesSettings.Helpers.ProfileName("Default");
public Settings()
public Settings() : base("Settings")
{
PropertyChanged += delegate
{
Save();
};
}
[UserScopedSetting]
[DefaultSettingValue("False")]
[BrowsableAttribute(false)]
public bool EnableSteamDetection
{
get { return ((bool)(this["EnableSteamDetection"])); }
set { this["EnableSteamDetection"] = value; }
get { return Get<bool>("EnableSteamDetection", false); }
set { Set("EnableSteamDetection", value); }
}
[UserScopedSetting]
[DefaultSettingValue("Desktop")]
[Description("Default profile used when going back to Desktop mode")]
[BrowsableAttribute(true)]
public ProfilesSettings.Helpers.ProfileName DefaultProfile
{
get { return ((ProfilesSettings.Helpers.ProfileName)(this["DefaultProfile"])); }
set { this["DefaultProfile"] = value; }
get { return Get<ProfilesSettings.Helpers.ProfileName>("DefaultProfile", DefaultProfileDefault); }
set { Set("DefaultProfile", value); }
}
public enum ScrollMode : int
@ -42,14 +35,12 @@ namespace SteamController
DownScrollDown = 1
}
[UserScopedSetting]
[DefaultSettingValue("DownScrollDown")]
[Description("Scroll direction for right pad and joystick.")]
[BrowsableAttribute(true)]
public ScrollMode ScrollDirection
{
get { return ((ScrollMode)(this["ScrollDirection"])); }
set { this["ScrollDirection"] = value; }
get { return Get<ScrollMode>("ScrollDirection", ScrollMode.DownScrollDown); }
set { Set("ScrollDirection", value); }
}
public enum SteamControllerConfigsMode
@ -58,16 +49,14 @@ namespace SteamController
Overwrite
}
[UserScopedSetting]
[BrowsableAttribute(true)]
[DefaultSettingValue("Overwrite")]
[Description("This does replace Steam configuration for controllers to prevent double inputs. " +
"Might require going to Steam > Settings > Controller > Desktop to apply " +
"'SteamController provided empty configuration'.")]
public SteamControllerConfigsMode SteamControllerConfigs
{
get { return ((SteamControllerConfigsMode)(this["SteamControllerConfigs"])); }
set { this["SteamControllerConfigs"] = value; }
get { return Get<SteamControllerConfigsMode>("SteamControllerConfigs", SteamControllerConfigsMode.Overwrite); }
set { Set("SteamControllerConfigs", value); }
}
[UserScopedSetting]
@ -76,8 +65,8 @@ namespace SteamController
[Description("Show Touch Keyboard or CTRL+WIN+O")]
public bool ShowTouchKeyboard
{
get { return ((bool)(this["ShowTouchKeyboard"])); }
set { this["ShowTouchKeyboard"] = value; }
get { return Get<bool>("ShowTouchKeyboard", true); }
set { Set("ShowTouchKeyboard", value); }
}
public override string ToString()