Hi Ashley,
I do this:
(given stringIndex)
IOReturn err;
UInt8 stringDescLenInBytes;
IOUSBDevRequest devRequest;
devRequest.bmRequestType = 0x80; // device to host
devRequest.bRequest = 0x06; // GET_DESCRIPTOR
devRequest.wValue = (0x0003 << 8) | stringIndex;
devRequest.wIndex = 0;
devRequest.wLength = 0x0001;
devRequest.pData = &stringDescLenInBytes;
err = (*dev)->DeviceRequest(dev, &devRequest);
if (err == kIOReturnSuccess && stringDescLenInBytes > 0)
{
UInt8* stringDescriptor = new UInt8[stringDescLenInBytes];
devRequest.wLength = stringDescLenInBytes;
devRequest.pData = stringDescriptor;
err = (*dev)->DeviceRequest(dev, &devRequest);
if (err == kIOReturnSuccess)
{
UInt8* descStr8Ptr = stringDescriptor + 2;
UniChar* descStrPtr = reinterpret_cast<UniChar*>(descStr8Ptr);
CFIndex uniStrLen = (stringDescLenInBytes - 2) / 2;
// Note bytes will be swapped (USB is little endian)
SwapUniCodeBytes(descStrPtr, uniStrLen);
// now create a CFString from the UTF-16 bytes
...
}
delete [] stringDescriptor;
}
--Ron