mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2026-01-20 15:30:28 +01:00
Fix using Playnite to launch Steam game where on exit Desktop was activated
This commit is contained in:
parent
381f940d8b
commit
c2f37dedd9
|
|
@ -21,3 +21,4 @@ It does help this project on being supported.
|
|||
- Fix `Process Kill` action (STEAM+B for 3s)
|
||||
- Go back to `Startup Profile` on `Toggle deskptop mode`
|
||||
- The `X360.Beep()` cycles currently connected device (fixes Playnite error)
|
||||
- Fix using Playnite to launch Steam game where on exit Desktop was activated
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ namespace SteamController
|
|||
private int selectedProfile;
|
||||
|
||||
public bool RequestEnable { get; set; } = true;
|
||||
public bool GameProcessRunning { get; set; } = false;
|
||||
public bool SteamUsesX360Controller { get; set; } = false;
|
||||
public bool SteamUsesSteamInput { get; set; } = false;
|
||||
|
||||
|
|
@ -54,6 +55,7 @@ namespace SteamController
|
|||
Mouse = new Devices.MouseController();
|
||||
|
||||
ProfileChanged += (_) => X360.Beep();
|
||||
ProfileChanged += (profile) => TraceLine("Context: Selected Profile: {0}", profile.Name);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
|
@ -139,8 +141,12 @@ namespace SteamController
|
|||
var current = CurrentProfile;
|
||||
if (current is null)
|
||||
return;
|
||||
|
||||
if (current.IsDesktop)
|
||||
{
|
||||
TraceLine("Context: SelectController");
|
||||
SelectNext();
|
||||
}
|
||||
}
|
||||
|
||||
public bool SelectNext()
|
||||
|
|
@ -173,6 +179,7 @@ namespace SteamController
|
|||
|
||||
public void BackToDefault()
|
||||
{
|
||||
TraceLine("Context: Back To Default.");
|
||||
if (SelectDefault is not null)
|
||||
SelectDefault();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ namespace SteamController
|
|||
},
|
||||
Managers = {
|
||||
new Managers.ProcessManager(),
|
||||
new Managers.SteamManager()
|
||||
new Managers.SteamManager(),
|
||||
new Managers.ProfileSwitcher()
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@ namespace SteamController.Managers
|
|||
"Playnite.FullscreenApp"
|
||||
};
|
||||
|
||||
private bool activated;
|
||||
|
||||
private Process? FindActivationProcess()
|
||||
{
|
||||
foreach (var processName in ActivationProcessNames)
|
||||
|
|
@ -25,23 +23,7 @@ namespace SteamController.Managers
|
|||
|
||||
public override void Tick(Context context)
|
||||
{
|
||||
// React to state change
|
||||
if (FindActivationProcess() is not null)
|
||||
{
|
||||
if (!activated)
|
||||
{
|
||||
activated = true;
|
||||
context.SelectController();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (activated)
|
||||
{
|
||||
activated = false;
|
||||
context.BackToDefault();
|
||||
}
|
||||
}
|
||||
context.GameProcessRunning = FindActivationProcess() is not null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
45
SteamController/Managers/ProfileSwitcher.cs
Normal file
45
SteamController/Managers/ProfileSwitcher.cs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
using System.Diagnostics;
|
||||
using SteamController.Helpers;
|
||||
|
||||
namespace SteamController.Managers
|
||||
{
|
||||
public sealed class ProfileSwitcher : Manager
|
||||
{
|
||||
[Flags]
|
||||
private enum ActiveMode
|
||||
{
|
||||
None,
|
||||
SteamInput = 1,
|
||||
SteamX360 = 2,
|
||||
OtherGame = 4
|
||||
}
|
||||
|
||||
private ActiveMode wasActive;
|
||||
|
||||
public override void Tick(Context context)
|
||||
{
|
||||
ActiveMode active = GetActiveMode(context);
|
||||
if (wasActive == active)
|
||||
return;
|
||||
|
||||
if (active != ActiveMode.None)
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -32,14 +32,11 @@ namespace SteamController.Managers
|
|||
Devices.Xbox360Controller.VendorID,
|
||||
Devices.Xbox360Controller.ProductID
|
||||
) != true;
|
||||
|
||||
context.SelectController();
|
||||
}
|
||||
else
|
||||
{
|
||||
context.SteamUsesSteamInput = false;
|
||||
context.SteamUsesX360Controller = false;
|
||||
context.BackToDefault();
|
||||
}
|
||||
|
||||
lastState = usesController;
|
||||
|
|
|
|||
Loading…
Reference in a new issue