public GamePadMapper(ControllerEngine controllerEngine)
 {
     controller = controllerEngine;
     StartClock();
     KeyboardQkcMapping = ReadKeyboardQkc();
     System.Diagnostics.Debug.WriteLine(controller.CapabilitiesGamePad.ToString());
     //hWindow = Launcher.NullDCWindowHandle();
 }
        public NetplayLaunchForm(bool tray = false, bool controllerSetup = false)
        {
            controller = new ControllerEngine();

            launcher = new Launcher();
            presets  = ConnectionPreset.ReadPresetsFile();

            StartTray = tray;

            string launcherCfgText = "";

            try
            {
                var launcherCfgUri = new System.Uri(Path.Combine(Launcher.rootDir, @"launcher.cfg"));
                launcherCfgText = File.ReadAllText(launcherCfgUri.LocalPath);
            }
            catch (System.IO.DirectoryNotFoundException)
            {
                MessageBox.Show("launcher.cfg not found. Please enter a valid root directory.");
                System.Environment.Exit(1);
            }


            if (launcherCfgText.Contains("enable_mapper=1"))
            {
                StartMapper();
            }

            if (controllerSetup)
            {
                LaunchControllerSetup(true);
            }
            else
            {
                if (!StartTray)
                {
                    try
                    {
                        launcher.UpdateLauncher(true);
                    }
                    catch { }
                    if (!Launcher.FilesRestored)
                    {
                        Launcher.RestoreFiles();
                    }
                }

                InitializeComponent(StartTray);
                //InitializeComponent();

                if (StartTray)
                {
                    this.WindowState = FormWindowState.Minimized;
                }

                ReloadRomList();
                Launcher.LoadRegionSettings();


                if (StartTray)
                {
                    Process[] processes = Process.GetProcessesByName("nullDC_Win32_Release-NoTrace");
                    if (processes.Length > 0)
                    {
                        Process nulldcProcess = processes[0];
                        nulldcProcess.EnableRaisingEvents = true;

                        nulldcProcess.Exited += (sender, e) =>
                        {
                            Application.Exit();
                        };
                    }
                }
            }
        }