mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2026-01-06 08:39:59 +01:00
Check if AMD GPU scaling is enabled to allow changing resolution by default
This commit is contained in:
parent
85c8ee379f
commit
a7f16dbde6
44
PowerControl/Helpers/AMD.cs
Normal file
44
PowerControl/Helpers/AMD.cs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PowerControl.Helpers
|
||||
{
|
||||
internal class AMD
|
||||
{
|
||||
// TODO: This CLSID is likely to change over time and be broken
|
||||
// pnputil /enum-devices /class Display
|
||||
const String GPUDriverKey = "SYSTEM\\CurrentControlSet\\Control\\Class\\{4d36e968-e325-11ce-bfc1-08002be10318}\\0000";
|
||||
const String DriverDesc = "DriverDesc";
|
||||
const String ExpectedDriverDesc = "AMD Custom GPU 0405";
|
||||
const String GPUScaling = "GPUScaling00";
|
||||
|
||||
internal static bool IsGPUScalingEnabled()
|
||||
{
|
||||
try
|
||||
{
|
||||
var registry = Registry.LocalMachine.OpenSubKey(GPUDriverKey);
|
||||
if (registry == null)
|
||||
return false;
|
||||
|
||||
var driverDesc = registry.GetValue(DriverDesc);
|
||||
if (driverDesc is String && ((string)driverDesc) != ExpectedDriverDesc)
|
||||
return false;
|
||||
|
||||
var scalingBytes = registry.GetValue(GPUScaling);
|
||||
if (scalingBytes is not byte[])
|
||||
return false;
|
||||
|
||||
var scaling = BitConverter.ToUInt32((byte[])scalingBytes);
|
||||
return scaling == 1;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,16 +11,23 @@ namespace PowerControl.Helpers
|
|||
{
|
||||
public static int Get()
|
||||
{
|
||||
using var mclass = new ManagementClass("WmiMonitorBrightness")
|
||||
try
|
||||
{
|
||||
Scope = new ManagementScope(@"\\.\root\wmi")
|
||||
};
|
||||
using var instances = mclass.GetInstances();
|
||||
foreach (ManagementObject instance in instances)
|
||||
{
|
||||
return (byte)instance.GetPropertyValue("CurrentBrightness");
|
||||
using var mclass = new ManagementClass("WmiMonitorBrightness")
|
||||
{
|
||||
Scope = new ManagementScope(@"\\.\root\wmi")
|
||||
};
|
||||
using var instances = mclass.GetInstances();
|
||||
foreach (ManagementObject instance in instances)
|
||||
{
|
||||
return (byte)instance.GetPropertyValue("CurrentBrightness");
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int Get(double roundValue = 10.0)
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ namespace PowerControl
|
|||
Name = "Resolution",
|
||||
ApplyDelay = 1000,
|
||||
ResetValue = () => {
|
||||
if (!Settings.Default.EnableExperimentalFeatures)
|
||||
if (!AMD.IsGPUScalingEnabled() && !Settings.Default.EnableExperimentalFeatures)
|
||||
return null;
|
||||
return Helpers.PhysicalMonitorBrightnessController.GetAllResolutions().Last();
|
||||
},
|
||||
|
|
@ -69,7 +69,7 @@ namespace PowerControl
|
|||
},
|
||||
CurrentValue = delegate()
|
||||
{
|
||||
if (!Settings.Default.EnableExperimentalFeatures)
|
||||
if (!AMD.IsGPUScalingEnabled() && !Settings.Default.EnableExperimentalFeatures)
|
||||
return null;
|
||||
return Helpers.PhysicalMonitorBrightnessController.GetResolution();
|
||||
},
|
||||
|
|
|
|||
BIN
dump/gpu_scaling/DisableGPUScale.reg
Normal file
BIN
dump/gpu_scaling/DisableGPUScale.reg
Normal file
Binary file not shown.
BIN
dump/gpu_scaling/EnableGPUScaleAspect.reg
Normal file
BIN
dump/gpu_scaling/EnableGPUScaleAspect.reg
Normal file
Binary file not shown.
BIN
dump/gpu_scaling/EnableGPUScaleCenter.reg
Normal file
BIN
dump/gpu_scaling/EnableGPUScaleCenter.reg
Normal file
Binary file not shown.
BIN
dump/gpu_scaling/EnableGPUScaleFull.reg
Normal file
BIN
dump/gpu_scaling/EnableGPUScaleFull.reg
Normal file
Binary file not shown.
Loading…
Reference in a new issue