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 Aug 29, 2024
2 parents ab5b77a + 4d85919 commit ba918ed
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 30 deletions.
4 changes: 3 additions & 1 deletion app/AnimeMatrix/AniMatrixControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public void SetSlash(bool wakeUp = false)
switch ((SlashMode)running)
{
case SlashMode.Static:
Logger.WriteLine("Slash: Static");
var custom = AppConfig.GetString("slash_custom");
if (custom is not null && custom.Length > 0)
{
Expand All @@ -126,6 +127,7 @@ public void SetSlash(bool wakeUp = false)
break;
case SlashMode.BatteryLevel:
// call tick to immediately update the pattern
Logger.WriteLine("Slash: Battery Level");
SlashTimer_start();
SlashTimer_tick();
break;
Expand Down Expand Up @@ -278,7 +280,7 @@ public void SetMatrixClock()
}


private void SlashTimer_start(int interval = 60000)
private void SlashTimer_start(int interval = 180000)
{
// 100% to 0% in 1hr = 1% every 36 seconds
// 1 bracket every 14.2857 * 36s = 514s ~ 8m 30s
Expand Down
12 changes: 6 additions & 6 deletions app/AnimeMatrix/SlashDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,17 @@ private byte[] GetBatteryPattern(int brightness, double percentage)

public void SetBatteryPattern(int brightness)
{
SetCustom(GetBatteryPattern(brightness, 100 * (GetBatteryChargePercentage() / AppConfig.Get("charge_limit", 100))));
SetCustom(GetBatteryPattern(brightness, 100 * (GetBatteryChargePercentage() / AppConfig.Get("charge_limit", 100))), null);
}

public void SetCustom(byte[] data)
public void SetCustom(byte[] data, string? log = "Static Data")
{
Set(CreatePacket([0xD2, 0x02, 0x01, 0x08, 0xAC]), "Static");
Set(CreatePacket([0xD3, 0x03, 0x01, 0x08, 0xAC, 0xFF, 0xFF, 0x01, 0x05, 0xFF, 0xFF]), "StaticSettings");
Set(CreatePacket([0xD4, 0x00, 0x00, 0x01, 0xAC]), "StaticSave");
Set(CreatePacket([0xD2, 0x02, 0x01, 0x08, 0xAC]), null);
Set(CreatePacket([0xD3, 0x03, 0x01, 0x08, 0xAC, 0xFF, 0xFF, 0x01, 0x05, 0xFF, 0xFF]), null);
Set(CreatePacket([0xD4, 0x00, 0x00, 0x01, 0xAC]), null);

byte[] payload = new byte[] { 0xD3, 0x00, 0x00, 0x07 };
Set(CreatePacket(payload.Concat(data.Take(7)).ToArray()), "Static Data");
Set(CreatePacket(payload.Concat(data.Take(7)).ToArray()), log);
}

public void SetOptions(bool status, int brightness = 0, int interval = 0)
Expand Down
21 changes: 13 additions & 8 deletions app/AppConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,15 @@ public static bool IsVivoZenPro()
return ContainsModel("Vivobook") || ContainsModel("Zenbook") || ContainsModel("ProArt");
}

public static bool IsHardwareFnLock()
{
return IsVivoZenPro();
}

// Devices with bugged bios command to change brightness
public static bool SwappedBrightness()
{
return ContainsModel("FA506IH") || ContainsModel("FA506IC") || ContainsModel("FX506LU") || ContainsModel("FX506IC") || ContainsModel("FX506LH") || ContainsModel("FA506IV") || ContainsModel("FA706IC");
return ContainsModel("FA506IH") || ContainsModel("FA506IC") || ContainsModel("FX506LU") || ContainsModel("FX506IC") || ContainsModel("FX506LH") || ContainsModel("FA506IV") || ContainsModel("FA706IC") || ContainsModel("FA706IH");
}


Expand All @@ -407,17 +412,17 @@ public static bool IsDUO()
// G14 2020 has no aura, but media keys instead
public static bool NoAura()
{
return ContainsModel("GA401I") && !ContainsModel("GA401IHR");
return (ContainsModel("GA401I") && !ContainsModel("GA401IHR")) || ContainsModel("HN7306");
}

public static bool MediaKeys()
{
return NoAura() || ContainsModel("G712L");
return (ContainsModel("GA401I") && !ContainsModel("GA401IHR")) || ContainsModel("G712L");
}

public static bool IsSingleColor()
{
return ContainsModel("GA401") || ContainsModel("FX517Z") || ContainsModel("FX516P") || ContainsModel("X13") || IsARCNM() || ContainsModel("GA502IU") || ContainsModel("FA617N") || ContainsModel("FA617X");
return ContainsModel("GA401") || ContainsModel("FX517Z") || ContainsModel("FX516P") || ContainsModel("X13") || IsARCNM() || ContainsModel("GA502IU") || ContainsModel("FA617N") || ContainsModel("FA617X") || NoAura();
}

public static bool IsSlash()
Expand All @@ -432,7 +437,7 @@ public static bool IsSlashAura()

public static bool IsInputBacklight()
{
return ContainsModel("GA503") || IsSlash();
return ContainsModel("GA503") || IsSlash() || IsVivoZenPro();
}

public static bool IsInvertedFNLock()
Expand All @@ -442,7 +447,7 @@ public static bool IsInvertedFNLock()

public static bool IsOLED()
{
return ContainsModel("OLED") || IsSlash() || ContainsModel("M7600") || ContainsModel("UX64") || ContainsModel("UX34") || ContainsModel("UX53") || ContainsModel("K360") || ContainsModel("X150") || ContainsModel("M350") || ContainsModel("K650") || ContainsModel("UM53") || ContainsModel("K660") || ContainsModel("UX84") || ContainsModel("M650") || ContainsModel("K340") || ContainsModel("K350") || ContainsModel("M140") || ContainsModel("UM340") || ContainsModel("S540") || ContainsModel("M7400") || ContainsModel("N650");
return ContainsModel("OLED") || IsSlash() || ContainsModel("M7600") || ContainsModel("UX64") || ContainsModel("UX34") || ContainsModel("UX53") || ContainsModel("K360") || ContainsModel("X150") || ContainsModel("M350") || ContainsModel("K650") || ContainsModel("UM53") || ContainsModel("K660") || ContainsModel("UX84") || ContainsModel("M650") || ContainsModel("M550") || ContainsModel("K340") || ContainsModel("K350") || ContainsModel("M140") || ContainsModel("UM340") || ContainsModel("S540") || ContainsModel("M7400") || ContainsModel("N650") || ContainsModel("HN7306") || ContainsModel("H7606");
}

public static bool IsNoOverdrive()
Expand Down Expand Up @@ -618,12 +623,12 @@ public static bool IsResetRequired()

public static bool IsFanRequired()
{
return ContainsModel("GA402X") || ContainsModel("G513") || ContainsModel("G713R") || ContainsModel("G713P") || ContainsModel("GU605") || ContainsModel("GA403") || ContainsModel("G634J") || ContainsModel("G834J") || ContainsModel("G614J") || ContainsModel("G814J") || ContainsModel("FX507V");
return ContainsModel("GA402X") || ContainsModel("G513") || ContainsModel("G713R") || ContainsModel("G713P") || ContainsModel("GU605") || ContainsModel("GA605") || ContainsModel("GA403") || ContainsModel("G634J") || ContainsModel("G834J") || ContainsModel("G614J") || ContainsModel("G814J") || ContainsModel("FX507V");
}

public static bool IsAMDLight()
{
return ContainsModel("GA402X") || ContainsModel("GA403") || ContainsModel("FA507N") || ContainsModel("FA507X") || ContainsModel("FA707N") || ContainsModel("FA707X");
return ContainsModel("GA402X") || ContainsModel("GA605") || ContainsModel("GA403") || ContainsModel("FA507N") || ContainsModel("FA507X") || ContainsModel("FA707N") || ContainsModel("FA707X");
}

public static bool IsPowerRequired()
Expand Down
12 changes: 8 additions & 4 deletions app/AsusACPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,8 @@ public class AsusACPI

public const int TUF_KB = 0x00100056;
public const int TUF_KB2 = 0x0010005a;
public const int VIVO_KB = 0x0012008E;

public const int TUF_KB_STATE = 0x00100057;
public const int VIVO_KB_STATE = 0x0012008F;

public const int MicMuteLed = 0x00040017;

Expand Down Expand Up @@ -791,6 +789,7 @@ public void TUFKeyboardBrightness(int brightness)
int param = 0x80 | (brightness & 0x7F);
DeviceSet(TUF_KB_BRIGHTNESS, param, "TUF Brightness");
if (AppConfig.IsVivoZenPro()) DeviceSet(VIVO_KB_BRIGHTNESS, param, "VIVO Brightness");

}

