public override DsPadId Notify(ScpDevice.Notified notification, string Class, string path) { Log.DebugFormat("++ Notify [{0}] [{1}] [{2}]", notification, Class, path); switch (notification) { case ScpDevice.Notified.Arrival: { if (_device.State != DsState.Connected) { BthDongle arrived; if (path.StartsWith("COM")) { arrived = new BthDongleSerial(); } else { arrived = new BthDongle(); } if (arrived.Open(path)) { Log.DebugFormat("-- Device Arrival [{0}]", arrived.BluetoothHostAddress.AsFriendlyName()); _device.Close(); _device = arrived; _device.DeviceArrived += OnDeviceArrival; _device.HidReportReceived += OnHidReportReceived; if (m_Started) _device.Start(); break; } arrived.Close(); arrived.Dispose(); } } break; case ScpDevice.Notified.Removal: if (_device.Path == path) { Log.DebugFormat("-- Device Removal [{0}]", _device.BluetoothHostAddress.AsFriendlyName()); _device.Stop(); } break; } return DsPadId.None; }
public override DsPadId Notify(ScpDevice.Notified notification, string Class, string Path) { Log.DebugFormat("++ Notify [{0}] [{1}] [{2}]", notification, Class, Path); switch (notification) { case ScpDevice.Notified.Arrival: { if (_device.State != DsState.Connected) { var arrived = new BthDongle(); if (arrived.Open(Path)) { Log.DebugFormat("-- Device Arrival [{0}]", arrived.Local); _device.Close(); _device = arrived; _device.DeviceArrived += OnDeviceArrival; _device.HidReportReceived += OnHidReportReceived; if (m_Started) _device.Start(); break; } arrived.Close(); arrived.Dispose(); } } break; case ScpDevice.Notified.Removal: if (_device.Path == Path) { Log.DebugFormat("-- Device Removal [{0}]", _device.Local); AudioPlayer.Instance.PlayCustomFile(GlobalConfiguration.Instance.BluetoothDisconnectSoundFile); _device.Stop(); } break; } return DsPadId.None; }
public override DsPadId Notify(ScpDevice.Notified notification, string Class, string path) { Log.DebugFormat("++ Notify [{0}] [{1}] [{2}]", notification, Class, path); switch (notification) { case ScpDevice.Notified.Arrival: { if (_device.State != DsState.Connected) { var arrived = new BthDongle(); if (arrived.Open(path)) { Log.DebugFormat("-- Device Arrival [{0}]", arrived.Local); _device.Close(); _device = arrived; _device.DeviceArrived += OnDeviceArrival; _device.HidReportReceived += OnHidReportReceived; if (m_Started) _device.Start(); break; } arrived.Close(); arrived.Dispose(); } } break; case ScpDevice.Notified.Removal: if (_device.Path == path) { Log.DebugFormat("-- Device Removal [{0}]", _device.Local); _device.Stop(); } break; } return DsPadId.None; }
public override DsPadId Notify(ScpDevice.Notified notification, string Class, string path) { Log.InfoFormat("++ Notify [{0}] [{1}] [{2}]", notification, Class, path); switch (notification) { case ScpDevice.Notified.Arrival: { var arrived = new UsbDevice(); if (string.Equals(Class, UsbDs3.USB_CLASS_GUID, StringComparison.CurrentCultureIgnoreCase)) { arrived = new UsbDs3(); Log.Debug("-- DS3 Arrival Event"); } if (string.Equals(Class, UsbDs4.USB_CLASS_GUID, StringComparison.CurrentCultureIgnoreCase)) { arrived = new UsbDs4(); Log.Debug("-- DS4 Arrival Event"); } Log.InfoFormat("Arrival event for GUID {0} received", Class); if (arrived.Open(path)) { Log.InfoFormat("-- Device Arrival [{0}]", arrived.Local); if (!Apply3RdPartyWorkaroundsForDs3(ref arrived, path: path)) break; if (LogArrival(arrived)) { if (_devices[(byte) arrived.PadId].IsShutdown) { _devices[(byte) arrived.PadId].IsShutdown = false; _devices[(byte) arrived.PadId].Close(); _devices[(byte) arrived.PadId] = arrived; return arrived.PadId; } arrived.HidReportReceived += OnHidReportReceived; _devices[(byte) arrived.PadId].Close(); _devices[(byte) arrived.PadId] = arrived; if (m_Started) arrived.Start(); return arrived.PadId; } } arrived.Close(); } break; case ScpDevice.Notified.Removal: { foreach (var t in _devices.Where(t => t.State == DsState.Connected && path == t.Path)) { Log.InfoFormat("-- Device Removal [{0}]", t.Local); // play disconnect sound if (GlobalConfiguration.Instance.IsUsbDisconnectSoundEnabled) AudioPlayer.Instance.PlayCustomFile(GlobalConfiguration.Instance.UsbDisconnectSoundFile); t.Stop(); } } break; } return DsPadId.None; }
public override DsPadId Notify(ScpDevice.Notified notification, string Class, string path) { Log.DebugFormat("++ Notify [{0}] [{1}] [{2}]", notification, Class, path); var classGuid = Guid.Parse(Class); switch (notification) { case ScpDevice.Notified.Arrival: { var arrived = new UsbDevice(); if (classGuid == UsbDs3.DeviceClassGuid) { arrived = new UsbDs3(); Log.Info("DualShock 3 plugged in via Usb"); } if (classGuid == UsbDs4.DeviceClassGuid) { arrived = new UsbDs4(); Log.Info("DualShock 4 plugged in via Usb"); } if (classGuid == UsbGenericGamepad.DeviceClassGuid) { arrived = UsbGenericGamepad.DeviceFactory(path); // unknown or unsupported device if (arrived == null) break; Log.Debug("Generic Gamepad plugged in via Usb"); } Log.DebugFormat("Arrival event for GUID {0} received", classGuid); if (arrived.Open(path)) { Log.DebugFormat("Device MAC address: {0}", arrived.DeviceAddress.AsFriendlyName()); if (!Apply3RdPartyWorkaroundsForDs3(ref arrived, path: path)) break; if (LogArrival(arrived)) { if (_devices[(byte) arrived.PadId].IsShutdown) { _devices[(byte) arrived.PadId].IsShutdown = false; _devices[(byte) arrived.PadId].Close(); _devices[(byte) arrived.PadId] = arrived; return arrived.PadId; } arrived.HidReportReceived += OnHidReportReceived; _devices[(byte) arrived.PadId].Close(); _devices[(byte) arrived.PadId] = arrived; if (m_Started) arrived.Start(); return arrived.PadId; } } else { Log.FatalFormat("Couldn't open device {0}", path); } arrived.Close(); } break; case ScpDevice.Notified.Removal: { foreach (var t in _devices.Where(t => t.State == DsState.Connected && path == t.Path)) { Log.InfoFormat("Device with MAC address {0} unplugged from Usb", t.DeviceAddress.AsFriendlyName()); // play disconnect sound if (GlobalConfiguration.Instance.IsUsbDisconnectSoundEnabled) AudioPlayer.Instance.PlayCustomFile(GlobalConfiguration.Instance.UsbDisconnectSoundFile); t.Stop(); } } break; } return DsPadId.None; }