コード例 #1
0
        static void Main(string[] args)
        {
            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();
                    }
                }
            }

            JoyconManager mgr = new JoyconManager();

            mgr.Awake();
            mgr.Start();

            server = new UdpServer(mgr.j);

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

            timer.Start();

            Console.Write("Press enter to quit.");
            Console.ReadLine();

            server.Stop();
            timer.Stop();
            mgr.OnApplicationQuit();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            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();
                    }
                }
            }

            JoyconManager mgr = new JoyconManager();

            mgr.Awake();
            mgr.Start();

            server = new UdpServer(mgr.j);

            //updateThread = new Thread(new ThreadStart(mgr.Update));
            //updateThread.Start();

            server.Start(26760);
            HighResTimer timer = new HighResTimer(pollsPerSecond, new HighResTimer.ActionDelegate(mgr.Update));

            timer.Start();

            Console.Write("Press enter to quit.");
            Console.ReadLine();

            server.Stop();
            timer.Stop();
            mgr.OnApplicationQuit();
        }
コード例 #3
0
        public static void Start()
        {
            pid = Process.GetCurrentProcess().Id.ToString(); // get current process id for HidCerberus.Srv

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

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

                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 BetterJoyForCemu to allowed processes
                } catch (Exception e) {
                    form.console.AppendText("Unable to add program to whitelist.\r\n");
                    useHIDG = false;
                }
            }

            if (Boolean.Parse(ConfigurationManager.AppSettings["ShowAsXInput"]) || Boolean.Parse(ConfigurationManager.AppSettings["ShowAsDS4"]))
            {
                try {
                    emClient = new ViGEmClient(); // Manages emulated XInput
                } catch (Nefarius.ViGEm.Client.Exceptions.VigemBusNotFoundException) {
                    form.console.AppendText("Could not start VigemBus. Make sure drivers are installed correctly.\r\n");
                }
            }

            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();
                    }
                }
            }

            // a bit hacky
            _3rdPartyControllers partyForm = new _3rdPartyControllers();

            partyForm.CopyCustomControllers();

            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"]));

            // Capture keyboard + mouse events for binding's sake
            keyboard           = WindowsInput.Capture.Global.KeyboardAsync();
            keyboard.KeyEvent += Keyboard_KeyEvent;
            mouse              = WindowsInput.Capture.Global.MouseAsync();
            mouse.MouseEvent  += Mouse_MouseEvent;

            form.console.AppendText("All systems go\r\n");
        }
コード例 #4
0
        public static void Start()
        {
            pid = Process.GetCurrentProcess().Id.ToString();             // get current process id for HidCerberus.Srv

            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";
                            useHIDG            = false;
                        }
                    }
                } 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";
                    useHIDG            = false;
                }

                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 BetterJoyForCemu to allowed processes
                } catch (Exception e) {
                    form.console.Text += "Unable to add program to whitelist.\r\n";
                    useHIDG            = false;
                }
            }
            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";
        }
