mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2026-04-04 22:07:40 +00:00
Allow to lock steam controller locking files
- This locks `controller_neptune` configs when adding steam detection - This overwrites default desktop/chord template - This enables a desktop template
This commit is contained in:
parent
cc085bfc2a
commit
19e7ed7012
14 changed files with 279 additions and 23 deletions
77
SteamController/Managers/SteamConfigsManager.cs
Normal file
77
SteamController/Managers/SteamConfigsManager.cs
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
using System.Diagnostics;
|
||||
using SteamController.Helpers;
|
||||
|
||||
namespace SteamController.Managers
|
||||
{
|
||||
public sealed class SteamConfigsManager : Manager
|
||||
{
|
||||
static readonly Dictionary<String, byte[]> lockedSteamControllerFiles = new Dictionary<string, byte[]>
|
||||
{
|
||||
// Use existing defaults in BasicUI and BigPicture
|
||||
// { "controller_base/basicui_neptune.vdf", Resources.basicui_neptune },
|
||||
// { "controller_base/bigpicture_neptune.vdf", Resources.bigpicture_neptune },
|
||||
{ "controller_base/desktop_neptune.vdf", Resources.empty_neptune },
|
||||
{ "controller_base/chord_neptune.vdf", Resources.chord_neptune }
|
||||
};
|
||||
static readonly Dictionary<String, byte[]> installedSteamControllerFiles = new Dictionary<string, byte[]> {
|
||||
{ "controller_base/templates/controller_neptune_steamcontroller.vdf", Resources.empty_neptune },
|
||||
};
|
||||
|
||||
private bool? filesLocked;
|
||||
|
||||
public SteamConfigsManager()
|
||||
{
|
||||
// always unlock configs when changed
|
||||
Settings.Default.SettingChanging += UnlockControllerFiles;
|
||||
SetSteamControllerFilesLock(false);
|
||||
}
|
||||
|
||||
private bool IsActive
|
||||
{
|
||||
get { return Settings.Default.ManageSteamControllerConfigs && Settings.Default.EnableSteamDetection; }
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
SetSteamControllerFilesLock(false);
|
||||
Settings.Default.SettingChanging -= UnlockControllerFiles;
|
||||
}
|
||||
|
||||
private void UnlockControllerFiles(object sender, System.Configuration.SettingChangingEventArgs e)
|
||||
{
|
||||
SetSteamControllerFilesLock(false);
|
||||
}
|
||||
|
||||
public override void Tick(Context context)
|
||||
{
|
||||
if (!IsActive)
|
||||
return;
|
||||
|
||||
bool running = Helpers.SteamConfiguration.IsRunning;
|
||||
if (running == filesLocked)
|
||||
return;
|
||||
|
||||
SetSteamControllerFilesLock(running);
|
||||
}
|
||||
|
||||
private void SetSteamControllerFilesLock(bool lockConfigs)
|
||||
{
|
||||
if (!IsActive)
|
||||
return;
|
||||
|
||||
if (lockConfigs)
|
||||
{
|
||||
foreach (var config in lockedSteamControllerFiles)
|
||||
Helpers.SteamConfiguration.OverwriteConfigFile(config.Key, config.Value, true);
|
||||
foreach (var config in installedSteamControllerFiles)
|
||||
Helpers.SteamConfiguration.OverwriteConfigFile(config.Key, config.Value, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var config in lockedSteamControllerFiles)
|
||||
Helpers.SteamConfiguration.ResetConfigFile(config.Key);
|
||||
}
|
||||
filesLocked = lockConfigs;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue