Skip to content

Commit

Permalink
Merge branch 'main' into cpu-auto-tdp
Browse files Browse the repository at this point in the history
# Conflicts:
#	app/AppConfig.cs
  • Loading branch information
IceStormNG committed Mar 20, 2024
2 parents 85a3e28 + 5e75829 commit e1f765d
Show file tree
Hide file tree
Showing 36 changed files with 1,189 additions and 430 deletions.
9 changes: 8 additions & 1 deletion app/AnimeMatrix/AniMatrixControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class AniMatrixControl : NAudio.CoreAudioApi.Interfaces.IMMNotificationCl
public SlashDevice? deviceSlash;

public static bool lidClose = false;
private static bool _wakeUp = false;

double[]? AudioValues;
WasapiCapture? AudioDevice;
Expand Down Expand Up @@ -91,7 +92,7 @@ public void SetSlash(bool wakeUp = false)
return;
}

if (wakeUp) deviceSlash.WakeUp();
if (wakeUp) _wakeUp = true;

if (brightness == 0 || (auto && SystemInformation.PowerStatus.PowerLineStatus != PowerLineStatus.Online) || (lid && lidClose))
{
Expand All @@ -100,6 +101,12 @@ public void SetSlash(bool wakeUp = false)
}
else
{
if (_wakeUp)
{
deviceSlash.WakeUp();
_wakeUp = false;
}

deviceSlash.Init();
deviceSlash.SetMode((SlashMode)running);
deviceSlash.SetOptions(true, brightness, inteval);
Expand Down
20 changes: 10 additions & 10 deletions app/AnimeMatrix/SlashDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,18 @@ public SlashDevice() : base(0x0B05, 0x193B, 128)

public void WakeUp()
{
Set(Packet<SlashPacket>(Encoding.ASCII.GetBytes("ASUS Tech.Inc.")));
Set(Packet<SlashPacket>(Encoding.ASCII.GetBytes("ASUS Tech.Inc.")), "SlashWakeUp");
}

public void Init()
{
Set(Packet<SlashPacket>(0xD7, 0x00, 0x00, 0x01, 0xAC));
Set(Packet<SlashPacket>(0xD2, 0x02, 0x01, 0x08, 0xAB));
Set(Packet<SlashPacket>(0xD7, 0x00, 0x00, 0x01, 0xAC), "SlashInit");
Set(Packet<SlashPacket>(0xD2, 0x02, 0x01, 0x08, 0xAB), "SlashInit");
}

public void Save()
{
Set(Packet<SlashPacket>(0xD4, 0x00, 0x00, 0x01, 0xAB));
Set(Packet<SlashPacket>(0xD4, 0x00, 0x00, 0x01, 0xAB), "SlashSave");
}

public void SetMode(SlashMode mode)
Expand All @@ -111,31 +111,31 @@ public void SetMode(SlashMode mode)
modeByte = 0x00;
}

Set(Packet<SlashPacket>(0xD2, 0x03, 0x00, 0x0C));
Set(Packet<SlashPacket>(0xD3, 0x04, 0x00, 0x0C, 0x01, modeByte, 0x02, 0x19, 0x03, 0x13, 0x04, 0x11, 0x05, 0x12, 0x06, 0x13));
Set(Packet<SlashPacket>(0xD2, 0x03, 0x00, 0x0C), "SlashMode");
Set(Packet<SlashPacket>(0xD3, 0x04, 0x00, 0x0C, 0x01, modeByte, 0x02, 0x19, 0x03, 0x13, 0x04, 0x11, 0x05, 0x12, 0x06, 0x13), "SlashMode");
}

public void SetOptions(bool status, int brightness = 0, int interval = 0)
{
byte brightnessByte = (byte)(brightness * 85.333);

Set(Packet<SlashPacket>(0xD3, 0x03, 0x01, 0x08, 0xAB, 0xFF, 0x01, status ? (byte)0x01 : (byte)0x00, 0x06, brightnessByte, 0xFF, (byte)interval));
Set(Packet<SlashPacket>(0xD3, 0x03, 0x01, 0x08, 0xAB, 0xFF, 0x01, status ? (byte)0x01 : (byte)0x00, 0x06, brightnessByte, 0xFF, (byte)interval), "SlashOptions");
}

public void SetBatterySaver(bool status)
{
Set(Packet<SlashPacket>(0xD8, 0x01, 0x00, 0x01, status ? (byte)0x80 : (byte)0x00));
Set(Packet<SlashPacket>(0xD8, 0x01, 0x00, 0x01, status ? (byte)0x80 : (byte)0x00), "SlashBatterySaver");
}

public void SetLidMode(bool status)
{
Set(Packet<SlashPacket>(0xD8, 0x00, 0x00, 0x02, 0xA5, status ? (byte)0x80 : (byte)0x00));
}

public void Set(Packet packet)
public void Set(Packet packet, string? log = null)
{
_usbProvider?.Set(packet.Data);
Logger.WriteLine("Slash:" + BitConverter.ToString(packet.Data));
if (log is not null) Logger.WriteLine("Slash:" + BitConverter.ToString(packet.Data));
}