public void TUFKeyboardRGB(AuraMode mode, Color color, int speed, string? log = "TUF RGB")
Expand All @@ -806,7 +805,13 @@ public void TUFKeyboardRGB(AuraMode mode, Color color, int speed, string? log =
setting[5] = (byte)speed;

int result = DeviceSet(TUF_KB, setting, log);
if (result != 1) DeviceSet(TUF_KB2, setting, log);
if (result != 1)
{
setting[0] = (byte)0xb3;
DeviceSet(TUF_KB2, setting, log);
setting[0] = (byte)0xb4;
DeviceSet(TUF_KB2, setting, log);
}

}

Expand All @@ -826,7 +831,6 @@ public void TUFKeyboardPower(bool awake = true, bool boot = false, bool sleep =
state = state | 0x01 << 8;

DeviceSet(TUF_KB_STATE, state, "TUF_KB");
if (AppConfig.IsVivoZenPro()) DeviceSet(VIVO_KB_STATE, state, "VIVO_KB");
}

public void SubscribeToEvents(Action<object, EventArrivedEventArgs> EventHandler)
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.184</AssemblyVersion>
<AssemblyVersion>0.186</AssemblyVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
15 changes: 10 additions & 5 deletions app/Input/InputDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ public void Init()

InitBacklightTimer();

