private void FindControllers() { // If we already have a controller, skip the search if (controller != null) { return; } try { DS4Devices.findControllers(); IEnumerable <DS4Device> devices = DS4Devices.getDS4Controllers(); if (devices.Count() < 1) { return; } DS4Device device = devices.FirstOrDefault(); Console.WriteLine("Controller found: " + device.MacAddress + " (" + device.ConnectionType + ")"); controller = new DS4Controller(device); controller.SetLightBarColor(Color.WhiteSmoke); OnDeviceConnectionStateChanged(controller, true); } catch (Exception e) { Console.Error.WriteLine(e.Message); } }
private void OnDeviceConnectionStateChanged(DS4Controller controller, bool isConnected) { DeviceConnectionStateChangedEventArgs args = new DeviceConnectionStateChangedEventArgs(); args.Controller = controller; args.IsConnected = isConnected; DeviceConnectionStateChanged?.Invoke(this, args); }
private void PurgeInactiveControllers() { if (controller == null) { return; } if (controller.Device == null) { OnDeviceConnectionStateChanged(controller, false); controller.Purge(); controller = null; } }