Skip to content

Commit

Permalink
TR
Browse files Browse the repository at this point in the history
  • Loading branch information
HamzaYslmn committed Mar 25, 2023
2 parents 759329c + 4853c09 commit c6f8266
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 35 deletions.
34 changes: 14 additions & 20 deletions app/ASUSWmi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,28 +253,22 @@ public void TUFKeyboardRGB(int mode, Color color, int speed)

}

const int ASUS_WMI_KEYBOARD_POWER_BOOT = 0x03 << 16;
const int ASUS_WMI_KEYBOARD_POWER_AWAKE = 0x0C << 16;
const int ASUS_WMI_KEYBOARD_POWER_SLEEP = 0x30 << 16;
const int ASUS_WMI_KEYBOARD_POWER_SHUTDOWN = 0xC0 << 16;
public void TUFKeyboardPower(bool awake = true, bool boot = false, bool sleep = false, bool shutdown = false)
{
uint flags;
uint cmd = 1;

flags = 0;
if (boot)
flags |= (1 << 1);
if (awake)
flags |= (1 << 3);
if (sleep)
flags |= (1 << 5);
if (shutdown)
flags |= (1 << 7);

byte[] state = new byte[12];
state[0] = 0xbd;
state[1] = (byte)((cmd != 0) ? (1 << 2) : 0);
state[2] = (byte)flags;

DeviceSet(TUF_KB, state);
Debug.WriteLine(BitConverter.ToString(state));
int state = 0xbd;

if (boot) state = state | ASUS_WMI_KEYBOARD_POWER_BOOT;
if (awake) state = state | ASUS_WMI_KEYBOARD_POWER_AWAKE;
if (sleep) state = state | ASUS_WMI_KEYBOARD_POWER_SLEEP;
if (shutdown) state = state | ASUS_WMI_KEYBOARD_POWER_SHUTDOWN;

state = state | 0x01 << 8;

DeviceSet(TUF_KB_STATE, state);
}

public void SubscribeToEvents(Action<object, EventArrivedEventArgs> EventHandler)
Expand Down
9 changes: 7 additions & 2 deletions app/AppConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ public AppConfig()
}



public bool ContainsModel(string contains)
public string GetModel()
{
if (_model is null)
{
Expand All @@ -56,6 +55,12 @@ public bool ContainsModel(string contains)
}
}

return _model;
}
public bool ContainsModel(string contains)
{

GetModel();
return (_model is not null && _model.Contains(contains));

}
Expand Down
21 changes: 18 additions & 3 deletions app/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 14 additions & 10 deletions app/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,17 @@ public SettingsForm()
aTimer = new System.Timers.Timer(500);
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);
Thread t = new Thread(() =>
{
await Task.Delay(TimeSpan.FromSeconds(5));
CheckForUpdatesAsync();
});
t.Start();
t.Join();

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

}

Expand All @@ -157,8 +157,6 @@ public async void CheckForUpdatesAsync()
var tag = config.GetProperty("tag_name").ToString().Replace("v", "");
var url = config.GetProperty("assets")[0].GetProperty("browser_download_url").ToString();

Thread.Sleep(5000);

var gitVersion = new Version(tag);
var appVersion = new Version(Assembly.GetExecutingAssembly().GetName().Version.ToString());

Expand Down Expand Up @@ -507,7 +505,7 @@ public void SetMatrix(PowerLineStatus Plugged = PowerLineStatus.Online)
private void LabelCPUFan_Click(object? sender, EventArgs e)
{
Program.config.setConfig("fan_rpm", (Program.config.getConfig("fan_rpm") == 1) ? 0 : 1);
RefreshSensors();
RefreshSensors(true);
}

private void PictureColor2_Click(object? sender, EventArgs e)
Expand Down Expand Up @@ -809,10 +807,10 @@ private static string FormatFan(int fan)
return " Fan: " + Math.Min(Math.Round(fan / 0.6), 100).ToString() + "%"; // relatively to 6000 rpm
}

private static void RefreshSensors()
private static void RefreshSensors(bool force = false)
{

if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastRefresh) < 2000) return;
if (!force && Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastRefresh) < 2000) return;
lastRefresh = DateTimeOffset.Now.ToUnixTimeMilliseconds();

string cpuFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.CPU_Fan));
Expand Down Expand Up @@ -903,6 +901,12 @@ public void AutoFansAndPower()

if (Program.config.getConfig("mid_fan") == 1)
Program.wmi.SetFanCurve(2, Program.config.getFanConfig(2));

labelPerf.Text = "Performance Mode+";

} else
{
labelPerf.Text = "Performance Mode";
}

if (Program.config.getConfigPerf("auto_apply_power") == 1)
Expand Down

0 comments on commit c6f8266

Please sign in to comment.