private void FindController() { new Thread(() => { var canRun = true; _game.OnEnd += () => canRun = false; while (canRun) { if (device == null) { DS4Devices.findControllers(); device = DS4Devices.getDS4Controllers().First(); device.Removal += (sender, args) => { device = null; DS4Devices.stopControllers(); }; device.Report += DeviceOnReport; device.StartUpdate(); device.LightBarColor = new DS4Color(Color.DeepPink); PrintInfo(); } if (device != null && !_isAlive) { device = null; } Thread.Sleep(16); } }).Start(); }
public void Shutdown() { Log.WriteLine ("Shutting down DS4 controllers..."); DS4Devices.stopControllers(); foreach (var c in Controllers) { c.Stop(); } }
public bool Stop(bool showlog = true) { if (running) { running = false; if (showlog) { LogDebug(Properties.Resources.StoppingX360); } bool anyUnplugged = false; for (int i = 0; i < DS4Controllers.Length; i++) { if (DS4Controllers[i] != null) { if (Global.getDCBTatStop() && !DS4Controllers[i].Charging && showlog) { DS4Controllers[i].DisconnectBT(); } else { DS4LightBar.defualtLight = true; DS4LightBar.updateLightBar(DS4Controllers[i], i, CurrentState[i], ExposedState[i], touchPad[i]); System.Threading.Thread.Sleep(50); } CurrentState[i].Battery = PreviousState[i].Battery = 0; // Reset for the next connection's initial status change. x360Bus.Unplug(i); anyUnplugged = true; DS4Controllers[i] = null; touchPad[i] = null; } } if (anyUnplugged) { System.Threading.Thread.Sleep(XINPUT_UNPLUG_SETTLE_TIME); } x360Bus.UnplugAll(); x360Bus.Stop(); if (showlog) { LogDebug(Properties.Resources.StoppingDS4); } DS4Devices.stopControllers(); if (showlog) { LogDebug(Properties.Resources.StoppedDS4Windows); } Global.ControllerStatusChanged(this); } return(true); }
public override void Shutdown() { if (!isInitialized) { return; } foreach (var dev in Devices) { dev.Disconnect(GlobalVarRegistry.GetVariable <bool>($"{DeviceName}_disconnect_when_stop")); } DS4Devices.stopControllers(); Devices.Clear(); isInitialized = false; }
public static void Stop() { if (_watcherThread == null) { return; } Logger.Write("Stopping controller manager"); _watcherThread.Abort(); _watcherThread = null; foreach (var controller in _allControllers) { controller?.Stop(); } _allControllers.Clear(); XboxController.StopPolling(); DS4Devices.stopControllers(); }
public override void Shutdown() { if (!IsInitialized) { return; } isDisconnecting = true; foreach (var dev in devices) { dev.Disconnect(Global.Configuration.VarRegistry.GetVariable <bool>($"{DeviceName}_disconnect_when_stop")); } DS4Devices.stopControllers(); devices.Clear(); IsInitialized = false; isDisconnecting = false; }
public void Shutdown() { try { if (isInitialized) { if (Global.Configuration.VarRegistry.GetVariable <bool>($"{devicename}_disconnect_when_stop")) { device.DisconnectBT(); device.DisconnectDongle(); } RestoreColor(); device.StopUpdate(); DS4Devices.stopControllers(); isInitialized = false; } } catch (Exception e) { Global.logger.Error("There was an error shutting down DualShock: " + e); isInitialized = true; } }
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { DS4Devices.stopControllers(); // Kill all connections with ds4 devices connected. leting the control to host os. }