UI tweaks

This commit is contained in:
Serge
2023-06-24 11:32:59 +02:00
parent 3c02d5cd95
commit 96dc22072a
7 changed files with 38 additions and 12 deletions

View File

@@ -359,7 +359,7 @@ namespace GHelper
if (device.ReadFeatureData(out byte[] data, AURA_HID_ID))
{
device.WriteFeatureData(msg);
//device.WriteFeatureData(MESSAGE_SET);
device.WriteFeatureData(MESSAGE_SET);
device.WriteFeatureData(MESSAGE_APPLY);
Logger.WriteLine("USB-KB " + device.Capabilities.FeatureReportByteLength + "|" + device.Capabilities.InputReportByteLength + device.Description + device.DevicePath + ":" + BitConverter.ToString(msg));
}

View File

@@ -622,13 +622,15 @@ namespace GHelper
public void InitPower(bool changed = false)
{
bool modeA0 = Program.acpi.DeviceGet(AsusACPI.PPT_TotalA0) >= 0 || Undervolter.IsAMD();
bool modeA0 = (Program.acpi.DeviceGet(AsusACPI.PPT_TotalA0) >= 0 || Undervolter.IsAMD());
bool modeB0 = Program.acpi.IsAllAmdPPT();
bool modeC1 = Program.acpi.DeviceGet(AsusACPI.PPT_APUC1) >= 0;
panelA0.Visible = modeA0;
panelB0.Visible = modeB0;
panelApplyPower.Visible = panelTitleCPU.Visible = modeA0 || modeB0 || modeC1;
// All AMD version has B0 but doesn't have C0 (Nvidia GPU) settings
if (modeB0)

View File

@@ -16,7 +16,7 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<AssemblyVersion>0.90</AssemblyVersion>
<AssemblyVersion>0.91</AssemblyVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

View File

@@ -24,6 +24,14 @@ namespace GHelper
{
while (!cancellationTokenSource.Token.IsCancellationRequested)
{
// Emergency break
if (input == null || !input.IsConnected )
{
Logger.WriteLine("Listener terminated");
break;
}
var data = input.Read().Data;
if (data.Length > 1 && data[0] == AsusUSB.INPUT_HID_ID && data[1] > 0 && data[1] != 236)
{
@@ -31,6 +39,7 @@ namespace GHelper
KeyHandler(data[1]);
}
}
Logger.WriteLine("Listener stopped");
}

View File

@@ -136,14 +136,14 @@ namespace Ryzen
public Status SendMp1(uint message, ref uint[] arguments)
{
var result = SendMsg(MP1_ADDR_MSG, MP1_ADDR_RSP, MP1_ADDR_ARG, message, ref arguments);
Logger.WriteLine($"RyzenMP1:{message} {arguments[0]} {result}");
//Logger.WriteLine($"RyzenMP1:{message} {arguments[0]} {result}");
return result;
}
public Status SendPsmu(uint message, ref uint[] arguments)
{
var result = SendMsg(PSMU_ADDR_MSG, PSMU_ADDR_RSP, PSMU_ADDR_ARG, message, ref arguments);
Logger.WriteLine($"RyzenPSMU:{message} {arguments[0]} {result}");
//Logger.WriteLine($"RyzenPSMU:{message} {arguments[0]} {result}");
return result;
}

View File

@@ -1058,7 +1058,8 @@ namespace GHelper
Program.acpi.DeviceSet(AsusACPI.PPT_TotalA0, limit_total, "PowerLimit A0");
Program.acpi.DeviceSet(AsusACPI.PPT_APUA3, limit_total, "PowerLimit A3");
customPower = limit_total;
} else if (Undervolter.IsAMD())
}
else if (Undervolter.IsAMD())
{
if (ProcessHelper.IsUserAdministrator())
@@ -1068,7 +1069,8 @@ namespace GHelper
SendCommand.set_slow_limit((uint)limit_total * 1000);
SendCommand.set_fast_limit((uint)limit_total * 1000);
customPower = limit_total;
} else if (launchAsAdmin)
}
else if (launchAsAdmin)
{
ProcessHelper.RunAsAdmin("cpu");
return;
@@ -1156,7 +1158,7 @@ namespace GHelper
public void SetUV(bool launchAsAdmin = false)
{
if (!ProcessHelper.IsUserAdministrator())
{
if (launchAsAdmin) ProcessHelper.RunAsAdmin("uv");
@@ -1255,13 +1257,14 @@ namespace GHelper
}
private static bool isManualModeRequired()
private static bool IsManualModeRequired()
{
if (!AppConfig.IsMode("auto_apply_power"))
return false;
return
AppConfig.Is("manual_mode") ||
AppConfig.ContainsModel("GU603") ||
AppConfig.ContainsModel("GU604") ||
AppConfig.ContainsModel("FX517") ||
AppConfig.ContainsModel("G733");
@@ -1286,7 +1289,7 @@ namespace GHelper
}
// Fix for models that don't support PPT settings in all modes, setting a "manual" mode for them
if (isManualModeRequired() && !applyFans)
if (IsManualModeRequired() && !applyFans)
{
AutoFans(true);
}
@@ -1376,7 +1379,7 @@ namespace GHelper
SetPerformanceLabel();
if (isManualModeRequired())
if (IsManualModeRequired())
Program.acpi.DeviceSet(AsusACPI.PerformanceMode, AsusACPI.PerformanceManual, "Manual Mode");
else
Program.acpi.DeviceSet(AsusACPI.PerformanceMode, Modes.GetBase(mode), "Mode");

View File

@@ -3,7 +3,6 @@ using System.Diagnostics;
using System.Management;
using System.Net;
using System.Text.Json;
using System.Windows.Forms;
namespace GHelper
{
@@ -24,9 +23,14 @@ namespace GHelper
static string bios;
static int updatesCount = 0;
private static long lastUpdate;
private void LoadUpdates()
{
if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastUpdate) < 5000) return;
lastUpdate = DateTimeOffset.Now.ToUnixTimeMilliseconds();
InitBiosAndModel();
updatesCount = 0;
@@ -72,8 +76,10 @@ namespace GHelper
InitializeComponent();
InitTheme();
LoadUpdates();
//buttonRefresh.Visible = false;
buttonRefresh.Click += ButtonRefresh_Click;
Shown += Updates_Shown;
}
@@ -147,6 +153,7 @@ namespace GHelper
httpClient.DefaultRequestHeaders.AcceptEncoding.ParseAdd("gzip, deflate, br");
httpClient.DefaultRequestHeaders.Add("User-Agent", "C# App");
var json = await httpClient.GetStringAsync(url);
var data = JsonSerializer.Deserialize<JsonElement>(json);
var groups = data.GetProperty("Result").GetProperty("Obj");
@@ -178,6 +185,7 @@ namespace GHelper
driver.hardwares = file.GetProperty("HardwareInfoList");
drivers.Add(driver);
Invoke(delegate
{
string versionText = driver.version.Replace("latest version at the ", "");
@@ -203,6 +211,7 @@ namespace GHelper
}
}
Invoke(delegate
{
table.Visible = true;
@@ -210,6 +219,7 @@ namespace GHelper
PerformLayout();
});
Dictionary<string, string> devices = new();
if (type == 0) devices = GetDeviceVersions();
@@ -255,6 +265,8 @@ namespace GHelper
count++;
}
GC.Collect();
GC.WaitForPendingFinalizers();
}
}
catch (Exception ex)