public override void Connect() { if (!Connected) { this.device = new HidDevice(deviceID); // Look up the VID/PID in the connected devices registry try { this.device.Scan(); } catch (HidDeviceException ex) { throw new ControllerConnectionException("Could not find USB controller - is it plugged in?", innerException: ex); } // Open file handles for communication try { tx = device.GetWriteFile(); rx = device.GetReadFile(); } catch (Exception ex) { throw new ControllerConnectionException("Could not connect to USB controller", innerException:ex); } // required when running outside visual studio for some reason??? //SendPacket(0x00); } NotifyConnect(); }
public override void Disconnect() { if (Connected) { tx.Close(); rx.Close(); this.device = null; } NotifyDisconnect(); }