Skip to content

Commit

Permalink
Allow manual disabling of all functions related to the dGPU and avoid…
Browse files Browse the repository at this point in the history
… errors when initializing AniMatrix.
  • Loading branch information
yinyue200 committed Nov 10, 2024
1 parent df5bdfd commit 3e37601
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 38 deletions.
34 changes: 18 additions & 16 deletions app/AnimeMatrix/AniMatrixControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,31 @@ public AniMatrixControl(SettingsForm settingsForm)
{
settings = settingsForm;

try
if(!AppConfig.IsNoAniMatrix())
{
if (AppConfig.IsSlash())
try
{
if (AppConfig.IsSlashAura())
deviceSlash = new SlashDeviceAura();
if (AppConfig.IsSlash())
{
if (AppConfig.IsSlashAura())
deviceSlash = new SlashDeviceAura();
else
deviceSlash = new SlashDevice();
}
else
deviceSlash = new SlashDevice();
{
deviceMatrix = new AnimeMatrixDevice();
}

matrixTimer = new System.Timers.Timer(100);
matrixTimer.Elapsed += MatrixTimer_Elapsed;

}
else
catch (Exception ex)
{
deviceMatrix = new AnimeMatrixDevice();
Logger.WriteLine(ex.Message);
}

matrixTimer = new System.Timers.Timer(100);
matrixTimer.Elapsed += MatrixTimer_Elapsed;

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

}

public void SetDevice(bool wakeUp = false)
Expand Down
10 changes: 10 additions & 0 deletions app/AppConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,16 @@ public static bool IsNoDirectRGB()
return ContainsModel("GA503") || ContainsModel("G533Q") || ContainsModel("GU502") || ContainsModel("GU603") || IsSlash();
}

public static bool IsNoAniMatrix()
{
return Is("no_ani_matrix") || IsVivoZenPro();
}

public static bool NoDgpu()
{
return Is("no_dgpu") || IsVivoZenbook();
}

public static bool IsStrixNumpad()
{
return ContainsModel("G713R");
Expand Down
2 changes: 1 addition & 1 deletion app/Gpu/AMD/AmdGpuControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class AmdGpuControl : IGpuControl

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

try
Expand Down
2 changes: 1 addition & 1 deletion app/Gpu/GPUModeControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void InitGPUMode()
// GPU mode not supported
if (eco < 0 && mux < 0)
{
if (gpuExists is null) gpuExists = Program.acpi.GetFan(AsusFan.GPU) >= 0;
if (gpuExists is null) gpuExists = (!AppConfig.NoDgpu()) && Program.acpi.GetFan(AsusFan.GPU) >= 0;
settings.HideGPUModes((bool)gpuExists);
}
}
Expand Down
37 changes: 20 additions & 17 deletions app/HardwareControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,26 +289,29 @@ public static void RecreateGpuControl()
{
GpuControl?.Dispose();

IGpuControl _gpuControl = new NvidiaGpuControl();

if (_gpuControl.IsValid)
if (!AppConfig.NoDgpu())
{
GpuControl = _gpuControl;
Logger.WriteLine(GpuControl.FullName);
return;
}
IGpuControl _gpuControl = new NvidiaGpuControl();

_gpuControl.Dispose();
if (_gpuControl.IsValid)
{
GpuControl = _gpuControl;
Logger.WriteLine(GpuControl.FullName);
return;
}

_gpuControl = new AmdGpuControl();
if (_gpuControl.IsValid)
{
GpuControl = _gpuControl;
if (GpuControl.FullName.Contains("6850M")) AppConfig.Set("xgm_special", 1);
Logger.WriteLine(GpuControl.FullName);
return;
}
_gpuControl.Dispose();
_gpuControl.Dispose();

_gpuControl = new AmdGpuControl();
if (_gpuControl.IsValid)
{
GpuControl = _gpuControl;
if (GpuControl.FullName.Contains("6850M")) AppConfig.Set("xgm_special", 1);
Logger.WriteLine(GpuControl.FullName);
return;
}
_gpuControl.Dispose();
}

Logger.WriteLine("dGPU not found");
GpuControl = null;
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

0 comments on commit 3e37601

Please sign in to comment.