2022-12-02 11:27:45 +01:00
|
|
|
using CommonHelpers;
|
2022-11-24 22:37:24 +01:00
|
|
|
using ExternalHelpers;
|
2023-01-05 11:47:18 +01:00
|
|
|
using Microsoft.Win32;
|
2022-11-24 22:37:24 +01:00
|
|
|
using System.ComponentModel;
|
2022-11-25 07:48:01 +01:00
|
|
|
using System.Diagnostics;
|
2022-11-24 22:37:24 +01:00
|
|
|
|
|
|
|
|
namespace SteamController
|
|
|
|
|
{
|
|
|
|
|
internal class Controller : IDisposable
|
|
|
|
|
{
|
|
|
|
|
public const String Title = "Steam Controller";
|
2022-12-15 21:28:14 +01:00
|
|
|
public static readonly String TitleWithVersion = Title + " v" + Application.ProductVersion.ToString();
|
2022-11-24 22:37:24 +01:00
|
|
|
|
2023-01-05 11:47:18 +01:00
|
|
|
public const int ControllerDelayAfterResumeMs = 1000;
|
|
|
|
|
|
2022-12-10 14:39:42 +01:00
|
|
|
public static readonly Dictionary<String, Profiles.Profile> PreconfiguredUserProfiles = new Dictionary<String, Profiles.Profile>()
|
|
|
|
|
{
|
|
|
|
|
{ "*.desktop.cs", new Profiles.Predefined.DesktopProfile() { Name = "Desktop" } },
|
|
|
|
|
{ "*.x360.cs", new Profiles.Predefined.X360HapticProfile() { Name = "X360" } }
|
|
|
|
|
};
|
|
|
|
|
|
2022-11-24 22:37:24 +01:00
|
|
|
Container components = new Container();
|
|
|
|
|
NotifyIcon notifyIcon;
|
|
|
|
|
StartupManager startupManager = new StartupManager(Title);
|
|
|
|
|
|
2022-11-25 07:48:01 +01:00
|
|
|
Context context = new Context()
|
|
|
|
|
{
|
|
|
|
|
Profiles = {
|
2022-12-08 20:57:20 +01:00
|
|
|
new Profiles.Predefined.DesktopProfile() { Name = "Desktop" },
|
|
|
|
|
new Profiles.Predefined.SteamProfile() { Name = "Steam", Visible = false },
|
|
|
|
|
new Profiles.Predefined.SteamWithShorcutsProfile() { Name = "Steam with Shortcuts", Visible = false },
|
|
|
|
|
new Profiles.Predefined.X360HapticProfile() { Name = "X360" }
|
2022-11-25 10:56:17 +01:00
|
|
|
},
|
|
|
|
|
Managers = {
|
|
|
|
|
new Managers.ProcessManager(),
|
2022-11-29 21:39:54 +01:00
|
|
|
new Managers.SteamManager(),
|
2022-12-12 12:31:59 +01:00
|
|
|
new Managers.RTSSManager(),
|
2022-12-02 11:03:28 +01:00
|
|
|
new Managers.ProfileSwitcher(),
|
2022-12-02 11:29:06 +01:00
|
|
|
new Managers.SteamConfigsManager(),
|
2022-12-10 10:18:21 +01:00
|
|
|
new Managers.SharedDataManager(),
|
|
|
|
|
new Managers.SASManager()
|
2022-11-25 07:48:01 +01:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2022-12-15 21:28:14 +01:00
|
|
|
static Controller()
|
|
|
|
|
{
|
|
|
|
|
Dependencies.ValidateHidapi(TitleWithVersion);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 22:37:24 +01:00
|
|
|
public Controller()
|
|
|
|
|
{
|
2022-12-11 13:26:46 +01:00
|
|
|
Instance.OnUninstall(() =>
|
|
|
|
|
{
|
|
|
|
|
Helpers.SteamConfiguration.KillSteam();
|
|
|
|
|
Helpers.SteamConfiguration.WaitForSteamClose(5000);
|
|
|
|
|
Helpers.SteamConfiguration.BackupSteamConfig();
|
|
|
|
|
|
|
|
|
|
var steamControllerUpdate = Helpers.SteamConfiguration.UpdateControllerBlacklist(
|
|
|
|
|
Devices.SteamController.VendorID, Devices.SteamController.ProductID, false
|
|
|
|
|
);
|
|
|
|
|
var x360ControllerUpdate = Helpers.SteamConfiguration.UpdateControllerBlacklist(
|
|
|
|
|
Devices.Xbox360Controller.VendorID, Devices.Xbox360Controller.ProductID, false
|
|
|
|
|
);
|
|
|
|
|
Settings.Default.EnableSteamDetection = false;
|
|
|
|
|
startupManager.Startup = false;
|
|
|
|
|
});
|
|
|
|
|
|
2022-11-24 22:37:24 +01:00
|
|
|
Instance.RunOnce(TitleWithVersion, "Global\\SteamController");
|
2022-12-11 02:35:46 +01:00
|
|
|
Instance.RunUpdater(TitleWithVersion);
|
2022-11-24 22:37:24 +01:00
|
|
|
|
2022-12-10 11:23:47 +01:00
|
|
|
if (Instance.WantsRunOnStartup)
|
|
|
|
|
startupManager.Startup = true;
|
|
|
|
|
|
2022-12-10 14:39:42 +01:00
|
|
|
notifyIcon = new NotifyIcon(components);
|
|
|
|
|
notifyIcon.Icon = WindowsDarkMode.IsDarkModeEnabled ? Resources.microsoft_xbox_controller_off_white : Resources.microsoft_xbox_controller_off;
|
|
|
|
|
notifyIcon.Text = TitleWithVersion;
|
|
|
|
|
notifyIcon.Visible = true;
|
|
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
|
foreach (var profile in Profiles.Dynamic.RoslynDynamicProfile.GetUserProfiles(PreconfiguredUserProfiles))
|
|
|
|
|
{
|
|
|
|
|
profile.ErrorsChanged += (errors) =>
|
|
|
|
|
{
|
|
|
|
|
notifyIcon.ShowBalloonTip(
|
|
|
|
|
3000, profile.Name,
|
|
|
|
|
String.Join("\n", errors),
|
|
|
|
|
ToolTipIcon.Error
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
profile.Compile();
|
|
|
|
|
profile.Watch();
|
|
|
|
|
context.Profiles.Add(profile);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// Set available profiles
|
|
|
|
|
ProfilesSettings.Helpers.ProfileStringConverter.Profiles = context.Profiles.
|
|
|
|
|
Where((profile) => profile.Visible).
|
|
|
|
|
Select((profile) => profile.Name).ToArray();
|
|
|
|
|
|
2022-11-25 07:48:01 +01:00
|
|
|
var contextMenu = new ContextMenuStrip(components);
|
|
|
|
|
|
|
|
|
|
var enabledItem = new ToolStripMenuItem("&Enabled");
|
2022-11-25 10:56:17 +01:00
|
|
|
enabledItem.Click += delegate { context.RequestEnable = !context.RequestEnable; };
|
|
|
|
|
contextMenu.Opening += delegate { enabledItem.Checked = context.RequestEnable; };
|
2022-11-25 07:48:01 +01:00
|
|
|
contextMenu.Items.Add(enabledItem);
|
2022-11-25 21:28:43 +01:00
|
|
|
contextMenu.Items.Add(new ToolStripSeparator());
|
2022-11-25 07:48:01 +01:00
|
|
|
|
2022-11-25 21:28:43 +01:00
|
|
|
foreach (var profile in context.Profiles)
|
2022-11-24 22:37:24 +01:00
|
|
|
{
|
2022-11-25 21:28:43 +01:00
|
|
|
if (profile.Name == "" || !profile.Visible)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
var profileItem = new ToolStripMenuItem(profile.Name);
|
2022-11-28 20:29:32 +01:00
|
|
|
profileItem.Click += delegate { context.SelectProfile(profile.Name); };
|
2022-12-10 14:39:42 +01:00
|
|
|
contextMenu.Opening += delegate
|
|
|
|
|
{
|
|
|
|
|
profileItem.Checked = context.CurrentProfile == profile;
|
|
|
|
|
profileItem.ToolTipText = String.Join("\n", profile.Errors ?? new string[0]);
|
|
|
|
|
profileItem.Enabled = profile.Errors is null;
|
|
|
|
|
};
|
2022-11-25 21:28:43 +01:00
|
|
|
contextMenu.Items.Add(profileItem);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-25 07:48:01 +01:00
|
|
|
contextMenu.Items.Add(new ToolStripSeparator());
|
2022-11-24 22:37:24 +01:00
|
|
|
|
2023-01-21 21:41:55 +01:00
|
|
|
var setupSteamItem = new ToolStripMenuItem("Setup &Steam");
|
|
|
|
|
setupSteamItem.Click += delegate { SetupSteam(true); };
|
|
|
|
|
contextMenu.Items.Add(setupSteamItem);
|
|
|
|
|
contextMenu.Items.Add(new ToolStripSeparator());
|
2022-11-25 21:28:43 +01:00
|
|
|
|
2022-12-12 18:54:28 +01:00
|
|
|
var settingsItem = contextMenu.Items.Add("&Settings");
|
|
|
|
|
settingsItem.Click += Settings_Click;
|
|
|
|
|
|
|
|
|
|
var shortcutsItem = contextMenu.Items.Add("&Shortcuts");
|
|
|
|
|
shortcutsItem.Click += delegate { Process.Start("explorer.exe", "https://steam-deck-tools.ayufan.dev/shortcuts.html"); };
|
|
|
|
|
|
|
|
|
|
contextMenu.Items.Add(new ToolStripSeparator());
|
|
|
|
|
|
2022-11-24 22:37:24 +01:00
|
|
|
if (startupManager.IsAvailable)
|
|
|
|
|
{
|
|
|
|
|
var startupItem = new ToolStripMenuItem("Run On Startup");
|
|
|
|
|
startupItem.Checked = startupManager.Startup;
|
2022-11-25 07:48:01 +01:00
|
|
|
startupItem.Click += delegate { startupItem.Checked = startupManager.Startup = !startupManager.Startup; };
|
2022-11-24 22:37:24 +01:00
|
|
|
contextMenu.Items.Add(startupItem);
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-11 02:35:46 +01:00
|
|
|
var checkForUpdatesItem = contextMenu.Items.Add("&Check for Updates");
|
|
|
|
|
checkForUpdatesItem.Click += delegate { Instance.RunUpdater(TitleWithVersion, true); };
|
2022-11-28 09:34:17 +01:00
|
|
|
|
2022-12-11 02:35:46 +01:00
|
|
|
var helpItem = contextMenu.Items.Add("&Help");
|
|
|
|
|
helpItem.Click += delegate { Process.Start("explorer.exe", "https://steam-deck-tools.ayufan.dev"); };
|
|
|
|
|
|
2022-11-24 22:37:24 +01:00
|
|
|
contextMenu.Items.Add(new ToolStripSeparator());
|
|
|
|
|
|
|
|
|
|
var exitItem = contextMenu.Items.Add("&Exit");
|
2022-11-25 07:48:01 +01:00
|
|
|
exitItem.Click += delegate { Application.Exit(); };
|
2022-11-24 22:37:24 +01:00
|
|
|
|
|
|
|
|
notifyIcon.ContextMenuStrip = contextMenu;
|
|
|
|
|
|
|
|
|
|
var contextStateUpdate = new System.Windows.Forms.Timer(components);
|
|
|
|
|
contextStateUpdate.Interval = 250;
|
|
|
|
|
contextStateUpdate.Enabled = true;
|
|
|
|
|
contextStateUpdate.Tick += ContextStateUpdate_Tick;
|
|
|
|
|
|
2022-11-28 23:43:46 +01:00
|
|
|
context.SelectDefault = () =>
|
|
|
|
|
{
|
2022-12-05 21:09:42 +01:00
|
|
|
if (!context.SelectProfile(Settings.Default.DefaultProfile, true))
|
2022-12-12 20:30:53 +01:00
|
|
|
context.SelectProfile(context.Profiles.First().Name, true);
|
2022-11-28 23:43:46 +01:00
|
|
|
};
|
|
|
|
|
context.BackToDefault();
|
|
|
|
|
|
2022-11-26 14:27:21 +01:00
|
|
|
context.ProfileChanged += (profile) =>
|
|
|
|
|
{
|
|
|
|
|
#if false
|
|
|
|
|
notifyIcon.ShowBalloonTip(
|
|
|
|
|
1000,
|
|
|
|
|
TitleWithVersion,
|
|
|
|
|
String.Format("Selected profile: {0}", profile.Name),
|
|
|
|
|
ToolTipIcon.Info
|
|
|
|
|
);
|
|
|
|
|
#endif
|
|
|
|
|
};
|
|
|
|
|
|
2023-01-21 21:41:55 +01:00
|
|
|
SetupSteam(false);
|
|
|
|
|
|
2022-12-02 11:10:58 +01:00
|
|
|
context.Start();
|
2023-01-05 11:47:18 +01:00
|
|
|
|
|
|
|
|
Microsoft.Win32.SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Log.TraceLine("SystemEvents_PowerModeChanged: {0}", e.Mode);
|
|
|
|
|
|
|
|
|
|
switch (e.Mode)
|
|
|
|
|
{
|
|
|
|
|
case PowerModes.Suspend:
|
|
|
|
|
context.Stop();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PowerModes.Resume:
|
|
|
|
|
context.Start(ControllerDelayAfterResumeMs);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-11-24 22:37:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ContextStateUpdate_Tick(object? sender, EventArgs e)
|
|
|
|
|
{
|
2022-11-28 20:29:32 +01:00
|
|
|
context.Tick();
|
2022-11-24 22:37:24 +01:00
|
|
|
|
2022-11-28 23:43:46 +01:00
|
|
|
var isDesktop = context.CurrentProfile?.IsDesktop ?? false;
|
2022-12-14 21:10:45 +01:00
|
|
|
var monitorOffIco = WindowsDarkMode.IsDarkModeEnabled ? Resources.monitor_off_white : Resources.monitor_off;
|
|
|
|
|
var monitorOnIco = WindowsDarkMode.IsDarkModeEnabled ? Resources.monitor_white : Resources.monitor;
|
|
|
|
|
var controllerOffIco = WindowsDarkMode.IsDarkModeEnabled ?
|
|
|
|
|
Resources.microsoft_xbox_controller_off_white :
|
|
|
|
|
Resources.microsoft_xbox_controller_off;
|
|
|
|
|
var controllerOnIco = WindowsDarkMode.IsDarkModeEnabled ?
|
|
|
|
|
Resources.microsoft_xbox_controller_white :
|
|
|
|
|
Resources.microsoft_xbox_controller;
|
2022-11-28 23:43:46 +01:00
|
|
|
|
2022-12-10 10:18:21 +01:00
|
|
|
if (!context.KeyboardMouseValid)
|
2022-11-24 22:37:24 +01:00
|
|
|
{
|
2022-11-25 07:48:01 +01:00
|
|
|
notifyIcon.Text = TitleWithVersion + ". Cannot send input.";
|
2022-11-24 22:37:24 +01:00
|
|
|
notifyIcon.Icon = Resources.microsoft_xbox_controller_off_red;
|
|
|
|
|
}
|
|
|
|
|
else if (!context.X360.Valid)
|
|
|
|
|
{
|
|
|
|
|
notifyIcon.Text = TitleWithVersion + ". Missing ViGEm?";
|
|
|
|
|
notifyIcon.Icon = Resources.microsoft_xbox_controller_red;
|
|
|
|
|
}
|
2022-11-25 07:48:01 +01:00
|
|
|
else if (context.Enabled)
|
|
|
|
|
{
|
2022-11-29 22:50:07 +01:00
|
|
|
if (context.State.SteamUsesSteamInput)
|
2022-11-27 13:41:28 +01:00
|
|
|
{
|
2022-12-14 21:10:45 +01:00
|
|
|
notifyIcon.Icon = isDesktop ? monitorOffIco : controllerOffIco;
|
2022-11-27 13:41:28 +01:00
|
|
|
notifyIcon.Text = TitleWithVersion + ". Steam uses Steam Input";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-12-14 21:10:45 +01:00
|
|
|
notifyIcon.Icon = isDesktop ? monitorOnIco : controllerOnIco;
|
2022-11-27 13:41:28 +01:00
|
|
|
notifyIcon.Text = TitleWithVersion;
|
|
|
|
|
}
|
2022-11-25 21:28:43 +01:00
|
|
|
|
2022-11-28 23:43:46 +01:00
|
|
|
var profile = context.CurrentProfile;
|
2022-11-25 21:28:43 +01:00
|
|
|
if (profile is not null)
|
|
|
|
|
notifyIcon.Text = TitleWithVersion + ". Profile: " + profile.Name;
|
2022-11-25 07:48:01 +01:00
|
|
|
}
|
2022-11-24 22:37:24 +01:00
|
|
|
else
|
|
|
|
|
{
|
2022-12-14 21:10:45 +01:00
|
|
|
notifyIcon.Icon = isDesktop ? monitorOffIco : controllerOffIco;
|
2022-11-25 07:48:01 +01:00
|
|
|
notifyIcon.Text = TitleWithVersion + ". Disabled";
|
2022-11-24 22:37:24 +01:00
|
|
|
}
|
2022-11-25 07:48:01 +01:00
|
|
|
|
2022-12-02 11:10:58 +01:00
|
|
|
notifyIcon.Text += String.Format(". Updates: {0}/s", context.UpdatesPerSec);
|
2022-11-24 22:37:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
2023-01-05 11:47:18 +01:00
|
|
|
Microsoft.Win32.SystemEvents.PowerModeChanged -= SystemEvents_PowerModeChanged;
|
2022-11-25 07:48:01 +01:00
|
|
|
notifyIcon.Visible = false;
|
2022-12-02 11:10:58 +01:00
|
|
|
context.Stop();
|
2022-11-24 22:37:24 +01:00
|
|
|
using (context) { }
|
|
|
|
|
}
|
2022-11-27 13:41:28 +01:00
|
|
|
|
2023-01-21 21:41:55 +01:00
|
|
|
public void SetupSteam(bool always)
|
2022-11-27 13:41:28 +01:00
|
|
|
{
|
2023-01-21 21:41:55 +01:00
|
|
|
var blacklistedSteamController = Helpers.SteamConfiguration.IsControllerBlacklisted(
|
|
|
|
|
Devices.SteamController.VendorID,
|
|
|
|
|
Devices.SteamController.ProductID
|
|
|
|
|
);
|
|
|
|
|
var blacklistedX360Controller = Helpers.SteamConfiguration.IsControllerBlacklisted(
|
|
|
|
|
Devices.Xbox360Controller.VendorID,
|
|
|
|
|
Devices.Xbox360Controller.ProductID
|
|
|
|
|
);
|
2022-11-27 13:41:28 +01:00
|
|
|
|
2023-01-21 21:41:55 +01:00
|
|
|
if (blacklistedSteamController is null || blacklistedX360Controller is null)
|
2022-11-27 13:41:28 +01:00
|
|
|
{
|
2023-01-21 21:41:55 +01:00
|
|
|
// Appears that Steam is not installed
|
|
|
|
|
if (always)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Steam appears not to be installed.", TitleWithVersion, MessageBoxButtons.OK);
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-11-27 13:41:28 +01:00
|
|
|
|
2023-01-21 21:41:55 +01:00
|
|
|
Application.DoEvents();
|
2022-11-27 13:41:28 +01:00
|
|
|
|
2023-01-21 21:41:55 +01:00
|
|
|
var page = new TaskDialogPage();
|
|
|
|
|
page.Caption = TitleWithVersion;
|
|
|
|
|
page.AllowCancel = true;
|
2022-11-27 13:41:28 +01:00
|
|
|
|
2023-01-21 21:41:55 +01:00
|
|
|
var useX360Controller = page.RadioButtons.Add("Use &X360 Controller with Steam (preferred)");
|
|
|
|
|
useX360Controller.Text += "\n- Will always use X360 controller.";
|
|
|
|
|
useX360Controller.Checked = Settings.Default.EnableSteamDetection == true &&
|
|
|
|
|
blacklistedSteamController == true &&
|
|
|
|
|
blacklistedX360Controller == false;
|
|
|
|
|
|
|
|
|
|
var useSteamInput = page.RadioButtons.Add("Use &Steam Input with Steam (requires configuration)");
|
|
|
|
|
useSteamInput.Text += "\n- Will try to use Steam controls.";
|
|
|
|
|
useSteamInput.Text += "\n- Does REQUIRE disabling DESKTOP MODE shortcuts in Steam.";
|
|
|
|
|
useSteamInput.Text += "\n- Click Help for more information.";
|
|
|
|
|
useSteamInput.Checked = Settings.Default.EnableSteamDetection == true &&
|
|
|
|
|
blacklistedSteamController == false &&
|
|
|
|
|
blacklistedX360Controller == true;
|
|
|
|
|
|
|
|
|
|
var ignoreSteam = page.RadioButtons.Add("&Ignore Steam (only if you know why you need it)");
|
|
|
|
|
ignoreSteam.Text += "\n- Will revert all previously made changes.";
|
|
|
|
|
ignoreSteam.Checked = Settings.Default.EnableSteamDetection == false;
|
|
|
|
|
|
|
|
|
|
bool valid = ignoreSteam.Checked || useX360Controller.Checked || useSteamInput.Checked;
|
|
|
|
|
|
|
|
|
|
// If everything is OK, on subsequent runs nothing to configure
|
|
|
|
|
if (valid && !always)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (valid || Settings.Default.EnableSteamDetection == null)
|
2022-11-27 13:41:28 +01:00
|
|
|
{
|
2023-01-21 21:41:55 +01:00
|
|
|
page.Heading = "Steam Controller Setup";
|
|
|
|
|
page.Text = "To use Steam Controller with Steam you need to configure it first.";
|
|
|
|
|
page.Icon = TaskDialogIcon.ShieldBlueBar;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
page.Heading = "Steam Controller Setup - Configuration Lost";
|
|
|
|
|
page.Text = "Configure your Steam Controller again.";
|
|
|
|
|
page.Icon = TaskDialogIcon.ShieldWarningYellowBar;
|
|
|
|
|
}
|
2022-11-27 13:41:28 +01:00
|
|
|
|
2023-01-21 21:41:55 +01:00
|
|
|
var continueButton = new TaskDialogButton("Continue") { ShowShieldIcon = true };
|
2022-11-27 13:41:28 +01:00
|
|
|
|
2023-01-21 21:41:55 +01:00
|
|
|
page.Buttons.Add(continueButton);
|
|
|
|
|
page.Buttons.Add(TaskDialogButton.Cancel);
|
|
|
|
|
page.Buttons.Add(TaskDialogButton.Help);
|
2022-11-27 13:41:28 +01:00
|
|
|
|
2023-01-21 21:41:55 +01:00
|
|
|
page.Footnote = new TaskDialogFootnote();
|
|
|
|
|
page.Footnote.Text = "This will change Steam configuration. ";
|
|
|
|
|
page.Footnote.Text += "Close Steam before confirming as otherwise Steam will be forcefully closed.";
|
|
|
|
|
page.Footnote.Icon = TaskDialogIcon.Warning;
|
2022-11-27 13:41:28 +01:00
|
|
|
|
2023-01-21 21:41:55 +01:00
|
|
|
page.HelpRequest += delegate
|
|
|
|
|
{
|
|
|
|
|
try { System.Diagnostics.Process.Start("explorer.exe", "https://steam-deck-tools.ayufan.dev/steam-controller"); }
|
|
|
|
|
catch { }
|
|
|
|
|
};
|
2022-11-27 13:41:28 +01:00
|
|
|
|
2023-01-21 21:41:55 +01:00
|
|
|
var result = TaskDialog.ShowDialog(new Form { TopMost = true }, page, TaskDialogStartupLocation.CenterScreen);
|
|
|
|
|
if (result != continueButton)
|
2022-11-27 13:41:28 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Helpers.SteamConfiguration.KillSteam();
|
|
|
|
|
Helpers.SteamConfiguration.WaitForSteamClose(5000);
|
|
|
|
|
Helpers.SteamConfiguration.BackupSteamConfig();
|
2022-12-02 11:29:06 +01:00
|
|
|
|
2022-11-27 13:41:28 +01:00
|
|
|
var steamControllerUpdate = Helpers.SteamConfiguration.UpdateControllerBlacklist(
|
|
|
|
|
Devices.SteamController.VendorID,
|
|
|
|
|
Devices.SteamController.ProductID,
|
2023-01-21 21:41:55 +01:00
|
|
|
useX360Controller.Checked
|
2022-11-27 13:41:28 +01:00
|
|
|
);
|
|
|
|
|
var x360ControllerUpdate = Helpers.SteamConfiguration.UpdateControllerBlacklist(
|
|
|
|
|
Devices.Xbox360Controller.VendorID,
|
|
|
|
|
Devices.Xbox360Controller.ProductID,
|
2023-01-21 21:41:55 +01:00
|
|
|
useSteamInput.Checked
|
2022-11-27 13:41:28 +01:00
|
|
|
);
|
2023-01-21 21:41:55 +01:00
|
|
|
Settings.Default.EnableSteamDetection = useSteamInput.Checked || useX360Controller.Checked;
|
2022-11-27 13:41:28 +01:00
|
|
|
|
|
|
|
|
if (steamControllerUpdate && x360ControllerUpdate)
|
|
|
|
|
{
|
|
|
|
|
notifyIcon.ShowBalloonTip(
|
|
|
|
|
3000, TitleWithVersion,
|
|
|
|
|
"Steam Configuration changed. You can start Steam now.",
|
|
|
|
|
ToolTipIcon.Info
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
notifyIcon.ShowBalloonTip(
|
|
|
|
|
3000, TitleWithVersion,
|
|
|
|
|
"Steam Configuration was not updated. Maybe Steam is open?",
|
|
|
|
|
ToolTipIcon.Warning
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-11-28 09:34:17 +01:00
|
|
|
|
|
|
|
|
private void Settings_Click(object? sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var form = new Form()
|
|
|
|
|
{
|
|
|
|
|
Text = TitleWithVersion + " Settings",
|
|
|
|
|
StartPosition = FormStartPosition.CenterScreen,
|
2022-12-06 21:40:44 +01:00
|
|
|
Size = new Size(400, 500),
|
|
|
|
|
AutoScaleMode = AutoScaleMode.Font,
|
|
|
|
|
AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F)
|
2022-11-28 09:34:17 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var propertyGrid = new PropertyGrid()
|
|
|
|
|
{
|
|
|
|
|
Dock = DockStyle.Fill,
|
2022-12-06 21:40:44 +01:00
|
|
|
ToolbarVisible = false,
|
|
|
|
|
LargeButtons = true,
|
2022-11-28 09:34:17 +01:00
|
|
|
SelectedObject = new
|
|
|
|
|
{
|
2022-12-08 01:48:14 +01:00
|
|
|
Desktop = ProfilesSettings.DesktopPanelSettings.Default,
|
|
|
|
|
X360 = ProfilesSettings.X360BackPanelSettings.Default,
|
2022-12-03 17:49:23 +01:00
|
|
|
X360Haptic = ProfilesSettings.X360HapticSettings.Default,
|
2022-12-10 10:29:37 +01:00
|
|
|
Application = Settings.Default,
|
|
|
|
|
DEBUG = SettingsDebug.Default
|
2022-11-28 09:34:17 +01:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2022-12-10 11:01:41 +01:00
|
|
|
var helpLabel = new Label()
|
|
|
|
|
{
|
|
|
|
|
Cursor = Cursors.Hand,
|
|
|
|
|
Dock = DockStyle.Top,
|
|
|
|
|
Font = new Font("Segoe UI", 9F, FontStyle.Bold | FontStyle.Underline),
|
|
|
|
|
ForeColor = SystemColors.HotTrack,
|
|
|
|
|
Text = "https://steam-deck-tools.ayufan.dev",
|
|
|
|
|
TextAlign = ContentAlignment.MiddleCenter
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var donateLabel = new Label()
|
|
|
|
|
{
|
|
|
|
|
Cursor = Cursors.Hand,
|
|
|
|
|
Dock = DockStyle.Top,
|
|
|
|
|
Font = new Font("Segoe UI", 9F, FontStyle.Bold),
|
|
|
|
|
Text = String.Join("\n",
|
|
|
|
|
"This project is provided free of charge, but development of it is not free:",
|
|
|
|
|
"- Consider donating to keep this project alive.",
|
|
|
|
|
"- Donating also helps to fund new features."
|
|
|
|
|
),
|
|
|
|
|
TextAlign = ContentAlignment.MiddleLeft,
|
|
|
|
|
Height = 100
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
helpLabel.Click += delegate { Process.Start("explorer.exe", "https://steam-deck-tools.ayufan.dev"); };
|
|
|
|
|
donateLabel.Click += delegate { Process.Start("explorer.exe", "https://steam-deck-tools.ayufan.dev/#help-this-project"); };
|
2022-11-28 09:34:17 +01:00
|
|
|
propertyGrid.ExpandAllGridItems();
|
2022-12-10 11:01:41 +01:00
|
|
|
|
2022-11-28 09:34:17 +01:00
|
|
|
form.Controls.Add(propertyGrid);
|
2022-12-10 11:01:41 +01:00
|
|
|
form.Controls.Add(donateLabel);
|
|
|
|
|
form.Controls.Add(helpLabel);
|
2022-11-28 09:34:17 +01:00
|
|
|
form.ShowDialog();
|
|
|
|
|
}
|
2022-11-24 22:37:24 +01:00
|
|
|
}
|
|
|
|
|
}
|