Skip to content

Commit

Permalink
Merge branch 'main' into cpu-auto-tdp
Browse files Browse the repository at this point in the history
  • Loading branch information
IceStormNG committed Nov 16, 2024
2 parents 72e431c + 0bbbd93 commit 6041d48
Show file tree
Hide file tree
Showing 18 changed files with 423 additions and 351 deletions.
3 changes: 2 additions & 1 deletion app/AnimeMatrix/AniMatrixControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public class AniMatrixControl : NAudio.CoreAudioApi.Interfaces.IMMNotificationCl
public AniMatrixControl(SettingsForm settingsForm)
{
settings = settingsForm;

if (!AppConfig.IsSlash() && !AppConfig.IsAnimeMatrix()) return;

try
{
if (AppConfig.IsSlash())
Expand Down
19 changes: 17 additions & 2 deletions app/AppConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,11 @@ public static bool IsSingleColor()
return ContainsModel("GA401") || ContainsModel("FX517Z") || ContainsModel("FX516P") || ContainsModel("X13") || IsARCNM() || ContainsModel("FA617N") || ContainsModel("FA617X") || NoAura();
}

public static bool IsAnimeMatrix()
{
return ContainsModel("GA401") || ContainsModel("GA402") || ContainsModel("GU604V");
}

public static bool IsSlash()
{
return ContainsModel("GA403") || ContainsModel("GU605") || ContainsModel("GA605");
Expand Down Expand Up @@ -659,6 +664,11 @@ public static bool IsNoGPUModes()
return ContainsModel("GV301RA") || ContainsModel("GV302XA") || IsAlly();
}

public static bool NoGpu()
{
return Is("no_gpu") || ContainsModel("UX540");
}

public static bool IsHardwareTouchpadToggle()
{
return ContainsModel("FA507");
Expand Down Expand Up @@ -702,17 +712,22 @@ public static bool IsChargeLimit6080()
// 2024 Models support Dynamic Lighting
public static bool IsDynamicLighting()
{
return IsSlash() || IsIntelHX() || ContainsModel("FA607P") || ContainsModel("FX607J") || ContainsModel("FA507U");
return IsSlash() || IsIntelHX() || IsTUF();
}

public static bool IsForceMiniled()
{
return ContainsModel("G834JYR") || ContainsModel("G834JZR") || Is("force_miniled");
}

public static bool SaveDimming()
{
return Is("save_dimming");
}

public static bool IsAutoStatusLed()
{
return Is("auto_status_led");
}


}
1 change: 1 addition & 0 deletions app/AsusACPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public class AsusACPI
public const int ScreenPadToggle = 0x00050031;
public const int ScreenPadBrightness = 0x00050032;

public const int CameraShutter = 0x00060078;
public const int CameraLed = 0x00060079;
public const int StatusLed = 0x000600C2;

Expand Down
615 changes: 308 additions & 307 deletions app/Extra.Designer.cs

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions app/Extra.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ private void SetKeyCombo(ComboBox combo, TextBox txbox, string name)
{"brightness_up", Properties.Strings.BrightnessUp},
{"visual", Properties.Strings.VisualMode},
{"touchscreen", Properties.Strings.ToggleTouchscreen },
{"micmute", Properties.Strings.MuteMic},
{"ghelper", Properties.Strings.OpenGHelper},
{"custom", Properties.Strings.Custom}
};
Expand All @@ -62,6 +63,7 @@ private void SetKeyCombo(ComboBox combo, TextBox txbox, string name)
break;
case "m3":
customActions[""] = Properties.Strings.MuteMic;
customActions.Remove("micmute");
break;
case "m4":
customActions[""] = Properties.Strings.OpenGHelper;
Expand Down Expand Up @@ -421,7 +423,7 @@ public Extra()
var statusLed = Program.acpi.DeviceGet(AsusACPI.StatusLed);
checkStatusLed.Visible = statusLed >= 0;
checkStatusLed.Checked = (statusLed > 0);
checkStatusLed.CheckedChanged += CheckLEDStatus_CheckedChanged; ;
checkStatusLed.CheckedChanged += CheckLEDStatus_CheckedChanged;


