The Apple Sudden Motion Sensor
© Amit Singh. All Rights Reserved.Update (25-nov-2005)
Beginning with a certain version of the IOI2CMotionSensor kernel extension (Apple's driver for the onboard accelerometer), the integer ID of the driver function used for retrieving acceleration values changed — from 24 to 21. Moreover, certain machines (apparently the "hi-res" PowerBooks) use a different motion sensor driver (PMUMotionSensor.kext) as well. As was widely suggested to me, Apple had not "locked down" the "API" (Apple provides no such API in the first place); nor had it anything to do with the name change from "ams" to "sms" in the output of pmset — I had just been too busy to update the software.
The motion sensor software available from the following links has now been updated to incorporate these changes. The motion sensing "engine" common to all applications available here now supports reading the function ID and the driver class name as application preferences (at least one AMS application must be run once to create the preference file with default values):
$ defaults read com.osxbook.motionsensor # default settings {classname = IOI2CMotionSensor; getorientationmethodid = 21; } $ defaults write com.osxbook.motionsensor classname PMUMotionSensor # newest PowerBooks? ... $ defaults write com.osxbook.motionsensor getorientationmethodid 24 # old Apple driver ...
Note that as shown above, by default, the engine uses IOI2CMotionSensor.kext as the driver. If your computer uses PMUMotionSensor.kext, you must set the classname preference as shown above. It is reasonable to expect the software to detect the type of machine automatically, but that's a future item at this point.
Core Articles
"The PowerBook Sudden Motion Sensor" describes and provides applications that use the orientation data retrieved from the built-in motion sensor in Apple's PowerBook and iBook lines of notebook computers.
"The Apple Motion Sensor As A Human Interface Device" describes how to use the motion sensor as a general purpose input device, and provides software to do that.