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.Runtime.InteropServices;
|
||||
using static Tools.ScreenInterrogatory;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Tools
|
||||
{
|
||||
@@ -545,22 +546,19 @@ public class NativeMethods
|
||||
|
||||
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;
|
||||
}
|
||||
count++;
|
||||
//Debug.WriteLine(device.outputTechnology);
|
||||
//Debug.WriteLine(device.monitorFriendlyDeviceName);
|
||||
//Logger.WriteLine(device.outputTechnology.ToString());
|
||||
//Logger.WriteLine(device.monitorFriendlyDeviceName);
|
||||
}
|
||||
|
||||
var screens = Screen.AllScreens;
|
||||
|
||||
if (screens.Length != count)
|
||||
{
|
||||
Debug.WriteLine("Mismatch between enumerated and available screens");
|
||||
return null;
|
||||
}
|
||||
if (screens.Length != count) return null;
|
||||
|
||||
count = 0;
|
||||
foreach (var screen in screens)
|
||||
@@ -569,13 +567,15 @@ public class NativeMethods
|
||||
{
|
||||
laptopScreen = screen.DeviceName;
|
||||
}
|
||||
//Debug.WriteLine(screen.DeviceName);
|
||||
//Logger.WriteLine(screen.DeviceName);
|
||||
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);
|
||||
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 (rand.Next(50) == 1) Cleanup();
|
||||
if (new Random().Next(100) == 1) Cleanup();
|
||||
|
||||
|
||||
}
|
||||
@@ -214,7 +220,9 @@ namespace GHelper
|
||||
settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));
|
||||
|
||||
settingsForm.AutoPerformance(isPlugged);
|
||||
settingsForm.AutoGPUMode(isPlugged);
|
||||
|
||||
bool switched = settingsForm.AutoGPUMode(isPlugged);
|
||||
if (!switched) settingsForm.AutoScreen(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");
|
||||
if (GpuAuto != 1) return;
|
||||
if (GpuAuto != 1) return false;
|
||||
|
||||
int eco = Program.wmi.DeviceGet(ASUSWmi.GPUEco);
|
||||
int mux = Program.wmi.DeviceGet(ASUSWmi.GPUMux);
|
||||
|
||||
if (mux == 0) // GPU in Ultimate, ignore
|
||||
return;
|
||||
return false;
|
||||
else
|
||||
{
|
||||
if (eco == 1 && Plugged == PowerLineStatus.Online) // Eco going Standard on plugged
|
||||
{
|
||||
SetEcoGPU(0);
|
||||
return true;
|
||||
}
|
||||
else if (eco == 0 && Plugged != PowerLineStatus.Online) // Standard going Eco on plugged
|
||||
{
|
||||
SetEcoGPU(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoScreen(Plugged);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public int InitGPUMode()
|
||||
|
||||
Reference in New Issue
Block a user