public override Boolean Start() { m_Started = true; Byte Index = 0; // enumerate DS4 devices for (Byte instance = 0; instance < _device.Length && Index < _device.Length; instance++) { try { UsbDevice current = new UsbDs4(); current.PadId = (DsPadId)Index; if (current.Open(instance)) { if (LogArrival(current)) { current.Report += new EventHandler <ReportEventArgs>(On_Report); _device[Index++] = current; } else { current.Close(); } } else { current.Close(); } } catch (Exception ex) { Log.ErrorFormat("Unexpected error: {0}", ex); break; } } // enumerate DS3 devices for (Byte instance = 0; instance < _device.Length && Index < _device.Length; instance++) { try { UsbDevice current = new UsbDs3(); current.PadId = (DsPadId)Index; if (current.Open(instance)) { if (LogArrival(current)) { current.Report += new EventHandler <ReportEventArgs>(On_Report); _device[Index++] = current; } else { current.Close(); } } else { current.Close(); } } catch (Exception ex) { Log.ErrorFormat("Unexpected error: {0}", ex); break; } } try { for (Index = 0; Index < _device.Length; Index++) { if (_device[Index].State == DsState.Reserved) { _device[Index].Start(); } } } catch (Exception ex) { Log.ErrorFormat("Unexpected error: {0}", ex); } return(base.Start()); }
public override Boolean Start() { m_Started = true; Byte Index = 0; // enumerate DS4 devices for (Byte instance = 0; instance < _device.Length && Index < _device.Length; instance++) { try { UsbDevice current = new UsbDs4(); current.PadId = (DsPadId)Index; if (current.Open(instance)) { if (LogArrival(current)) { current.HidReportReceived += new EventHandler<ReportEventArgs>(On_Report); _device[Index++] = current; } else current.Close(); } else current.Close(); } catch (Exception ex) { Log.ErrorFormat("Unexpected error: {0}", ex); break; } } // enumerate DS3 devices for (Byte instance = 0; instance < _device.Length && Index < _device.Length; instance++) { try { UsbDevice current = new UsbDs3(); current.PadId = (DsPadId)Index; if (current.Open(instance)) { if (LogArrival(current)) { current.HidReportReceived += new EventHandler<ReportEventArgs>(On_Report); _device[Index++] = current; } else current.Close(); } else current.Close(); } catch (Exception ex) { Log.ErrorFormat("Unexpected error: {0}", ex); break; } } try { for (Index = 0; Index < _device.Length; Index++) { if (_device[Index].State == DsState.Reserved) { _device[Index].Start(); } } } catch (Exception ex) { Log.ErrorFormat("Unexpected error: {0}", ex); } return base.Start(); }
public override Boolean Start() { m_Started = true; Byte Index = 0; for (Byte Instance = 0; Instance < Device.Length && Index < Device.Length; Instance++) { try { UsbDevice Current = new UsbDs4(); Current.PadId = (DsPadId)Index; if (Current.Open(Instance)) { if (LogArrival(Current)) { Current.Debug += new EventHandler <DebugEventArgs> (On_Debug); Current.Report += new EventHandler <ReportEventArgs>(On_Report); Device[Index++] = Current; } else { Current.Close(); } } else { Current.Close(); } } catch { break; } } for (Byte Instance = 0; Instance < Device.Length && Index < Device.Length; Instance++) { try { UsbDevice Current = new UsbDs3(); Current.PadId = (DsPadId)Index; if (Current.Open(Instance)) { if (LogArrival(Current)) { Current.Debug += new EventHandler <DebugEventArgs> (On_Debug); Current.Report += new EventHandler <ReportEventArgs>(On_Report); Device[Index++] = Current; } else { Current.Close(); } } else { Current.Close(); } } catch { break; } } try { for (Index = 0; Index < Device.Length; Index++) { if (Device[Index].State == DsState.Reserved) { Device[Index].Start(); } } } catch { } return(base.Start()); }