mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
GPU and Screen Controls
This commit is contained in:
100
app/Display/ScreenControl.cs
Normal file
100
app/Display/ScreenControl.cs
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace GHelper.Display
|
||||||
|
{
|
||||||
|
public class ScreenControl
|
||||||
|
{
|
||||||
|
static SettingsForm settings = Program.settingsForm;
|
||||||
|
public void AutoScreen(bool force = false)
|
||||||
|
{
|
||||||
|
if (force || AppConfig.Is("screen_auto"))
|
||||||
|
{
|
||||||
|
if (SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online)
|
||||||
|
SetScreen(1000, 1);
|
||||||
|
else
|
||||||
|
SetScreen(60, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetScreen(overdrive: AppConfig.Get("overdrive"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetScreen(int frequency = -1, int overdrive = -1, int miniled = -1)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (NativeMethods.GetRefreshRate() < 0) // Laptop screen not detected or has unknown refresh rate
|
||||||
|
{
|
||||||
|
InitScreen();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (frequency >= 1000)
|
||||||
|
{
|
||||||
|
frequency = NativeMethods.GetRefreshRate(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (frequency > 0)
|
||||||
|
{
|
||||||
|
NativeMethods.SetRefreshRate(frequency);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (overdrive >= 0)
|
||||||
|
{
|
||||||
|
if (AppConfig.Get("no_overdrive") == 1) overdrive = 0;
|
||||||
|
Program.acpi.DeviceSet(AsusACPI.ScreenOverdrive, overdrive, "ScreenOverdrive");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (miniled >= 0)
|
||||||
|
{
|
||||||
|
Program.acpi.DeviceSet(AsusACPI.ScreenMiniled, miniled, "Miniled");
|
||||||
|
Debug.WriteLine("Miniled " + miniled);
|
||||||
|
}
|
||||||
|
|
||||||
|
InitScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void ToogleMiniled()
|
||||||
|
{
|
||||||
|
int miniled = (AppConfig.Get("miniled") == 1) ? 0 : 1;
|
||||||
|
AppConfig.Set("miniled", miniled);
|
||||||
|
SetScreen(-1, -1, miniled);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void InitScreen()
|
||||||
|
{
|
||||||
|
int frequency = NativeMethods.GetRefreshRate();
|
||||||
|
int maxFrequency = NativeMethods.GetRefreshRate(true);
|
||||||
|
|
||||||
|
bool screenAuto = AppConfig.Is("screen_auto");
|
||||||
|
bool overdriveSetting = !AppConfig.Is("no_overdrive");
|
||||||
|
|
||||||
|
int overdrive = Program.acpi.DeviceGet(AsusACPI.ScreenOverdrive);
|
||||||
|
int miniled = Program.acpi.DeviceGet(AsusACPI.ScreenMiniled);
|
||||||
|
|
||||||
|
if (miniled >= 0)
|
||||||
|
AppConfig.Set("miniled", miniled);
|
||||||
|
|
||||||
|
bool screenEnabled = (frequency >= 0);
|
||||||
|
|
||||||
|
AppConfig.Set("frequency", frequency);
|
||||||
|
AppConfig.Set("overdrive", overdrive);
|
||||||
|
|
||||||
|
settings.Invoke(delegate
|
||||||
|
{
|
||||||
|
settings.VisualiseScreen(
|
||||||
|
screenEnabled: screenEnabled,
|
||||||
|
screenAuto: screenAuto,
|
||||||
|
frequency: frequency,
|
||||||
|
maxFrequency: maxFrequency,
|
||||||
|
overdrive: overdrive,
|
||||||
|
overdriveSetting: overdriveSetting,
|
||||||
|
miniled: miniled
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using GHelper.Gpu.AMD;
|
using GHelper.Display;
|
||||||
|
using GHelper.Gpu.AMD;
|
||||||
using GHelper.Helpers;
|
using GHelper.Helpers;
|
||||||
using GHelper.Input;
|
using GHelper.Input;
|
||||||
using GHelper.UI;
|
using GHelper.UI;
|
||||||
@@ -9,6 +10,9 @@ namespace GHelper
|
|||||||
public partial class Extra : RForm
|
public partial class Extra : RForm
|
||||||
{
|
{
|
||||||
|
|
||||||
|
ScreenControl screenControl = new ScreenControl();
|
||||||
|
|
||||||
|
|
||||||
Dictionary<string, string> customActions = new Dictionary<string, string>
|
Dictionary<string, string> customActions = new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
{"","--------------" },
|
{"","--------------" },
|
||||||
@@ -371,7 +375,7 @@ namespace GHelper
|
|||||||
private void CheckNoOverdrive_CheckedChanged(object? sender, EventArgs e)
|
private void CheckNoOverdrive_CheckedChanged(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
AppConfig.Set("no_overdrive", (checkNoOverdrive.Checked ? 1 : 0));
|
AppConfig.Set("no_overdrive", (checkNoOverdrive.Checked ? 1 : 0));
|
||||||
Program.settingsForm.AutoScreen(true);
|
screenControl.AutoScreen(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
|
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
|
||||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
<AssemblyVersion>0.91</AssemblyVersion>
|
<AssemblyVersion>0.92</AssemblyVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using GHelper.Gpu.NVidia;
|
using GHelper.Display;
|
||||||
|
using GHelper.Gpu.NVidia;
|
||||||
using GHelper.Helpers;
|
using GHelper.Helpers;
|
||||||
using GHelper.Mode;
|
using GHelper.Mode;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
@@ -9,6 +10,7 @@ namespace GHelper.Gpu
|
|||||||
{
|
{
|
||||||
static SettingsForm settings = Program.settingsForm;
|
static SettingsForm settings = Program.settingsForm;
|
||||||
ModeControl modeControl = new ModeControl();
|
ModeControl modeControl = new ModeControl();
|
||||||
|
ScreenControl screenControl = new ScreenControl();
|
||||||
|
|
||||||
public void InitGPUMode()
|
public void InitGPUMode()
|
||||||
{
|
{
|
||||||
@@ -33,6 +35,7 @@ namespace GHelper.Gpu
|
|||||||
|
|
||||||
// Ultimate mode not suported
|
// Ultimate mode not suported
|
||||||
if (mux != 1) settings.HideUltimateMode();
|
if (mux != 1) settings.HideUltimateMode();
|
||||||
|
// GPU mode not supported
|
||||||
if (eco < 0 && mux < 0) settings.HideGPUModes();
|
if (eco < 0 && mux < 0) settings.HideGPUModes();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,7 +146,7 @@ namespace GHelper.Gpu
|
|||||||
settings.Invoke(delegate
|
settings.Invoke(delegate
|
||||||
{
|
{
|
||||||
InitGPUMode();
|
InitGPUMode();
|
||||||
settings.AutoScreen();
|
screenControl.AutoScreen();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (eco == 0)
|
if (eco == 0)
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using System.Diagnostics;
|
using System.Drawing.Drawing2D;
|
||||||
using System.Drawing.Drawing2D;
|
|
||||||
|
|
||||||
|
|
||||||
namespace GHelper.Helpers
|
namespace GHelper.Helpers
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using GHelper.Helpers;
|
using GHelper.Display;
|
||||||
|
using GHelper.Helpers;
|
||||||
using GHelper.Mode;
|
using GHelper.Mode;
|
||||||
using HidLibrary;
|
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using NAudio.CoreAudioApi;
|
using NAudio.CoreAudioApi;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
@@ -8,58 +8,6 @@ using System.Management;
|
|||||||
|
|
||||||
namespace GHelper.Input
|
namespace GHelper.Input
|
||||||
{
|
{
|
||||||
public class KeyboardListener
|
|
||||||
{
|
|
||||||
|
|
||||||
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
|
|
||||||
|
|
||||||
public KeyboardListener(Action<int> KeyHandler)
|
|
||||||
{
|
|
||||||
HidDevice? input = AsusUSB.GetDevice();
|
|
||||||
if (input == null) return;
|
|
||||||
|
|
||||||
Logger.WriteLine($"Input: {input.DevicePath}");
|
|
||||||
|
|
||||||
var task = Task.Run(() =>
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
while (!cancellationTokenSource.Token.IsCancellationRequested)
|
|
||||||
{
|
|
||||||
|
|
||||||
// Emergency break
|
|
||||||
if (input == null || !input.IsConnected)
|
|
||||||
{
|
|
||||||
Logger.WriteLine("Listener terminated");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
var data = input.Read().Data;
|
|
||||||
if (data.Length > 1 && data[0] == AsusUSB.INPUT_HID_ID && data[1] > 0 && data[1] != 236)
|
|
||||||
{
|
|
||||||
Logger.WriteLine($"Key: {data[1]}");
|
|
||||||
KeyHandler(data[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger.WriteLine("Listener stopped");
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Logger.WriteLine(ex.ToString());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
cancellationTokenSource?.Cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public class InputDispatcher
|
public class InputDispatcher
|
||||||
{
|
{
|
||||||
@@ -70,7 +18,7 @@ namespace GHelper.Input
|
|||||||
public static Keys keyApp = Keys.F12;
|
public static Keys keyApp = Keys.F12;
|
||||||
|
|
||||||
static ModeControl modeControl = new ModeControl();
|
static ModeControl modeControl = new ModeControl();
|
||||||
static ToastForm toast = new ToastForm();
|
static ScreenControl screenControl = new ScreenControl();
|
||||||
|
|
||||||
KeyboardListener listener;
|
KeyboardListener listener;
|
||||||
KeyboardHook hook = new KeyboardHook();
|
KeyboardHook hook = new KeyboardHook();
|
||||||
@@ -255,12 +203,12 @@ namespace GHelper.Input
|
|||||||
break;
|
break;
|
||||||
case Keys.F7:
|
case Keys.F7:
|
||||||
if (AppConfig.ContainsModel("TUF"))
|
if (AppConfig.ContainsModel("TUF"))
|
||||||
toast.RunToast(ScreenBrightness.Adjust(-10) + "%", ToastIcon.BrightnessDown);
|
Program.toast.RunToast(ScreenBrightness.Adjust(-10) + "%", ToastIcon.BrightnessDown);
|
||||||
HandleOptimizationEvent(16);
|
HandleOptimizationEvent(16);
|
||||||
break;
|
break;
|
||||||
case Keys.F8:
|
case Keys.F8:
|
||||||
if (AppConfig.ContainsModel("TUF"))
|
if (AppConfig.ContainsModel("TUF"))
|
||||||
toast.RunToast(ScreenBrightness.Adjust(+10) + "%", ToastIcon.BrightnessUp);
|
Program.toast.RunToast(ScreenBrightness.Adjust(+10) + "%", ToastIcon.BrightnessUp);
|
||||||
HandleOptimizationEvent(32);
|
HandleOptimizationEvent(32);
|
||||||
break;
|
break;
|
||||||
case Keys.F9:
|
case Keys.F9:
|
||||||
@@ -330,7 +278,7 @@ namespace GHelper.Input
|
|||||||
NativeMethods.TurnOffScreen(Program.settingsForm.Handle);
|
NativeMethods.TurnOffScreen(Program.settingsForm.Handle);
|
||||||
break;
|
break;
|
||||||
case "miniled":
|
case "miniled":
|
||||||
Program.settingsForm.BeginInvoke(Program.settingsForm.ToogleMiniled);
|
screenControl.ToogleMiniled();
|
||||||
break;
|
break;
|
||||||
case "aura":
|
case "aura":
|
||||||
Program.settingsForm.BeginInvoke(Program.settingsForm.CycleAuraMode);
|
Program.settingsForm.BeginInvoke(Program.settingsForm.CycleAuraMode);
|
||||||
@@ -353,7 +301,7 @@ namespace GHelper.Input
|
|||||||
var commDevice = enumerator.GetDefaultAudioEndpoint(DataFlow.Capture, Role.Communications);
|
var commDevice = enumerator.GetDefaultAudioEndpoint(DataFlow.Capture, Role.Communications);
|
||||||
bool muteStatus = !commDevice.AudioEndpointVolume.Mute;
|
bool muteStatus = !commDevice.AudioEndpointVolume.Mute;
|
||||||
commDevice.AudioEndpointVolume.Mute = muteStatus;
|
commDevice.AudioEndpointVolume.Mute = muteStatus;
|
||||||
toast.RunToast(muteStatus ? "Muted" : "Unmuted", muteStatus ? ToastIcon.MicrophoneMute : ToastIcon.Microphone);
|
Program.toast.RunToast(muteStatus ? "Muted" : "Unmuted", muteStatus ? ToastIcon.MicrophoneMute : ToastIcon.Microphone);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "brightness_up":
|
case "brightness_up":
|
||||||
@@ -389,7 +337,7 @@ namespace GHelper.Input
|
|||||||
else
|
else
|
||||||
Program.settingsForm.BeginInvoke(Program.inputDispatcher.RegisterKeys);
|
Program.settingsForm.BeginInvoke(Program.inputDispatcher.RegisterKeys);
|
||||||
|
|
||||||
toast.RunToast("Fn-Lock " + (fnLock == 1 ? "On" : "Off"), ToastIcon.FnLock);
|
Program.toast.RunToast("Fn-Lock " + (fnLock == 1 ? "On" : "Off"), ToastIcon.FnLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void TabletMode()
|
public static void TabletMode()
|
||||||
@@ -444,14 +392,11 @@ namespace GHelper.Input
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!OptimizationService.IsRunning())
|
if (!OptimizationService.IsRunning())
|
||||||
|
|
||||||
HandleOptimizationEvent(EventID);
|
HandleOptimizationEvent(EventID);
|
||||||
|
|
||||||
// Asus Optimization service Events
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Asus Optimization service Events
|
||||||
static void HandleOptimizationEvent(int EventID)
|
static void HandleOptimizationEvent(int EventID)
|
||||||
{
|
{
|
||||||
switch (EventID)
|
switch (EventID)
|
||||||
@@ -465,7 +410,7 @@ namespace GHelper.Input
|
|||||||
case 107: // FN+F10
|
case 107: // FN+F10
|
||||||
bool touchpadState = GetTouchpadState();
|
bool touchpadState = GetTouchpadState();
|
||||||
AsusUSB.TouchpadToggle();
|
AsusUSB.TouchpadToggle();
|
||||||
toast.RunToast(touchpadState ? "Off" : "On", ToastIcon.Touchpad);
|
Program.toast.RunToast(touchpadState ? "Off" : "On", ToastIcon.Touchpad);
|
||||||
break;
|
break;
|
||||||
case 108: // FN+F11
|
case 108: // FN+F11
|
||||||
Program.acpi.DeviceSet(AsusACPI.UniversalControl, AsusACPI.KB_Sleep, "Sleep");
|
Program.acpi.DeviceSet(AsusACPI.UniversalControl, AsusACPI.KB_Sleep, "Sleep");
|
||||||
@@ -518,7 +463,7 @@ namespace GHelper.Input
|
|||||||
{
|
{
|
||||||
AsusUSB.ApplyBrightness(backlight, "HotKey");
|
AsusUSB.ApplyBrightness(backlight, "HotKey");
|
||||||
string[] backlightNames = new string[] { "Off", "Low", "Mid", "Max" };
|
string[] backlightNames = new string[] { "Off", "Low", "Mid", "Max" };
|
||||||
toast.RunToast(backlightNames[backlight], delta > 0 ? ToastIcon.BacklightUp : ToastIcon.BacklightDown);
|
Program.toast.RunToast(backlightNames[backlight], delta > 0 ? ToastIcon.BacklightUp : ToastIcon.BacklightDown);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
56
app/Input/KeyboardListener.cs
Normal file
56
app/Input/KeyboardListener.cs
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
using HidLibrary;
|
||||||
|
|
||||||
|
namespace GHelper.Input
|
||||||
|
{
|
||||||
|
public class KeyboardListener
|
||||||
|
{
|
||||||
|
|
||||||
|
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
|
||||||
|
|
||||||
|
public KeyboardListener(Action<int> KeyHandler)
|
||||||
|
{
|
||||||
|
HidDevice? input = AsusUSB.GetDevice();
|
||||||
|
if (input == null) return;
|
||||||
|
|
||||||
|
Logger.WriteLine($"Input: {input.DevicePath}");
|
||||||
|
|
||||||
|
var task = Task.Run(() =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
while (!cancellationTokenSource.Token.IsCancellationRequested)
|
||||||
|
{
|
||||||
|
|
||||||
|
// Emergency break
|
||||||
|
if (input == null || !input.IsConnected)
|
||||||
|
{
|
||||||
|
Logger.WriteLine("Listener terminated");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = input.Read().Data;
|
||||||
|
if (data.Length > 1 && data[0] == AsusUSB.INPUT_HID_ID && data[1] > 0 && data[1] != 236)
|
||||||
|
{
|
||||||
|
Logger.WriteLine($"Key: {data[1]}");
|
||||||
|
KeyHandler(data[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger.WriteLine("Listener stopped");
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.WriteLine(ex.ToString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
cancellationTokenSource?.Cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,7 +8,6 @@ namespace GHelper.Mode
|
|||||||
{
|
{
|
||||||
|
|
||||||
static SettingsForm settings = Program.settingsForm;
|
static SettingsForm settings = Program.settingsForm;
|
||||||
static ToastForm toast = new ToastForm();
|
|
||||||
|
|
||||||
private static bool customFans = false;
|
private static bool customFans = false;
|
||||||
private static int customPower = 0;
|
private static int customPower = 0;
|
||||||
@@ -46,7 +45,7 @@ namespace GHelper.Mode
|
|||||||
if (AppConfig.Is("xgm_fan") && Program.acpi.IsXGConnected()) AsusUSB.ResetXGM();
|
if (AppConfig.Is("xgm_fan") && Program.acpi.IsXGConnected()) AsusUSB.ResetXGM();
|
||||||
|
|
||||||
if (notify)
|
if (notify)
|
||||||
toast.RunToast(Modes.GetCurrentName(), SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online ? ToastIcon.Charger : ToastIcon.Battery);
|
Program.toast.RunToast(Modes.GetCurrentName(), SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online ? ToastIcon.Charger : ToastIcon.Battery);
|
||||||
|
|
||||||
SetGPUClocks();
|
SetGPUClocks();
|
||||||
AutoFans();
|
AutoFans();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using GHelper.Gpu;
|
|||||||
using GHelper.Helpers;
|
using GHelper.Helpers;
|
||||||
using GHelper.Input;
|
using GHelper.Input;
|
||||||
using GHelper.Mode;
|
using GHelper.Mode;
|
||||||
|
using GHelper.Display;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using Ryzen;
|
using Ryzen;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
@@ -26,6 +27,9 @@ namespace GHelper
|
|||||||
public static SettingsForm settingsForm = new SettingsForm();
|
public static SettingsForm settingsForm = new SettingsForm();
|
||||||
public static ModeControl modeControl = new ModeControl();
|
public static ModeControl modeControl = new ModeControl();
|
||||||
public static GPUModeControl gpuControl = new GPUModeControl();
|
public static GPUModeControl gpuControl = new GPUModeControl();
|
||||||
|
public static ScreenControl screenControl = new ScreenControl();
|
||||||
|
|
||||||
|
public static ToastForm toast = new ToastForm();
|
||||||
|
|
||||||
public static IntPtr unRegPowerNotify;
|
public static IntPtr unRegPowerNotify;
|
||||||
|
|
||||||
@@ -159,7 +163,7 @@ namespace GHelper
|
|||||||
if (!switched)
|
if (!switched)
|
||||||
{
|
{
|
||||||
gpuControl.InitGPUMode();
|
gpuControl.InitGPUMode();
|
||||||
settingsForm.AutoScreen();
|
screenControl.AutoScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
settingsForm.AutoKeyboard();
|
settingsForm.AutoKeyboard();
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using GHelper.Gpu;
|
|||||||
using GHelper.Helpers;
|
using GHelper.Helpers;
|
||||||
using GHelper.Input;
|
using GHelper.Input;
|
||||||
using GHelper.Mode;
|
using GHelper.Mode;
|
||||||
|
using GHelper.Display;
|
||||||
using GHelper.UI;
|
using GHelper.UI;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
@@ -21,6 +22,7 @@ namespace GHelper
|
|||||||
|
|
||||||
ModeControl modeControl = new ModeControl();
|
ModeControl modeControl = new ModeControl();
|
||||||
GPUModeControl gpuControl = new GPUModeControl();
|
GPUModeControl gpuControl = new GPUModeControl();
|
||||||
|
ScreenControl screenControl = new ScreenControl();
|
||||||
|
|
||||||
public static System.Timers.Timer aTimer = default!;
|
public static System.Timers.Timer aTimer = default!;
|
||||||
public string versionUrl = "http://github.com/seerge/g-helper/releases";
|
public string versionUrl = "http://github.com/seerge/g-helper/releases";
|
||||||
@@ -190,7 +192,7 @@ namespace GHelper
|
|||||||
aTimer.Enabled = this.Visible;
|
aTimer.Enabled = this.Visible;
|
||||||
if (this.Visible)
|
if (this.Visible)
|
||||||
{
|
{
|
||||||
InitScreen();
|
screenControl.InitScreen();
|
||||||
gpuControl.InitXGM();
|
gpuControl.InitXGM();
|
||||||
|
|
||||||
// Run update once per 12 hours
|
// Run update once per 12 hours
|
||||||
@@ -537,8 +539,7 @@ namespace GHelper
|
|||||||
private void ButtonScreenAuto_Click(object? sender, EventArgs e)
|
private void ButtonScreenAuto_Click(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
AppConfig.Set("screen_auto", 1);
|
AppConfig.Set("screen_auto", 1);
|
||||||
InitScreen();
|
screenControl.AutoScreen();
|
||||||
AutoScreen();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -779,76 +780,26 @@ namespace GHelper
|
|||||||
private void Button120Hz_Click(object? sender, EventArgs e)
|
private void Button120Hz_Click(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
AppConfig.Set("screen_auto", 0);
|
AppConfig.Set("screen_auto", 0);
|
||||||
SetScreen(1000, 1);
|
screenControl.SetScreen(1000, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Button60Hz_Click(object? sender, EventArgs e)
|
private void Button60Hz_Click(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
AppConfig.Set("screen_auto", 0);
|
AppConfig.Set("screen_auto", 0);
|
||||||
SetScreen(60, 0);
|
screenControl.SetScreen(60, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ToogleMiniled()
|
|
||||||
{
|
|
||||||
int miniled = (AppConfig.Get("miniled") == 1) ? 0 : 1;
|
|
||||||
AppConfig.Set("miniled", miniled);
|
|
||||||
SetScreen(-1, -1, miniled);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonMiniled_Click(object? sender, EventArgs e)
|
private void ButtonMiniled_Click(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
ToogleMiniled();
|
screenControl.ToogleMiniled();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetScreen(int frequency = -1, int overdrive = -1, int miniled = -1)
|
|
||||||
|
|
||||||
|
public void VisualiseScreen(bool screenEnabled, bool screenAuto, int frequency, int maxFrequency, int overdrive, bool overdriveSetting, int miniled)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (NativeMethods.GetRefreshRate() < 0) // Laptop screen not detected or has unknown refresh rate
|
|
||||||
{
|
|
||||||
InitScreen();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (frequency >= 1000)
|
|
||||||
{
|
|
||||||
frequency = NativeMethods.GetRefreshRate(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (frequency > 0)
|
|
||||||
{
|
|
||||||
NativeMethods.SetRefreshRate(frequency);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (overdrive >= 0)
|
|
||||||
{
|
|
||||||
if (AppConfig.Get("no_overdrive") == 1) overdrive = 0;
|
|
||||||
Program.acpi.DeviceSet(AsusACPI.ScreenOverdrive, overdrive, "ScreenOverdrive");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (miniled >= 0)
|
|
||||||
{
|
|
||||||
Program.acpi.DeviceSet(AsusACPI.ScreenMiniled, miniled, "Miniled");
|
|
||||||
Debug.WriteLine("Miniled " + miniled);
|
|
||||||
}
|
|
||||||
|
|
||||||
InitScreen();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void InitScreen()
|
|
||||||
{
|
|
||||||
|
|
||||||
int frequency = NativeMethods.GetRefreshRate();
|
|
||||||
int maxFrequency = NativeMethods.GetRefreshRate(true);
|
|
||||||
|
|
||||||
bool screenAuto = AppConfig.Is("screen_auto");
|
|
||||||
bool overdriveSetting = (AppConfig.Get("no_overdrive") != 1);
|
|
||||||
|
|
||||||
int overdrive = Program.acpi.DeviceGet(AsusACPI.ScreenOverdrive);
|
|
||||||
int miniled = Program.acpi.DeviceGet(AsusACPI.ScreenMiniled);
|
|
||||||
|
|
||||||
bool screenEnabled = (frequency >= 0);
|
|
||||||
|
|
||||||
ButtonEnabled(button60Hz, screenEnabled);
|
ButtonEnabled(button60Hz, screenEnabled);
|
||||||
ButtonEnabled(button120Hz, screenEnabled);
|
ButtonEnabled(button120Hz, screenEnabled);
|
||||||
ButtonEnabled(buttonScreenAuto, screenEnabled);
|
ButtonEnabled(buttonScreenAuto, screenEnabled);
|
||||||
@@ -888,15 +839,12 @@ namespace GHelper
|
|||||||
if (miniled >= 0)
|
if (miniled >= 0)
|
||||||
{
|
{
|
||||||
buttonMiniled.Activated = (miniled == 1);
|
buttonMiniled.Activated = (miniled == 1);
|
||||||
AppConfig.Set("miniled", miniled);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
buttonMiniled.Visible = false;
|
buttonMiniled.Visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AppConfig.Set("frequency", frequency);
|
|
||||||
AppConfig.Set("overdrive", overdrive);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonQuit_Click(object? sender, EventArgs e)
|
private void ButtonQuit_Click(object? sender, EventArgs e)
|
||||||
@@ -914,9 +862,6 @@ namespace GHelper
|
|||||||
if (keyb != null && keyb.Text != "") keyb.Close();
|
if (keyb != null && keyb.Text != "") keyb.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CloseOthers()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SettingsForm_FormClosing(object? sender, FormClosingEventArgs e)
|
private void SettingsForm_FormClosing(object? sender, FormClosingEventArgs e)
|
||||||
{
|
{
|
||||||
@@ -1058,24 +1003,6 @@ namespace GHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void AutoScreen(bool force = false)
|
|
||||||
{
|
|
||||||
if (force || AppConfig.Is("screen_auto"))
|
|
||||||
{
|
|
||||||
if (SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online)
|
|
||||||
SetScreen(1000, 1);
|
|
||||||
else
|
|
||||||
SetScreen(60, 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SetScreen(overdrive: AppConfig.Get("overdrive"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void VisualizeXGM(bool connected, bool activated)
|
public void VisualizeXGM(bool connected, bool activated)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -1113,10 +1040,12 @@ namespace GHelper
|
|||||||
public void HideGPUModes()
|
public void HideGPUModes()
|
||||||
{
|
{
|
||||||
isGpuSection = false;
|
isGpuSection = false;
|
||||||
|
|
||||||
buttonEco.Visible = false;
|
buttonEco.Visible = false;
|
||||||
buttonStandard.Visible = false;
|
buttonStandard.Visible = false;
|
||||||
buttonUltimate.Visible = false;
|
buttonUltimate.Visible = false;
|
||||||
buttonOptimized.Visible = false;
|
buttonOptimized.Visible = false;
|
||||||
|
|
||||||
buttonStopGPU.Visible = true;
|
buttonStopGPU.Visible = true;
|
||||||
|
|
||||||
SetContextMenu();
|
SetContextMenu();
|
||||||
|
|||||||
Reference in New Issue
Block a user