Skip to content

Commit

Permalink
Add gamemode spamming fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rankynbass committed Mar 14, 2024
2 parents 6cfff13 + 78376e2 commit a5ba7f5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ public SettingsTabWine()
CheckVisibility = () => RuntimeInformation.IsOSPlatform(OSPlatform.Linux),
CheckValidity = b =>
{
var handle = IntPtr.Zero;
if (b == true && !NativeLibrary.TryLoad("libgamemodeauto.so.0", out handle))
if (b == true && !CoreEnvironmentSettings.IsGameModeInstalled())
return "GameMode was not detected on your system.";
NativeLibrary.Free(handle);
return null;
}
},
Expand Down
18 changes: 18 additions & 0 deletions src/XIVLauncher.Core/CoreEnvironmentSettings.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.InteropServices;

namespace XIVLauncher.Core;

Expand Down Expand Up @@ -55,4 +56,21 @@ public static string GetCType()
var output = proc.StandardOutput.ReadToEnd().Split('\n', StringSplitOptions.RemoveEmptyEntries);
return Array.Find(output, s => s.ToUpper().StartsWith("C."));
}

static private bool? gameModeInstalled = null;

static public bool IsGameModeInstalled()
{
if (gameModeInstalled is not null)
return gameModeInstalled ?? false;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
var handle = IntPtr.Zero;
gameModeInstalled = NativeLibrary.TryLoad("libgamemodeauto.so.0", out handle);
NativeLibrary.Free(handle);
}
else
gameModeInstalled = false;
return gameModeInstalled ?? false;
}
}

0 comments on commit a5ba7f5

Please sign in to comment.