Expand Down
20 changes: 16 additions & 4 deletions app/AppConfig.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using GHelper;
using GHelper;
using GHelper.Mode;
using System.Management;
using System.Text.Json;
Expand Down Expand Up @@ -380,7 +380,7 @@ public static bool SwappedBrightness()

public static bool IsDUO()
{
return ContainsModel("Duo");
return ContainsModel("Duo") || ContainsModel("GX550") || ContainsModel("GX650");
}

// G14 2020 has no aura, but media keys instead
Expand All @@ -406,7 +406,7 @@ public static bool IsInputBacklight()

public static bool IsOLED()
{
return ContainsModel("OLED") || IsSlash() || ContainsModel("UX64") || ContainsModel("UX34") || ContainsModel("UX53") || ContainsModel("K360") || ContainsModel("X150") || ContainsModel("M3500") || ContainsModel("K650") || ContainsModel("UM53") || ContainsModel("K660");
return ContainsModel("OLED") || IsSlash() || ContainsModel("M7600") || ContainsModel("UX64") || ContainsModel("UX34") || ContainsModel("UX53") || ContainsModel("K360") || ContainsModel("X150") || ContainsModel("M3500") || ContainsModel("K650") || ContainsModel("UM53") || ContainsModel("K660");
}

public static bool IsNoOverdrive()
Expand Down Expand Up @@ -437,7 +437,7 @@ public static bool IsNoAirplaneMode()

public static bool NoWMI()
{
return ContainsModel("GL704G");
return ContainsModel("GL704G") || ContainsModel("GM501G");
}

public static bool IsNoDirectRGB()
Expand All @@ -455,6 +455,11 @@ public static bool IsZ13()
return ContainsModel("Z13");
}

public static bool IsS17()
{
return ContainsModel("S17");
}

public static bool HasTabletMode()
{
return ContainsModel("X16") || ContainsModel("X13");
Expand Down Expand Up @@ -598,6 +603,11 @@ public static bool IsNewAura()
return ContainsModel("G834") || ContainsModel("G614") || ContainsModel("G834") || ContainsModel("G634");
}

public static bool IsNoFNV()
{
return ContainsModel("FX507") || ContainsModel("FX707");
}

public static bool IsROG()
{
return ContainsModel("ROG");
Expand All @@ -612,4 +622,6 @@ public static bool IsBWIcon()
return Is("bw_icon");
}



}
6 changes: 6 additions & 0 deletions app/Extra.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public Extra()
labelBacklightLogo.Text = Properties.Strings.Logo;

checkGpuApps.Text = Properties.Strings.KillGpuApps;
checkBWIcon.Text = Properties.Strings.BWTrayIcon;
labelHibernateAfter.Text = Properties.Strings.HibernateAfter;

labelAPUMem.Text = Properties.Strings.APUMemory;
Expand Down Expand Up @@ -209,6 +210,11 @@ public Extra()
labelFNE.Visible = comboFNE.Visible = textFNE.Visible = false;
}

if (AppConfig.IsNoFNV())
{
labelFNV.Visible = comboFNV.Visible = textFNV.Visible = false;
}

if (Program.acpi.DeviceGet(AsusACPI.GPUEco) < 0)
{
checkGpuApps.Visible = false;
Expand Down
1 change: 1 addition & 0 deletions app/Fans.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public Fans()
labelGPUMemoryTitle.Text = Properties.Strings.GPUMemoryClockOffset;
labelGPUBoostTitle.Text = Properties.Strings.GPUBoost;
labelGPUTempTitle.Text = Properties.Strings.GPUTempTarget;
labelGPUPowerTitle.Text = Properties.Strings.GPUPower;

labelRisky.Text = Properties.Strings.UndervoltingRisky;
buttonApplyAdvanced.Text = Properties.Strings.Apply;
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.159</AssemblyVersion>
<AssemblyVersion>0.161</AssemblyVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
19 changes: 9 additions & 10 deletions app/Input/InputDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ public static void KeyProcess(string name = "m3")
break;
case "micmute":
bool muteStatus = Audio.ToggleMute();
Program.toast.RunToast(muteStatus ? "Muted" : "Unmuted", muteStatus ? ToastIcon.MicrophoneMute : ToastIcon.Microphone);
Program.toast.RunToast(muteStatus ? Properties.Strings.Muted : Properties.Strings.Unmuted, muteStatus ? ToastIcon.MicrophoneMute : ToastIcon.Microphone);
if (AppConfig.IsVivoZenbook()) Program.acpi.DeviceSet(AsusACPI.MicMuteLed, muteStatus ? 1 : 0, "MicmuteLed");
break;
case "brightness_up":
Expand Down Expand Up @@ -551,7 +551,7 @@ static void ToggleTouchpadEvent(bool hotkey = false)
{
if (hotkey || !AppConfig.IsHardwareTouchpadToggle()) ToggleTouchpad();
Thread.Sleep(200);
Program.toast.RunToast(GetTouchpadState() ? "On" : "Off", ToastIcon.Touchpad);
Program.toast.RunToast(GetTouchpadState() ? Properties.Strings.On : Properties.Strings.Off, ToastIcon.Touchpad);
}

static void ToggleTouchpad()
Expand All @@ -570,7 +570,7 @@ public static void ToggleArrowLock()
AppConfig.Set("arrow_lock", arLock);

Program.settingsForm.BeginInvoke(Program.inputDispatcher.RegisterKeys);
Program.toast.RunToast("Arrow-Lock " + (arLock == 1 ? "On" : "Off"), ToastIcon.FnLock);
Program.toast.RunToast("Arrow-Lock " + (arLock == 1 ? Properties.Strings.On : Properties.Strings.Off), ToastIcon.FnLock);
}

