Skip to content

Commit

Permalink
TR
Browse files Browse the repository at this point in the history
  • Loading branch information
HamzaYslmn committed Apr 3, 2023
2 parents 5ac52eb + dcfaf66 commit 924ca08
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
12 changes: 10 additions & 2 deletions app/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public static void Main()

wmi.SubscribeToEvents(WatcherEventArrived);

settingsForm.InitGPUMode();
settingsForm.InitAura();
settingsForm.InitMatrix();

Expand All @@ -79,6 +78,10 @@ public static void Main()
SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
SystemEvents.UserPreferenceChanged += SystemEvents_UserPreferenceChanged;

// Subscribing for monitor power on events
var settingGuid = new NativeMethods.PowerSettingGuid();
unRegPowerNotify = NativeMethods.RegisterPowerSettingNotification(ds, settingGuid.ConsoleDisplayState, NativeMethods.DEVICE_NOTIFY_WINDOW_HANDLE);


if (Environment.CurrentDirectory.Trim('\\') == Application.StartupPath.Trim('\\'))
{
Expand Down Expand Up @@ -129,7 +132,12 @@ public static void SetAutoModes()
settingsForm.AutoPerformance();

bool switched = settingsForm.AutoGPUMode();
if (!switched) settingsForm.AutoScreen();

if (!switched)
{
settingsForm.InitGPUMode();
settingsForm.AutoScreen();
}

settingsForm.AutoKeyboard();
settingsForm.SetMatrix();
Expand Down
36 changes: 19 additions & 17 deletions app/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,6 @@ public SettingsForm()
aTimer = new System.Timers.Timer(1000);
aTimer.Elapsed += OnTimedEvent;

// Subscribing for monitor power on events
var settingGuid = new NativeMethods.PowerSettingGuid();
Program.unRegPowerNotify = NativeMethods.RegisterPowerSettingNotification(Handle, settingGuid.ConsoleDisplayState, NativeMethods.DEVICE_NOTIFY_WINDOW_HANDLE);

SetVersionLabel("[₺] Sürüm: " + Assembly.GetExecutingAssembly().GetName().Version);

string model = Program.config.GetModel();
Expand Down Expand Up @@ -1048,7 +1044,11 @@ public bool AutoGPUMode()
var Plugged = SystemInformation.PowerStatus.PowerLineStatus;

bool GpuAuto = Program.config.getConfig("gpu_auto") == 1;
if (!GpuAuto) return false;
bool ForceGPU = Program.config.ContainsModel("503");

int GpuMode = Program.config.getConfig("gpu_mode");

if (!GpuAuto && !ForceGPU) return false;

int eco = Program.wmi.DeviceGet(ASUSWmi.GPUEco);
int mux = Program.wmi.DeviceGet(ASUSWmi.GPUMux);
Expand All @@ -1057,16 +1057,18 @@ public bool AutoGPUMode()
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);
return true;
}
if (eco == 1)
if ((GpuAuto && Plugged == PowerLineStatus.Online) || (ForceGPU && GpuMode == ASUSWmi.GPUModeStandard))
{
SetEcoGPU(0);
return true;
}
if (eco == 0)
if ((GpuAuto && Plugged != PowerLineStatus.Online) || (ForceGPU && GpuMode == ASUSWmi.GPUModeEco))
{
SetEcoGPU(1);
return true;
}
}

return false;
Expand Down Expand Up @@ -1095,8 +1097,8 @@ public int InitGPUMode()
int eco = Program.wmi.DeviceGet(ASUSWmi.GPUEco);
int mux = Program.wmi.DeviceGet(ASUSWmi.GPUMux);

//Logger.WriteLine("Eco flag : " + eco);
//Logger.WriteLine("Mux flag : " + mux);
Logger.WriteLine("Eco flag : " + eco);
Logger.WriteLine("Mux flag : " + mux);

int GpuMode;

Expand Down

0 comments on commit 924ca08

Please sign in to comment.