mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2026-01-23 08:50:27 +01:00
Detect GamePad UI open temporarily for controller layout
This commit is contained in:
parent
9c1cc74f40
commit
eb37020803
|
|
@ -31,3 +31,4 @@ It does help this project on being supported.
|
|||
- Merge `X360 with Haptic` into `X360` profile
|
||||
- Improve responsiveness of PowerControl (read input more frequently)
|
||||
- Fix selecting `DefaultProfile` on startup
|
||||
- Detect GamePad UI open temporarily for controller layout
|
||||
|
|
|
|||
|
|
@ -30,12 +30,16 @@ namespace SteamController.Helpers
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static Process? Find()
|
||||
{
|
||||
return Find(GetForegroundWindow());
|
||||
}
|
||||
|
||||
public static Process? Find(IntPtr hWnd)
|
||||
{
|
||||
try
|
||||
{
|
||||
var id = GetTopLevelProcessId();
|
||||
var id = GetProcessId(hWnd);
|
||||
if (id is null)
|
||||
return null;
|
||||
|
||||
|
|
@ -50,9 +54,11 @@ namespace SteamController.Helpers
|
|||
|
||||
private static int? GetTopLevelProcessId()
|
||||
{
|
||||
var hWnd = GetForegroundWindow();
|
||||
if (hWnd == IntPtr.Zero)
|
||||
return null;
|
||||
return GetProcessId(GetForegroundWindow());
|
||||
}
|
||||
|
||||
private static int? GetProcessId(IntPtr hWnd)
|
||||
{
|
||||
var result = GetWindowThreadProcessId(hWnd, out var processId);
|
||||
if (result != 0)
|
||||
return processId;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.Win32;
|
||||
|
||||
|
|
@ -54,13 +55,32 @@ namespace SteamController.Helpers
|
|||
get
|
||||
{
|
||||
var steamWindow = FindWindow("SDL_app", "SP");
|
||||
if (steamWindow == null)
|
||||
if (steamWindow == IntPtr.Zero)
|
||||
return false;
|
||||
|
||||
return GetForegroundWindow() == steamWindow;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsPossibleGamePadUI
|
||||
{
|
||||
get
|
||||
{
|
||||
IntPtr hWnd = GetForegroundWindow();
|
||||
if (hWnd == IntPtr.Zero)
|
||||
return false;
|
||||
|
||||
StringBuilder className = new StringBuilder(256);
|
||||
if (GetClassName(hWnd, className, className.Capacity) == 0)
|
||||
return false;
|
||||
|
||||
if (className.ToString() != "SDL_app")
|
||||
return false;
|
||||
|
||||
return ForegroundProcess.Find(hWnd)?.ProcessName == "steamwebhelper";
|
||||
}
|
||||
}
|
||||
|
||||
public static String? SteamExe
|
||||
{
|
||||
get { return GetValue2<string>(SteamKey, SteamExeValue); }
|
||||
|
|
@ -374,5 +394,11 @@ namespace SteamController.Helpers
|
|||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
private static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
private static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Diagnostics;
|
||||
using CommonHelpers;
|
||||
using SteamController.Helpers;
|
||||
|
||||
namespace SteamController.Managers
|
||||
|
|
@ -59,6 +60,8 @@ namespace SteamController.Managers
|
|||
if (!IsActive)
|
||||
return;
|
||||
|
||||
Log.TraceLine("SetSteamControllerFilesLock: {0}", lockConfigs);
|
||||
|
||||
if (lockConfigs)
|
||||
{
|
||||
foreach (var config in lockedSteamControllerFiles)
|
||||
|
|
|
|||
|
|
@ -75,6 +75,8 @@ namespace SteamController.Managers
|
|||
return "game";
|
||||
if (SteamConfiguration.IsGamePadUI)
|
||||
return "gamepadui";
|
||||
if (SteamConfiguration.IsPossibleGamePadUI)
|
||||
return "possiblegamepadui";
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue