diff --git a/BizHawk.Client.EmuHawk/CustomControls/Win32.cs b/BizHawk.Client.EmuHawk/CustomControls/Win32.cs index 40b0923a19..d1ebb963b5 100644 --- a/BizHawk.Client.EmuHawk/CustomControls/Win32.cs +++ b/BizHawk.Client.EmuHawk/CustomControls/Win32.cs @@ -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) || diff --git a/BizHawk.Client.EmuHawk/Input/GamePad360.cs b/BizHawk.Client.EmuHawk/Input/GamePad360.cs index f926703771..1abbe0d5f1 100644 --- a/BizHawk.Client.EmuHawk/Input/GamePad360.cs +++ b/BizHawk.Client.EmuHawk/Input/GamePad360.cs @@ -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 { }