Search code examples
objective-ckernelusbdriverosx-elcapitan

Upgrading osx driver for 10.11 (Changes in USB stack)


I am upgrading existing custom mouse driver devices to OSX 10.11. It is seen that apple has updated its usb stack.

Please refer - https://developer.apple.com/library/mac/releasenotes/General/APIDiffsMacOSX10_11/Objective-C/Kernel.html

My existing code uses many of the removed classes (IOUSBHIDDriver, IOUSBInterface, IOUSBPipe etc). Can someone help me in finding replacements or any useful information for upgrading to 10.11?

Many classes and header files are renamed, and I can figure out the replacements from the above link. But code also uses deprecated class IOUSBPipe and its methods. I have not fully understood what it is used for. Can someone explain purpose of IOUSBPipe as well as suggest me the alternative class for OSX 10.11?

Please find below this line a code snippet that deals with IOUSBpipe

IOMemoryDescriptor *report;
setReport(report, kIOHIDReportTypeOutput);
IOReturn ret;
IOUSBDevRequest request;

IOUSBFindEndpointRequest findRequest = {
    kUSBAnyType,
    kUSBAnyDirn,
    0,
    0
};

IOUSBPipe *pipe = NULL;

while(pipe=usbInterface->FindNextPipe(pipe, &findRequest))
{
if (!pipe)
{
    IOLog("NO PIPE!\n");
    return 0;
}
IOLog("control request on pipe!\n");

request.bmRequestType = (UInt8)req->bmRequestType;
request.bRequest = (UInt8)req->bRequest;
request.wIndex = (UInt16)req->wIndex;
request.wLength = req->wLength;
request.wValue = (UInt16)req->wValue;
request.pData = (void*)data;

pipe->ControlRequest(&request);
    IOLog("result: %d", data[0]);
}

Solution

  • A pipe basically represents one direction of a USB endpoint. You can send or receive data from it. I don't know much about kernel-level development in Mac OS X, but by looking at the document you posted, I suspect you are supposed to use IOUSBHostPipe now instead of IOUSBPipe.