public static void ToggleFnLock()
Expand All @@ -585,7 +585,7 @@ public static void ToggleFnLock()

Program.settingsForm.BeginInvoke(Program.settingsForm.VisualiseFnLock);

Program.toast.RunToast("Fn-Lock " + (fnLock == 1 ? "On" : "Off"), ToastIcon.FnLock);
Program.toast.RunToast(fnLock == 1 ? Properties.Strings.FnLockOn : Properties.Strings.FnLockOff, ToastIcon.FnLock);
}

public static void TabletMode()
Expand Down Expand Up @@ -687,11 +687,6 @@ static void HandleEvent(int EventID)
case 199: // ON Z13 - FN+F11 - cycles backlight
SetBacklight(4);
return;
case 51: // Fn+F6 on old TUFs
case 53: // Fn+F6 on GA-502DU model
if (AppConfig.IsNoSleepEvent()) NativeMethods.TurnOffScreen();
else SleepEvent();
return;
}
}

Expand Down Expand Up @@ -750,6 +745,10 @@ static void HandleOptimizationEvent(int EventID)
else
SetScreenpad(100);
break;
case 51: // Fn+F6 on old TUFs
case 53: // Fn+F6 on GA-502DU model
NativeMethods.TurnOffScreen();
return;


}
Expand Down Expand Up @@ -801,7 +800,7 @@ public static void SetBacklight(int delta, bool force = false)

if (!OptimizationService.IsOSDRunning())
{
string[] backlightNames = new string[] { "Off", "Low", "Mid", "Max" };
string[] backlightNames = new string[] { Properties.Strings.BacklightOff, Properties.Strings.BacklightLow, Properties.Strings.BacklightMid, Properties.Strings.BacklightMax };
Program.toast.RunToast(backlightNames[backlight], delta > 0 ? ToastIcon.BacklightUp : ToastIcon.BacklightDown);
}

Expand Down
4 changes: 2 additions & 2 deletions app/Mode/ModeControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void SetPerformanceMode(int mode = -1, bool notify = false)

Task.Run(async () =>
{
bool reset = AppConfig.IsResetRequired() && (Modes.GetBase(oldMode) == Modes.GetBase(mode)) && customPower > 0;
bool reset = AppConfig.IsResetRequired() && (Modes.GetBase(oldMode) == Modes.GetBase(mode)) && customPower > 0 && !AppConfig.IsMode("auto_apply_power");

customFans = false;
customPower = 0;
Expand All @@ -78,7 +78,7 @@ public void SetPerformanceMode(int mode = -1, bool notify = false)
// Workaround for not properly resetting limits on G14 2024
if (reset)
{
Program.acpi.DeviceSet(AsusACPI.PerformanceMode, (Modes.GetBase(oldMode) != 1) ? AsusACPI.PerformanceTurbo : AsusACPI.PerformanceBalanced, "Reset");
Program.acpi.DeviceSet(AsusACPI.PerformanceMode, (Modes.GetBase(oldMode) != 1) ? AsusACPI.PerformanceTurbo : AsusACPI.PerformanceBalanced, "ModeReset");
await Task.Delay(TimeSpan.FromMilliseconds(1500));
}

Expand Down
7 changes: 3 additions & 4 deletions app/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ static void SystemEvents_UserPreferenceChanged(object sender, UserPreferenceChan
{
case UserPreferenceCategory.General:
bool changed = settingsForm.InitTheme();
settingsForm.VisualiseIcon();

if (changed)
{
Debug.WriteLine("Theme Changed");
Expand All @@ -201,11 +203,8 @@ static void SystemEvents_UserPreferenceChanged(object sender, UserPreferenceChan
if (settingsForm.matrixForm is not null && settingsForm.matrixForm.Text != "")
settingsForm.matrixForm.InitTheme();

if (settingsForm.handheldForm is not null && settingsForm.handheldForm.Text != "")
{
if (settingsForm.handheldForm is not null && settingsForm.handheldForm.Text != "")
settingsForm.handheldForm.InitTheme();
settingsForm.VisualiseIcon();
}

break;
}
Expand Down
Loading

0 comments on commit e1f765d

Please sign in to comment.