public override Ds3PadId Notify(ScpDevice.Notified Notification, String Class, String Path) { LogDebug(String.Format("++ Notify [{0}] [{1}] [{2}]", Notification, Class, Path)); switch (Notification) { case ScpDevice.Notified.Arrival: { UsbDevice Arrived = new UsbDevice(); if (Arrived.Open(Path)) { LogDebug(String.Format("-- Device Arrival [{0}]", Arrived.Local, Path)); if (LogArrival(Arrived)) { if (Device[(Byte) Arrived.PadId].IsShutdown) { Device[(Byte) Arrived.PadId].IsShutdown = false; Device[(Byte) Arrived.PadId].Close(); Device[(Byte) Arrived.PadId] = Arrived; return Arrived.PadId; } else { Arrived.Debug += new EventHandler<DebugEventArgs> (On_Debug ); Arrived.Report += new EventHandler<ReportEventArgs>(On_Report); Device[(Byte) Arrived.PadId].Close(); Device[(Byte) Arrived.PadId] = Arrived; if (m_Started) Arrived.Start(); return Arrived.PadId; } } } Arrived.Close(); } break; case ScpDevice.Notified.Removal: { for (Int32 Index = 0; Index < Device.Length; Index++) { if (Device[Index].State == DeviceState.Connected && Path == Device[Index].Path) { LogDebug(String.Format("-- Device Removal [{0}]", Device[Index].Local, Path)); Device[Index].Stop(); } } } break; } return Ds3PadId.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: { UsbDevice 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 (LogArrival(arrived)) { if (_device[(Byte)arrived.PadId].IsShutdown) { _device[(Byte)arrived.PadId].IsShutdown = false; _device[(Byte)arrived.PadId].Close(); _device[(Byte)arrived.PadId] = arrived; return arrived.PadId; } else { arrived.HidReportReceived += new EventHandler<ReportEventArgs>(On_Report); _device[(Byte)arrived.PadId].Close(); _device[(Byte)arrived.PadId] = arrived; if (m_Started) arrived.Start(); return arrived.PadId; } } } arrived.Close(); } break; case ScpDevice.Notified.Removal: { for (Int32 index = 0; index < _device.Length; index++) { if (_device[index].State == DsState.Connected && Path == _device[index].Path) { Log.InfoFormat("-- Device Removal [{0}]", _device[index].Local); _device[index].Stop(); } } } break; } return DsPadId.None; }
public override Boolean Open() { for (Byte Pad = 0; Pad < _device.Length; Pad++) { _device[Pad] = new UsbDevice(); _device[Pad].PadId = (DsPadId)Pad; } return base.Open(); }
public override Boolean Open() { for (Byte Pad = 0; Pad < Device.Length; Pad++) { Device[Pad] = new UsbDevice(); Device[Pad].PadId = (Ds3PadId) Pad; } for (Byte Pad = 0; Pad < Device.Length; Pad++) { try { if (Device[Pad].Open(Pad)) { if (LogArrival(Device[Pad])) { Device[Pad].Debug += new EventHandler<DebugEventArgs> (On_Debug ); Device[Pad].Report += new EventHandler<ReportEventArgs>(On_Report); } } else Device[Pad].Close(); } catch { } } return base.Open(); }