checkBWIcon.Checked = AppConfig.IsBWIcon();
Expand Down Expand Up @@ -458,7 +460,7 @@ private void CheckPerKeyRGB_CheckedChanged(object? sender, EventArgs e)

private void CheckLEDStatus_CheckedChanged(object? sender, EventArgs e)
{
Program.acpi.DeviceSet(AsusACPI.StatusLed, (checkStatusLed.Checked ? 7 : 0), "StatusLED");
InputDispatcher.SetStatusLED(checkStatusLed.Checked);
}

private void CheckBWIcon_CheckedChanged(object? sender, EventArgs e)
Expand Down
4 changes: 2 additions & 2 deletions app/Extra.resx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Microsoft ResX Schema
Version 2.0
Expand Down Expand Up @@ -48,7 +48,7 @@
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
Expand Down
2 changes: 1 addition & 1 deletion app/GHelper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<AssemblyVersion>0.198</AssemblyVersion>
<AssemblyVersion>0.199</AssemblyVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
3 changes: 1 addition & 2 deletions app/Gpu/AMD/AmdGpuControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ public class AmdGpuControl : IGpuControl

public AmdGpuControl()
{
if (!Adl2.Load())
return;
if (AppConfig.NoGpu() || !Adl2.Load()) return;

try
{
Expand Down
6 changes: 6 additions & 0 deletions app/Gpu/GPUModeControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ public GPUModeControl(SettingsForm settingsForm)

public void InitGPUMode()
{
if (AppConfig.NoGpu())
{
settings.HideGPUModes(false);
return;
}

int eco = Program.acpi.DeviceGet(AsusACPI.GPUEco);
int mux = Program.acpi.DeviceGet(AsusACPI.GPUMux);

Expand Down
1 change: 1 addition & 0 deletions app/HardwareControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ public static void RecreateGpuControlWithDelay(int delay = 5)

public static void RecreateGpuControl()
{
if (AppConfig.NoGpu()) return;
try
{
GpuControl?.Dispose();
Expand Down
88 changes: 65 additions & 23 deletions app/Input/InputDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,14 @@ public void Init()
Program.acpi.DeviceInit();

if (!OptimizationService.IsRunning())
{
Program.acpi.DeviceGet(AsusACPI.CameraShutter);
listener = new KeyboardListener(HandleEvent);
}
else
{
Logger.WriteLine("Optimization service is running");
}

InitBacklightTimer();

Expand Down Expand Up @@ -427,7 +432,7 @@ public void KeyPressed(object sender, KeyPressedEventArgs e)
if (e.Modifier == (ModifierKeys.Control | ModifierKeys.Shift | ModifierKeys.Alt))
{
if (e.Key == keyProfile) modeControl.CyclePerformanceMode(true);

if (e.Key == keyProfile0) modeControl.SetPerformanceMode(0, true);
if (e.Key == keyProfile1) modeControl.SetPerformanceMode(1, true);
if (e.Key == keyProfile2) modeControl.SetPerformanceMode(2, true);
Expand Down Expand Up @@ -664,7 +669,7 @@ public static void ToggleFnLock()
bool fnLock = !AppConfig.Is("fn_lock");
AppConfig.Set("fn_lock", fnLock ? 1 : 0);

if (AppConfig.IsHardwareFnLock())
if (AppConfig.IsHardwareFnLock())
HardwareFnLock(fnLock);
else
Program.settingsForm.BeginInvoke(Program.inputDispatcher.RegisterKeys);
Expand Down Expand Up @@ -944,33 +949,55 @@ public static void ToggleScreenRate()

public static void ToggleCamera()
{
if (!ProcessHelper.IsUserAdministrator()) return;

string CameraRegistryKeyPath = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\webcam";
string CameraRegistryValueName = "Value";
int cameraShutter = Program.acpi.DeviceGet(AsusACPI.CameraShutter);

try
if (cameraShutter == 0)
{
Program.acpi.DeviceSet(AsusACPI.CameraShutter, 1, "CameraShutterOn");
Program.toast.RunToast($"Camera Off");
}
else if (cameraShutter == 1)
{
Program.acpi.DeviceSet(AsusACPI.CameraShutter, 0, "CameraShutterOff");
Program.toast.RunToast($"Camera On");
}
else if (cameraShutter == 262144)
{
var status = (string?)Registry.GetValue(CameraRegistryKeyPath, CameraRegistryValueName, "");
Program.toast.RunToast($"Camera Off");
}
else if (cameraShutter == 262145)
{
Program.toast.RunToast($"Camera On");
}
else
{
if (!ProcessHelper.IsUserAdministrator()) return;

if (status == "Allow") status = "Deny";
else if (status == "Deny") status = "Allow";
else
string CameraRegistryKeyPath = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\webcam";
string CameraRegistryValueName = "Value";

try
{
Logger.WriteLine("Unknown camera status");
return;
}
var status = (string?)Registry.GetValue(CameraRegistryKeyPath, CameraRegistryValueName, "");

Registry.SetValue(CameraRegistryKeyPath, CameraRegistryValueName, status, RegistryValueKind.String);
Program.acpi.DeviceSet(AsusACPI.CameraLed, (status == "Deny" ? 1 : 0), "Camera");
Program.toast.RunToast($"Camera " + (status == "Deny" ? "Off" : "On"));
if (status == "Allow") status = "Deny";
else if (status == "Deny") status = "Allow";
else
{
Logger.WriteLine("Unknown camera status");
return;
}

}
catch (Exception ex)
{
Logger.WriteLine(ex.ToString());
}
Registry.SetValue(CameraRegistryKeyPath, CameraRegistryValueName, status, RegistryValueKind.String);
Program.acpi.DeviceSet(AsusACPI.CameraLed, (status == "Deny" ? 1 : 0), "Camera");
Program.toast.RunToast($"Camera " + (status == "Deny" ? "Off" : "On"));

}
catch (Exception ex)
{
Logger.WriteLine(ex.ToString());
}
}
}

private static System.Threading.Timer screenpadActionTimer;
Expand All @@ -988,7 +1015,7 @@ public static void ApplyScreenpadAction(int brightness, bool instant = true)
if (b < 0) Program.acpi.DeviceSet(AsusACPI.ScreenPadToggle, 0, "ScreenpadOff");
};

if(delay <= 0 || instant) //instant action
if (delay <= 0 || instant) //instant action
{
action(brightness);
}
Expand Down Expand Up @@ -1039,6 +1066,21 @@ public static void InitScreenpad()
if (brightness >= 0) ApplyScreenpadAction(brightness);
}

public static void SetStatusLED(bool status)
{
Program.acpi.DeviceSet(AsusACPI.StatusLed, status ? 7 : 0, "StatusLED");
}

public static void InitStatusLed()
{
if (AppConfig.IsAutoStatusLed()) SetStatusLED(true);
}

public static void ShutdownStatusLed()
{
if (AppConfig.IsAutoStatusLed()) SetStatusLED(false);
}

static void LaunchProcess(string command = "")
{
if (string.IsNullOrEmpty(command)) return;
Expand Down
1 change: 1 addition & 0 deletions app/Input/KeyboardListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ private void Listen()
input.ReadTimeout = int.MaxValue;

var data = input.Read();
if (cancellationTokenSource.Token.IsCancellationRequested) break;
if (data.Length > 1 && data[0] == AsusHid.INPUT_ID && data[1] > 0 && data[1] != 236)
{
Logger.WriteLine($"Key: {data[1]}");
Expand Down
1 change: 1 addition & 0 deletions app/Mode/PowerNative.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ public static void SetBalancedPowerPlan()

if (activeSchemeGuid.ToString() != balanced && !AppConfig.Is("skip_power_plan"))
{
Logger.WriteLine($"Changing power plan from {activeSchemeGuid.ToString()} to Balanced");
SetPowerPlan(balanced);
}
}
Expand Down
5 changes: 2 additions & 3 deletions app/Peripherals/Mouse/AsusMouse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,8 @@ public bool IsDeviceConnected()
{
try
{
HidSharp.DeviceList.Local.GetHidDevices(VendorID(), ProductID())
.First(x => x.DevicePath.Contains(path));
return true;
return HidSharp.DeviceList.Local.GetHidDevices(VendorID(), ProductID())
.FirstOrDefault(x => x.DevicePath.Contains(path)) != null;
}
catch
{
Expand Down
6 changes: 4 additions & 2 deletions app/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ private static void SystemEvents_SessionEnding(object sender, SessionEndingEvent
{
gpuControl.StandardModeFix();
BatteryControl.AutoBattery();
InputDispatcher.ShutdownStatusLed();
}

private static void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e)
Expand Down Expand Up @@ -236,10 +237,8 @@ public static bool SetAutoModes(bool powerChanged = false, bool init = false)
Logger.WriteLine("AutoSetting for " + isPlugged.ToString());

BatteryControl.AutoBattery(init);

if (init)
{
screenControl.InitMiniled();
InputDispatcher.InitScreenpad();
}

Expand All @@ -266,6 +265,8 @@ public static bool SetAutoModes(bool powerChanged = false, bool init = false)
InputDispatcher.AutoKeyboard();
}

screenControl.InitMiniled();
InputDispatcher.InitStatusLed();
XGM.InitLight();
VisualControl.InitBrightness();

Expand All @@ -279,6 +280,7 @@ private static void SystemEvents_PowerModeChanged(object sender, PowerModeChange
{
Logger.WriteLine("Power Mode Changed:" + e.Mode.ToString());
gpuControl.StandardModeFix();
InputDispatcher.ShutdownStatusLed();
}

int delay = AppConfig.Get("charger_delay");
Expand Down
2 changes: 1 addition & 1 deletion app/Properties/Strings.de.resx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
<value>Animationsgeschwindigkeit</value>
</data>
<data name="AnimeMatrix" xml:space="preserve">
<value>AniMeMatrix</value>
<value>AniMe Matrix</value>
</data>
<data name="AppAlreadyRunning" xml:space="preserve">
<value>Die Anwendung läuft bereits</value>
Expand Down
9 changes: 5 additions & 4 deletions app/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,9 @@ public SettingsForm()
labelCharge.Click += LabelCharge_Click;

buttonDonate.Click += ButtonDonate_Click;

if (AppConfig.Get("start_count") > 10 && !AppConfig.Is("donate_click"))

int click = AppConfig.Get("donate_click");
if (AppConfig.Get("start_count") >= ((click < 10) ? 10 : click + 50))
{
buttonDonate.BorderColor = colorTurbo;
buttonDonate.Badge = true;
Expand All @@ -297,9 +298,9 @@ private void LabelBattery_Click(object? sender, EventArgs e)

private void ButtonDonate_Click(object? sender, EventArgs e)
{
AppConfig.Set("donate_click", 1);
AppConfig.Set("donate_click", AppConfig.Get("start_count"));
buttonDonate.Badge = false;
Process.Start(new ProcessStartInfo("https://github.com/seerge/g-helper/wiki/Support-Project") { UseShellExecute = true });
Process.Start(new ProcessStartInfo("https://g-helper.com/support") { UseShellExecute = true });
}

private void LabelDynamicLighting_Click(object? sender, EventArgs e)
Expand Down
Loading

0 comments on commit 6041d48

Please sign in to comment.