if (AppConfig.IsVivoZenbook())
Program.acpi.DeviceSet(AsusACPI.FnLock, AppConfig.Is("fn_lock") ^ AppConfig.IsInvertedFNLock() ? 1 : 0, "FnLock");
if (AppConfig.IsHardwareFnLock()) HardwareFnLock(AppConfig.Is("fn_lock"));

}

Expand Down Expand Up @@ -155,7 +154,7 @@ public void RegisterKeys()

// FN-Lock group

if (AppConfig.Is("fn_lock") && !AppConfig.IsVivoZenbook())
if (AppConfig.Is("fn_lock") && !AppConfig.IsHardwareFnLock())
for (Keys i = Keys.F1; i <= Keys.F11; i++) hook.RegisterHotKey(ModifierKeys.None, i);

// Arrow-lock group
Expand Down Expand Up @@ -629,13 +628,19 @@ public static void ToggleArrowLock()
Program.toast.RunToast("Arrow-Lock " + (arLock == 1 ? Properties.Strings.On : Properties.Strings.Off), ToastIcon.FnLock);
}

public static void HardwareFnLock(bool fnLock)
{
Program.acpi.DeviceSet(AsusACPI.FnLock, fnLock ^ AppConfig.IsInvertedFNLock() ? 1 : 0, "FnLock");
AsusHid.WriteInput([AsusHid.INPUT_ID, 0xD0, 0x4E, fnLock ? (byte)0x00 : (byte)0x01], "USB FnLock");
}

