As things stand now on Windows Mobile, there exist devices with accelerometers, but the method for reading that accelerometer is dependent on the device OEM. Currently the only OEM that supports access to their accelerometers is Samsung through the Samsung Windows Mobile SDK; their solution for giving developers access to their device specific features. HTC doesn't officially provide accelerometer support but their implementation has been reverse engineered far enough to be usable. There are other devices with accelerometers, but documentation on accessing them is not widely available (example: does anyone know how to read the accelerometer on the LG Incite).
While it's not officially known if and when Microsoft will provide a common API on accelerometer access, the ZuneHD is believed to be an indicator of what is yet to come. With the USA release of the ZuneHD, there was also an update to the XNA game studio, a free managed (C#/VB.NET based) development environment that supports the previous generation Zunes, the Xbox 360, and the PC. In addition to adding the ZuneHD as a supported target, some new classes were added to access some of the ZuneHD specific functionality, including the Accelerometer. I had interest in looking at the class in the hopes that it provides insight on what is yet to come.
Accelerometer Capabilities
The Accelerometer
class has two methods of interest, GetCapabilities
and GetState
. You will always want to call GetCapabilities
first. It will let you know whether or not your code is running on a device that has an accelerometer. It returns an AccelerometerCapabilities
member. The IsConnected
member lets you know whether or not the accelerometer is available. Three members, HasXAxis
, HasYAxis
, and HasZAxis
tell on what axes the accelerometer detects acceleration. For the ZuneHD, all three of these are true. Though in the future, I could see an interface (such as a steering wheel) that doesn't need all three axes. If you needed information on the resolution of the accelerometer or its boundries, the information can be retrieved through the members AccelerometerResolution
, MaximumAcceleration
, and MinimumAcceleration
.
Reading the Values
The accelerometer's values can be acquired through the method Accelerometer.GetState()
. It returns an AccelerometerState
object. The IsConnected
member lets you know if an accelerometer is available and Acceleration
which is of type Vector3
(member containing X, Y, and Z values of type float).
So What Does this Mean for Windows Mobile Developers
Nothing officially. But this being an accelerometer API coming from Microsoft I found it interesting to look at. My hopes are that it gives insight to what to expect in Windows Mobile 7. But right now, there is no way to be certain of that.
CodeProject