mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2026-01-24 17:30:27 +01:00
Add ContextState to compare all active states in Bulk
This commit is contained in:
parent
ffcdd8f82c
commit
8604e67568
|
|
@ -19,10 +19,20 @@ namespace SteamController
|
|||
|
||||
private int selectedProfile;
|
||||
|
||||
public struct ContextState
|
||||
{
|
||||
public bool GameProcessRunning { get; set; }
|
||||
public bool SteamUsesX360Controller { get; set; }
|
||||
public bool SteamUsesSteamInput { get; set; }
|
||||
|
||||
public bool IsActive
|
||||
{
|
||||
get { return GameProcessRunning || SteamUsesSteamInput || SteamUsesSteamInput; }
|
||||
}
|
||||
}
|
||||
|
||||
public bool RequestEnable { get; set; } = true;
|
||||
public bool GameProcessRunning { get; set; } = false;
|
||||
public bool SteamUsesX360Controller { get; set; } = false;
|
||||
public bool SteamUsesSteamInput { get; set; } = false;
|
||||
public ContextState State;
|
||||
|
||||
public event Action<Profiles.Profile> ProfileChanged;
|
||||
public Action? SelectDefault;
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ namespace SteamController
|
|||
}
|
||||
else if (context.Enabled)
|
||||
{
|
||||
if (context.SteamUsesSteamInput)
|
||||
if (context.State.SteamUsesSteamInput)
|
||||
{
|
||||
notifyIcon.Icon = isDesktop ? Resources.monitor_off : Resources.microsoft_xbox_controller_off;
|
||||
notifyIcon.Text = TitleWithVersion + ". Steam uses Steam Input";
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ namespace SteamController.Managers
|
|||
|
||||
public override void Tick(Context context)
|
||||
{
|
||||
context.GameProcessRunning = FindActivationProcess() is not null;
|
||||
context.State.GameProcessRunning = FindActivationProcess() is not null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,41 +5,19 @@ namespace SteamController.Managers
|
|||
{
|
||||
public sealed class ProfileSwitcher : Manager
|
||||
{
|
||||
[Flags]
|
||||
private enum ActiveMode
|
||||
{
|
||||
None,
|
||||
SteamInput = 1,
|
||||
SteamX360 = 2,
|
||||
OtherGame = 4
|
||||
}
|
||||
|
||||
private ActiveMode wasActive;
|
||||
private Context.ContextState wasState;
|
||||
|
||||
public override void Tick(Context context)
|
||||
{
|
||||
ActiveMode active = GetActiveMode(context);
|
||||
if (wasActive == active)
|
||||
if (wasState.Equals(context.State))
|
||||
return;
|
||||
|
||||
if (active != ActiveMode.None)
|
||||
if (context.State.IsActive)
|
||||
context.SelectController();
|
||||
else
|
||||
context.BackToDefault();
|
||||
|
||||
wasActive = active;
|
||||
}
|
||||
|
||||
private ActiveMode GetActiveMode(Context context)
|
||||
{
|
||||
ActiveMode mode = ActiveMode.None;
|
||||
if (context.SteamUsesSteamInput)
|
||||
mode |= ActiveMode.SteamInput;
|
||||
if (context.SteamUsesX360Controller)
|
||||
mode |= ActiveMode.SteamX360;
|
||||
if (context.GameProcessRunning)
|
||||
mode |= ActiveMode.OtherGame;
|
||||
return mode;
|
||||
wasState = context.State;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ namespace SteamController.Managers
|
|||
{
|
||||
if (!Settings.Default.EnableSteamDetection)
|
||||
{
|
||||
context.SteamUsesSteamInput = false;
|
||||
context.SteamUsesX360Controller = false;
|
||||
context.State.SteamUsesSteamInput = false;
|
||||
context.State.SteamUsesX360Controller = false;
|
||||
lastState = false;
|
||||
return;
|
||||
}
|
||||
|
|
@ -23,20 +23,20 @@ namespace SteamController.Managers
|
|||
|
||||
if (usesController)
|
||||
{
|
||||
context.SteamUsesSteamInput = Helpers.SteamConfiguration.IsControllerBlacklisted(
|
||||
context.State.SteamUsesSteamInput = Helpers.SteamConfiguration.IsControllerBlacklisted(
|
||||
Devices.SteamController.VendorID,
|
||||
Devices.SteamController.ProductID
|
||||
) != true;
|
||||
|
||||
context.SteamUsesX360Controller = Helpers.SteamConfiguration.IsControllerBlacklisted(
|
||||
context.State.SteamUsesX360Controller = Helpers.SteamConfiguration.IsControllerBlacklisted(
|
||||
Devices.Xbox360Controller.VendorID,
|
||||
Devices.Xbox360Controller.ProductID
|
||||
) != true;
|
||||
}
|
||||
else
|
||||
{
|
||||
context.SteamUsesSteamInput = false;
|
||||
context.SteamUsesX360Controller = false;
|
||||
context.State.SteamUsesSteamInput = false;
|
||||
context.State.SteamUsesX360Controller = false;
|
||||
}
|
||||
|
||||
lastState = usesController;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace SteamController.Profiles
|
|||
|
||||
public override bool Selected(Context context)
|
||||
{
|
||||
return context.Enabled && context.SteamUsesSteamInput;
|
||||
return context.Enabled && context.State.SteamUsesSteamInput;
|
||||
}
|
||||
|
||||
public override Status Run(Context context)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace SteamController.Profiles
|
|||
|
||||
public override bool Selected(Context context)
|
||||
{
|
||||
return context.Enabled && context.SteamUsesSteamInput;
|
||||
return context.Enabled && context.State.SteamUsesSteamInput;
|
||||
}
|
||||
|
||||
public override Status Run(Context context)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ namespace SteamController.Profiles
|
|||
{
|
||||
public override bool Selected(Context context)
|
||||
{
|
||||
return context.Enabled && context.X360.Valid && context.Mouse.Valid && !context.SteamUsesSteamInput;
|
||||
return context.Enabled && context.X360.Valid && context.Mouse.Valid && !context.State.SteamUsesSteamInput;
|
||||
}
|
||||
|
||||
internal override ProfilesSettings.BackPanelSettings BackPanelSettings
|
||||
|
|
|
|||
Loading…
Reference in a new issue