Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Starfox

macrumors 6502
Original poster
Apr 7, 2011
256
9
I have some HID code that writes output reports to a device using write() that I'm trying to port to OS X - The closest match I found it IOHIDDeviceSetReport(), but how do I translate the parameters for write (a buffer and a length) to the set of parameters requested by IOHIDDeviceSetReport()?
 
Because as far as I know OS X doesn't support hidraw and accessing HID devices using a file descriptor.
 
So, did you look at the documentation then ? IOHIDDevice.setReport() takes 3 parameters according to the reference :

https://developer.apple.com/library...HIDDevice.html#//apple_ref/doc/uid/TP40011784

The first one is a pointer to a IOMemoryDescription class which is said to be your "report" (i'd wager, your bytes to write here). Looking at that class, it has both an initWithOptions method to create a report and a writeBytes method to actually write bytes in there (which would be the bytes and count parameters of your standard write() syscall) :

https://developer.apple.com/library...ce/translated_content/IOMemoryDescriptor.html

If you want to know how a IOMemoryDescriptor works, the full source code to the implementation is available in the Darwin sources of course :

http://www.opensource.apple.com/source/xnu/xnu-1699.26.8/iokit/Kernel/IOMemoryDescriptor.cpp
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.