steam-deck-tools/SteamController/Profiles/ProcessProfile.cs
Kamil Trzciński 10d6c055da Add Process and Steam detection
- This makes to autmatically swittch to controller
  when Playnite Fullscreen is in use.
- This makes to automatically disable when Steam
  is in Big Picture or running Game
- Indicate current status with well distinguishable icons
- Expose all options via Context Menu
2022-11-26 10:19:50 +01:00

53 lines
1.3 KiB
C#

using System.Diagnostics;
namespace SteamController.Profiles
{
public sealed class ProcessProfile : Profile
{
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;
}
}
}
public override Status Run(Context context)
{
return Status.Continue;
}
}
}