How to use USBmakebmRequestType in fast

To set the USB request type to objective-c, I use:

#define USBmakebmRequestType

For instance:

IOUSBDevRequest request;
request.bmRequestType = USBmakebmRequestType(kUSBOut, kUSBVendor, kUSBDevice);

How to use it fast? Swift missing fumntion USBmakebmRequestType

+4
source share
1 answer

I myself implemented this:

func USBmakebmRequestType(direction:Int, type:Int, recipient:Int) -> UInt8 {
    return UInt8((direction & kUSBRqDirnMask) << kUSBRqDirnShift)|UInt8((type & kUSBRqTypeMask) << kUSBRqTypeShift)|UInt8(recipient & kUSBRqRecipientMask)
}

Using:

USBmakebmRequestType(direction: kUSBIn, type: kUSBDevice, recipient: kUSBStandard)
+1
source

Source: https://habr.com/ru/post/1663895/


All Articles