コード例 #5
0
        public static void Start()
        {
            pid = Process.GetCurrentProcess().Id.ToString(); // get current process id for HidCerberus.Srv

            if (useHIDG)
            {
                form.console.AppendText("HidGuardian已启用.\r\n");
                try {
                    var HidCerberusService = new ServiceController("HidCerberus服务");
                    if (HidCerberusService.Status == ServiceControllerStatus.Stopped)
                    {
                        form.console.AppendText("HidGuardian已停止. 启动中...\r\n");

                        try {
                            HidCerberusService.Start();
                        } catch (Exception e) {
                            form.console.AppendText("无法启动HidGuardian - 没有它一切都可以正常工作,但是如果需要,请以管理员身份再次运行.\r\n");
                            useHIDG = false;
                        }
                    }
                } catch (Exception e) {
                    form.console.AppendText("无法启动HidGuardian - 没有它一切都可以正常工作,但是如果需要,请以管理员身份正确安装.\r\n");
                    useHIDG = false;
                }

                HttpWebResponse response;
                if (Boolean.Parse(ConfigurationManager.AppSettings["清除白名单"]))
                {
                    try {
                        response = (HttpWebResponse)WebRequest.Create(@"http://*****:*****@"http://localhost:26762/api/v1/hidguardian/whitelist/add/" + pid).GetResponse(); // add BetterJoyForCemu to allowed processes
                } catch (Exception e) {
                    form.console.AppendText("无法添加程序至白名单.\r\n");
                    useHIDG = false;
                }
            }

            if (Boolean.Parse(ConfigurationManager.AppSettings["以XInput显示"]) || Boolean.Parse(ConfigurationManager.AppSettings["以DS4显示"]))
            {
                try {
                    emClient = new ViGEmClient(); // Manages emulated XInput
                } catch (Nefarius.ViGEm.Client.Exceptions.VigemBusNotFoundException) {
                    form.console.AppendText("无法启动VigemBus驱动程序.请确认驱动已正确安装.\r\n");
                }
            }

            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();
                    }
                }
            }

            // a bit hacky
            _3rdPartyControllers partyForm = new _3rdPartyControllers();

            partyForm.CopyCustomControllers();

            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["端口"]));

            // Capture keyboard + mouse events for binding's sake
            keyboard           = WindowsInput.Capture.Global.KeyboardAsync();
            keyboard.KeyEvent += Keyboard_KeyEvent;
            mouse              = WindowsInput.Capture.Global.MouseAsync();
            mouse.MouseEvent  += Mouse_MouseEvent;

            form.console.AppendText("一切就绪\r\n");
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: d3xMachina/BetterJoy
        public static void Start()
        {
            if (useHidHide)
            {
                form.console.AppendText("HidHide is enabled.\r\n");

                if (useHidHide && Boolean.Parse(ConfigurationManager.AppSettings["PurgeAffectedDevices"]))
                {
                    try {
                        HidHide.blacklistDevices(new List <string>(), false);
                    } catch (Exception /*e*/) {
                        form.console.AppendText("Unable to purge blacklisted devices.\r\n");
                        useHidHide = false;
                    }
                }

                if (useHidHide)
                {
                    try {
                        List <string> applications = new List <string>();
                        applications.Add(System.Environment.ProcessPath);
                        bool keepExisting = true;
                        if (Boolean.Parse(ConfigurationManager.AppSettings["PurgeWhitelist"]))
                        {
                            keepExisting = false;
                        }
                        HidHide.whitelistApplications(applications, keepExisting);
                    } catch (Exception /*e*/) {
                        form.console.AppendText("Unable to add program to whitelist.\r\n");
                        useHidHide = false;
                    }
                }

                if (useHidHide)
                {
                    try {
                        HidHide.setStatus(true);
                    } catch (Exception /*e*/) {
                        form.console.AppendText("Unable to hide devices.\r\n");
                        useHidHide = false;
                    }
                }
            }

            if (Boolean.Parse(ConfigurationManager.AppSettings["ShowAsXInput"]) || Boolean.Parse(ConfigurationManager.AppSettings["ShowAsDS4"]))
            {
                try {
                    emClient = new ViGEmClient(); // Manages emulated XInput
                } catch (Nefarius.ViGEm.Client.Exceptions.VigemBusNotFoundException) {
                    form.console.AppendText("Could not start VigemBus. Make sure drivers are installed correctly.\r\n");
                }
            }

            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();
                    }
                }
            }

            // a bit hacky
            _3rdPartyControllers partyForm = new _3rdPartyControllers();

            partyForm.CopyCustomControllers();

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

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

            server.Start(IPAddress.Parse(ConfigurationManager.AppSettings["IP"]), Int32.Parse(ConfigurationManager.AppSettings["Port"]));

            // Capture keyboard + mouse events for binding's sake
            keyboard           = WindowsInput.Capture.Global.KeyboardAsync();
            keyboard.KeyEvent += Keyboard_KeyEvent;
            mouse              = WindowsInput.Capture.Global.MouseAsync();
            mouse.MouseEvent  += Mouse_MouseEvent;

            form.console.AppendText("All systems go\r\n");
            mgr.Start();
        }