USB_DeviceDetach

This commit is contained in:
ergo720 2018-07-09 21:40:09 +02:00
parent 7bb0ebddd5
commit b24e15a09c
4 changed files with 14 additions and 2 deletions

View File

@ -548,7 +548,7 @@ void Hub::UsbHub_HandleData(XboxDeviceState* dev, USBPacket* p)
void Hub::UsbHub_HandleDestroy()
{
// Inform upstream that the hub is detached and gone
m_HubState->dev.Port->Operations->detach(m_HubState->dev.Port);
m_UsbDev->USB_DeviceDetach(&m_HubState->dev);
m_UsbDev->m_FreePorts.push_back(m_HubState->dev.Port);
for (int i = 0; i < NUM_PORTS; i++) {

View File

@ -665,6 +665,17 @@ void USBDevice::USB_DeviceAttach(XboxDeviceState* dev)
USB_Attach(port);
}
void USBDevice::USB_DeviceDetach(XboxDeviceState* dev)
{
USBPort* port = dev->Port;
assert(port != nullptr);
assert(dev->Attached);
USB_Detach(port);
dev->Attached--;
}
void USBDevice::USB_EpInit(XboxDeviceState* dev)
{
USB_EpReset(dev);

View File

@ -79,6 +79,8 @@ class USBDevice : public PCIDevice {
void USB_PortReset(USBPort* Port);
// update device status during an attach
void USB_DeviceAttach(XboxDeviceState* dev);
// update device status during an detach
void USB_DeviceDetach(XboxDeviceState* dev);
// update port status when a device is attached
void USB_Attach(USBPort* Port);
// update port status when a device is detached

View File

@ -330,7 +330,6 @@ struct USBEndpoint {
struct XboxDeviceState {
USBPort* Port; // usb port struct of this device
int PortPath; // port index to which this device is attached to
char* Serial;
USBDeviceClass* klass; // usb class struct of this device
int Speed; // actual speed of the connected device