| 61 | } |
| 62 | |
| 63 | bool USB::CreateDevice(u32 port) |
| 64 | { |
| 65 | const Pcsx2Config::USBOptions::Port& portcfg = EmuConfig.USB.Ports[port]; |
| 66 | const DeviceProxy* proxy = (portcfg.DeviceType != DEVTYPE_NONE) ? RegisterDevice::instance().Device(portcfg.DeviceType) : nullptr; |
| 67 | if (!proxy) |
| 68 | return true; |
| 69 | |
| 70 | DevCon.WriteLn("(USB) Creating a %s in port %u", proxy->Name(), port + 1); |
| 71 | USBDevice* dev; |
| 72 | { |
| 73 | auto lock = Host::GetSettingsLock(); |
| 74 | dev = proxy->CreateDevice(*Host::GetSettingsInterface(), port, portcfg.DeviceSubtype); |
| 75 | } |
| 76 | if (!dev) |
| 77 | { |
| 78 | Console.Error("Failed to create USB device in port %u (%s)", port + 1, proxy->Name()); |
| 79 | return false; |
| 80 | } |
| 81 | |
| 82 | pxAssertRel(s_qemu_ohci, "Has OHCI"); |
| 83 | pxAssertRel(!GetOHCIPort(port).port.dev, "No device in OHCI when creating"); |
| 84 | GetOHCIPort(port).port.dev = dev; |
| 85 | dev->attached = true; |
| 86 | usb_attach(&GetOHCIPort(port).port); |
| 87 | s_usb_device[port] = dev; |
| 88 | s_usb_device_proxy[port] = proxy; |
| 89 | return true; |
| 90 | } |
| 91 | |
| 92 | void USB::DestroyDevice(u32 port) |
| 93 | { |
no test coverage detected