| 344 | } |
| 345 | |
| 346 | bool Xbox360Peripheral::start(IOService *provider) |
| 347 | { |
| 348 | const IOUSBConfigurationDescriptor *cd; |
| 349 | IOUSBFindInterfaceRequest intf; |
| 350 | IOUSBFindEndpointRequest pipe; |
| 351 | XBOX360_OUT_LED led; |
| 352 | IOWorkLoop *workloop = NULL; |
| 353 | |
| 354 | if (!super::start(provider)) |
| 355 | return false; |
| 356 | // Get device |
| 357 | device=OSDynamicCast(IOUSBDevice,provider); |
| 358 | if(device==NULL) { |
| 359 | IOLog("start - invalid provider\n"); |
| 360 | goto fail; |
| 361 | } |
| 362 | // Check for configurations |
| 363 | if(device->GetNumConfigurations()<1) { |
| 364 | device=NULL; |
| 365 | IOLog("start - device has no configurations!\n"); |
| 366 | goto fail; |
| 367 | } |
| 368 | // Set configuration |
| 369 | cd=device->GetFullConfigurationDescriptor(0); |
| 370 | if(cd==NULL) { |
| 371 | device=NULL; |
| 372 | IOLog("start - couldn't get configuration descriptor\n"); |
| 373 | goto fail; |
| 374 | } |
| 375 | // Open |
| 376 | if(!device->open(this)) { |
| 377 | device=NULL; |
| 378 | IOLog("start - unable to open device\n"); |
| 379 | goto fail; |
| 380 | } |
| 381 | if(device->SetConfiguration(this,cd->bConfigurationValue,true)!=kIOReturnSuccess) { |
| 382 | IOLog("start - unable to set configuration\n"); |
| 383 | goto fail; |
| 384 | } |
| 385 | // Get release |
| 386 | { |
| 387 | UInt16 release = device->GetDeviceRelease(); |
| 388 | switch (release) { |
| 389 | default: |
| 390 | IOLog("Unknown device release %.4x\n", release); |
| 391 | // fall through |
| 392 | case 0x0110: |
| 393 | chatpadInit[0] = 0x01; |
| 394 | chatpadInit[1] = 0x02; |
| 395 | break; |
| 396 | case 0x0114: |
| 397 | chatpadInit[0] = 0x09; |
| 398 | chatpadInit[1] = 0x00; |
| 399 | break; |
| 400 | } |
| 401 | } |
| 402 | // Find correct interface |
| 403 | controllerType = Xbox360; |
no test coverage detected