public static void Stop() { if (Program.useHidHide) { try { HidHide.whitelistApplications(new List <string>(), false); } catch (Exception /*e*/) { form.console.AppendText("Unable to purge whitelist.\r\n"); } try { HidHide.setStatus(false); } catch (Exception /*e*/) { form.console.AppendText("Unable to disable HidHide.\r\n"); } if (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"); } } } keyboard.Dispose(); mouse.Dispose(); server.Stop(); mgr.OnApplicationQuit(); }
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(); }