Start device
| 46 | |
| 47 | // Start device |
| 48 | bool WirelessGamingReceiver::start(IOService *provider) |
| 49 | { |
| 50 | const IOUSBConfigurationDescriptor *cd; |
| 51 | IOUSBFindInterfaceRequest interfaceRequest; |
| 52 | IOUSBFindEndpointRequest pipeRequest; |
| 53 | IOUSBInterface *interface; |
| 54 | int iConnection, iOther, i; |
| 55 | |
| 56 | if (!IOService::start(provider)) |
| 57 | { |
| 58 | // IOLog("start - superclass failed\n"); |
| 59 | return false; |
| 60 | } |
| 61 | |
| 62 | device = OSDynamicCast(IOUSBDevice, provider); |
| 63 | if (device == NULL) |
| 64 | { |
| 65 | // IOLog("start - invalid provider\n"); |
| 66 | goto fail; |
| 67 | } |
| 68 | |
| 69 | // Check for configurations |
| 70 | if (device->GetNumConfigurations() < 1) |
| 71 | { |
| 72 | device = NULL; |
| 73 | // IOLog("start - device has no configurations!\n"); |
| 74 | goto fail; |
| 75 | } |
| 76 | |
| 77 | // Set configuration |
| 78 | cd = device->GetFullConfigurationDescriptor(0); |
| 79 | if (cd == NULL) |
| 80 | { |
| 81 | device = NULL; |
| 82 | // IOLog("start - couldn't get configuration descriptor\n"); |
| 83 | goto fail; |
| 84 | } |
| 85 | |
| 86 | if (!device->open(this)) |
| 87 | { |
| 88 | device = NULL; |
| 89 | // IOLog("start - failed to open device\n"); |
| 90 | goto fail; |
| 91 | } |
| 92 | if (device->SetConfiguration(this, cd->bConfigurationValue, true) != kIOReturnSuccess) |
| 93 | { |
| 94 | // IOLog("start - unable to set configuration\n"); |
| 95 | goto fail; |
| 96 | } |
| 97 | |
| 98 | for (i = 0; i < WIRELESS_CONNECTIONS; i++) |
| 99 | { |
| 100 | connections[i].controller = NULL; |
| 101 | connections[i].controllerIn = NULL; |
| 102 | connections[i].controllerOut = NULL; |
| 103 | connections[i].other = NULL; |
| 104 | connections[i].otherIn = NULL; |
| 105 | connections[i].otherOut = NULL; |