2022-11-25 10:56:17 +01:00
|
|
|
using System.Diagnostics;
|
|
|
|
|
using SteamController.Helpers;
|
|
|
|
|
|
|
|
|
|
namespace SteamController.Managers
|
|
|
|
|
{
|
|
|
|
|
public sealed class SteamManager : Manager
|
|
|
|
|
{
|
2022-11-27 13:41:28 +01:00
|
|
|
private bool lastState;
|
|
|
|
|
|
2022-11-25 10:56:17 +01:00
|
|
|
public override void Tick(Context context)
|
|
|
|
|
{
|
|
|
|
|
if (!Settings.Default.EnableSteamDetection)
|
|
|
|
|
{
|
2022-11-29 22:50:07 +01:00
|
|
|
context.State.SteamUsesSteamInput = false;
|
|
|
|
|
context.State.SteamUsesX360Controller = false;
|
2022-11-27 13:41:28 +01:00
|
|
|
lastState = false;
|
2022-11-25 10:56:17 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-27 13:41:28 +01:00
|
|
|
var usesController = UsesController() ?? false;
|
|
|
|
|
if (lastState == usesController)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (usesController)
|
|
|
|
|
{
|
2022-11-29 22:50:07 +01:00
|
|
|
context.State.SteamUsesSteamInput = Helpers.SteamConfiguration.IsControllerBlacklisted(
|
2022-11-27 13:41:28 +01:00
|
|
|
Devices.SteamController.VendorID,
|
|
|
|
|
Devices.SteamController.ProductID
|
|
|
|
|
) != true;
|
|
|
|
|
|
2022-11-29 22:50:07 +01:00
|
|
|
context.State.SteamUsesX360Controller = Helpers.SteamConfiguration.IsControllerBlacklisted(
|
2022-11-27 13:41:28 +01:00
|
|
|
Devices.Xbox360Controller.VendorID,
|
|
|
|
|
Devices.Xbox360Controller.ProductID
|
|
|
|
|
) != true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-11-29 22:50:07 +01:00
|
|
|
context.State.SteamUsesSteamInput = false;
|
|
|
|
|
context.State.SteamUsesX360Controller = false;
|
2022-11-27 13:41:28 +01:00
|
|
|
}
|
2022-11-25 10:56:17 +01:00
|
|
|
|
2022-11-27 13:41:28 +01:00
|
|
|
lastState = usesController;
|
2022-11-25 10:56:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool? UsesController()
|
|
|
|
|
{
|
2022-11-28 20:28:21 +01:00
|
|
|
if (!SteamConfiguration.IsRunning)
|
2022-11-25 10:56:17 +01:00
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
return
|
2022-11-27 13:41:28 +01:00
|
|
|
SteamConfiguration.IsBigPictureMode.GetValueOrDefault(false) ||
|
|
|
|
|
SteamConfiguration.IsRunningGame.GetValueOrDefault(false) ||
|
|
|
|
|
SteamConfiguration.IsGamePadUI;
|
2022-11-25 10:56:17 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|