Ejemplo n.º 1
0
        static Program()
        {
            //this needs to be done before the warnings/errors show up
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //http://www.codeproject.com/Articles/310675/AppDomain-AssemblyResolve-Event-Tips
#if WINDOWS
            //try loading libraries we know we'll need
            //something in the winforms, etc. code below will cause .net to popup a missing msvcr100.dll in case that one's missing
            //but oddly it lets us proceed and we'll then catch it here
            var  d3dx9 = Win32.LoadLibrary("d3dx9_43.dll");
            var  vc2015 = Win32.LoadLibrary("vcruntime140.dll");
            var  vc2010 = Win32.LoadLibrary("msvcr100.dll");            //TODO - check version?
            var  vc2010p = Win32.LoadLibrary("msvcp100.dll");
            bool fail = false, warn = false;
            warn |= d3dx9 == IntPtr.Zero;
            fail |= vc2015 == IntPtr.Zero;
            fail |= vc2010 == IntPtr.Zero;
            fail |= vc2010p == IntPtr.Zero;
            if (fail || warn)
            {
                var sw = new System.IO.StringWriter();
                sw.WriteLine("[ OK ] .Net 4.0 (You couldn't even get here without it)");
                sw.WriteLine("[{0}] Direct3d 9", d3dx9 == IntPtr.Zero ? "FAIL" : " OK ");
                sw.WriteLine("[{0}] Visual C++ 2010 SP1 Runtime", (vc2010 == IntPtr.Zero || vc2010p == IntPtr.Zero) ? "FAIL" : " OK ");
                sw.WriteLine("[{0}] Visual C++ 2015 Runtime", (vc2015 == IntPtr.Zero) ? "FAIL" : " OK ");
                var str = sw.ToString();
                var box = new BizHawk.Client.EmuHawk.CustomControls.PrereqsAlert(!fail);
                box.textBox1.Text = str;
                box.ShowDialog();
                if (!fail)
                {
                }
                else
                {
                    System.Diagnostics.Process.GetCurrentProcess().Kill();
                }
            }

            Win32.FreeLibrary(d3dx9);
            Win32.FreeLibrary(vc2015);
            Win32.FreeLibrary(vc2010);
            Win32.FreeLibrary(vc2010p);

            // this will look in subdirectory "dll" to load pinvoked stuff
            string dllDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "dll");
            SetDllDirectory(dllDir);

            //in case assembly resolution fails, such as if we moved them into the dll subdiretory, this event handler can reroute to them
            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);

            //but before we even try doing that, whack the MOTW from everything in that directory (thats a dll)
            //otherwise, some people will have crashes at boot-up due to .net security disliking MOTW.
            //some people are getting MOTW through a combination of browser used to download bizhawk, and program used to dearchive it
            WhackAllMOTW(dllDir);

            //We need to do it here too... otherwise people get exceptions when externaltools we distribute try to startup
#endif
        }
Ejemplo n.º 2
0
        public static void Initialize()
        {
            IsAvailable = false;
            try
            {
                //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 { }

            if (!IsAvailable)
            {
                return;
            }

            var c1 = new Controller(UserIndex.One);
            var c2 = new Controller(UserIndex.Two);
            var c3 = new Controller(UserIndex.Three);
            var c4 = new Controller(UserIndex.Four);

            if (c1.IsConnected)
            {
                Devices.Add(new GamePad360(c1));
            }
            if (c2.IsConnected)
            {
                Devices.Add(new GamePad360(c2));
            }
            if (c3.IsConnected)
            {
                Devices.Add(new GamePad360(c3));
            }
            if (c4.IsConnected)
            {
                Devices.Add(new GamePad360(c4));
            }
        }