check for existence of xinput1_3.dll before calling on the slimdx code to attempt using it

This commit is contained in:
zeromus 2014-07-23 06:52:04 +00:00
parent fd0a31721e
commit 0d674308b9
2 changed files with 19 additions and 3 deletions

View File

@ -19,6 +19,14 @@ namespace BizHawk.Client.EmuHawk
[Out] out bool wow64Process
);
[DllImport("kernel32.dll")]
public static extern IntPtr LoadLibrary(string dllToLoad);
[DllImport("kernel32.dll")]
public static extern IntPtr GetProcAddress(IntPtr hModule, string procedureName);
[DllImport("kernel32.dll")]
public static extern bool FreeLibrary(IntPtr hModule);
static bool InternalCheckIsWow64()
{
if ((Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor >= 1) ||

View File

@ -17,9 +17,17 @@ namespace BizHawk.Client.EmuHawk
IsAvailable = false;
try
{
//don't remove this code. it's important to catch errors on systems with broken xinput installs.
var test = new SlimDX.XInput.Controller(UserIndex.One).IsConnected;
IsAvailable = true;
//some users wont even have xinput installed. in order to avoid spurious exceptions and possible instability, check for the library first
IntPtr lib = Win32.LoadLibrary("xinput1_3.dll");
if (lib != IntPtr.Zero)
{
Win32.FreeLibrary(lib);
//don't remove this code. it's important to catch errors on systems with broken xinput installs.
//(probably, checking for the library was adequate, but lets not get rid of this anyway)
var test = new SlimDX.XInput.Controller(UserIndex.One).IsConnected;
IsAvailable = true;
}
}
catch { }