Windows Phone Emulator since version 7.1 has support for accelerometer emulation which is helpfull when you don’t have physical device. Currently it allows you to run predefined sequentions of accelerometer data to test your application. How to do this?

In additional panel of WP7 Emulator (you can run it using >> button) we have tab called Acceleromenter and section Recorded data.

By default we have only one item on list. It represents example set of data reads when you are shaking your phone. What if we want something more? What if we need some other set of data? It is quite easy to do. First of all we need to go to C:\Program Files (x86)\Microsoft XDE\1.0\sensordata\acc (directory (x86) part is ofcourse optional) – there is a file called Shake. It can be opened with any text editor – I’m using Notepad++ because it is simple XML file. The most important part of this file is connected with AccData elements. Sample entry is listed below.

<AccData offset="2185" x="00.45899999" y="-00.69300002" z="-00.49500000" />

Meaning of X,Y,Z attributes is quite obvious. Offset attribute is responsible for defining when this part of data (X,Y,Z) should be send to emulator and it is defined in milliseconds. Now we can simply create analogical file (ex. by simple copy and paste) and modify its content. As a result we are getting now two options on Recorded Data list as you can see below.

Simple as it is :) I hope that now it will be easier for you to test your applications using accelerometer emulation.