mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Dimming init
This commit is contained in:
@@ -2,6 +2,13 @@
|
|||||||
|
|
||||||
namespace GHelper.Display
|
namespace GHelper.Display
|
||||||
{
|
{
|
||||||
|
enum SplendidCommand: int
|
||||||
|
{
|
||||||
|
Init = 10,
|
||||||
|
DimmingAsus = 9,
|
||||||
|
DimmingVisual = 19
|
||||||
|
}
|
||||||
|
|
||||||
public static class ScreenControl
|
public static class ScreenControl
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -10,28 +17,41 @@ namespace GHelper.Display
|
|||||||
public static DisplayGammaRamp? gammaRamp;
|
public static DisplayGammaRamp? gammaRamp;
|
||||||
|
|
||||||
private static int _brightness = 100;
|
private static int _brightness = 100;
|
||||||
|
private static bool _init = true;
|
||||||
|
|
||||||
private static System.Timers.Timer brightnessTimer = new System.Timers.Timer(100);
|
private static System.Timers.Timer brightnessTimer = new System.Timers.Timer(100);
|
||||||
|
|
||||||
static ScreenControl () {
|
static ScreenControl () {
|
||||||
brightnessTimer.Elapsed += BrightnessTimerTimer_Elapsed;
|
brightnessTimer.Elapsed += BrightnessTimerTimer_Elapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool RunSplendid(SplendidCommand command, int? param1 = null, int? param2 = null)
|
||||||
|
{
|
||||||
|
var splendid = Environment.SystemDirectory + "\\DriverStore\\FileRepository\\asussci2.inf_amd64_f2eed2fae3b45a67\\ASUSOptimization\\AsusSplendid.exe";
|
||||||
|
bool isGameVisual = Directory.Exists("C:\\ProgramData\\ASUS\\GameVisual");
|
||||||
|
bool isSplenddid = File.Exists(splendid);
|
||||||
|
|
||||||
|
if (isSplenddid)
|
||||||
|
{
|
||||||
|
if (command == SplendidCommand.DimmingVisual && !isGameVisual) command = SplendidCommand.DimmingAsus;
|
||||||
|
var result = ProcessHelper.RunCMD(splendid, (int)command + " " + param1 + " " + param2);
|
||||||
|
if (result.Contains("file not exist") || (result.Length == 0 && isGameVisual)) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private static void BrightnessTimerTimer_Elapsed(object? sender, System.Timers.ElapsedEventArgs e)
|
private static void BrightnessTimerTimer_Elapsed(object? sender, System.Timers.ElapsedEventArgs e)
|
||||||
{
|
{
|
||||||
brightnessTimer.Stop();
|
brightnessTimer.Stop();
|
||||||
|
|
||||||
var splendid = Environment.SystemDirectory + "\\DriverStore\\FileRepository\\asussci2.inf_amd64_f2eed2fae3b45a67\\ASUSOptimization\\AsusSplendid.exe";
|
if (_init)
|
||||||
|
|
||||||
bool isSplenddid = File.Exists(splendid);
|
|
||||||
bool isGameVisual = Directory.Exists("C:\\ProgramData\\ASUS\\GameVisual");
|
|
||||||
|
|
||||||
if (isSplenddid)
|
|
||||||
{
|
{
|
||||||
var result = ProcessHelper.RunCMD(splendid, (isGameVisual ? 19 : 9) + " 0 " + (40 + _brightness * 0.6));
|
RunSplendid(SplendidCommand.Init, 4);
|
||||||
bool fail = result.Contains("file not exist") || (result.Length == 0 && isGameVisual);
|
_init = false;
|
||||||
if (!fail) return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (RunSplendid(SplendidCommand.DimmingVisual, 0, (int)(40 + _brightness * 0.6))) return;
|
||||||
// GammaRamp Fallback
|
// GammaRamp Fallback
|
||||||
SetGamma(_brightness);
|
SetGamma(_brightness);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user