public void Dispose() { if (sessionHandle != null) { sessionHandle.Dispose(); sessionHandle = null; } }
// there is no connect, we just check if we can open and claim an interface, and if we can then we can "connect" public bool Connect() { lock (_sync) { if (context != null) { if (!context.IsClosed) { context.Close(); } context.Dispose(); context = null; } context = new MonoUsbSessionHandle(); var usbHandle = MonoUsbApi.OpenDeviceWithVidPid(context, 1406, 12288); if (usbHandle != null) { if (MonoUsbApi.ClaimInterface(usbHandle, 0) == 0) { MonoUsbApi.ReleaseInterface(usbHandle, 0); usbHandle.Close(); Connected = true; return(true); } usbHandle.Close(); } else { throw new Exception("Console not found or usb driver failed to open device. Is the console connected and is libusb configured correctly?"); } Connected = false; UnityEngine.Debug.Log("Failed"); return(false); } }