mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Fixed auto resolution switching in some exotic cases
This commit is contained in:
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using static Tools.ScreenInterrogatory;
|
using static Tools.ScreenInterrogatory;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace Tools
|
namespace Tools
|
||||||
{
|
{
|
||||||
@@ -545,22 +546,19 @@ public class NativeMethods
|
|||||||
|
|
||||||
foreach (var device in devices)
|
foreach (var device in devices)
|
||||||
{
|
{
|
||||||
if (device.outputTechnology == DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY.DISPLAYCONFIG_OUTPUT_TECHNOLOGY_INTERNAL)
|
if (device.outputTechnology == DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY.DISPLAYCONFIG_OUTPUT_TECHNOLOGY_INTERNAL ||
|
||||||
|
device.outputTechnology == DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY.DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DISPLAYPORT_EMBEDDED)
|
||||||
{
|
{
|
||||||
displayNum = count;
|
displayNum = count;
|
||||||
}
|
}
|
||||||
count++;
|
count++;
|
||||||
//Debug.WriteLine(device.outputTechnology);
|
//Logger.WriteLine(device.outputTechnology.ToString());
|
||||||
//Debug.WriteLine(device.monitorFriendlyDeviceName);
|
//Logger.WriteLine(device.monitorFriendlyDeviceName);
|
||||||
}
|
}
|
||||||
|
|
||||||
var screens = Screen.AllScreens;
|
var screens = Screen.AllScreens;
|
||||||
|
|
||||||
if (screens.Length != count)
|
if (screens.Length != count) return null;
|
||||||
{
|
|
||||||
Debug.WriteLine("Mismatch between enumerated and available screens");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
foreach (var screen in screens)
|
foreach (var screen in screens)
|
||||||
@@ -569,13 +567,15 @@ public class NativeMethods
|
|||||||
{
|
{
|
||||||
laptopScreen = screen.DeviceName;
|
laptopScreen = screen.DeviceName;
|
||||||
}
|
}
|
||||||
//Debug.WriteLine(screen.DeviceName);
|
//Logger.WriteLine(screen.DeviceName);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Debug.WriteLine("Can't find internal screen");
|
Logger.WriteLine(ex.ToString());
|
||||||
|
Logger.WriteLine("Can't detect internal screen");
|
||||||
|
//laptopScreen = Screen.PrimaryScreen.DeviceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
18
Program.cs
18
Program.cs
@@ -14,13 +14,19 @@ public static class Logger
|
|||||||
Debug.WriteLine(logMessage);
|
Debug.WriteLine(logMessage);
|
||||||
if (!Directory.Exists(appPath)) Directory.CreateDirectory(appPath);
|
if (!Directory.Exists(appPath)) Directory.CreateDirectory(appPath);
|
||||||
|
|
||||||
using (StreamWriter w = File.AppendText(logFile))
|
try
|
||||||
{
|
{
|
||||||
w.WriteLine($"{DateTime.Now}: {logMessage}");
|
using (StreamWriter w = File.AppendText(logFile))
|
||||||
|
{
|
||||||
|
w.WriteLine($"{DateTime.Now}: {logMessage}");
|
||||||
|
w.Close();
|
||||||
|
}
|
||||||
|
} catch
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var rand = new Random();
|
if (new Random().Next(100) == 1) Cleanup();
|
||||||
if (rand.Next(50) == 1) Cleanup();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -214,7 +220,9 @@ namespace GHelper
|
|||||||
settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));
|
settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));
|
||||||
|
|
||||||
settingsForm.AutoPerformance(isPlugged);
|
settingsForm.AutoPerformance(isPlugged);
|
||||||
settingsForm.AutoGPUMode(isPlugged);
|
|
||||||
|
bool switched = settingsForm.AutoGPUMode(isPlugged);
|
||||||
|
if (!switched) settingsForm.AutoScreen(isPlugged);
|
||||||
|
|
||||||
settingsForm.SetMatrix(isPlugged);
|
settingsForm.SetMatrix(isPlugged);
|
||||||
}
|
}
|
||||||
|
|||||||
14
Settings.cs
14
Settings.cs
@@ -858,33 +858,33 @@ namespace GHelper
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AutoGPUMode(PowerLineStatus Plugged = PowerLineStatus.Online)
|
public bool AutoGPUMode(PowerLineStatus Plugged = PowerLineStatus.Online)
|
||||||
{
|
{
|
||||||
|
|
||||||
int GpuAuto = Program.config.getConfig("gpu_auto");
|
int GpuAuto = Program.config.getConfig("gpu_auto");
|
||||||
if (GpuAuto != 1) return;
|
if (GpuAuto != 1) return false;
|
||||||
|
|
||||||
int eco = Program.wmi.DeviceGet(ASUSWmi.GPUEco);
|
int eco = Program.wmi.DeviceGet(ASUSWmi.GPUEco);
|
||||||
int mux = Program.wmi.DeviceGet(ASUSWmi.GPUMux);
|
int mux = Program.wmi.DeviceGet(ASUSWmi.GPUMux);
|
||||||
|
|
||||||
if (mux == 0) // GPU in Ultimate, ignore
|
if (mux == 0) // GPU in Ultimate, ignore
|
||||||
return;
|
return false;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (eco == 1 && Plugged == PowerLineStatus.Online) // Eco going Standard on plugged
|
if (eco == 1 && Plugged == PowerLineStatus.Online) // Eco going Standard on plugged
|
||||||
{
|
{
|
||||||
SetEcoGPU(0);
|
SetEcoGPU(0);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else if (eco == 0 && Plugged != PowerLineStatus.Online) // Standard going Eco on plugged
|
else if (eco == 0 && Plugged != PowerLineStatus.Online) // Standard going Eco on plugged
|
||||||
{
|
{
|
||||||
SetEcoGPU(1);
|
SetEcoGPU(1);
|
||||||
}
|
return true;
|
||||||
else
|
|
||||||
{
|
|
||||||
AutoScreen(Plugged);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int InitGPUMode()
|
public int InitGPUMode()
|
||||||
|
|||||||
Reference in New Issue
Block a user