public static void ToggleFnLock()
{
bool fnLock = !AppConfig.Is("fn_lock");
AppConfig.Set("fn_lock", fnLock ? 1 : 0);

if (AppConfig.IsVivoZenbook())
Program.acpi.DeviceSet(AsusACPI.FnLock, fnLock ^ AppConfig.IsInvertedFNLock() ? 1 : 0, "FnLock");
if (AppConfig.IsHardwareFnLock())
HardwareFnLock(fnLock);
else
Program.settingsForm.BeginInvoke(Program.inputDispatcher.RegisterKeys);

Expand Down
2 changes: 1 addition & 1 deletion app/Properties/Strings.zh-CN.resx
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@
<value>关闭屏幕</value>
</data>
<data name="ToggleTouchscreen" xml:space="preserve">
<value>Toggle Touchscreen</value>
<value>切换触摸屏</value>
</data>
<data name="Touchscreen" xml:space="preserve">
<value/>
Expand Down
11 changes: 8 additions & 3 deletions app/Ryzen/RyzenControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ internal class RyzenControl
//PHEONIX - 9
//RAPHAEL/DRAGON RANGE - 10
//MENDOCINO - 11
//HAWKPOINT - 12
//HAWKPOINT/STRIXPOINT - 12

public static void Init()
{
Expand Down Expand Up @@ -77,7 +77,7 @@ public static void Init()
FAMID = 1; //PICASSO
}

if (CPUModel.Contains("Model " + Convert.ToString(32)))
if (CPUModel.Contains("Family " + Convert.ToString(23)) && CPUModel.Contains("Model " + Convert.ToString(32)))
{
FAMID = 2; //DALI
}
Expand Down Expand Up @@ -127,6 +127,11 @@ public static void Init()
FAMID = 12; //HAWKPOINT
}

if (CPUModel.Contains("Family " + Convert.ToString(26)) && CPUModel.Contains("Model " + Convert.ToString(36)))
{
FAMID = 12; //STRIXPOINT
}

Logger.WriteLine($"CPU: {FAMID} - {CPUName} - {CPUModel}");

SetAddresses();
Expand All @@ -141,7 +146,7 @@ public static bool IsAMD()
public static bool IsSupportedUV()
{
if (CPUName.Length == 0) Init();
return CPUName.Contains("Ryzen 9") || CPUName.Contains("4900H") || CPUName.Contains("4800H") || CPUName.Contains("4600H");
return CPUName.Contains("Ryzen AI 9") || CPUName.Contains("Ryzen 9") || CPUName.Contains("4900H") || CPUName.Contains("4800H") || CPUName.Contains("4600H");
}

public static bool IsSupportedUViGPU()
Expand Down
2 changes: 1 addition & 1 deletion app/Ryzen/SendCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ internal class SendCommand
//PHEONIX - 9
//RAPHAEL/DRAGON RANGE - 10
//MENDOCINO - 11
//HAWKPOINT - 12
//HAWKPOINT/STRIXPOINT - 12

public static Smu RyzenAccess = new Smu(false);
public static int FAMID = RyzenControl.FAMID;
Expand Down
10 changes: 10 additions & 0 deletions app/USB/Aura.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,16 @@ public static void Init()
Encoding.ASCII.GetBytes("]ASUS Tech.Inc."),
new byte[] { AsusHid.AURA_ID, 0x05, 0x20, 0x31, 0, 0x1A },
}, "Init");

if (AppConfig.IsProArt())
{
AsusHid.WriteInput([AsusHid.INPUT_ID, 0x05, 0x20, 0x31, 0x00, 0x08], "ProArt Init");
//AsusHid.WriteInput([AsusHid.INPUT_ID, 0xD0, 0x4E], "ProArt Init");
AsusHid.WriteInput([AsusHid.INPUT_ID, 0xBA, 0xC5, 0xC4], "ProArt Init");
AsusHid.WriteInput([AsusHid.INPUT_ID, 0xD0, 0x8F, 0x01], "ProArt Init");
AsusHid.WriteInput([AsusHid.INPUT_ID, 0xD0, 0x85, 0xFF], "ProArt Init");
//AsusHid.WriteInput([AsusHid.INPUT_ID, 0xD0, 0x4E], "ProArt Init");
}
}


Expand Down

0 comments on commit ba918ed

Please sign in to comment.