public void Disconnect(bool stop) { device.Report -= Device_Report; state.LightBarExplicitlyOff = sendColor.R == 0 && sendColor.G == 0 && sendColor.B == 0; state.LightBarColor = new DS4Color(RestoreColor); device.pushHapticState(state); if (stop) { device.DisconnectBT(); device.DisconnectDongle(); } device.StopUpdate(); }
public void Disconnect(bool stop) { sendColor = RestoreColor; Thread.Sleep(10);//HACK: this is terrible, but it works reliably so i'll leave it like this :( //this is needed so that OnDeviceReport has time to send the color once the device sends a report. device.Report -= OnDeviceReport; if (stop) { device.DisconnectBT(); device.DisconnectDongle(); } device.StopUpdate(); }
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; } }