mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2026-01-26 02:04:22 +01:00
Improve SteamConfiguration performance
This commit is contained in:
parent
3c209f04b4
commit
190b14e66f
|
|
@ -20,15 +20,14 @@ namespace SteamController.Helpers
|
|||
|
||||
private static readonly Regex ControllerBlacklistRegex = new Regex("^(\\s*\"controller_blacklist\"\\s*\")([^\"]*)(\"\\s*)$");
|
||||
|
||||
public static bool? IsRunning
|
||||
public static bool IsRunning
|
||||
{
|
||||
get
|
||||
{
|
||||
var value = GetValue<int>(ActiveProcessKey, PIDValue);
|
||||
if (value is null)
|
||||
return null;
|
||||
using (var process = SteamProcess)
|
||||
{
|
||||
return process is not null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -143,7 +142,7 @@ namespace SteamController.Helpers
|
|||
|
||||
while (DateTimeOffset.Now < waitTill)
|
||||
{
|
||||
if (IsRunning != true)
|
||||
if (!IsRunning)
|
||||
return true;
|
||||
Application.DoEvents();
|
||||
Thread.Sleep(50);
|
||||
|
|
@ -159,7 +158,7 @@ namespace SteamController.Helpers
|
|||
if (configPath is null)
|
||||
return null;
|
||||
|
||||
foreach (var line in File.ReadLines(configPath))
|
||||
foreach (var line in File.ReadLines(configPath).Reverse())
|
||||
{
|
||||
var match = ControllerBlacklistRegex.Match(line);
|
||||
if (!match.Success)
|
||||
|
|
@ -208,7 +207,7 @@ namespace SteamController.Helpers
|
|||
|
||||
public static bool UpdateControllerBlacklist(ushort vendorId, ushort productId, bool add)
|
||||
{
|
||||
if (IsRunning == true)
|
||||
if (IsRunning)
|
||||
return false;
|
||||
|
||||
var configPath = SteamConfigPath;
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ namespace SteamController.Managers
|
|||
|
||||
private bool? UsesController()
|
||||
{
|
||||
if (!SteamConfiguration.IsRunning.GetValueOrDefault(false))
|
||||
if (!SteamConfiguration.IsRunning)
|
||||
return null;
|
||||
|
||||
return
|
||||
|
|
|
|||
Loading…
Reference in a new issue