Пример #1
0
 public void Awake()
 {
     instance = this;
     j        = new List <Joycon>();
     HIDapi.hid_init();
 }
Пример #2
0
        public static void Start()
        {
            pid             = Process.GetCurrentProcess().Id.ToString(); // get current process id for HidCerberus.Srv
            generic_manager = new GenericControllerManager();

            if (useHIDG)
            {
                try {
                    var HidCerberusService = new ServiceController("HidCerberus Service");
                    if (HidCerberusService.Status == ServiceControllerStatus.Stopped)
                    {
                        form.console.Text += "HidGuardian was stopped. Starting...\r\n";

                        try {
                            HidCerberusService.Start();
                        } catch (Exception e) {
                            form.console.Text += "Unable to start HidGuardian - everything should work fine without it, but if you need it, run the app again as an admin.\r\n";
                        }
                    }
                } catch (Exception e) {
                    form.console.Text += "Unable to start HidGuardian - everything should work fine without it, but if you need it, install it properly as admin.\r\n";
                }

                HttpWebResponse response;
                if (Boolean.Parse(ConfigurationManager.AppSettings["PurgeWhitelist"]))
                {
                    try {
                        response = (HttpWebResponse)WebRequest.Create(@"http://*****:*****@"http://localhost:26762/api/v1/hidguardian/whitelist/add/" + pid).GetResponse();                     // add BetterJoyForDolphin to allowed processes
                } catch (Exception e) {
                    form.console.Text += "Unable to add program to whitelist.\r\n";
                }
            }
            else
            {
                form.console.Text += "HidGuardian is disabled.\r\n";
            }

            emClient = new ViGEmClient();             // Manages emulated XInput

            foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
            {
                // Get local BT host MAC
                if (nic.NetworkInterfaceType != NetworkInterfaceType.FastEthernetFx && nic.NetworkInterfaceType != NetworkInterfaceType.Wireless80211)
                {
                    if (nic.Name.Split()[0] == "Bluetooth")
                    {
                        btMAC = nic.GetPhysicalAddress();
                    }
                }
            }

            mgr      = new JoyconManager();
            mgr.form = form;
            mgr.Awake();
            mgr.CheckForNewControllers();
            mgr.Start();

            server      = new UdpServer(mgr.j);
            server.form = form;

            server.Start(IPAddress.Parse(ConfigurationManager.AppSettings["IP"]), Int32.Parse(ConfigurationManager.AppSettings["Port"]));
            timer = new HighResTimer(pollsPerSecond, new HighResTimer.ActionDelegate(mgr.Update));
            timer.Start();

            form.console.Text += "All systems go\r\n";
        }