R – Snow Leopard compatible “sudden motion sensor” API available

accelerometercocoamacososx-snow-leopardsmslib

I have been using Unimotion in my application to read motion sensor values for Apple laptops, but have been unable to port the code to 10.6 64-bit. (I have also tried SMSLib and had the no luck either.)

  • Is there any simple 10.6 compatible
    SMS API?

If there is no alternative, I am also considering patching one of the libraries. Both Unimotion and SMSLib use the following call, which has been deprecated in 10.5 and removed from 10.6 64-bit:

result = IOConnectMethodStructureIStructureO(
    dataPort, kernFunc, structureInputSize,
    &structureOutputSize, &inputStructure, 
    outputStructure);
  • Is there any simple way to replace
    this with new IOKit calls?

(This post did not really get me much further)

Best Answer

If there is no alternative, I am also considering patching one of the libraries. Both Unimotion and SMSLib use the following call, which has been deprecated in 10.5 and removed from 10.6 64-bit:

result = IOConnectMethodStructureIStructureO(
    dataPort, kernFunc, structureInputSize,
    &structureOutputSize, &inputStructure, 
    outputStructure);

Is there any simple way to replace this with new IOKit calls?

That very document suggests replacements. What about this one?

kern_return_t
IOConnectCallStructMethod(
    mach_port_t  connection,        // In
    uint32_t     selector,      // In
    const void  *inputStruct,       // In
    size_t       inputStructCnt,    // In
    void        *outputStruct,      // Out
    size_t      *outputStructCnt)   // In/Out

As far as I can tell, there should be no difference except for the order of the arguments. That said, I've never used I/O Kit, so I could be missing some critical conceptual difference that will make this call not work as the old one did.

Related Topic