2022-11-25 07:48:01 +01:00
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
2022-11-25 10:56:17 +01:00
|
|
|
namespace SteamController.Managers
|
2022-11-25 07:48:01 +01:00
|
|
|
{
|
2022-11-25 10:56:17 +01:00
|
|
|
public sealed class ProcessManager : Manager
|
2022-11-25 07:48:01 +01:00
|
|
|
{
|
|
|
|
|
public static readonly String[] ActivationProcessNames = new String[]
|
|
|
|
|
{
|
|
|
|
|
"Playnite.FullscreenApp"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private bool activated;
|
|
|
|
|
|
|
|
|
|
private Process? FindActivationProcess()
|
|
|
|
|
{
|
|
|
|
|
foreach (var processName in ActivationProcessNames)
|
|
|
|
|
{
|
|
|
|
|
var process = Process.GetProcessesByName(processName).FirstOrDefault();
|
|
|
|
|
if (process is not null)
|
|
|
|
|
return process;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Tick(Context context)
|
|
|
|
|
{
|
|
|
|
|
// React to state change
|
|
|
|
|
if (FindActivationProcess() is not null)
|
|
|
|
|
{
|
|
|
|
|
if (!activated)
|
|
|
|
|
{
|
|
|
|
|
activated = true;
|
|
|
|
|
context.RequestDesktopMode = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (activated)
|
|
|
|
|
{
|
|
|
|
|
activated = false;
|
|
|
|
|
context.RequestDesktopMode = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|