steam-deck-tools/SteamController/Profiles/SteamDetectProfile.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

36 lines
963 B
C#

using System.Diagnostics;
using SteamController.Helpers;
namespace SteamController.Profiles
{
public sealed class SteamDetectProfile : Profile
{
public override void Tick(Context context)
{
if (!Settings.Default.EnableSteamDetection)
{
context.DisableDueToSteam = false;
return;
}
var usesController = UsesController();
// if controller is used, disable due to Steam
context.DisableDueToSteam = usesController ?? true;
}
private bool? UsesController()
{
if (!SteamManager.IsRunning.GetValueOrDefault(false))
return null;
return SteamManager.IsBigPictureMode.GetValueOrDefault(false) || SteamManager.IsRunningGame.GetValueOrDefault(false);
}
public override Status Run(Context context)
{
return Status.Continue;
}
}
}