| 507 | } |
| 508 | |
| 509 | HRESULT FeedbackXBOBT::InitializeTerminate(NumVersion APIversion, io_object_t hidDevice, boolean_t begin) |
| 510 | { |
| 511 | if(begin) { |
| 512 | if (APIversion.majorRev != kFFPlugInAPIMajorRev) |
| 513 | { |
| 514 | // fprintf(stderr,"Feedback: Invalid version\n"); |
| 515 | return FFERR_INVALIDPARAM; |
| 516 | } |
| 517 | // From probe |
| 518 | if( (hidDevice==0) |
| 519 | || !goodProbe(hidDevice) ) |
| 520 | { |
| 521 | // fprintf(stderr,"Feedback: Invalid device\n"); |
| 522 | return FFERR_INVALIDPARAM; |
| 523 | } |
| 524 | this->device = IOHIDDeviceCreate(kCFAllocatorDefault, hidDevice); |
| 525 | if(!this->device) { |
| 526 | // fprintf(stderr,"Feedback: Failed to initialise\n"); |
| 527 | return FFERR_NOINTERFACE; |
| 528 | } |
| 529 | IOHIDDeviceOpen(this->device, 0); |
| 530 | Queue = dispatch_queue_create("com.mice.driver.FeedbackXBOBT", NULL); |
| 531 | Timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, Queue); |
| 532 | dispatch_source_set_timer(Timer, dispatch_walltime(NULL, 0), LoopGranularity*1000, 10); |
| 533 | dispatch_set_context(Timer, this); |
| 534 | dispatch_source_set_event_handler_f(Timer, EffectProc); |
| 535 | dispatch_resume(Timer); |
| 536 | } |
| 537 | else { |
| 538 | dispatch_sync(Queue, ^{ |
| 539 | dispatch_source_cancel(Timer); |
| 540 | SetForce(0, 0, 0, 0); |
| 541 | IOHIDDeviceClose(this->device, 0); |
| 542 | CFRelease(this->device); |
| 543 | }); |
| 544 | |
| 545 | } |
| 546 | return FF_OK; |
| 547 | } |
| 548 | |
| 549 | HRESULT FeedbackXBOBT::DestroyEffect(FFEffectDownloadID EffectHandle) |
| 550 | { |
no test coverage detected