johnvisiomvp

Life with Visio and other Microsoft Toys!

WP7 Shake, Rattle and Roll

leave a comment »

One of the nice features of the new WP7 emulator is the ability to emulate motion on the emulated device. Unfortunately, there is only one prerecorded action and no documentation on how to add your own. Thanks to one intrepid explorer, Den Delimarsky, he created an app to capture the motion http://dotnet.dzone.com/articles/custom-accelerometer-motions.

In that article, he left breadcrumbs to where the actions are stored (I found them under Program Files (x86) ) and it is just a matter of creating new files in the directory to add actions. As a quick test, I copied the default shake action and renamed the copies as rattle and roll. Rerunning the emulator and there was now three actions… rattle, roll, shake (isn’t alphabetical order fun).

So what is in the file? It is a standard XML file in this format.

<?xml version=”1.0″ encoding=”utf-8″?>
<WindowsPhoneEmulator xmlns=”http://schemas.microsoft.com/WindowsPhoneEmulator/2009/08/SensorData“>
<SensorData>
<Header version=”1″/>
<AccData offset=”21″ x=”-00.084″ y=”-01.02100003″ z=”-00.41700000″ />
<AccData offset=”42″ x=”-00.142″ y=”-00.95099998″ z=”-00.39700001″ />
</SensorData>
</WindowsPhoneEmulator>

The actual data records are the ones with the AccData keywords. The offset tag starts with 21 for the first record and increases by 21 for all the subsequent ones. The x, y and z tags are the actual motions. They appear to be delta changes. Though they appear to have eight decimal places, there is no need for that precision.

So hopefully this is enough information to help you create some actions.

John Marshall… Visio MVP       Visio.MVPs.org

Advertisements

Written by johnvisiomvp

November 2, 2011 at 7:45 pm

Posted in Windows Phone 7, WP7

Tagged with ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: