mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Internal screen detection
This commit is contained in:
@@ -24,8 +24,8 @@ namespace GHelper.Display
|
|||||||
|
|
||||||
public void SetScreen(int frequency = -1, int overdrive = -1, int miniled = -1)
|
public void SetScreen(int frequency = -1, int overdrive = -1, int miniled = -1)
|
||||||
{
|
{
|
||||||
|
|
||||||
var laptopScreen = ScreenNative.FindLaptopScreen(true);
|
var laptopScreen = ScreenNative.FindLaptopScreen(true);
|
||||||
|
|
||||||
if (laptopScreen is null) return;
|
if (laptopScreen is null) return;
|
||||||
|
|
||||||
if (ScreenNative.GetRefreshRate(laptopScreen) < 0) return;
|
if (ScreenNative.GetRefreshRate(laptopScreen) < 0) return;
|
||||||
@@ -66,7 +66,6 @@ namespace GHelper.Display
|
|||||||
|
|
||||||
public void InitScreen()
|
public void InitScreen()
|
||||||
{
|
{
|
||||||
|
|
||||||
var laptopScreen = ScreenNative.FindLaptopScreen();
|
var laptopScreen = ScreenNative.FindLaptopScreen();
|
||||||
|
|
||||||
int frequency = ScreenNative.GetRefreshRate(laptopScreen);
|
int frequency = ScreenNative.GetRefreshRate(laptopScreen);
|
||||||
|
|||||||
@@ -118,14 +118,34 @@ namespace GHelper.Display
|
|||||||
public const int ENUM_CURRENT_SETTINGS = -1;
|
public const int ENUM_CURRENT_SETTINGS = -1;
|
||||||
public const string defaultDevice = @"\\.\DISPLAY1";
|
public const string defaultDevice = @"\\.\DISPLAY1";
|
||||||
|
|
||||||
|
static bool? _ultimate = null;
|
||||||
|
|
||||||
|
static bool isUltimate
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_ultimate is null) _ultimate = (Program.acpi.DeviceGet(AsusACPI.GPUMux) == 0);
|
||||||
|
return (bool)_ultimate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static string? FindLaptopScreen(bool log = false)
|
public static string? FindLaptopScreen(bool log = false)
|
||||||
{
|
{
|
||||||
string? laptopScreen = null;
|
string? laptopScreen = null;
|
||||||
|
var screens = Screen.AllScreens;
|
||||||
|
|
||||||
|
if (!isUltimate)
|
||||||
|
{
|
||||||
|
foreach (var screen in screens )
|
||||||
|
{
|
||||||
|
if (log) Logger.WriteLine(screen.DeviceName);
|
||||||
|
if (screen.DeviceName == defaultDevice) return defaultDevice;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var devices = GetAllDevices().ToArray();
|
var devices = GetAllDevices().ToArray();
|
||||||
var screens = Screen.AllScreens;
|
|
||||||
|
|
||||||
int count = 0, displayNum = -1;
|
int count = 0, displayNum = -1;
|
||||||
|
|
||||||
@@ -147,11 +167,7 @@ namespace GHelper.Display
|
|||||||
count = 0;
|
count = 0;
|
||||||
foreach (var screen in screens)
|
foreach (var screen in screens)
|
||||||
{
|
{
|
||||||
if (count == displayNum)
|
if (count == displayNum) laptopScreen = screen.DeviceName;
|
||||||
{
|
|
||||||
laptopScreen = screen.DeviceName;
|
|
||||||
}
|
|
||||||
//if (log) Logger.WriteLine(screen.DeviceName);
|
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
|
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
|
||||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
<AssemblyVersion>0.97</AssemblyVersion>
|
<AssemblyVersion>0.98</AssemblyVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace GHelper.Gpu
|
|||||||
else
|
else
|
||||||
GpuMode = AsusACPI.GPUModeStandard;
|
GpuMode = AsusACPI.GPUModeStandard;
|
||||||
|
|
||||||
// Ultimate mode not suported
|
// Ultimate mode not supported
|
||||||
if (mux != 1) settings.HideUltimateMode();
|
if (mux != 1) settings.HideUltimateMode();
|
||||||
// GPU mode not supported
|
// GPU mode not supported
|
||||||
if (eco < 0 && mux < 0) settings.HideGPUModes();
|
if (eco < 0 && mux < 0) settings.HideGPUModes();
|
||||||
|
|||||||
Reference in New Issue
Block a user