<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Coding4Fun : hardware</title><link>http://blogs.msdn.com/coding4fun/archive/tags/hardware/default.aspx</link><description>Tags: hardware</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Build your own Windows 7 Sensors!</title><link>http://blogs.msdn.com/coding4fun/archive/2009/12/10/9934884.aspx</link><pubDate>Thu, 10 Dec 2009 13:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9934884</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/9934884.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=9934884</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=9934884</wfw:comment><description>&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/BuildyourownWindows7Sensors_A690/image_2.png" mce_href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/BuildyourownWindows7Sensors_A690/image_2.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; MARGIN-LEFT: 0px; BORDER-LEFT-WIDTH: 0px; MARGIN-RIGHT: 0px" title=image border=0 alt=image align=right src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/BuildyourownWindows7Sensors_A690/image_thumb.png" width=240 height=220 mce_src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/BuildyourownWindows7Sensors_A690/image_thumb.png"&gt;&lt;/A&gt; Tired of having a computer with no sensors?&amp;nbsp; We’ve created a &lt;A href="http://code.msdn.microsoft.com/motionsensor" mce_href="http://code.msdn.microsoft.com/motionsensor"&gt;parallax windows 7 sensor driver with source code&lt;/A&gt; so you can create your own!&lt;/P&gt;
&lt;P&gt;The sensor device we made here is a Passive-Infrared Sensor.&amp;nbsp; So basically it is a motion sensor.&amp;nbsp; The board used in the white paper is the Parallax “BASIC Stamp HomeWork Board”.&amp;nbsp; Sadly these only come in a 10-pack so the fallback would be the &lt;A href="http://www.parallax.com/Store/Microcontrollers/BASICStampModules/tabid/134/CategoryID/11/List/0/SortField/0/Level/a/ProductID/1/Default.aspx" mce_href="http://www.parallax.com/Store/Microcontrollers/BASICStampModules/tabid/134/CategoryID/11/List/0/SortField/0/Level/a/ProductID/1/Default.aspx"&gt;BASIC Stamp 2 Module ($49.00)&lt;/A&gt; and getting either the &lt;A href="http://www.parallax.com/Store/Microcontrollers/BASICStampDevelopmentBoards/tabid/137/CategoryID/12/List/0/SortField/0/Level/a/ProductID/121/Default.aspx" mce_href="http://www.parallax.com/Store/Microcontrollers/BASICStampDevelopmentBoards/tabid/137/CategoryID/12/List/0/SortField/0/Level/a/ProductID/121/Default.aspx"&gt;BASIC Stamp 2 Carrier Board” ($15.99)&lt;/A&gt; or &lt;A href="http://www.parallax.com/Store/Microcontrollers/BASICStampDevelopmentBoards/tabid/137/CategoryID/12/List/0/Level/a/ProductID/126/Default.aspx?SortField=ProductName%2cProductName" mce_href="http://www.parallax.com/Store/Microcontrollers/BASICStampDevelopmentBoards/tabid/137/CategoryID/12/List/0/Level/a/ProductID/126/Default.aspx?SortField=ProductName%2cProductName"&gt;the Board of Education Dev Board (USB) ($41.99)&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;The code example also has a .Net application that interprets the data from the sensor.&lt;/P&gt;
&lt;P&gt;More of an Arduino fan?&amp;nbsp; Coding4Fun is working with Brian Jepson (&lt;A href="http://twitter.com/bjepson" mce_href="http://twitter.com/bjepson"&gt;@bjepson&lt;/A&gt;) of &lt;A href="http://www.makezine.com/" mce_href="http://www.makezine.com/"&gt;MAKE&lt;/A&gt; and O'Reilly to create a driver that works with Arduino!&amp;nbsp; I’ll post more when it gets finished.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9934884" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/coding4fun/archive/tags/c4fnews/default.aspx">c4fnews</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/hardware/default.aspx">hardware</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/Windows+7/default.aspx">Windows 7</category></item><item><title>Coding4Fun at PDC 2009 – Video Montage</title><link>http://blogs.msdn.com/coding4fun/archive/2009/12/04/9931631.aspx</link><pubDate>Fri, 04 Dec 2009 18:25:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9931631</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/9931631.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=9931631</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=9931631</wfw:comment><description>&lt;p&gt;We’ll be posting one project each month but here is the Coding4Fun booth at PDC 2009!&amp;#160; You can even view the Iron Bartender challenge at GeekFest as well!&lt;/p&gt;  &lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/Clint/Coding4Fun-at-PDC-2009/"&gt;Overall Recap of each project&lt;/a&gt;     &lt;br /&gt;&lt;object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="512" height="384"&gt; &lt;param name="source" value="http://channel9.msdn.com/App_Themes/default/vp09_11_30.xap" /&gt; &lt;param name="initParams" value="deferredLoad=true,duration=0,m=http://ecn.channel9.msdn.com/o9/ch9/4/4/0/8/0/5/coding4funAtPdc_ch9.wmv,autostart=false,autohide=true,showembed=true, postid=508044, thumbnail=http://ecn.channel9.msdn.com/o9/ch9/4/4/0/8/0/5/coding4funAtPdc_512_ch9.png" /&gt; &lt;param name="background" value="#00FFFFFF" /&gt; &lt;a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;"&gt; &lt;img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none" /&gt; &lt;/a&gt; &lt;/object&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/LauraFoy/Coding4Fun-DrinkTendr/"&gt;Iron Bartender!&lt;/a&gt;     &lt;br /&gt;&lt;object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="512" height="384"&gt; &lt;param name="source" value="http://channel9.msdn.com/App_Themes/default/vp09_11_30.xap" /&gt; &lt;param name="initParams" value="deferredLoad=true,duration=0,m=http://ecn.channel9.msdn.com/o9/ch9/9/4/1/0/1/5/DrinkTendr_ch9.wmv,autostart=false,autohide=true,showembed=true, postid=510149, thumbnail=http://ecn.channel9.msdn.com/o9/ch9/9/4/1/0/1/5/DrinkTendr_512_ch9.png
" /&gt; &lt;param name="background" value="#00FFFFFF" /&gt; &lt;a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;"&gt; &lt;img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none" /&gt; &lt;/a&gt; &lt;/object&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9931631" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/coding4fun/archive/tags/c4fnews/default.aspx">c4fnews</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/hardware/default.aspx">hardware</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/hardwarehacks/default.aspx">hardwarehacks</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/XNA/default.aspx">XNA</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/wiimote/default.aspx">wiimote</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/WPF/default.aspx">WPF</category></item><item><title>Coding4Fun at PDC!</title><link>http://blogs.msdn.com/coding4fun/archive/2009/11/17/9923716.aspx</link><pubDate>Tue, 17 Nov 2009 18:09:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9923716</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/9923716.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=9923716</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=9923716</wfw:comment><description>&lt;p&gt;Coding4Fun is in attendance at the Microsoft Professional Developer Conference!&amp;#160; We are demoing 5 projects that will have full how-to’s and will be open-sourced as well.&amp;#160; Drinktendr, Mind Blaster, Laser Graffiti, Augmented Reality, and Wi-Fi Warthogs are powered by .Net, XNA, WPF, Ling2Sql, WiiMote, MSMQ, Power Wheels, a Mind Set and a giant freaking laser!&lt;/p&gt;  &lt;h3&gt;Drinktendr&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/Coding4FunatPDC_8947/IMG_4372.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="IMG_4372" border="0" alt="IMG_4372" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/Coding4FunatPDC_8947/IMG_4372_thumb.jpg" width="240" height="160" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Ever get tired of pouring your own drink?&amp;#160; Have someone get upset at you since it was too strong or too weak?&amp;#160; Well, why not have a machine pour you the perfect beverage every time!&amp;#160; Drinktendr uses Linq2Sql and SQL Server to know what drinks it can make with what is on hand.&amp;#160; Combine this with WPF; the end user is given a top end experience.&lt;/p&gt;  &lt;h3&gt;Mind Blaster&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/Coding4FunatPDC_8947/IMG_4328.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="IMG_4328" border="0" alt="IMG_4328" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/Coding4FunatPDC_8947/IMG_4328_thumb.jpg" width="240" height="160" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;With aliens threatening to invade Earth, it’s your job to travel into outer space and destroy the alien threat…with your mind!&amp;#160; Wearing a brainwave detecting headset, coupled with head tracking hardware using a wiimote, use only your brain to destroy alien ships before they destroy you and the rest of humanity.&lt;/p&gt;  &lt;h3&gt;Laser Graffiti&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/Coding4FunatPDC_8947/IMG_4323.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="IMG_4323" border="0" alt="IMG_4323" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/Coding4FunatPDC_8947/IMG_4323_thumb.jpg" width="240" height="160" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Putting graffiti on something is not a very nice thing to do but what if with a flick of a switch, it was gone.&amp;#160; With a projector, an off the shelf webcam and a laser pointer, you can do just that.&amp;#160; Aim the laser at the building and start drawing.&amp;#160; Turn off the laser and it all goes away!&amp;#160; Using WPF and XNA, we can apply a variety of effects including fire, paint, and various particles.&amp;#160; This project was influenced by the Graffiti Research Lab.&lt;/p&gt;  &lt;h3&gt;Augmented Reality&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/Coding4FunatPDC_8947/IMG_4340.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="IMG_4340" border="0" alt="IMG_4340" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/Coding4FunatPDC_8947/IMG_4340_thumb.jpg" width="240" height="160" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;We’ll be showing off two AR games.&amp;#160; ARroller and AR Domino Knockdown. ARroller is a single-player “marble game” experienced through a 3DOF-tracked video–see-through head-worn display. The player holds a tracked board on which a virtual marble must be manipulated through a maze of obstacles by tilting and moving the board. AR Domino Knockdown is a two-player first-person-shooter. Players hold 6DOF-tracked UMPCs through which they fire virtual balls at a configuration of virtual dominos on a shared table.&lt;/p&gt;  &lt;h3&gt;Wi-Fi Warthogs&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/Coding4FunatPDC_8947/IMG_4311.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="IMG_4311" border="0" alt="IMG_4311" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/Coding4FunatPDC_8947/IMG_4311_thumb.jpg" width="240" height="160" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Go big or go home.&amp;#160; After seeing Halo, we decided we had to make some remote control wart hogs to play laser tag with.&amp;#160; Using Xbox controllers, a wireless network, and Power Wheel cars, we’ve made a game of laser tag like no other.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9923716" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/coding4fun/archive/tags/c4fnews/default.aspx">c4fnews</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/hardware/default.aspx">hardware</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/XNA/default.aspx">XNA</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/wiimote/default.aspx">wiimote</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/PDC/default.aspx">PDC</category></item><item><title>Remote Controlled lunaring with Arduino</title><link>http://blogs.msdn.com/coding4fun/archive/2009/08/18/9727393.aspx</link><pubDate>Tue, 18 Aug 2009 22:01:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9727393</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/9727393.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=9727393</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=9727393</wfw:comment><description>&lt;p&gt;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; padding-top: 0px" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:56a2b4c6-feff-43d5-a5a8-49ebe34e7ee5" class="wlWriterEditableSmartContent"&gt;&lt;div id="70103c64-82b3-42f5-a873-90c4b319e9b4" style="margin: 0px; padding: 0px; display: inline;"&gt;&lt;div&gt;&lt;a href="http://www.youtube.com/watch?v=-AqTJ7hOJTk" target="_new"&gt;&lt;img src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/RemoteControlledlunaringwithArduino_C218/video9579a69d1e46.jpg" style="border-style: none" galleryimg="no" onload="var downlevelDiv = document.getElementById('70103c64-82b3-42f5-a873-90c4b319e9b4'); downlevelDiv.innerHTML = &amp;quot;&amp;lt;div&amp;gt;&amp;lt;object width=\&amp;quot;425\&amp;quot; height=\&amp;quot;355\&amp;quot;&amp;gt;&amp;lt;param name=\&amp;quot;movie\&amp;quot; value=\&amp;quot;http://www.youtube.com/v/-AqTJ7hOJTk&amp;amp;hl=en\&amp;quot;&amp;gt;&amp;lt;\/param&amp;gt;&amp;lt;embed src=\&amp;quot;http://www.youtube.com/v/-AqTJ7hOJTk&amp;amp;hl=en\&amp;quot; type=\&amp;quot;application/x-shockwave-flash\&amp;quot; width=\&amp;quot;425\&amp;quot; height=\&amp;quot;355\&amp;quot;&amp;gt;&amp;lt;\/embed&amp;gt;&amp;lt;\/object&amp;gt;&amp;lt;\/div&amp;gt;&amp;quot;;" alt=""&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Nothing puts the fun back into coding like watching your very own creations come to life in the physical world. Luckily, with the current glut of high-tech toys and electronic gadgets on the market, it’s never been easier to experience the thrill of designing your own hardware by modifying what’s already available. A great way to get into the hobby is to wander the isles of your local toy store or browse the pages of an online novelty shop and just let your imagination run wild. I try to go through the toy department with a certain child-like wonderment. I look at everything on every shelf and try to imagine what might be done to improve upon the design, to make it more interesting, or just plain more fun.&lt;/p&gt;  &lt;p&gt;In this article, we’ll take a quick look at this hobby by exploring one of my most well received projects to date. We’ll take a simple night-light that cycles through the phases of the moon based on input from an infrared remote control and modify it so that it displays the phases of the moon based off the actual calendar date instead.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;b&gt;Run it now: &lt;/b&gt;&lt;a href="http://www.imagitronics.org/download/lunarupdate.NET.zip"&gt;Download Installer&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;b&gt;Source Code:&lt;/b&gt; &lt;a href="http://rcmoon.codeplex.com"&gt;Download&lt;/a&gt;      &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;&lt;b&gt;Difficulty:&lt;/b&gt; Intermediate&lt;/li&gt;    &lt;li&gt;&lt;b&gt;Time Required:&lt;/b&gt; 8 hours&lt;/li&gt;    &lt;li&gt;&lt;b&gt;Cost:&lt;/b&gt; $90&lt;/li&gt;    &lt;li&gt;&lt;b&gt;Software Needed:&lt;/b&gt; &lt;a href="http://www.imagitronics.org/rc-moon/dsf"&gt;Arduino Development Environment&lt;/a&gt;, &lt;a href="http://www.imagitronics.org/download/moon.pde"&gt;Lunarupdate arduino sketch&lt;/a&gt;, &lt;a href="http://www.microsoft.com/express/download/"&gt;Visual Basic or Visual C# Express&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;b&gt;Hardware:&lt;/b&gt; &lt;a href="http://www.thinkgeek.com/geek-kids/7-13-years/958c/"&gt;ThinkGeek R/C Moon Phase light&lt;/a&gt; - $29.99, &lt;a href="http://www.sparkfun.com/commerce/product_info.php?products_id=99"&gt;Sparkfun DS1307 RTC module&lt;/a&gt; - $19.99, &lt;a href="http://www.sparkfun.com/commerce/product_info.php?products_id=666"&gt;Arduino Duemilanove&lt;/a&gt; - $34.95, &lt;a href="http://www.sparkfun.com/commerce/product_info.php?products_id=8647"&gt;0-100k Potentiometer&lt;/a&gt;&amp;#160; - $0.95, &lt;a href="http://www.adafruit.com/index.php?main_page=product_info&amp;amp;cPath=17_22&amp;amp;products_id=63"&gt;9V DC power adapter (optional)&lt;/a&gt; - $7.00 Required only if you plan to run the moon from mains power instead of battery. &lt;/li&gt; &lt;/ul&gt;  &lt;h2&gt;&lt;strong&gt;Gathering the materials&lt;/strong&gt;&lt;/h2&gt;  &lt;p&gt;Let’s take a moment to think about what is needed in order for our project to work.&lt;/p&gt;  &lt;p&gt;Obviously, we need some way to keep track of the current date, and preferably retain that date even when the batteries run out. We also need some means of controlling the LEDs on the device and to calculate the current lunar phase based on that date. In addition, it would be nice to have some user-friendly method by which we could update the stored date, should it start to drift over time.&lt;/p&gt;  &lt;p&gt;As it happens, everything we need to get our prototype off the ground is readily available – and for a reasonable price.&lt;/p&gt;  &lt;p&gt;Arduino: The Arduino is an open source electronics prototyping platform designed to help artists and designers rapidly prototype their ideas; it allows designers to write their programs in a highly abstracted form of the C programming language that hides a lot of the technical underpinnings of microcontroller programming. Because it is open source, the Arduino comes in many varieties. You can even build one yourself. A pre-built Arduino typically runs around $30 or less, but building one yourself can be significantly cheaper.&lt;/p&gt;  &lt;p&gt;DS1307 Real Time Clock Module: While the Arduino offers a powerful and flexible platform on which to build our project, we still need some way to keep track of the date. For this, we will use a DS1307 real time clock module. I opted to go with the offering from SparkFun Electronics, a Colorado-based company that specialies in providing drop-in solutions for hobbyists and prototypes. This DS1307 module comes pre-configured with an oscillator, coin cell battery backup, and ready to communicate with the Arduino using a standard I2C two-wire bus.&lt;/p&gt;  &lt;p&gt;I also chose to add a standard 100k potentiometer (variable resistor) in-line with the existing Light-dependent resistor (LDR) so that we can easily tweak the moon’s sensitivity to light in different environments.&lt;/p&gt;  &lt;p&gt;Finally, in order to update the DS1307 clock, I wrote a very simple C# application that simply queries the system date of your PC and passes that to the Arduino which in turn uses the I2C bus to set the date on the DS1307.&lt;/p&gt;  &lt;h2&gt;Getting Started&lt;/h2&gt;  &lt;p&gt;If you’ve ever peered into the mysterious inner workings of an electronic device, then you’ll appreciate how extremely straightforward this moon really is.&lt;/p&gt;  &lt;p&gt;The video below will give you a basic overview of the hardware that we’re using.&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:a8e6d2fd-9c29-451f-8a0c-fb2bbd7a099d" class="wlWriterEditableSmartContent"&gt;&lt;div id="a04de03b-96be-43ad-8e0e-909e11f1b479" style="margin: 0px; padding: 0px; display: inline;"&gt;&lt;div&gt;&lt;a href="http://www.youtube.com/watch?v=F0yKRRh9LF0" target="_new"&gt;&lt;img src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/RemoteControlledlunaringwithArduino_C218/video1f1d06ee829c.jpg" style="border-style: none" galleryimg="no" onload="var downlevelDiv = document.getElementById('a04de03b-96be-43ad-8e0e-909e11f1b479'); downlevelDiv.innerHTML = &amp;quot;&amp;lt;div&amp;gt;&amp;lt;object width=\&amp;quot;425\&amp;quot; height=\&amp;quot;355\&amp;quot;&amp;gt;&amp;lt;param name=\&amp;quot;movie\&amp;quot; value=\&amp;quot;http://www.youtube.com/v/F0yKRRh9LF0&amp;amp;hl=en\&amp;quot;&amp;gt;&amp;lt;\/param&amp;gt;&amp;lt;embed src=\&amp;quot;http://www.youtube.com/v/F0yKRRh9LF0&amp;amp;hl=en\&amp;quot; type=\&amp;quot;application/x-shockwave-flash\&amp;quot; width=\&amp;quot;425\&amp;quot; height=\&amp;quot;355\&amp;quot;&amp;gt;&amp;lt;\/embed&amp;gt;&amp;lt;\/object&amp;gt;&amp;lt;\/div&amp;gt;&amp;quot;;" alt=""&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Essentially, all we’ve done here is to remove the existing controller from the moon and replace it with our Arduino controller, which is in-turn connected to the DS1307 RTC.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/RemoteControlledlunaringwithArduino_C218/clip_image002_2.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="moon_schematic[1]" border="0" alt="moon_schematic[1]" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/RemoteControlledlunaringwithArduino_C218/moon_schematic%5B1%5D_271671bc-41a5-4a5a-b599-2bb4bf97a037.png" width="500" height="312" /&gt; &lt;/a&gt;&lt;/p&gt;  &lt;p&gt;If you’re unfamiliar with how to read electronic schematic diagrams, the table below explains how the parts are interconnected.   &lt;table border="1" cellspacing="0" cellpadding="0" width="447"&gt;&lt;tbody&gt;       &lt;tr&gt;         &lt;td valign="top" width="165"&gt;           &lt;p&gt;Arduino pin:&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="280"&gt;           &lt;p&gt;Connected to:&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td valign="top" width="165"&gt;           &lt;p&gt;Digital pin 3&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="280"&gt;           &lt;p&gt;Center leg of potentiometer&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td valign="top" width="165"&gt;           &lt;p&gt;Digital pins 7-12&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="280"&gt;           &lt;p&gt;LED lights (Red 7 … Purple 12)&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td valign="top" width="165"&gt;           &lt;p&gt;Analog pin 5&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="280"&gt;           &lt;p&gt;DS1307 SCL pin&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td valign="top" width="165"&gt;           &lt;p&gt;Analog pin 4&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="280"&gt;           &lt;p&gt;DS1307 SDA pin&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td valign="top" width="165"&gt;           &lt;p&gt;GND&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="280"&gt;           &lt;p&gt;GND of DS1307&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td valign="top" width="165"&gt;           &lt;p&gt;GND&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="280"&gt;           &lt;p&gt;(-) Negative battery Terminal&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td valign="top" width="165"&gt;           &lt;p&gt;GND&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="280"&gt;           &lt;p&gt;Outside leg of potentiometer&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td valign="top" width="165"&gt;           &lt;p&gt;GND&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="280"&gt;           &lt;p&gt;GND (Brown) wire from LED panel&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td valign="top" width="165"&gt;           &lt;p&gt;5V&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="280"&gt;           &lt;p&gt;One leg of LDR&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td valign="top" width="165"&gt;           &lt;p&gt;5V&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="280"&gt;           &lt;p&gt;5V of DS1307&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td valign="top" width="165"&gt;           &lt;p&gt;VIN&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="280"&gt;           &lt;p&gt;Center leg of power switch.&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;     &lt;/tbody&gt;&lt;/table&gt; &lt;/p&gt;  &lt;p&gt;Also connect:   &lt;table border="1" cellspacing="0" cellpadding="0"&gt;&lt;tbody&gt;       &lt;tr&gt;         &lt;td valign="top" width="217"&gt;           &lt;p&gt;Unused leg of LDR&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="373"&gt;           &lt;p&gt;Unused leg of potentiometer&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td valign="top" width="217"&gt;           &lt;p&gt;Outside leg of power switch&lt;/p&gt;         &lt;/td&gt;          &lt;td valign="top" width="373"&gt;           &lt;p&gt;(+) Positive battery terminal&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;     &lt;/tbody&gt;&lt;/table&gt; &lt;/p&gt;  &lt;p&gt;If it all sounds too complicated. It isn’t. Once you have the components in your hands, you can easily identify the parts listed above and put everything together by simply using the table above as a checklist.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;The Code&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;The code for interfacing the Arduino with the DS1307 module is available in the Arduino playground. The Arduino playground is a fantastic resource of community-contributed code samples that you can use in your own projects to interact with a remarkable array of hardware devices and software platforms.&lt;/p&gt;  &lt;p&gt;Once we retrieve the date from the DS1307, we can calculate the phase of the moon in our Arduino program:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;// Adapted from Stephen R. Schmitt’s Lunar phase computation program.&lt;/span&gt;
&lt;span class="rem"&gt;// Originally written for the Zeno programming language.&lt;/span&gt;
&lt;span class="rem"&gt;// http://home.att.net/~srschmitt/lunarphasecalc.html&lt;/span&gt;

&lt;span class="kwrd"&gt;byte&lt;/span&gt; getPhase(&lt;span class="kwrd"&gt;int&lt;/span&gt; Y, &lt;span class="kwrd"&gt;int&lt;/span&gt; M, &lt;span class="kwrd"&gt;int&lt;/span&gt; D) {
  &lt;span class="kwrd"&gt;double&lt;/span&gt; AG, IP;
  &lt;span class="kwrd"&gt;byte&lt;/span&gt; phase;
  &lt;span class="kwrd"&gt;long&lt;/span&gt; YY, MM, K1, K2, K3, JD;
  YY = Y - floor((12 - M) / 10);
  MM = M + 9;
  &lt;span class="kwrd"&gt;if&lt;/span&gt;(MM &amp;gt;= 12)
    MM = MM - 12;
  
  K1 = floor(365.25 * (YY + 4712));
  K2 = floor(30.6 * MM + 0.5);
  K3 = floor(floor((YY / 100) + 49) * 0.75) - 38;

  JD = K1 + K2 + D + 59;
  &lt;span class="kwrd"&gt;if&lt;/span&gt;(JD &amp;gt; 2299160)
    JD = JD -K3;
  
  IP = normalize((JD - 2451550.1) / 29.530588853);
  AG = IP*29.53;
  
  &lt;span class="kwrd"&gt;if&lt;/span&gt;(AG &amp;lt; 1.20369)
    phase = B00000000;
  &lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt;(AG &amp;lt; 3.61108)
    phase = B00000001;
  &lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt;(AG &amp;lt; 6.01846)
    phase = B00000011;
  &lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt;(AG &amp;lt; 8.42595)
    phase = B00000111;
  &lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt;(AG &amp;lt; 10.83323)
    phase = B00001111;
  &lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt;(AG &amp;lt; 13.24062)
    phase = B00011111;
  &lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt;(AG &amp;lt; 15.64800)
    phase = B00111111;
  &lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt;(AG &amp;lt; 18.05539)
    phase = B00111110;
  &lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt;(AG &amp;lt; 20.46277)
    phase = B00111100;
  &lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt;(AG &amp;lt; 22.87016)
    phase = B00111000;
  &lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt;(AG &amp;lt; 25.27754)
    phase = B00110000;
  &lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt;(AG &amp;lt; 27.68493)
    phase = B00100000;
  &lt;span class="kwrd"&gt;else&lt;/span&gt;
    phase = 0;
  
  &lt;span class="kwrd"&gt;return&lt;/span&gt; phase;    
}&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Finally, the Arduino is capable of communicating with a PC via standard serial communication thanks to the FTDI USB-to-serial controller that comes standard with many Arduino boards.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C#:&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;// Use a button Click event to send data to the Arduino.&lt;/span&gt;
&lt;span class="rem"&gt;// The following example is intended to be a very basic example&lt;/span&gt;
&lt;span class="rem"&gt;// of writing the date to the serial port. A more robust application&lt;/span&gt;
&lt;span class="rem"&gt;// would use a protocol and CRC to ensure that the data being transmitted&lt;/span&gt;
&lt;span class="rem"&gt;// was valid.&lt;/span&gt;
&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; updateButton_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)
{
    &lt;span class="kwrd"&gt;byte&lt;/span&gt;[] result = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;byte&lt;/span&gt;[7];

    DateTime currTime = DateTime.Now;

    serialPort.PortName = “COM4”;
    serialPort.BaudRate = 19200;
    serialPort.DataBits = 8;
    serialPort.Parity = Parity.None;
    serialPort.StopBits = StopBits.One;

    &lt;span class="kwrd"&gt;try&lt;/span&gt;
    {
        serialPort.Open();
    }
    &lt;span class="kwrd"&gt;catch&lt;/span&gt; (IOException ioe)
    {
         &lt;span class="rem"&gt;// Handle your exceptions.&lt;/span&gt;
    }

    &lt;span class="rem"&gt;// Some Arduino models reboot automatically when the serial&lt;/span&gt;
    &lt;span class="rem"&gt;// port is open. Allow a small delay to account for this.&lt;/span&gt;
    Thread.Sleep(10000);

    result[0] = BitConverter.GetBytes(currTime.Second)[0];
    result[1] = BitConverter.GetBytes(currTime.Minute)[0];
    result[2] = BitConverter.GetBytes(currTime.Hour)[0];
    result[3] = BitConverter.GetBytes(1)[0];
    result[4] = BitConverter.GetBytes(currTime.Day)[0];
    result[5] = BitConverter.GetBytes(currTime.Month)[0];
    result[6] = BitConverter.GetBytes((currTime.Year % 2000))[0];
    
    &lt;span class="kwrd"&gt;try&lt;/span&gt;
    {
         serialPort.Write(result, 0, result.Length);
         serialPort.Close();
    }
    &lt;span class="kwrd"&gt;catch&lt;/span&gt; (InvalidOperationException ioe)
    {
         &lt;span class="rem"&gt;// Handle more exceptions.&lt;/span&gt;
    }
    &lt;span class="kwrd"&gt;catch&lt;/span&gt; (TimeoutException te)
    {
         &lt;span class="rem"&gt;// Handle more exceptions.&lt;/span&gt;
    }
}&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;Arduino&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;All that’s left is for the Arduino to read and process the data. Using our extremely simple example above, let’s take a look at some Arduino code.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;void&lt;/span&gt; loop() {
  &lt;span class="kwrd"&gt;while&lt;/span&gt;(Serial.available()) {
    reader = Serial.read();
    &lt;span class="kwrd"&gt;if&lt;/span&gt;(reader == 255) {
      &lt;span class="rem"&gt;// do nothing - dummy byte&lt;/span&gt;
    }
    &lt;span class="kwrd"&gt;else&lt;/span&gt; {
        &lt;span class="rem"&gt;// populate our array with values&lt;/span&gt;
      needsUpdate = &lt;span class="kwrd"&gt;true&lt;/span&gt;;
      update[addr] = reader;
      addr += 1;
    }
  }
  
    &lt;span class="rem"&gt;// Once we have all the values, update the clock.&lt;/span&gt;
  &lt;span class="kwrd"&gt;if&lt;/span&gt;((needsUpdate) &amp;amp;&amp;amp; (addr == 7)) { 
    setDateDs1307(update[0],
          update[1],
          update[2],
          update[3],
          update[4],
          update[5],
          update[6]);
      &lt;span class="rem"&gt;// Store the last two digits of the year in EEPROM.&lt;/span&gt;
    EEPROM.write(0, update[6]);
  }
  delay(100);
  needsUpdate = &lt;span class="kwrd"&gt;false&lt;/span&gt;;
  addr = 0;
}&lt;/pre&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;That’s really all there is to it. Feel free to check out the complete code samples at imagitronics.org, or strike out on your own. Take part in the true spirit of the hobby by extending or modifying the moon to meet your own ends: implement a communication protocol, create a more robust desktop application, find ways to make the device cheaper using a USB HID controller and allowing the moon to run from USB power. &lt;/p&gt;

&lt;p&gt;My intent in writing this article was to get people excited about the prospect hardware design and prototyping and to remove any preconceived notions about the difficulty of such projects.&lt;/p&gt;

&lt;p&gt;Most importantly, just remember my motto: Dream it, build it, break it, repeat.&lt;/p&gt;

&lt;h4&gt;Special Thanks&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;John Vaughters’s &lt;a href="http://combustory.com/wiki/index.php/RTC1307_-_Real_Time_Clock"&gt;DS1307 RTC functions&lt;/a&gt;&lt;/li&gt;

  &lt;li&gt;SparkFun Electronics’ &lt;a href="http://www.opencircuits.com/SFE_Footprint_Library_Eagle"&gt;EAGLE CAD library&lt;/a&gt;&lt;/li&gt;

  &lt;li&gt;Rob Faludi’s &lt;a href="http://www.faludi.com/2008/10/07/arduino-avr-library-for-eagle-layout-editor/"&gt;Arduino EAGLE CAD library&lt;/a&gt;&lt;/li&gt;

  &lt;li&gt;Stephen Schmitt’s Zeno programming language &lt;a href="http://home.att.net/~srschmitt/lunarphasecalc.html"&gt;lunar phase sample&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;About the author&lt;/h2&gt;

&lt;p&gt;Tim Farley is an Iraq war veteran, Systems Integrator for the Department of Defense (DoD), military spouse, and sole maintainer of &lt;a href="http://www.imagitronics.org"&gt;imagitronics.org&lt;/a&gt;; a site devoted to his personal projects and hobbies. Although he has been working in and around government agencies for over 12 years, he hopes to someday break into world of toy/game research and design.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9727393" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/coding4fun/archive/tags/hardware/default.aspx">hardware</category></item><item><title>GPS tools</title><link>http://blogs.msdn.com/coding4fun/archive/2009/08/11/9864795.aspx</link><pubDate>Tue, 11 Aug 2009 22:01:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9864795</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/9864795.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=9864795</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=9864795</wfw:comment><description>&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/GPStools_C54C/ToolboxBig%5B1%5D_2.png" mce_href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/GPStools_C54C/ToolboxBig%5B1%5D_2.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; MARGIN-LEFT: 0px; BORDER-LEFT-WIDTH: 0px; MARGIN-RIGHT: 0px" title=ToolboxBig[1] border=0 alt=ToolboxBig[1] align=right src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/GPStools_C54C/ToolboxBig%5B1%5D_thumb.png" width=256 height=256 mce_src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/GPStools_C54C/ToolboxBig%5B1%5D_thumb.png"&gt;&lt;/A&gt; GeoFrameworks and Jon Person released their GPS Framework for .NET on CodePlex!&amp;nbsp; The really nice thing about this framework is it works with both the full blown .NET Framework and the Compact Framework.&amp;nbsp; If you’re developing for a Windows Mobile, embedded, laptop or desktop computer, it should handle all your needs.&lt;/P&gt;
&lt;P&gt;Just a few of the features are:&lt;/P&gt;
&lt;LI&gt;Automatic detection of serial GPS devices (or devices found via a virtual serial port). &lt;/LI&gt;
&lt;LI&gt;Automatic detection of Bluetooth devices (when using the Microsoft Bluetooth stack.) &lt;/LI&gt;
&lt;LI&gt;Automatic baud rate detection. &lt;/LI&gt;
&lt;LI&gt;Automatic recovery of lost connections. &lt;/LI&gt;
&lt;LI&gt;Advanced GPS precision via Kalman filtering. &lt;/LI&gt;
&lt;LI&gt;Support for desktops and mobile devices. &lt;/LI&gt;
&lt;LI&gt;Support for real-time GPS data without relying on Microsoft's GPS API. &lt;/LI&gt;
&lt;LI&gt;Support for control and monitoring of precision. &lt;/LI&gt;
&lt;LI&gt;A set of animated gauge controls for desktops and mobile devices (Altimeter, Compass, Speedometer, SatelliteViewer, SatelliteSignalBar). 
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;Update:&lt;/STRONG&gt; Forgot to put in the link!&amp;nbsp; &lt;A href="http://gps3.codeplex.com/"&gt;http://gps3.codeplex.com&lt;/A&gt;&lt;/P&gt;&lt;/LI&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9864795" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/coding4fun/archive/tags/c4fnews/default.aspx">c4fnews</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/hardware/default.aspx">hardware</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/windows+mobile/default.aspx">windows mobile</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/GPS/default.aspx">GPS</category></item><item><title>Building Multiplayer Texas Holdem Poker For The Zune</title><link>http://blogs.msdn.com/coding4fun/archive/2009/05/05/9582637.aspx</link><pubDate>Tue, 05 May 2009 22:06:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9582637</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/9582637.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=9582637</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=9582637</wfw:comment><description>&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/BuildingMultiplayerTexasHoldemPokerForTh_10423/clip_image002_2.gif"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="clip_image002" border="0" alt="clip_image002" align="right" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/BuildingMultiplayerTexasHoldemPokerForTh_10423/clip_image002_thumb.gif" width="240" height="320" /&gt;&lt;/a&gt;Have you ever been interested in creating a game that harnesses XNA’s powerful network library to create multiplayer experiences for the Zune device?&lt;/p&gt;  &lt;p&gt;The Zune firmware version 3.1 brought us a professionally built incarnation of Texas Holdem that supports network play. Understanding how to send and receive data with the Zune can be a little daunting at first, but once you understand the pattern, it’s easy. &lt;/p&gt;  &lt;p&gt;To build out the entire game, you probably need about a week, but you can build some simpler examples in far less time. &lt;/p&gt;  &lt;p&gt;This is an earlier project from before the release of my &lt;a href="http://www.tinyurl.com/zunebook"&gt;Zune game development book&lt;/a&gt;. Accordingly, some of the code samples you see in this article may be inconsistent with what you find in the download. The code in the article is the “correct” way to do things. The code in the download is still a work in progress.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;b&gt;Source Code:&lt;/b&gt; &lt;a href="https://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=zuneholdem&amp;amp;ReleaseId=2382"&gt;Download&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;b&gt;Difficulty &lt;/b&gt;Intermediate|Advanced &lt;/li&gt;    &lt;li&gt;&lt;b&gt;Time Required:&lt;/b&gt; 40 hours &lt;/li&gt;    &lt;li&gt;&lt;b&gt;Hardware:&lt;/b&gt; 2x &lt;a href="http://www.amazon.com/Zune-Video-MP3-Player-Black/dp/B001EWDFCI/ref=pd_bbs_sr_3?ie=UTF8&amp;amp;s=electronics&amp;amp;qid=1237183912&amp;amp;sr=8-3"&gt;Zune&lt;/a&gt; devices ($170 ea) &lt;/li&gt;    &lt;li&gt;&lt;b&gt;Software Needed:&lt;/b&gt; &lt;a href="http://www.microsoft.com/express/download/"&gt;Visual C# Express&lt;/a&gt;, &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=7d70d6ed-1edd-4852-9883-9a33c0ad8fee&amp;amp;displaylang=en"&gt;XNA Game Studio 3.0&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;The Workflow&lt;/h3&gt;  &lt;p&gt;Developing multiplayer games for the Zune is interesting because you have to deploy to each device individually. Once you have a build that works for you, it’s helpful to run-deploy (Control+F5) to one device, leave it running there, and then plug in the other Zune and debug-deploy (F5) to it. This way you have one debuggable instance of the game running. Make sure to set the appropriate Zune device as the default in the XNA Game Studio Device Center (accessible from the Tools menu).&lt;/p&gt;  &lt;h3&gt;Starting A Network Session&lt;/h3&gt;  &lt;p&gt;Because the Zunes connect over an ad-hoc, peer-to-peer connection rather than through an access point, you will have to designate one Zune as the host device. The host is usually determined to be the one that creates a new game. Therefore, all Zunes that join the host’s network session are simply peers. The difference between the host and the peers is that the host usually maintains the game state on top of executing the game as well, because the game data has to be centralized somewhere. Keep that in mind, because if one Zune is doing substantially more processing, it can lag behind and mess up your network session. Also, remember that all Zunes are running the exact same copy of the game, so the game must support both host and peer scenarios.&lt;/p&gt;  &lt;h4&gt;Create / Join / Lobby Model&lt;/h4&gt;  &lt;p&gt;Most peer-to-peer connected games allow a user to create or join a game. After doing so, the player is funneled into an area called the Lobby where they can specify their readiness. When all players are ready, the host can start the game. Some of this functionality is provided directly by the XNA Framework’s Net and GamerServices libraries. &lt;/p&gt;  &lt;p&gt;I normally create three separate screens based on the &lt;a href="http://creators.xna.com/en-US/sample/network_game_state_mgt_sample"&gt;Network Game State Management sample&lt;/a&gt; from the Creators Club website. The first is the Create screen, which looks exactly like a lobby. It starts up a network session and waits for players to join and become ready. The code to create a network session looks like this (note that I have employed some abstraction to make my code a little more cohesive):&lt;/p&gt;  &lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; CreateZuneSession(&lt;span class="kwrd"&gt;int&lt;/span&gt; maxNetworkPlayers)
{
    KillSession();

    &lt;span class="kwrd"&gt;try&lt;/span&gt;
    {
        Session = NetworkSession.Create(NetworkSessionType.SystemLink, 1,      
            maxNetworkPlayers); 
        Me = Session.LocalGamers[0];
    }
    &lt;span class="kwrd"&gt;catch&lt;/span&gt; (NetworkNotAvailableException)
    {
        &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; NetworkNotAvailableException(&lt;span class="str"&gt;&amp;quot;Zune wireless is not 
            enabled.&amp;quot;&lt;/span&gt;);
    }
    &lt;span class="kwrd"&gt;catch&lt;/span&gt; (NetworkException ne)
    {
        &lt;span class="kwrd"&gt;throw&lt;/span&gt; ne;
    }

    &lt;span class="kwrd"&gt;if&lt;/span&gt; (Session == &lt;span class="kwrd"&gt;null&lt;/span&gt;)
        &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; NetworkException(&lt;span class="str"&gt;&amp;quot;The network session could not be 
            created.&amp;quot;&lt;/span&gt;);
}&lt;/pre&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;All Zune network sessions are of the type SystemLink, much like LAN-networked Xbox consoles. The ‘1’ parameter specifies the number of local players – of course, on a Zune, there can only be one.&lt;/p&gt;

&lt;p&gt;This line of code sets the Session property to a newly created network session. The Join screen, running on another Zune, will find this session asynchronously as an available network session and attempt to join it. The first step is to enumerate available network sessions:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C# 
    &lt;br /&gt;&lt;/b&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;span class="rem"&gt;/// Asynchronous: Begins to discover network sessions.&lt;/span&gt;
&lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; BeginGetAvailableSessions()
{
    &lt;span class="rem"&gt;// Destroy any existing connections&lt;/span&gt;
    KillSession();

    NetworkSession.BeginFind(NetworkSessionType.SystemLink, 1, &lt;span class="kwrd"&gt;null&lt;/span&gt;, &lt;span class="kwrd"&gt;new&lt;/span&gt; 
        AsyncCallback(SessionsFoundCallback), &lt;span class="kwrd"&gt;null&lt;/span&gt;);
}&lt;/pre&gt;

&lt;p&gt;This code looks for SystemLink sessions and calls the callback method SessionsFoundCallback when the operation completes (successfully or unsuccessfully). If sessions are found, an event is fired. Other screens can subscribe to this event and transition to other screens or do other processing with the network session.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;span class="rem"&gt;/// Called when network sessions are found.&lt;/span&gt;
&lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;span class="rem"&gt;/// &amp;lt;param name=&amp;quot;result&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SessionsFoundCallback(IAsyncResult result)
{
    AvailableNetworkSessionCollection availableSessions = &lt;span class="kwrd"&gt;null&lt;/span&gt;;
    availableSessions = NetworkSession.EndFind(result);

    &lt;span class="kwrd"&gt;if&lt;/span&gt; (NetworkSessionsFound != &lt;span class="kwrd"&gt;null&lt;/span&gt;)
        NetworkSessionsFound(availableSessions);
}        &lt;/pre&gt;

&lt;p&gt;When all players are ready and the host presses the middle button, the network session’s StartGame() method is called, which will cause all connected peers to receive a GameStarted event. This loads up the playing screen.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;if&lt;/span&gt; (allPlayersReady &amp;amp;&amp;amp; atLeastTwoPlayers)
{
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (ScreenManager.Network.Session != &lt;span class="kwrd"&gt;null&lt;/span&gt;)
        ScreenManager.Network.Session.StartGame();
}&lt;/pre&gt;

&lt;p&gt;That’s basically how to connect up two Zunes in a network session. See my &lt;a href="http://www.tinyurl.com/zunebook"&gt;book&lt;/a&gt; for a much more detailed explanation.&lt;/p&gt;

&lt;h3&gt;Dealing With Cards&lt;/h3&gt;

&lt;p&gt;As Poker is a card game, you might want to develop a testable, standalone library that you can use not only to house your objects, but also to write out all the intense logic required for a game like poker. The task of determining what a player’s best hand is out of seven cards (and whether it beats another player’s hand) is more in-depth than you might expect. &lt;/p&gt;

&lt;p&gt;An easy way to go about this is to create a Zune game library. I called mine CardLib. CardLib has objects such as these:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Card which has a suit, a value, some comparers and some utility methods) &lt;/li&gt;

  &lt;li&gt;Deck, which has a collection of cards and methods like Shuffle, ResetDeck, etc. &lt;/li&gt;

  &lt;li&gt;Dealer, which has a deck, a list of the five community cards, and methods like Shuffle, DealCard, Burn, DealFlop, DealTurn, etc. &lt;/li&gt;

  &lt;li&gt;HoldemHand, which contains all of the logic for determining what a hand is (always 7 cards) &lt;/li&gt;

  &lt;li&gt;BestHand, which takes a HoldemHand and determines what the best possible hand is within that hand &lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Shuffling Cards&lt;/h4&gt;

&lt;p&gt;Shuffling cards is surprisingly easy. I use the &lt;a href="http://www.codinghorror.com/blog/archives/001015.html"&gt;Knuth-Fisher-Yates shuffling algorithm&lt;/a&gt;, which takes every card in the deck and randomly swaps it with another.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C# 
    &lt;br /&gt;&lt;/b&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;span class="rem"&gt;/// Knuth-Fisher-Yates shuffling algorithm:&lt;/span&gt;
&lt;span class="rem"&gt;/// http://www.codinghorror.com/blog/archives/001015.html&lt;/span&gt;
&lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Shuffle()
{
    Random rand = &lt;span class="kwrd"&gt;new&lt;/span&gt; Random();
    &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; cardIndex = _cards.Count - 1; cardIndex &amp;gt; 0; cardIndex--)
    {
        &lt;span class="kwrd"&gt;int&lt;/span&gt; randomIndex = rand.Next(cardIndex + 1);
        SwapCardsByIndex(cardIndex, randomIndex);
    }
    _dealIndex = 0;
}&lt;/pre&gt;

&lt;h4&gt;Poker Logic&lt;/h4&gt;

&lt;p&gt;An example method you’ll see in this library is this snippet to check if the hand is a royal flush:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C# 
    &lt;br /&gt;&lt;/b&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; IsRoyalFlush(&lt;span class="kwrd"&gt;out&lt;/span&gt; List&amp;lt;Card&amp;gt; winningCards)
{
    List&amp;lt;Card&amp;gt; straightFlushCards;

    &lt;span class="kwrd"&gt;if&lt;/span&gt; (IsStraightFlush(&lt;span class="kwrd"&gt;out&lt;/span&gt; straightFlushCards))
    {                
        &lt;span class="rem"&gt;// Check to make sure the straight flush cards are: 10 J Q K A&lt;/span&gt;
        straightFlushCards.Sort();

        &lt;span class="kwrd"&gt;if&lt;/span&gt; (straightFlushCards[0].Value == 10 &amp;amp;&amp;amp;
            straightFlushCards[1].Value == Card.Jack &amp;amp;&amp;amp;
            straightFlushCards[2].Value == Card.Queen &amp;amp;&amp;amp;
            straightFlushCards[3].Value == Card.King &amp;amp;&amp;amp;
            straightFlushCards[4].Value == Card.Ace)
        {
            winningCards = straightFlushCards;
            &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;true&lt;/span&gt;;
        }

        &lt;span class="kwrd"&gt;else&lt;/span&gt;
        {
            winningCards = &lt;span class="kwrd"&gt;null&lt;/span&gt;;
            &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;false&lt;/span&gt;;
        }
    }
    &lt;span class="kwrd"&gt;else&lt;/span&gt;
    {
        winningCards = &lt;span class="kwrd"&gt;null&lt;/span&gt;;
        &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;false&lt;/span&gt;;
    }
}&lt;/pre&gt;

&lt;p&gt;There is a ton of similar and even more disgusting logic to peruse in the HoldemHand.cs file in the region entitled “Poker Logic Fun Times.” This logic covers every possible poker hand and could probably be refactored to be way more elegant.&lt;/p&gt;

&lt;p&gt;When it comes time to evaluate the winner, each player’s best hand is determined and they are evaluated against each other to determine the winner. This code returns a list of WinnerInfo objects, which returns the player info and a list of the cards they won with.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; List&amp;lt;WinnerInfo&amp;gt; DetermineWinners()
{
    BestHand overallBestHand = &lt;span class="kwrd"&gt;null&lt;/span&gt;;
    HoldemPlayer winner = &lt;span class="kwrd"&gt;null&lt;/span&gt;;

    List&amp;lt;WinnerInfo&amp;gt; winners = &lt;span class="kwrd"&gt;new&lt;/span&gt; List&amp;lt;WinnerInfo&amp;gt;();

    &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (HoldemPlayer player &lt;span class="kwrd"&gt;in&lt;/span&gt; _players)
    {
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (player.Status != PlayerStatus.Folded)
        {
            HoldemHand tempHand = &lt;span class="kwrd"&gt;new&lt;/span&gt; HoldemHand(player.Pocket, _communityCards);
            BestHand bestHand = tempHand.GetBestHand();

            &lt;span class="kwrd"&gt;if&lt;/span&gt; (overallBestHand == &lt;span class="kwrd"&gt;null&lt;/span&gt;) &lt;span class="rem"&gt;// if there is no best hand yet&lt;/span&gt;
            {
                overallBestHand = bestHand;
                winner = player;
                winners.Add(&lt;span class="kwrd"&gt;new&lt;/span&gt; WinnerInfo(overallBestHand, winner, Me));
            }
            &lt;span class="kwrd"&gt;else&lt;/span&gt;
            {
                &lt;span class="rem"&gt;// if this hand beats the current best hand&lt;/span&gt;
                &lt;span class="kwrd"&gt;if&lt;/span&gt; (BestHand.Beats(bestHand, overallBestHand))
                {
                    winners.Clear();
                    overallBestHand = bestHand;
                    winner = player;
                    winners.Add(&lt;span class="kwrd"&gt;new&lt;/span&gt; WinnerInfo(overallBestHand, winner, Me));
                }
                &lt;span class="kwrd"&gt;else&lt;/span&gt;
                {
                    &lt;span class="kwrd"&gt;if&lt;/span&gt; (BestHand.IsEquivalentTo(bestHand, overallBestHand))
                    {
                        winners.Add(&lt;span class="kwrd"&gt;new&lt;/span&gt; WinnerInfo(bestHand, player, Me));
                    }
                }
            }
        }
    }

    _winners = winners;
    &lt;span class="kwrd"&gt;return&lt;/span&gt; winners;
}&lt;/pre&gt;

&lt;h4&gt;Drawing Cards On The Screen&lt;/h4&gt;

&lt;p&gt;Rather than have 52 different sprites that represent each possible card, I just made my own sheet of Zune-sized playing cards. Horizontally, they are ordered by value (1-13) and vertically they are ordered by suit (both alphabetically and corresponding to the numeric value of the Suit enumeration in the project, 1-4).&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/BuildingMultiplayerTexasHoldemPokerForTh_10423/clip_image004_2.gif"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image004" border="0" alt="clip_image004" src="http://blogs.msdn.com/blogfiles/coding4fun/WindowsLiveWriter/BuildingMultiplayerTexasHoldemPokerForTh_10423/clip_image004_thumb.gif" width="572" height="240" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When a specific card is requested to be drawn, a formula is used to calculate the source rectangle from this larger image. This is very similar to how fonts worked before spritefonts were introduced into XNA. This allows us to strip out the graphic of a specific card and draw it onscreen at some other location.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C# 
    &lt;br /&gt;&lt;/b&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; DrawCard(Card card, Vector2 position)
{
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (card != Card.Undefined &amp;amp;&amp;amp; card.Suit != Suit.Unassigned)
        ScreenManager.SpriteBatch.Draw(_texDeck, position, GetCardSourceRect(card), Color.White);
}

&lt;span class="kwrd"&gt;private&lt;/span&gt; Rectangle GetCardSourceRect(Card card)
{
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (card.Suit == Suit.Unassigned)
        &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; ArgumentException(&lt;span class="str"&gt;&amp;quot;Unassigned cards cannot be drawn.&amp;quot;&lt;/span&gt;);

    &lt;span class="kwrd"&gt;int&lt;/span&gt; cardColumn = card.Value - 1;
    &lt;span class="kwrd"&gt;int&lt;/span&gt; cardRow = (&lt;span class="kwrd"&gt;int&lt;/span&gt;)card.Suit - 1;

    &lt;span class="kwrd"&gt;int&lt;/span&gt; x = cardColumn * MainScreenElements.CARD_WIDTH;
    &lt;span class="kwrd"&gt;int&lt;/span&gt; y = cardRow * MainScreenElements.CARD_HEIGHT;

    &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; Rectangle(x, y, MainScreenElements.CARD_WIDTH, MainScreenElements.CARD_HEIGHT);
}&lt;/pre&gt;

&lt;h3&gt;Managing Network Data&lt;/h3&gt;

&lt;p&gt;One thing that increases the complexity of this game (in no small way) is the management of network data. First of all, the host’s actions are a superset of the peer’s actions (a host is also a peer, but it also has to manage the game and network state). For example, when a peer decides to bet, it has to send a message to the host saying “I would like to bet,” and then the host will process that message and relay it to the other peers. The host is also responsible for managing whose turn it is and determining who the winner is. Theoretically, you could do a lot of this with every peer acting equally but it feels safer to me to have the host responsible for important activities like dealing cards. In fact, the host has to be the only one who can deal cards, because if each client maintained its own deck, it would be randomized for every peer when the deck is shuffled. &lt;/p&gt;

&lt;h4&gt;How Data Is Sent And Received&lt;/h4&gt;

&lt;p&gt;I will usually create a static class called NetworkMessageSender that is responsible for sending various messages. I keep an enumeration of type byte that holds the possible network messages. &lt;/p&gt;

&lt;p&gt;I always send the byte indicating the message type first, so that when the peer receives a byte, it knows how to respond. For example, if the peer receives a CardDealt message, it can pop off a string and a card from the incoming packets. If the card is not intended for the peer, it can simply discard the message. &lt;/p&gt;

&lt;p&gt;Data you want to send is written to a packet writer object. When the data is ready to be sent, you call the SendData method of the LocalGamer object. Depending on how important packet receipt is, you can specify the type of transmission. I use ReliableInOrder during poker because network data is exchanged relatively infrequently. Although there is only one local network gamer, you can use a foreach loop to ensure this code will work on other platforms.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C# 
    &lt;br /&gt;&lt;/b&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SendData()
{
    &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (LocalNetworkGamer gamer &lt;span class="kwrd"&gt;in&lt;/span&gt; NetworkSessionManager.Session.LocalGamers)
        gamer.SendData(NetworkSessionManager.PacketWriter, SendDataOptions.ReliableInOrder);
}&lt;/pre&gt;

&lt;p&gt;Specific chunks of data are then sent using various static methods. Each piece of information is written sequentially. The card is serialized into a string format before being sent. The following chunk of code is used to send a card to a player.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C# 
    &lt;br /&gt;&lt;/b&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; DealCards(HoldemPlayer player)
{
    NetworkSessionManager.PacketWriter.Write((&lt;span class="kwrd"&gt;byte&lt;/span&gt;)NetworkMessageType.Deal);
    NetworkSessionManager.PacketWriter.Write(player.Name);
    NetworkSessionManager.PacketWriter.Write(player.Pocket.Card1.Serialize());
    NetworkSessionManager.PacketWriter.Write(player.Pocket.Card2.Serialize());
    SendData();
}&lt;/pre&gt;

&lt;p&gt;On the other side of that, whenever the screen updates, the game is constantly checking for new network data. The following code is part of a method that is called from the game screen’s Update loop.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C# 
    &lt;br /&gt;&lt;/b&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; UpdateNetworkSession()
{
    NetworkSessionManager.Update();

    &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (LocalNetworkGamer localGamer &lt;span class="kwrd"&gt;in&lt;/span&gt; 
        NetworkSessionManager.Session.LocalGamers)
    {
        &lt;span class="kwrd"&gt;while&lt;/span&gt; (localGamer.IsDataAvailable)
        {
            NetworkGamer sender;
            localGamer.ReceiveData(NetworkSessionManager.PacketReader, 
                &lt;span class="kwrd"&gt;out&lt;/span&gt; sender);

            &lt;span class="rem"&gt;// Interpret the first piece of information, the message.&lt;/span&gt;
            NetworkMessageType message = (NetworkMessageType)NetworkSessionManager.PacketReader.ReadByte();

            &lt;span class="rem"&gt;// Determine what to read and what to do based on this message type&lt;/span&gt;
            &lt;span class="kwrd"&gt;switch&lt;/span&gt; (message)
            {
                &lt;span class="rem"&gt;// major snippage&lt;/span&gt;
                &lt;span class="kwrd"&gt;case&lt;/span&gt; NetworkMessageType.Deal: &lt;span class="rem"&gt;// Happens when a card is dealt&lt;/span&gt;
                {
                    &lt;span class="kwrd"&gt;string&lt;/span&gt; playerName = NetworkSessionManager.PacketReader.ReadString();
                    &lt;span class="kwrd"&gt;string&lt;/span&gt; card1 = NetworkSessionManager.PacketReader.ReadString();
                    &lt;span class="kwrd"&gt;string&lt;/span&gt; card2 = NetworkSessionManager.PacketReader.ReadString();

                 _gameplayManager.Players[playerName].Pocket.Set(PlayerPocket.FIRST_CARD_INDEX, &lt;span class="kwrd"&gt;new&lt;/span&gt; 
                    Card(card1));
                 _gameplayManager.Players[playerName].Pocket.Set(PlayerPocket.SECOND_CARD_INDEX, &lt;span class="kwrd"&gt;new&lt;/span&gt; 
                    Card(card2));
                }
                &lt;span class="kwrd"&gt;break&lt;/span&gt;;
            }
        }
    }
}&lt;/pre&gt;

&lt;p&gt;There is a whole bunch of similar code that underlies how the game executes. When a message needs to be sent, the NetworkMessageSender class is used. To determine what happens when a message is received, we look at that ginormous switch statement that gets called in the screen update loop. &lt;/p&gt;

&lt;p&gt;Remember that the host is also a peer and it will receive the very same messages it sends (unless you specify otherwise). Be careful not to double-process messages if they are sent by the host. In some cases you will need to check that the current device is or is not the host. In the sample download, this is achieved just by checking a Boolean value that is set early on in the game.&lt;/p&gt;

&lt;h3&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;Building Poker for the Zune, from the ground up, is no small feat! Networked Zune games are far simpler when you have a much more limited set of possible data and messages that could be sent. For example, networked Pong, Battleship or Tetris would be pretty easy compared to poker. Turn-based games on the Zune also provide an interesting challenge in terms of what happens when a Zune drops from the network session.&lt;/p&gt;

&lt;p&gt;This is just a small dip into networked Zune game development. For a deep dive, check out my book, &lt;a href="http://www.tinyurl.com/zunebook"&gt;Zune Game Development using XNA 3.0&lt;/a&gt;, also available on &lt;a href="http://www.apress.com/book/view/9781430218616"&gt;Apress.com as an eBook&lt;/a&gt;. The final chapter is a sprawling 120 pages covering how to build Crazy Eights for the Zune from the ground up.&lt;/p&gt;

&lt;h3&gt;About The Author&lt;/h3&gt;

&lt;p&gt;Dan Waters is an Academic Developer Evangelist at Microsoft, based in Tampa, FL. When he’s not out showing the latest and greatest MS technology to students and faculty, he’s spending time with his wife and young daughter or rocking out on one of his (far too numerous) guitars. Follow Dan on &lt;a href="http://www.twitter.com/danwaters"&gt;Twitter&lt;/a&gt; or check out his &lt;a href="http://www.danwaters.com"&gt;blog&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9582637" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/coding4fun/archive/tags/puzzle/default.aspx">puzzle</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/gaming/default.aspx">gaming</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/hardware/default.aspx">hardware</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/card+and+board+games/default.aspx">card and board games</category></item><item><title>Wiimote Virtual Reality Desktop</title><link>http://blogs.msdn.com/coding4fun/archive/2009/02/11/9412433.aspx</link><pubDate>Thu, 12 Feb 2009 00:15:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9412433</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/9412433.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=9412433</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=9412433</wfw:comment><description>&lt;table border="0" cellspacing="0" cellpadding="1" width="100%"&gt;&lt;tbody&gt;     &lt;tr class="entry_overview"&gt;       &lt;td&gt;&lt;/td&gt;        &lt;td&gt;In this article I want to introduce a Virtual Reality system that can be build with two Nintendo Wii Remotes (Wiimotes) and just a little extra hardware that costs less than $10 USD.&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td colspan="2"&gt;         &lt;div class="entry_author"&gt;&amp;#160;&lt;/div&gt;          &lt;div class="entry_author"&gt;&lt;a href="http://www.vrhome.de/" target="_blank" mce_href="http://www.vrhome.de/"&gt;Timo Fleisch&lt;/a&gt;&lt;/div&gt;          &lt;div class="entry_author"&gt;&amp;#160;&lt;/div&gt;          &lt;div class="entry_details"&gt;&lt;b&gt;&lt;/b&gt;&lt;/div&gt;          &lt;div class="entry_details"&gt;&lt;b&gt;Difficulty: &lt;/b&gt;&lt;span class="entry_details_input"&gt;Expert&lt;/span&gt;&lt;/div&gt;          &lt;div class="entry_details"&gt;&lt;b&gt;Time Required:&lt;/b&gt; 3-4&lt;span class="entry_details_input"&gt; hours&lt;/span&gt;&lt;/div&gt;          &lt;div class="entry_details"&gt;&lt;b&gt;Cost: &lt;/b&gt;: $80 for two Wiimotes, ~$20 for IR-LEDs, stripboards, battery holder&lt;/div&gt;          &lt;div class="entry_details"&gt;&lt;b&gt;Software: &lt;/b&gt;&lt;a href="http://www.microsoft.com/express/vcsharp/" target="_blank" mce_href="http://www.microsoft.com/express/vcsharp/"&gt;Visual C# Express Edition 2008&lt;/a&gt;, &lt;a href="http://creators.xna.com/" target="_blank" mce_href="http://creators.xna.com"&gt;XNA Games Studio 3.0&lt;/a&gt;, &lt;a href="http://www.codeplex.com/WiimoteLib" target="_blank" mce_href="http://www.codeplex.com/WiimoteLib"&gt;Managed Library for Nintendo's Wiimote&lt;/a&gt;, &lt;a href="http://opencv.willowgarage.com/wiki/" target="_blank" mce_href="http://opencv.willowgarage.com/wiki/"&gt;OpenCV Computer Vision Library&lt;/a&gt; and &lt;a href="http://www.emgu.com/wiki/index.php/Main_Page" target="_blank" mce_href="http://www.emgu.com/wiki/index.php/Main_Page"&gt;EmguCV C# Wrapper&lt;/a&gt;&lt;/div&gt;          &lt;div class="entry_details"&gt;&lt;b&gt;Hardware: &lt;/b&gt;Two Nintendo Wii Remote (Wiimote), Anaglyph 3D Glasses (Red/Green Glasses) or Zalman 3D Monitor, compatible PC Bluetooth adapter and stack&lt;/div&gt;          &lt;div class="entry_details"&gt;&lt;b&gt;Download Binary: &lt;/b&gt;&lt;a href="http://vrhome.de/vrdesktopsetup.exe" target="_blank" mce_href="http://vrhome.de/vrdesktopsetup.exe"&gt;Download&lt;/a&gt;&lt;/div&gt;          &lt;div class="entry_details"&gt;&lt;b&gt;Download Source: &lt;/b&gt;&lt;a href="http://vrhome.de/VRDesktopSrc.zip" target="_blank" mce_href="http://vrhome.de/VRDesktopSrc.zip"&gt;Download&lt;/a&gt;&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;h4&gt;Introduction&lt;/h4&gt;  &lt;p&gt;The term Virtual Reality (VR) has been around many years by now but is still associated with very special and expensive hardware that is only available for research laboratories or big companies. Most people might think of a setup where the user wears a head-mounted-display and a data glove. Technically speaking Virtual Reality is defined by two things:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Immersion and &lt;/li&gt;    &lt;li&gt;Interactivity &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;By immersion is meant, that the user gets the impression of being inside a computer generated world. Usually VR systems use stereoscopic output devices to give the user a real 3D impression of the virtual world. But besides visual immersion, haptic and acoustic can also play an important role.&lt;/p&gt;  &lt;p&gt;3D images can for example be experienced in IMAX 3D cinemas – but this is still no Virtual Reality. What is missing is the interactivity. When the user is able to interact with the virtual world, by navigation and manipulation of the objects then the definition for VR is complete.&lt;/p&gt;  &lt;p&gt;In this article I want to introduce a Virtual Reality system that can be build with two Nintendo Wii Remotes (Wiimotes) and just a little extra hardware that costs less than 10 USD. By that VR should be affordable for everyone. The demo software and source can be downloaded from my website:    &lt;br /&gt;&lt;a href="http://www.vrhome.de" target="_blank" mce_href="http://www.vrhome.de"&gt;http://www.vrhome.de&lt;/a&gt;.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:313bfb23-8e16-4be6-94d5-db05144cffed" class="wlWriterEditableSmartContent"&gt;&lt;div id="dd7579ad-f36e-40b9-980a-d1b7bd53880e" style="margin: 0px; padding: 0px; display: inline;"&gt;&lt;div&gt;&lt;a href="http://www.youtube.com/watch?v=eLy9AWi67XU&amp;amp;hl=en&amp;amp;fs=1" target="_new"&gt;&lt;img src="http://www.coding4fun.net/images/WiimoteVirtualRealityDesktop_2FF6/video838d632e3098.jpg" style="border-style: none" galleryimg="no" onload="var downlevelDiv = document.getElementById('dd7579ad-f36e-40b9-980a-d1b7bd53880e'); downlevelDiv.innerHTML = &amp;quot;&amp;lt;div&amp;gt;&amp;lt;object width=\&amp;quot;425\&amp;quot; height=\&amp;quot;355\&amp;quot;&amp;gt;&amp;lt;param name=\&amp;quot;movie\&amp;quot; value=\&amp;quot;http://www.youtube.com/v/eLy9AWi67XU&amp;amp;hl=en&amp;amp;fs=1&amp;amp;hl=en\&amp;quot;&amp;gt;&amp;lt;\/param&amp;gt;&amp;lt;embed src=\&amp;quot;http://www.youtube.com/v/eLy9AWi67XU&amp;amp;hl=en&amp;amp;fs=1&amp;amp;hl=en\&amp;quot; type=\&amp;quot;application/x-shockwave-flash\&amp;quot; width=\&amp;quot;425\&amp;quot; height=\&amp;quot;355\&amp;quot;&amp;gt;&amp;lt;\/embed&amp;gt;&amp;lt;\/object&amp;gt;&amp;lt;\/div&amp;gt;&amp;quot;;" alt=""&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;  &lt;h4&gt;Virtual Reality Desktop&lt;/h4&gt;  &lt;p&gt;A VR Desktop setup uses a monitor as 3D output display and is sometimes referred to as fishtank Virtual Reality. I use a stereo monitor that needs a pair of polarization glasses to display stereo images. If you don't own a stereo monitor you can still construct the VR Desktop by using the anaglyph or red/green stereo method. For that you just need a pair of red/green glasses and you can use any monitor. Even though you loose color information the stereo effect is still very good.&lt;/p&gt;  &lt;p&gt;For interactivity the two Wiimotes come into play. In this setup there are two kinds of interaction possible. First we have a kind of navigation support. Navigation inside a rendered 3D scenes means the movement of the camera, as the camera represents the eyes of the user. For the Desktop setup this means we have to track the users' eyes or head position to move the 3D scene camera correctly – therefore this is also called head tracking. For the head tracking I mount one Wiimote at the top of the monitor to point at the user's face.&lt;/p&gt;  &lt;p&gt;The second Wiimote is mounted from the top in vertical down position facing the area in front of the monitor. This will be used to interact with the 3D scene by manipulating the transformation of a 3D object. As you use the hand for this interaction I call this hand tracking. The Virtual Reality Desktop setup is shown in Picture 1.&lt;/p&gt;  &lt;h4&gt;Wiimote 6DOF Tracking&lt;/h4&gt;  &lt;p&gt;The core of this VR setup is using the Nintendo Wiimote Controller as a tracking camera. As one might already know the Wiimote is equipped with an infra-red camera that is able to recognize up to four infra-red lights. The main idea now is to build a device with four infra-red LEDs that can be recognized by the Wiimote. This device I call IR-LED beacon. Using the values of the 4 LEDs as recognized by the Wiimote I use an algorithm to reconstruct the original position and orientation of the IR-LED beacon. Getting all 3 axis translations and all 3 axis rotation angles of the device is called 6 degree of freedom tracking – or short 6DOF tracking.&lt;/p&gt;  &lt;h4&gt;&lt;a title="TOC-IR-LED-Beacon1" name="TOC-IR-LED-Beacon1"&gt;&lt;/a&gt;IR-LED Beacon&lt;/h4&gt;  &lt;p&gt;&lt;a href="http://www.coding4fun.net/images/WiimoteVirtualRealityDesktop_2FF6/wiimotevrdesktop1.jpg" mce_href="http://www.coding4fun.net/images/WiimoteVirtualRealityDesktop_2FF6/wiimotevrdesktop1.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="OLYMPUS DIGITAL CAMERA         " border="0" alt="OLYMPUS DIGITAL CAMERA         " src="http://www.coding4fun.net/images/WiimoteVirtualRealityDesktop_2FF6/wiimotevrdesktop1_thumb.jpg" width="166" height="244" mce_src="http://www.coding4fun.net/images/WiimoteVirtualRealityDesktop_2FF6/wiimotevrdesktop1_thumb.jpg" /&gt;&lt;/a&gt;     &lt;br /&gt;&lt;strong&gt;Picture 1: Wiimote Desktop Virtual Reality Setup&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Because this setup uses head tracking as well as a tracking for a hand manipulation two beacon have to be built. In pictures 2 and 3 the beacons that I built for my setup are shown. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.coding4fun.net/images/WiimoteVirtualRealityDesktop_2FF6/IRbeaconheadtracker.jpg" mce_href="http://www.coding4fun.net/images/WiimoteVirtualRealityDesktop_2FF6/IRbeaconheadtracker.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="IR-beacon headtracker" border="0" alt="IR-beacon headtracker" src="http://www.coding4fun.net/images/WiimoteVirtualRealityDesktop_2FF6/IRbeaconheadtracker_thumb.jpg" width="244" height="145" mce_src="http://www.coding4fun.net/images/WiimoteVirtualRealityDesktop_2FF6/IRbeaconheadtracker_thumb.jpg" /&gt;&lt;/a&gt;     &lt;br /&gt;&lt;strong&gt;Picture 2: Head Tracking IR-LED Beacon&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.coding4fun.net/images/WiimoteVirtualRealityDesktop_2FF6/IRbeaconhandtracker.jpg" mce_href="http://www.coding4fun.net/images/WiimoteVirtualRealityDesktop_2FF6/IRbeaconhandtracker.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="OLYMPUS DIGITAL CAMERA         " border="0" alt="OLYMPUS DIGITAL CAMERA         " src="http://www.coding4fun.net/images/WiimoteVirtualRealityDesktop_2FF6/IRbeaconhandtracker_thumb.jpg" width="244" height="195" mce_src="http://www.coding4fun.net/images/WiimoteVirtualRealityDesktop_2FF6/IRbeaconhandtracker_thumb.jpg" /&gt;&lt;/a&gt;     &lt;br /&gt;&lt;strong&gt;Picture 3: Hand Tracking IR-LED Beacon&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;As can bee seen the beacons just consist of 4 IR-LEDs, a battery holder and wiring. For easy construction and less wiring I use a stripboard. When choosing the IR-LEDs it is important to look out for a very wide angle of radiation. Typical LED just have a small angle, try to find LEDs with angles greater than 120°, a good source might be digikey.com. Three of the four LEDs are aligned in a line with only slightly different height. The fourth LED is mounted above the line with more height. This special order of the lights is needed by the algorithm to be able to assign the IR-points recognized by the Wiimote to the original LEDs of the beacon. It is also important that the fourth LED has not the same height, so that the LEDs are not so planar. Please see picture 4 for a schematic layout of the beacon. For power supply I just us on AAA battery and connect all LEDs in parallel to the battery poles. For easy handling I use a battery holder which are also available at electronic components supply stores. &lt;/p&gt;  &lt;p&gt;After soldering everything together the exact positions of the LEDs have to be measured in the correct order. It is very important to measure the 3D position of the LED lights very accurately. If the data for these coordinates is not accurate the tracking results will be poor. The values have to be in millimeters. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.coding4fun.net/images/WiimoteVirtualRealityDesktop_2FF6/led.png" mce_href="http://www.coding4fun.net/images/WiimoteVirtualRealityDesktop_2FF6/led.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="led" border="0" alt="led" src="http://www.coding4fun.net/images/WiimoteVirtualRealityDesktop_2FF6/led_thumb.png" width="260" height="157" mce_src="http://www.coding4fun.net/images/WiimoteVirtualRealityDesktop_2FF6/led_thumb.png" /&gt;&lt;/a&gt;     &lt;br /&gt;&lt;strong&gt;Picture 4: Schematic of IR-LED Beacon&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;For example, my LEDs have the following measurements:&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;point3d&lt;/span&gt; &lt;span style="color: #ff0000"&gt;value&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;1, 0, 8.5&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;point3d&lt;/span&gt; &lt;span style="color: #ff0000"&gt;value&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;29, 0, 11&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;point3d&lt;/span&gt; &lt;span style="color: #ff0000"&gt;value&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;56, 0, 6&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;point3d&lt;/span&gt; &lt;span style="color: #ff0000"&gt;value&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;29, 45, 21&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p mce_keep="true"&gt;&amp;#160;&lt;/p&gt;

&lt;h4&gt;Configuring the Software&lt;/h4&gt;

&lt;p&gt;After position the Wiimotes as shown and constructing and measuring the beacons you have to configure the software using two configuration files. You will find the files in the application's directory.&lt;/p&gt;

&lt;h5&gt;Settings.xml&lt;/h5&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Settings&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Stereo&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #ff0000"&gt;eyeDistance&lt;/span&gt; = &lt;span style="color: #0000ff"&gt;&amp;quot;0.02&amp;quot;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #ff0000"&gt;switchLeftRight&lt;/span&gt; = &lt;span style="color: #0000ff"&gt;&amp;quot;False&amp;quot;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #ff0000"&gt;fieldOfView&lt;/span&gt; = &lt;span style="color: #0000ff"&gt;&amp;quot;60&amp;quot;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #ff0000"&gt;antiAlias&lt;/span&gt; = &lt;span style="color: #0000ff"&gt;&amp;quot;False&amp;quot;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #ff0000"&gt;stereoMode&lt;/span&gt; = &lt;span style="color: #0000ff"&gt;&amp;quot;lineInterlaced&amp;quot;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #ff0000"&gt;fullscreen&lt;/span&gt; = &lt;span style="color: #0000ff"&gt;&amp;quot;False&amp;quot;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #ff0000"&gt;resolution&lt;/span&gt; = &lt;span style="color: #0000ff"&gt;&amp;quot;1280,1024&amp;quot;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #ff0000"&gt;displayDevice&lt;/span&gt; = &lt;span style="color: #0000ff"&gt;&amp;quot;Screen&amp;quot;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #ff0000"&gt;anaglyph&lt;/span&gt; = &lt;span style="color: #0000ff"&gt;&amp;quot;True&amp;quot;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #ff0000"&gt;windowPosition&lt;/span&gt; = &lt;span style="color: #0000ff"&gt;&amp;quot;0,0&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Settings&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;If you own a line-interlaced 3D Monitor from Zalman, you can change the anaglyph to False. If you have difficulties adjusting your eyes to the stereo image you can try changing the value for the eyeDistance. Reducing the value makes it easier to adjust but might reduce the 3D effect. The other parameters should work as you might expect from the name.&lt;/p&gt;

&lt;h5&gt;Tracker.xml&lt;/h5&gt;

&lt;p&gt;In this file the configuration for the tracking is stored. It defines the Wiimotes and its positions and the IR-LED beacons. Furthermore it defines filtering parameters. Here I will point to the places where you need to adjust the values for your setup. &lt;/p&gt;

&lt;p&gt;First you will need to specify the exact position of your Wiimotes relative to the center of the screen. You need to measure this distance for each Wiimote in millimeter. Probably the values will be similar to the default values:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;TrackerCam&lt;/span&gt; &lt;br /&gt;    &lt;span style="color: #ff0000"&gt;id&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;2&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;cameramodel&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote&amp;quot;&lt;/span&gt; &lt;br /&gt;    &lt;span style="color: #ff0000"&gt;translation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;0,200,50&amp;quot;&lt;/span&gt; &lt;br /&gt;    &lt;span style="color: #ff0000"&gt;rotation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;0,0,0&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;scale&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;0.001&amp;quot;&lt;/span&gt; &lt;br /&gt;    &lt;span style="color: #ff0000"&gt;xAxis&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;x&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;yAxis&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;y&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;zAxis&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;z&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;TrackerCam&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;TrackerCam&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #ff0000"&gt;id&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;1&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;cameramodel&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote&amp;quot;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #ff0000"&gt;translation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;0,350,350&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;rotation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;0,0,0&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;scale&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;0.001&amp;quot;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #ff0000"&gt;xAxis&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;x&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;yAxis&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;z&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;zAxis&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;y&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;TrackerCam&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;br /&gt;&lt;/div&gt;

&lt;p mce_keep="true"&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;The Wiimote with id=2 is the one mounted at the top of the monitor to do the head tracking. In the translation field enter the distance of the front tip of the Wiimote to the center of the screen. In the default settings the Wiimote is 200mm above (y-value) and 50mm in front (z-value) of the center. Do the same for the second Wiimote in the following entry with id=1. You can see, that here the y-axis is assigned to the z-axis and the z-axis is assigned to the y-axis. This is necessary because the Wiimote is mounted in vertical position. If the software recognizes the Wiimotes in wrong order you can exchange the order of the definition blocks.&lt;/p&gt;

&lt;p&gt;The second part where you need to make changes is the definition of the IR-LED-Beacons:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;MarkerBody&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;WiiMarkerBody&lt;/span&gt; &lt;span style="color: #ff0000"&gt;id&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;0&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;WiiMote Head Beacon&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;nearClip&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;20&amp;quot;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #ff0000"&gt;farClip&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;1500&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;translation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;0,0,0&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;rotation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;0,0,0&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;point3d&lt;/span&gt; &lt;span style="color: #ff0000"&gt;value&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;0, 4, 7&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;point3d&lt;/span&gt; &lt;span style="color: #ff0000"&gt;value&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;40, 4.5, 10.5&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;point3d&lt;/span&gt; &lt;span style="color: #ff0000"&gt;value&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;83.5, 5, 7.5&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;point3d&lt;/span&gt; &lt;span style="color: #ff0000"&gt;value&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;38, 45, 18&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;WiiMarkerBody&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;WiiMarkerBody&lt;/span&gt; &lt;span style="color: #ff0000"&gt;id&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;4&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;WiiMote Hand Beacon&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;nearClip&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;20&amp;quot;&lt;/span&gt; &lt;br /&gt;        &lt;span style="color: #ff0000"&gt;farClip&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;1500&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;translation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;0,0,0&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;rotation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;0,0,0&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;point3d&lt;/span&gt; &lt;span style="color: #ff0000"&gt;value&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;1, 0, 8.5&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;point3d&lt;/span&gt; &lt;span style="color: #ff0000"&gt;value&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;29, 0, 11&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;point3d&lt;/span&gt; &lt;span style="color: #ff0000"&gt;value&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;56, 0, 6&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;point3d&lt;/span&gt; &lt;span style="color: #ff0000"&gt;value&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;29, 45, 21&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;WiiMarkerBody&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;MarkerBody&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p mce_keep="true"&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Here you need to change the values for the beacon points in millimeter according to your measurements. Please note that the correct order of the points is necessary. They have to be from LED1 to LED4 according to the schematic in Picture 4.&lt;/p&gt;

&lt;p&gt;Furthermore you will find a description for the tracked device:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;TrackedDevice&lt;/span&gt; &lt;span style="color: #ff0000"&gt;id&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;4&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;type&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;WiiMote&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;rotation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;True&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;translation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;True&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;MarkerBodyId&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;0&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;MarkerBodyId&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;TrackerCamId&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;2&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;TrackerCamId&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;ReverseTranslation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;False,True,True&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;ReverseTranslation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;ReverseRotation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;False,False,False&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;ReverseRotation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;LocalTranslation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;-45,25,0&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;LocalTranslation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;LocalRotation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;0,0,0&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;LocalRotation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;WorldTranslation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;0,0,0&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;WorldTranslation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;WorldRotation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;0,0,0 &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;WorldRotation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;RotationFilterId&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;4&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;RotationFilterId&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;TranslationFilterId&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;4&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;TranslationFilterId&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;TrackedDevice&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;Here you assign which Wiimote (TrackedCamId) to use with which IR-LED-Beacon (MarkerBodyId). The only value that you might want to adjust from these settings is the LocalTranslation. The translation and rotation values that are calculated need to have their reference point on the beacon. By default the first LED will be this reference. Usually you want to have a different reference point, like the center of the beacon. Therefore measure the distance from the first LED to your preferred reference point in the same metric as the beacon values and write it in the LocalTranslation.&lt;/p&gt;

&lt;p&gt;There are lot of more parameters you can tweak inside this configuration file, but to make the VR-Desktop run this shouldn't be necessary.&lt;/p&gt;

&lt;h4&gt;Run the Software&lt;/h4&gt;

&lt;p&gt;Before running the software it is necessary to connect the Wiimotes with the computer. For that the computer needs to be equipped with a compatible Bluetooth adapter. For more detailed description on how to do that please refer to Brian Peek's Wiimote Library article: &lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/coding4fun/archive/2007/03/14/1879033.aspx" mce_href="http://blogs.msdn.com/coding4fun/archive/2007/03/14/1879033.aspx"&gt;http://blogs.msdn.com/coding4fun/archive/2007/03/14/1879033.aspx&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After putting in your values in the configuration files and placement and connection of the two Wiimotes you can run the binary installation by clicking on the VRDesktoDemo in the start menu. If you want to run from the source code you have to copy the OpenCV dlls from &lt;i&gt;(VRDesktopSrc)&lt;/i&gt;\&lt;i&gt;ExtLibs\OpenCV\opencvlib&lt;/i&gt; to the binary destination directory of the compiled project, e.g. (&lt;i&gt;VRDesktopSrc)\VRDesktopDemo\bin\x86\Release &lt;/i&gt;before you can start the application.&lt;/p&gt;

&lt;h4&gt;Using the Library&lt;/h4&gt;

&lt;p&gt;Using the VRDesktop in your own XNA application is very easy. Here I will point out the relevant steps from the VRDesktopDemo application.&lt;/p&gt;

&lt;p&gt;To start from scratch you will have to create a new XNA Windows Game Project. First include the references to the two libraries Tgex and Tvrx. Then open the created Game class.&lt;/p&gt;

&lt;p&gt;At the top the namespaces for libraries have to be added:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; Tgex.Graphics;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; Tgex;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; Tvrx;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p mce_keep="true"&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Then the parent class has to be changed from Game to VRGame:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; VRDesktop : VRGame&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;VRGame is part of the Tgex library and adds the support for the stereo display. It creates a stereo camera and the application window according to the settings file. You can use the class more or less similar to the original game class. The main difference is, that for the drawing you must not override the Draw(GameTime time) function but the new DrawScene(GameTime time) because the Draw function of the VRGame class takes care about the stereo rendering.&lt;/p&gt;

&lt;p&gt;For storing the transformation matrix of the hand tracker we define a variable:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;Matrix modelTransform = Matrix.Identity;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;And in this simple example we define a variable for the model:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;Model model;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;In the Initialize function the initialization of the TrackerManager needs to be done:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Initialize()&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #008000"&gt;// The tracker manager is a singleton but needs to be initialized once.&lt;/span&gt;&lt;br /&gt;    TrackerManager.Instance.Initialize();&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #008000"&gt;// initialize base clase.&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;base&lt;/span&gt;.Initialize();&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;In the LoadContent function the model is loaded and the tracking is started:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; LoadContent()&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #008000"&gt;// for this demo just load the coordinate cross&lt;/span&gt;&lt;br /&gt;    model = Content.Load&amp;lt;Model&amp;gt;(&lt;span style="color: #006080"&gt;&amp;quot;coordinate&amp;quot;&lt;/span&gt;);&lt;br /&gt;    modelTransforms = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Matrix[model.Bones.Count];&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #008000"&gt;// start tracking now&lt;/span&gt;&lt;br /&gt;    TrackerManager.Instance.StartTracking();&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;The Update function is for the main game logic. First we allow the user to exit the game and the tracker to stop regularly:&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #008000"&gt;// Allows the default game to exit on Xbox 360 and Windows&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt; ((GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)&lt;br /&gt;    || (Keyboard.GetState().IsKeyDown(Keys.Escape)))&lt;br /&gt;{&lt;br /&gt;    TrackerManager.Instance.StopTracking();&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Exit();&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;Before getting the latest tracking data we have to call an update on the TrackerManager:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;TrackerManager.Instance.Update();&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;To get the transformation data we have to call the GetProxyTransform(indexNumber) from the manager. The proxies are defined in the tracking.xml file. In the example we call:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #008000"&gt;// tracking proxy with id 1 is the hand tracker&lt;/span&gt;&lt;br /&gt;modelTransform = TrackerManager.Instance.GetProxyTransform(1);&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;// tracking proxy with id 0 is the head tracker - change eye position.&lt;/span&gt;&lt;br /&gt;m_camera.EyePosition = &lt;br /&gt;    TrackerManager.Instance.GetProxyTransform(0).Translation;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;The m_camera is defined in the VRGame parent class. The camera class will also make the necessary camera transformation adjustments for screen projected head-tracking by creating a perspective of center projection matrix.&lt;/p&gt;

&lt;p&gt;Finally in the DrawScene function the model mesh is drawn. Here we need to pass the model transformation matrix as well as the camera matrices to the effect:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #008000"&gt;//Draw the model, a model can have multiple meshes, so loop&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (ModelMesh mesh &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; model.Meshes)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #008000"&gt;//This is where the mesh orientation is set, as well &lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #008000"&gt;// as our camera and projection&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (BasicEffect effect &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; mesh.Effects)&lt;br /&gt;    {&lt;br /&gt;        effect.EnableDefaultLighting();&lt;br /&gt;        effect.World = modelTransforms[mesh.ParentBone.Index]&lt;br /&gt;                       * Matrix.CreateScale(0.01f) &lt;span style="color: #008000"&gt;// coordinate scale&lt;/span&gt;&lt;br /&gt;                       * modelTransform;&lt;br /&gt;        effect.View = m_camera.ViewMatrix;&lt;br /&gt;        effect.Projection = m_camera.ProjectionMatrix;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #008000"&gt;//Draw the mesh, will use the effects set above.&lt;/span&gt;&lt;br /&gt;    mesh.Draw();&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;That’s all what has to be done to make use of the Wiimote Virtual Reality Desktop in your own application.&lt;/p&gt;

&lt;h4&gt;How does it work&lt;/h4&gt;

&lt;p&gt;For the interested reader I will explain now in more detail how the Wiimote tracking actually works. Anyhow, I will not go into the mathematical details of the core algorithm but provide you with the necessary references. I will just focus on the Wiimote tracking part and will not go into details of neither the tracking library Tvrx nor the game library Tgex.&lt;/p&gt;

&lt;h5&gt;&lt;a title="TOC-Pose-Estimation" name="TOC-Pose-Estimation"&gt;&lt;/a&gt;Pose Estimation&lt;/h5&gt;

&lt;p&gt;Technically speaking, the Wiimote tracking is an optical marker based tracking. It is optical because we use the Wiimote camera and it is marker based, because we don't use the whole camera image. Instead the Wiimote returns the position of up to four infrared LEDs which represent our markers. 
  &lt;br /&gt;The four LED positions are given in 2D coordinates which represent the markers as seen by the camera. Technically this is a 2D projection of the real LEDs according to the focus of the camera lens, this projection plane is called image plane - the 2D coordinated are therefore called image points. 

  &lt;br /&gt;The main task now is to calculate the position and rotation of the IR-LED Beacon in real space according to the image points of the LEDs measured by the Wiimote. This task is called Pose Estimation and has been investigated by scientists since many years. One main application of pose estimation is computer vision for robotics. The pose estimation algorithm used for the Wiimote tracking has already been published in 1995 and still performs nice for our purpose. If you are interested in the exact details about how the pose estimation algorithm works, you can study the original paper, please see the references. 

  &lt;br /&gt;To be able to perform the pose estimation calculation you need the exact information about the image plane. Actually, the plane is nothing else then the image sensor of the camera. The picture is focused on the image sensor by the camera lens. For the calculation of the projection we need a mathematical model for the camera, in computer vision usually a pinhole camera model is used. The pinhole is the projection point origin. The image plane is at a certain distance from the origin. This distance is called focus length. 

  &lt;br /&gt;Now, what we need for the calculation is the focal length and the size of image plane, the camera sensor. These values are also called the intrinsic camera values. Unfortunately Nintendo does not publish these values for the Wiimote, so the values I use are assumptions: 

  &lt;br /&gt;focal length in pixel = 1380&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #008000"&gt;// assume 1/4&amp;quot; cd sensor (even though it probably is not)&lt;/span&gt;&lt;br /&gt;pixel size &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; mm = 0.0035&lt;br /&gt;chip resolution = 1024x768&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;// Wiimote center (approx.)&lt;/span&gt;&lt;br /&gt;principal point = 512x384&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;The resolution of the values returned by the Wiimote are 1024x768. Obviously this is not the physical resolution because cameras with this resolution would cost more than 1000 USD. The Wiimote has a PixArt Imaging Inc. (&lt;a href="http://www.pixart.com.tw/" mce_href="http://www.pixart.com.tw/"&gt;http://www.pixart.com.tw&lt;/a&gt;) sensor and probably has a resolution of 352x288 or 164x124. However, trying to guess the real values with the help of the PixArt Sensor data sheets did not work out satisfactory so I decided to fix the pixel size and resolution on the above values and estimate the focal length. Even thought the values are not correct, they only need to be correct relative to each other to make the pose estimation work. The principal point is the actual origin of the image plane. Ideally this value should be measured, here I just assume it is the middle of the sensor chip.&lt;/p&gt;

&lt;h5&gt;Overview of the tracking algorithm&lt;/h5&gt;

&lt;p&gt;The overall tracking algorithm can be divided in the following steps:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Retrieve the image point values of the infrared LEDs from the Wiimote. &lt;/li&gt;

  &lt;li&gt;Assign the image points to the LED beacon lights. &lt;/li&gt;

  &lt;li&gt;Run the pose estimation to calculate the rotation and translation of the LED beacon. &lt;/li&gt;

  &lt;li&gt;Filter the resulting rotation and translation values. &lt;/li&gt;

  &lt;li&gt;Build a transformation matrix and transform the result according to configuration file. 
    &lt;br /&gt;(Wiimote position and orientation and local LED beacon transformation) &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the following I will describe the steps in more detail and with code examples.&lt;/p&gt;

&lt;h6&gt;Retrieve image points&lt;/h6&gt;

&lt;p&gt;The connection and data retrieval with the Wiimote is done in the WiiMoteTracker class. This class implements the interface IMarkerTracker, that defines the interface for an optical marker based tracker. The Wiimote is initialized in the Initialize() function and connected when StartTracking() is called :&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Initialize()&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #008000"&gt;// test static variable for first time call&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (m_wiimoteCount == 0)&lt;br /&gt;        m_wiimoteCollection.FindAllWiimotes();&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (m_wiimoteCollection.Count &amp;lt;= m_wiimoteCount)&lt;br /&gt;    {&lt;br /&gt;        ErrorHandler.Report(&lt;span style="color: #006080"&gt;&amp;quot;Invalid WiimoteTracker count, only &amp;quot;&lt;/span&gt;&lt;br /&gt;        + m_wiimoteCollection.Count.ToString() + &lt;span style="color: #006080"&gt;&amp;quot; Wiimotes found&amp;quot;&lt;/span&gt;);&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;return&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    wm = m_wiimoteCollection.ElementAt(m_wiimoteCount);&lt;br /&gt;    m_wiimoteId = m_wiimoteCount;&lt;br /&gt;    m_wiimoteCount++;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #008000"&gt;// setup the event to handle state changes&lt;/span&gt;&lt;br /&gt;    wm.WiimoteChanged += wm_WiimoteChanged;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #008000"&gt;// setup the event to handle insertion/removal of extensions&lt;/span&gt;&lt;br /&gt;    wm.WiimoteExtensionChanged += wm_WiimoteExtensionChanged;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #008000"&gt;// create filter for accelerator values&lt;/span&gt;&lt;br /&gt;    AverageFilterDesc filterDesc = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AverageFilterDesc();&lt;br /&gt;    filterDesc.numOfValues = 1000;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;for&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; i = 0; i &amp;lt; 3; i++)&lt;br /&gt;    {&lt;br /&gt;        m_acceleratorFilter[i] = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AverageFilter();&lt;br /&gt;        m_acceleratorFilter[i].SetFilterDesc(filterDesc);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #008000"&gt;// create filter for image points&lt;/span&gt;&lt;br /&gt;    filterDesc = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AverageFilterDesc();&lt;br /&gt;    filterDesc.numOfValues = 5;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;for&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; i = 0; i &amp;lt; 8; i++)&lt;br /&gt;    {&lt;br /&gt;        m_imagePointsFilter[i] = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AverageFilter();&lt;br /&gt;        m_imagePointsFilter[i].SetFilterDesc(filterDesc);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; StartTracking()&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (!m_isTracking)&lt;br /&gt;    {&lt;br /&gt;        m_isTracking = &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: #008000"&gt;// connect to the Wiimote&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;try&lt;/span&gt;&lt;br /&gt;        {&lt;br /&gt;            wm.Connect();&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: #008000"&gt;// set the report type to return the IR sensor and accelerometer data &lt;/span&gt;&lt;br /&gt;            &lt;span style="color: #008000"&gt;// (buttons always come back)&lt;/span&gt;&lt;br /&gt;            wm.SetReportType(InputReport.IRAccel, &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;);&lt;br /&gt;            wm.SetLEDs(m_wiimoteId);&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;catch&lt;/span&gt;&lt;br /&gt;        {&lt;br /&gt;            ErrorHandler.Report(&lt;span style="color: #006080"&gt;&amp;quot;Cannot connect to Wiimote&amp;quot;&lt;/span&gt;);&lt;br /&gt;            m_isTracking = &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;To receive the Wiimote data the &lt;i&gt;wm_WiimoteChanged &lt;/i&gt;Callback has been registered. This function is then called whenever the Wiimote has updated values. Inside this function the infrared LED values are read and the LED beacon light assignment is done.&lt;/p&gt;

&lt;p&gt;For that, first a list with with Vector2 for the image points is created:&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #008000"&gt;// put in list&lt;/span&gt;&lt;br /&gt;irList.Clear();&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;for&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; i = 0; i &amp;lt; 4; i++)&lt;br /&gt;    irList.Add(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Vector2((&lt;span style="color: #0000ff"&gt;float&lt;/span&gt;)&lt;br /&gt;           (ws.IRState.IRSensors[i].Position.X * m_resolution.X) - m_principalPoint.X,&lt;br /&gt;           (&lt;span style="color: #0000ff"&gt;float&lt;/span&gt;)(ws.IRState.IRSensors[i].Position.Y * m_resolution.Y) - m_principalPoint.Y));&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;h6&gt;Assign image points&lt;/h6&gt;

&lt;p&gt;Then the values have to be assigned to the IR-LEDs by putting them into the right order. This is done by a simple geometric pattern recognition. The idea is to have a geometric pattern that is invariant to the projection from 3D to 2D. As can be seen in picture 4, the 3 LEDs of the LED beacon are arranged in more or less a line and the 4&lt;sup&gt;th&lt;/sup&gt; LED is above of the line. In the 2D image data of the Wiimote the 3 LEDs also form more or less a line. Therefore, the first step in the assignment algorithm is to find the 3 image points which are most close to form a line.The line test is done in the following function:&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;void&lt;/span&gt; TestPoints(Vector2 lineStartPoint, Vector2 lineEndPoint,&lt;br /&gt;                Vector2 onLinePoint, Vector2 freePoint)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;float&lt;/span&gt; lambda;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;float&lt;/span&gt; dist = onLinePoint.DistanceToLine(lineStartPoint, lineEndPoint, &lt;span style="color: #0000ff"&gt;out&lt;/span&gt; lambda);&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #008000"&gt;// check if projected point is between line end and start point&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; ((lambda &amp;gt; 0) &amp;amp;&amp;amp; (lambda &amp;lt; 1))&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: #008000"&gt;// if distance is short, make this combination the result&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (dist &amp;lt; m_pointLineDist)&lt;br /&gt;        {&lt;br /&gt;            m_pointLineDist = dist;&lt;br /&gt;            m_lineStartPoint = lineStartPoint;&lt;br /&gt;            m_lineEndPoint = lineEndPoint;&lt;br /&gt;            m_onLinePoint = onLinePoint;&lt;br /&gt;            m_freePoint = freePoint;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;The function is called with the four image points as input. It assumes the first point to be the line start point and the second point to be the line end point. Then the distance of the third point to the line is calculated. This is done by using a C# 3.0 extension function of Vector2:&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;float&lt;/span&gt; DistanceToLine(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt; Vector2 point,&lt;br /&gt;                                   Vector2 startLinePoint,&lt;br /&gt;                                   Vector2 endLinePoint,&lt;br /&gt;                                   &lt;span style="color: #0000ff"&gt;out&lt;/span&gt; &lt;span style="color: #0000ff"&gt;float&lt;/span&gt; lambda)&lt;br /&gt;{&lt;br /&gt;    Vector2 rv = endLinePoint - startLinePoint;&lt;br /&gt;    Vector2 p_ap = point - startLinePoint;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;float&lt;/span&gt; dot_rv = Vector2.Dot(rv, rv);&lt;br /&gt;    lambda = Vector2.Dot(p_ap, (rv / dot_rv));&lt;br /&gt;    Vector2 distVec = point - (startLinePoint + lambda * rv);&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; distVec.Length();&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p mce_keep="true"&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;The line distance test is a typical algorithm as described on: &lt;a href="http://mathenexus.zum.de/html/geometrie/abstaende/AbstandPG.htm" mce_href="http://mathenexus.zum.de/html/geometrie/abstaende/AbstandPG.htm"&gt;http://mathenexus.zum.de/html/geometrie/abstaende/AbstandPG.htm&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It returns the distance to the line and an lambda value, which defines the position of the line projected point. If the projection point is outside the line start and line end point the lambda will be below 0 or greater than 1.&lt;/p&gt;

&lt;p&gt;If the line was valid the distance of the third point is compared to the formerly smallest distance, and if it is smaller, then this order of image points will be saved as best solution.&lt;/p&gt;

&lt;p&gt;To find the right order of the image points this function has to be called with all possible combinations of the 4 LED image points. In my code I do all the calls explicitly after initializing the minimum distance with float max value:&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;m_pointLineDist = &lt;span style="color: #0000ff"&gt;float&lt;/span&gt;.MaxValue;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;// write all test cases explicite&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;// in the end the three point line should be found&lt;/span&gt;&lt;br /&gt;TestPoints(irList[0], irList[1], irList[2], irList[3]);&lt;br /&gt;TestPoints(irList[0], irList[1], irList[3], irList[2]);&lt;br /&gt;TestPoints(irList[0], irList[2], irList[1], irList[3]);&lt;br /&gt;TestPoints(irList[0], irList[2], irList[3], irList[1]);&lt;br /&gt;TestPoints(irList[0], irList[3], irList[1], irList[2]);&lt;br /&gt;TestPoints(irList[0], irList[3], irList[2], irList[1]);&lt;br /&gt;TestPoints(irList[1], irList[2], irList[0], irList[3]);&lt;br /&gt;TestPoints(irList[1], irList[2], irList[3], irList[0]);&lt;br /&gt;TestPoints(irList[1], irList[3], irList[0], irList[2]);&lt;br /&gt;TestPoints(irList[1], irList[3], irList[2], irList[0]);&lt;br /&gt;TestPoints(irList[2], irList[3], irList[0], irList[1]);&lt;br /&gt;TestPoints(irList[2], irList[3], irList[1], irList[0]);&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;Now that we have the right order of the three points that form the line and the 4&lt;sup&gt;th&lt;/sup&gt; point, it is still necessary to determine the right direction of the line. In our LED beacon the 4&lt;sup&gt;th&lt;/sup&gt; LED is above the line. If the start and end point of the line would be interchanged then the 4&lt;sup&gt;th&lt;/sup&gt; LED would be below the line. Mathematically we check if the order of the points is clockwise or counterclockwise:&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #008000"&gt;// only remaing test is check if line start and &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;// end point is in right order&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;// check start and end line point with free point&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;// if clockwise direction then ok, if counterclockwise then exchange start &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;// and end point&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Vector2 E1 = m_lineStartPoint - m_freePoint; &lt;span style="color: #008000"&gt;// P1-P2 &lt;/span&gt;&lt;br /&gt;Vector2 E2 = m_lineEndPoint - m_freePoint; &lt;span style="color: #008000"&gt;// P3-P2 &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; clockwise;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt; ((E1.X * E2.Y - E1.Y * E2.X) &amp;gt;= 0)&lt;br /&gt;    clockwise = &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;br /&gt;    clockwise = &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (!clockwise)&lt;br /&gt;{&lt;br /&gt;    Vector2 tmp = m_lineEndPoint;&lt;br /&gt;    m_lineEndPoint = m_lineStartPoint;&lt;br /&gt;    m_lineStartPoint = tmp;&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p mce_keep="true"&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;The algorithm for the clockwise check is taken from&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.geocities.com/siliconvalley/2151/math2d.html" target="_blank" mce_href="http://www.geocities.com/siliconvalley/2151/math2d.html"&gt;http://www.geocities.com/siliconvalley/2151/math2d.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then the correctly ordered points are slightly filtered with a simple average filter over the last 5 values and multiplied with the pixel size the change from pixel metric to millimeter metric. Finally the points are passed to the pose estimation class.&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #008000"&gt;// now write resulting order to image points&lt;/span&gt;&lt;br /&gt;m_imagePoints[0].X = m_imagePointsFilter[0].Filter(m_lineStartPoint.X);&lt;br /&gt;m_imagePoints[0].Y = m_imagePointsFilter[1].Filter(m_lineStartPoint.Y);&lt;br /&gt;m_imagePoints[1].X = m_imagePointsFilter[2].Filter(m_onLinePoint.X);&lt;br /&gt;m_imagePoints[1].Y = m_imagePointsFilter[3].Filter(m_onLinePoint.Y);&lt;br /&gt;m_imagePoints[2].X = m_imagePointsFilter[4].Filter(m_lineEndPoint.X);&lt;br /&gt;m_imagePoints[2].Y = m_imagePointsFilter[5].Filter(m_lineEndPoint.Y);&lt;br /&gt;m_imagePoints[3].X = m_imagePointsFilter[6].Filter(m_freePoint.X);&lt;br /&gt;m_imagePoints[3].Y = m_imagePointsFilter[7].Filter(m_freePoint.Y);&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;for&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; i = 0; i &amp;lt; 4; i++)&lt;br /&gt;{&lt;br /&gt;    m_imagePoints[i] *= m_pixelSize;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;// send points to estimation&lt;/span&gt;&lt;br /&gt;m_poseEstimate.UpdateImagePoints(m_imagePoints);&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p mce_keep="true"&gt;&amp;#160;&lt;/p&gt;

&lt;h6&gt;Run pose estimation&lt;/h6&gt;

&lt;p&gt;The pose estimation is done by the class Posit. This class implements the IPoseEstimate interface:&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;interface&lt;/span&gt; IPoseEstimate&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; InitializeCameraParameter(&lt;span style="color: #0000ff"&gt;double&lt;/span&gt; focalLengthMM, &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; flipImage,&lt;br /&gt;                        &lt;span style="color: #0000ff"&gt;float&lt;/span&gt; scale, &lt;span style="color: #0000ff"&gt;int&lt;/span&gt;[] assignAxis, &lt;span style="color: #0000ff"&gt;int&lt;/span&gt;[] assignAxisSign);&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; InitializeMarkerBody(Vector3[] markerPoints);&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; UpdateImagePoints(Vector2[] imagePoints);&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; GetTransform(&lt;span style="color: #0000ff"&gt;out&lt;/span&gt; Vector3 position, &lt;span style="color: #0000ff"&gt;out&lt;/span&gt; Vector3 rotation);&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; StartEstimation();&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; StopEstimation();&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p mce_keep="true"&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;The pose estimation has to be initialized with the focal length of the tracking camera. The 3D positions of the real device – in our case the LEDs of the LED beacon – are passed in the InitializateMarkerBody function. The measured image points are passed with the UpdateImagePoints call and the calculated result can be taken from the GetTransform function. Because the pose estimation itself runs in an own thread asynchronously it has to be started and stopped by StartEstimation and StopEstimation. By using the interface it is easy to plug in different pose estimation algorithms.&lt;/p&gt;

&lt;p&gt;As mentioned before the pose estimation algorithm used here is the PosIt algorithm published by D. DeMenthon. I use the implementation from the OpenCV computer vision library. As this library is C code it has to wrapped to manage code. I use the freely available wrapper EmguCV. Before the pose estimation can be done a pose estimation object has to be created. This is done when the 3D positions of the markers are passed:&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; InitializeMarkerBody(Vector3[] markerPoints)&lt;br /&gt;{&lt;br /&gt;    m_numOfMarker = markerPoints.Length;&lt;br /&gt;    MCvPoint3D32f[] worldMarker = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; MCvPoint3D32f[m_numOfMarker];&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;for&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; i = 0; i &amp;lt; m_numOfMarker; i++)&lt;br /&gt;    {&lt;br /&gt;        worldMarker[i].x = markerPoints[i].X;&lt;br /&gt;        worldMarker[i].y = markerPoints[i].Y;&lt;br /&gt;        worldMarker[i].z = markerPoints[i].Z;&lt;br /&gt;    }&lt;br /&gt;    m_positObject = CvInvoke.cvCreatePOSITObject(&lt;br /&gt;    worldMarker, m_numOfMarker);&lt;br /&gt;    m_imagePoints = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; MCvPoint2D32f[m_numOfMarker];&lt;br /&gt;    m_imagePointsBuffer = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Vector2[m_numOfMarker];&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;MCvPoint32f is a managed structure for the OpenCV CvPoint32f and similar to a Vector3f. The CvInvoke class of the EmguCV wrapper is a collection of static functions to invoke the original OpenCV functions. Because the pose estimation algorithm was not included in the class I had to insert the following functions:&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;/// Create pose estimation object&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;[DllImport(CV_LIBRARY)]&lt;br /&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;extern&lt;/span&gt; IntPtr cvCreatePOSITObject(MCvPoint3D32f[] points, &lt;br /&gt;                                                &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; point_count);&lt;br /&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;/// Do pose estimation&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;[DllImport(CV_LIBRARY)]&lt;br /&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;extern&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; cvPOSIT(IntPtr posit_object, &lt;br /&gt;                                  MCvPoint2D32f[] image_points,&lt;br /&gt;                                  &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; focal_length,&lt;br /&gt;                                  MCvTermCriteria criteria,&lt;br /&gt;                                  &lt;span style="color: #0000ff"&gt;float&lt;/span&gt;[] rotation_matrix,&lt;br /&gt;                                  &lt;span style="color: #0000ff"&gt;float&lt;/span&gt;[] translation_vector);&lt;br /&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;/// Release pose esitmation object&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;[DllImport(CV_LIBRARY)]&lt;br /&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;extern&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; cvReleasePOSITObject(IntPtr posit_object);&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p mce_keep="true"&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;The returned object of the CvInvoke.cvCreatePOSITObject function call is a simple IntPtr and is used later for the pose estimation function.&lt;/p&gt;

&lt;p&gt;The pose estimation itself is done in an own thread in the PoseEstimate() function. First the new image points are fetched. If no update is available we wait for new values. This is done with the Monitor.Wait and Monitor.Pulse mechanism:&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #008000"&gt;// copy image points&lt;/span&gt;&lt;br /&gt;Monitor.Enter(m_imagePointsLock);&lt;br /&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (!m_imagePointsUpdate)&lt;br /&gt;    Monitor.Wait(m_imagePointsLock);&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;for&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; i = 0; i &amp;lt; m_numOfMarker; i++)&lt;br /&gt;{&lt;br /&gt;    m_imagePoints[i].x = m_imagePointsBuffer[i].X;&lt;br /&gt;    m_imagePoints[i].y = m_imagePointsBuffer[i].Y;&lt;br /&gt;}&lt;br /&gt;m_imagePointsUpdate = &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;br /&gt;Monitor.Exit(m_imagePointsLock);&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;After getting the new image values the cvPOSIT function is invoked:&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;MCvTermCriteria criteria;&lt;br /&gt;criteria.type = TERMCRIT.CV_TERMCRIT_EPS | TERMCRIT.CV_TERMCRIT_ITER;&lt;br /&gt;criteria.epsilon = 0.00001;&lt;br /&gt;criteria.max_iter = 500;&lt;br /&gt;CvInvoke.cvPOSIT(m_positObject,m_imagePoints, m_focalLengthMM,&lt;br /&gt;                 criteria, POSITRot, POSITTrans);&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;Because the algorithm is an iterative algorithm the MCvTermCriteria defines when the algorithm should terminate. Here I defined that it should either terminate when either 500 iteration steps have been reached or when the difference of the values from the former iteration are smaller than 0.00001. You can play around with these value to see how the tracking accuracy reacts. Besides the termination criteria you have to pass the cvPOSIT function the IntPtr to the posit object, the image points and the camera focal length in millimeter. As result you get a 9 float array for the rotation matrix and a 3 float array for the translation result.&lt;/p&gt;

&lt;p&gt;Because the rotation values should later be filtered they are translated to euler angels in the EulerAngles function. Euler angles define the rotation by giving the rotation about each coordinate axis. Before storing the final values there is some axis swapping and scaling according to the settings in the tracker.xml.&lt;/p&gt;

&lt;h6&gt;Filter the estimation results&lt;/h6&gt;

&lt;p&gt;Because the resolution of the Wiimote camera is not very hight and optical tracking always to some degree noisy the transformation results have quite strong jitters. To reduce the jittering the result values have to be filtered. As a side effect of strong filtering in tracking the virtual object seems not to follow the tracked objects movements directly and feels like swimming behind. A good compromise between jitter reduction and direct response is using Kalman filters. Kalman filters use a mathematical model to predict the change of the values and then uses the measured data to correct its prediction. A good introduction to Kalman Filters is the Siggraph 2001 Course from Greg Welch – see References. Anyhow, determine the best parameters for the filter for non-mathematicians is difficult. A good reference how to apply the filter in the tracking domain is the dissertation of Ronald Azuma “Predictive Tracking for Augmented Reality”. Please refer to that document if you want to learn the meaning of the parameters. For the Wiimote VR-Desktop the Kalman parameters are defined in the tracking.xml file:&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Kalman&lt;/span&gt; &lt;span style="color: #ff0000"&gt;class&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;KalmanFilter&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;id&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;4&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;A&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;1, 0.005, 0, 1&amp;quot;&lt;/span&gt; &lt;br /&gt;    &lt;span style="color: #ff0000"&gt;measurement_noise_cov&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;process_noise_cov_1&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;0.0000001&amp;quot;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #ff0000"&gt;process_noise_cov_2&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;0.0000001&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;The Kalman implementation used is again part of the OpenCV library. The EmguCV wrapper comes with a complete wrapper for this function. In my implementation there is an interface for data filers, the IDataFilter. The KalmanFilter class implements this interface. Beside the Kalman filter there is also a simple AvarageFilter in the library. The initialization of the Kalman filter is like this:&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; SetFilterDesc(DataFilterDesc desc)&lt;br /&gt;{&lt;br /&gt;    m_kalman = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Kalman(2, 1, 0);&lt;br /&gt;    filterDesc = (KalmanFilterDesc)desc;&lt;br /&gt;    &lt;span style="color: #008000"&gt;// set A - second parameter is frames per second&lt;/span&gt;&lt;br /&gt;    m_kalman.TransitionMatrix.Data.SetValue(filterDesc.A[0], 0, 0);&lt;br /&gt;    m_kalman.TransitionMatrix.Data.SetValue(filterDesc.A[1], 0, 1);&lt;br /&gt;    m_kalman.TransitionMatrix.Data.SetValue(filterDesc.A[2], 1, 0);&lt;br /&gt;    m_kalman.TransitionMatrix.Data.SetValue(filterDesc.A[3], 1, 1);&lt;br /&gt;    &lt;span style="color: #008000"&gt;// set H&lt;/span&gt;&lt;br /&gt;    m_kalman.MeasurementMatrix.Data.SetValue(1.0f, 0, 0);&lt;br /&gt;    m_kalman.MeasurementMatrix.Data.SetValue(0.0f, 0, 1);&lt;br /&gt;    &lt;span style="color: #008000"&gt;// set Q&lt;/span&gt;&lt;br /&gt;    CvInvoke.cvSetIdentity(m_kalman.ProcessNoiseCovariance.Ptr, &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; MCvScalar(1));&lt;br /&gt;    m_kalman.ProcessNoiseCovariance.Data.SetValue(filterDesc.process_noise_cov_1, 0, 0);&lt;br /&gt;    m_kalman.ProcessNoiseCovariance.Data.SetValue(filterDesc.process_noise_cov_2, 1, 0);&lt;br /&gt;    &lt;span style="color: #008000"&gt;// set R&lt;/span&gt;&lt;br /&gt;    CvInvoke.cvSetIdentity(m_kalman.MeasurementNoiseCovariance.Ptr, &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; MCvScalar(1e-5));&lt;br /&gt;    m_kalman.MeasurementNoiseCovariance.Data.SetValue(filterDesc.measurement_noise_cov, 0, 0);&lt;br /&gt;    CvInvoke.cvSetIdentity(m_kalman.ErrorCovariancePost.Ptr, &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;br /&gt;    MCvScalar(500));&lt;br /&gt;    m_kalman.ErrorCovariancePost.Data.SetValue(2, 0, 0);&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;After initializing a float value can be simply filter in the Filter function:&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;float&lt;/span&gt; Filter(&lt;span style="color: #0000ff"&gt;float&lt;/span&gt; inData)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #008000"&gt;// Z measurement&lt;/span&gt;&lt;br /&gt;    data.Data[0,0] = inData;&lt;br /&gt;    m_kalman.Predict(predict);&lt;br /&gt;    m_kalman.Correct(data);&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; m_kalman.CorrectedState[0, 0];&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;Because in the resulting transformation of the pose estimation there are 3 float values for the translation and 3 float values for the rotation altogether 6 separate instances of the filter are needed. In the Tvrx library the filtering is done inside the TrackedDevice class, which is a parent class for tracked devices and is derived to the TrackedWiimote:&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;virtual&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Filter() &lt;br /&gt;{&lt;br /&gt;    m_rawTranslation.X = m_translationFilter[0].Filter(m_rawTranslation.X);&lt;br /&gt;    m_rawTranslation.Y = m_translationFilter[1].Filter(m_rawTranslation.Y);&lt;br /&gt;    m_rawTranslation.Z = m_translationFilter[2].Filter(m_rawTranslation.Z);&lt;br /&gt;    m_rawRotation.X = m_rotationFilter[0].Filter(m_rawRotation.X);&lt;br /&gt;    m_rawRotation.Y = m_rotationFilter[1].Filter(m_rawRotation.Y);&lt;br /&gt;    m_rawRotation.Z = m_rotationFilter[2].Filter(m_rawRotation.Z);&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p mce_keep="true"&gt;&amp;#160;&lt;/p&gt;

&lt;h6&gt;Final transformations&lt;/h6&gt;

&lt;p&gt;Also in the TrackedDevice class the transformation of the tracking values from the camera world space coordinate system to the actual in game virtual space coordinate system takes place:&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;virtual&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; TransformToVirtualSpace() &lt;br /&gt;{&lt;br /&gt;    Matrix bodyTransformMatrix =&lt;br /&gt;    Matrix.CreateFromYawPitchRoll(m_rawRotation.Y, m_rawRotation.X, m_rawRotation.Z)&lt;br /&gt;                                  * Matrix.CreateTranslation(m_rawTranslation);&lt;br /&gt;    Matrix result = m_TrackerWorldTransform * m_DeviceWorldTransform;&lt;br /&gt;    result = bodyTransformMatrix * result;&lt;br /&gt;    result = m_DeviceLocalTransform * result;&lt;br /&gt;    Vector3 scale;&lt;br /&gt;    result.Decompose(&lt;span style="color: #0000ff"&gt;out&lt;/span&gt; scale, &lt;span style="color: #0000ff"&gt;out&lt;/span&gt; m_Rotation, &lt;span style="color: #0000ff"&gt;out&lt;/span&gt; m_Translation);&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;First a transformation matrix of the Euler angels and the translation vector is composed to the Body-Transform. From the tracking.xml configuration file we also have matrices for Tracker-World-Transform, Device-World-Transform and Device-Local-Transform. &lt;/p&gt;

&lt;p&gt;In addition to the Tracker-World-Transform translation from the tracker.xml I calculate the rotation angles of the Wiimotes using the acceleration sensors. By that it is possible to rotate the Wiimotes around the x and z axis to better focus the area you want to track and still get correct tracking results automatically.&lt;/p&gt;

&lt;p&gt;Finally, to get the correct final transformation the matrices have to be multiplied in the correct order:&lt;/p&gt;

&lt;p&gt;Device-Local-Transform * Body-Transform * Tracker-World-Transform * Device-World-Transform&lt;/p&gt;

&lt;p&gt;Now the pose estimation transformation result is ready to be read by the TrackerManager.&lt;/p&gt;

&lt;h5&gt;Conclusion and Limitation&lt;/h5&gt;

&lt;p&gt;As I have shown it is possible to create a low-cost Desktop Virtual Reality Setup using two Wiimotes and anaglyph stereo glasses. But because of the low resolution of the Wiimote camera the quality is not comparable to professional monocular tracking systems. However, the quality of the presented system could still be improved by correctly measuring the intrinsic parameters of the Wiimote camera. There are various known algorithms how to measure these parameters by a set of sample data of an object with regular known geometry. For standard cameras usually a checkerboard pattern is used. An algorithm for that purpose is also integrated in OpenCV, so applying it to the Wiimote shouldn't be to hard.&lt;/p&gt;

&lt;p&gt;Another issue with intrinsic parameters that I completely ignored so far is the lens distortion. All camera lenses do distort the image to a certain degree. By assuming a circular distortion the algorithms that measure the intrinsic parameters also calculate distortion parameters. If those parameters would be measured the Wiimote image points could be easily undistorted and the pose estimation results would be improved.&lt;/p&gt;

&lt;h5&gt;&lt;a title="TOC-References" name="TOC-References"&gt;&lt;/a&gt;References&lt;/h5&gt;

&lt;ul&gt;
  &lt;li&gt;D. DeMenthon and L.S. Davis, &amp;quot;Model-Based Object Pose in 25 Lines of Code&amp;quot;, International Journal of Computer Vision, 15, pp. 123-141, June 1995. 
    &lt;br /&gt;Paper about the used pose estimation algorithm by Daniel DeMenthon. You can find this brilliant paper on his &lt;a href="http://www.cfar.umd.edu/~daniel/Site_2/Welcome.html" mce_href="http://www.cfar.umd.edu/~daniel/Site_2/Welcome.html"&gt;homepage&lt;/a&gt;. &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://opencv.willowgarage.com/wiki/" mce_href="http://opencv.willowgarage.com/wiki/"&gt;OpenCV&lt;/a&gt;: Open Source computer vision library. Includes implementation of the pose estimation algorithm and Kalman filter. &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://www.emgu.com/wiki/index.php/Main_Page" mce_href="http://www.emgu.com/wiki/index.php/Main_Page"&gt;EmguCV&lt;/a&gt;: C# wrapper for OpenCV &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://blogs.msdn.com/coding4fun/archive/2007/03/14/1879033.aspx" mce_href="http://blogs.msdn.com/coding4fun/archive/2007/03/14/1879033.aspx"&gt;WiimoteLib&lt;/a&gt;: Managed Library for Nintendo's Wiimote by &lt;a href="http://www.brianpeek.com/" target="_blank" mce_href="http://www.brianpeek.com/"&gt;Brian Peek&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://www.codeplex.com/xnanimation" mce_href="http://www.codeplex.com/xnanimation"&gt;XNAnimation&lt;/a&gt;: Very nice library for animations in XNA. I didn't use it for the actual Wiimote tracking, but used his animation demo application in the demonstration video. &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://creators.xna.com/" mce_href="http://creators.xna.com/"&gt;XNA&lt;/a&gt;: Game development library in C# that I use as base for my applications. &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://www.cs.unc.edu/~welch/kalman/kalmanIntro.html" mce_href="http://www.cs.unc.edu/~welch/kalman/kalmanIntro.html"&gt;An Introduction to the Kalman Filter&lt;/a&gt;. Greg Welch and Gary Bishop. Siggraph 2001 Course 8. &lt;/li&gt;

  &lt;li&gt;Predictive Tracking for Augmented Reality. &lt;a href="http://www.cs.unc.edu/~azuma/" mce_href="http://www.cs.unc.edu/~azuma/"&gt;Ronald Tadao Azuma&lt;/a&gt;. Dissertation. University of North Carolina. February 1995. &lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9412433" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/coding4fun/archive/tags/hardware/default.aspx">hardware</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/hardwarehacks/default.aspx">hardwarehacks</category></item><item><title>Controlling Your Festive Lights with the .NET Micro Framework</title><link>http://blogs.msdn.com/coding4fun/archive/2008/11/27/9149635.aspx</link><pubDate>Fri, 28 Nov 2008 07:58:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9149635</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>9</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/9149635.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=9149635</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=9149635</wfw:comment><description>&lt;table class="" cellspacing="0" cellpadding="2" width="470" border="0"&gt;&lt;tbody&gt;     &lt;tr&gt;&lt;/tr&gt;      &lt;tr&gt;       &lt;td class="" valign="top" width="105"&gt;&lt;strong&gt;Author:&lt;/strong&gt;&lt;/td&gt;        &lt;td class="" valign="top" width="363"&gt;Rob Miles: &lt;a href="http://www.robmiles.com"&gt;www.robmiles.com&lt;/a&gt; &lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td class="" valign="top" width="105"&gt;&lt;strong&gt;Download:&lt;/strong&gt;&lt;/td&gt;        &lt;td class="" valign="top" width="363"&gt;&lt;a title="http://coding4fun.net/source/festivelights1.0.zip" href="http://coding4fun.net/source/festivelights1.0.zip"&gt;http://coding4fun.net/source/festivelights1.0.zip&lt;/a&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td class="" valign="top" width="105"&gt;&lt;strong&gt;Software:&lt;/strong&gt;&lt;/td&gt;        &lt;td class="" valign="top" width="363"&gt;Visual Studio 2008 Express Edition or better,          &lt;br /&gt;&lt;a href="http://www.microsoft.com/netmf/about/gettingstarted.mspx"&gt;.NET Micro Framework 3.0&lt;/a&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td class="" valign="top" width="105"&gt;&lt;strong&gt;Hardware:&lt;/strong&gt;&lt;/td&gt;        &lt;td class="" valign="top" width="363"&gt;&lt;a href="http://www.digi.com/products/embeddedsolutions/digiconnectme.jsp"&gt;Digi Connect-ME&lt;/a&gt;           &lt;br /&gt;&lt;a href="http://www.ghielectronics.com/embeddedmaster.php"&gt;GHI Electronics Embedded Master&lt;/a&gt;           &lt;br /&gt;&lt;a href="http://devicesolutions.net/Products/Tahoe.aspx"&gt;Devices Solutions Tahoe II &lt;/a&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td class="" valign="top" width="105"&gt;&lt;strong&gt;Time Required:&lt;/strong&gt;&lt;/td&gt;        &lt;td class="" valign="top" width="363"&gt;3 hours&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td class="" valign="top" width="105"&gt;&lt;strong&gt;Cost:&lt;/strong&gt;&lt;/td&gt;        &lt;td class="" valign="top" width="363"&gt;30 dollars for lights plus the .NET Micro Framework device&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;The Micro Framework is one of the newest kids on the .NET block, but it does something really rather wonderful. It brings embedded development within the reach of any C# programmer. If you know C# and love Visual Studio, you can now get started building hardware and controlling it with your software. Moreover, it lets developers achieve one of their most cherished dreams, to control their festive lights using programs that they have written. This project shows you how to do just that and adds an extra magical feature, in that you can make all your festive lights flash red whenever I, Rob Miles, make a new post on that most famous of blogs, &lt;a href="http://www.robmiles.com"&gt;www.robmiles.com&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;Actually, you can modify the code so that you can make your lights do most anything in response to an event that happens on the web. You could signal home that you are running late, send the weather forecast to your Christmas tree or explore any number of communication options. You might decide that this is so useful that you leave your decorations up all year round.&lt;/p&gt;  &lt;p&gt;If you just want to play with the .NET Micro Framework and get a feel for how easy it is to create software for tiny devices you don't actually need to use any extra hardware at all. The project comes with a complete emulation of the lights display so that you can run the whole thing on your computer and learn how hardware and software can be made to work together without burning your fingers with a soldering iron.&lt;/p&gt;  &lt;p&gt;However building the hardware will give you an understanding of how some simple electronic components can be controlled from C# and even how serial and parallel data transfer works. It is also great fun.&lt;/p&gt;  &lt;p&gt;To get started you will need some hardware and some software. Let's take each in turn.&lt;/p&gt;  &lt;h1&gt;Hardware&lt;/h1&gt;  &lt;h2&gt;Processor Hardware&lt;/h2&gt;  &lt;p&gt;The .NET Micro Framework lets you run C# programs on tiny embedded devices. There are a number of these available today, and they are getting progressively cheaper. You can base this project on any.NET Micro Framework device that has a network port and three or more output ports. The ones I'd recommend are:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Digi Connect-ME: &lt;a href="http://www.digi.com/products/embeddedsolutions/digiconnectme.jsp"&gt;http://www.digi.com/products/embeddedsolutions/digiconnectme.jsp&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;GHI Electronics Embedded Master: &lt;a href="http://www.ghielectronics.com/embeddedmaster.php"&gt;http://www.ghielectronics.com/embeddedmaster.php&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Devices Solutions Tahoe II: &lt;a href="http://devicesolutions.net/Products/Tahoe.aspx"&gt;http://devicesolutions.net/Products/Tahoe.aspx&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;I built the project for Digi Connect board but the code can be customised for any of the above platforms. The beauty of the .NET Micro Framework is that you hardly need to change your program even if the underlying hardware is completely replaced. The only thing you will have to do is adjust the code to target different output pins. I'll flag this part of the program up when we get to it.&lt;/p&gt;  &lt;p&gt;The project as supplied runs on a special emulator that runs on the PC and behaves like a .NET Micro Framework device with lights connected, so you can get started exploring the code right away.&lt;/p&gt;  &lt;h2&gt;Lights&lt;/h2&gt;  &lt;p&gt;I'm keeping things deliberately low voltage for this project. This means that kids of all ages can have a go at building the hardware without messing around with mains. The lights that I used were supplied as lines of twenty leds wired up as four strands of five leds each. All the leds in each strand were the same colour. The lights were fitted with a little battery box which held three AA batteries and a tiny controller. To get my display I simply removed the battery box and connected the strands to my hardware.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.coding4fun.net/images/8258df29ac59_13B9C/image.png"&gt;&lt;img title="image" style="display: inline" height="226" alt="image" src="http://www.coding4fun.net/images/8258df29ac59_13B9C/image_thumb.png" width="324" border="0" /&gt;&lt;/a&gt;&amp;#160; &lt;br /&gt;&lt;strong&gt;Figure 1: My Battery Powered Lights&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;You can do the same with any low power lighting kit that you wish to use. The drivers that I'm using can handle around 500 milliamps of continuous current and so you can connect a fair number of lights to each strand. &lt;/p&gt;  &lt;h2&gt;Buying the Lights&lt;/h2&gt;  &lt;p&gt;The lights I used can be bought in the UK from Lights4Fun: www.lights4fun.co.uk and are called &amp;quot;C-LED-4.5-M 20 Multi Coloured Battery Operated LED Fairy Lights&amp;quot;. They are supplied with a battery box and controller that you can remove to connect to the Darlington drivers. I used an old 5 volt mobile phone charger to power the lights. If you search eBay for &amp;quot;led christmas lights battery&amp;quot; you should find plenty of suppliers.&lt;/p&gt;  &lt;h2&gt;Driver Hardware&lt;/h2&gt;  &lt;p&gt;We can't connect a .NET Micro Framework device directly to our lights. There are two reasons for this:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;The Micro Framework device will not be able to switch the amount of current that we need to drive the lights themselves.&lt;/li&gt;    &lt;li&gt;The Micro Framework device will not have enough outputs to control all the lights that we want to use.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;This means that we need to make some hardware that goes between the processor and our lights. I actually don't see this as a problem. Making hardware is great fun, seeing something that you've built spring into life is very nice. The hardware we are going to use will provide a means by which we can control many hundreds of lights from a single Micro Framework board if we wish. It also has the ability to switch reasonable amounts of current, so you can use quite large numbers of lights if you wish. We are going to use two semiconductor components, a CD4094 Shift Register/Latch and a ULN2803 Octal Darlington Driver. A pair of these chips will allow us to control 8 outputs. If you want to control more outputs you simply get more chips and chain them together. For my version of the project I just used one of each chip, you can use as many as you like.The shift registers and Darlington amplifiers can be obtained in the UK from Maplin: &lt;a href="http://www.maplin.co.uk"&gt;www.maplin.co.uk&lt;/a&gt;. The chip numbers and part numbers as are as follows: QW54J 4094 Shift Register, QY79L ULN2803A Darlington Driver. In the US you can obtain the components and breadboard from Digi-Key: &lt;a href="http://www.digikey.com"&gt;www.digikey.com&lt;/a&gt;. &lt;/p&gt;  &lt;h2&gt;Serial and Parallel Data&lt;/h2&gt;  &lt;p&gt;You might be wondering how we can use just three output lines to control lots of lights. We are going to do this by using the three output lines to provide a &lt;i&gt;serial&lt;/i&gt; data stream which is converted by our hardware into &lt;i&gt;parallel&lt;/i&gt; data that can be used to control our lights. This is a fundamental principle of digital electronics and is how, amongst many other things, computer networks transfer data.&lt;/p&gt;  &lt;p&gt;We are going to use three signals which are called &lt;b&gt;clock&lt;/b&gt;, &lt;b&gt;data&lt;/b&gt; and &lt;b&gt;latch&lt;/b&gt;. Each of these can be set high (a voltage is present) or low (no voltage is present) by the .NET Micro Framework device under the control of our software. The signals are connected to the clock, data and latch inputs of our CD4094 shift register so that the program can talk to it.&lt;/p&gt;  &lt;p&gt;The clock line triggers the shift register to do two things:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Shift all the bits along to make room.&lt;/li&gt;    &lt;li&gt;Sample the value of the data input and store this value in the space that was created.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;To get a feel for how this works, take a look at Figure 2 below. It shows a shift register with a pattern of bits in it. The pattern is &lt;b&gt;01100001&lt;/b&gt;. Note that although this represents a number; it can also be regarded as a pattern of 0s and 1s in the shift register itself. The value 0 means 0 volts and the value 1 means some volts. These are the signals that will be used to control our lights. I'm going to call them 0 and 1 from now on. The Shift Register has Clock, Data and Latch signals connected and they are all set to 1. We can ignore the latch part of the chip for now.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.coding4fun.net/images/8258df29ac59_13B9C/image_3.png"&gt;&lt;img title="image" style="display: inline" height="251" alt="image" src="http://www.coding4fun.net/images/8258df29ac59_13B9C/image_thumb_3.png" width="500" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 2: A shift register and latch with some data in it&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;When the clock signal changes from 1 to 0 this causes the shift register to perform the two steps described above. First the data is shifted along to the right. Note that this means that there is an &amp;quot;empty&amp;quot; location at the start of the register, and that the right most bit in the register &amp;quot;falls off&amp;quot; the register and disappears. Figure 3 shows how this works.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.coding4fun.net/images/8258df29ac59_13B9C/image_4.png"&gt;&lt;img title="image" style="display: inline" height="236" alt="image" src="http://www.coding4fun.net/images/8258df29ac59_13B9C/image_thumb_4.png" width="500" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 3: Shifting along the values in the shift register&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Once the shift has finished the shift register can copy the data signal into the empty bit at the left as shown in Figure 4 below.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.coding4fun.net/images/8258df29ac59_13B9C/image_5.png"&gt;&lt;img title="image" style="display: inline" height="251" alt="image" src="http://www.coding4fun.net/images/8258df29ac59_13B9C/image_thumb_5.png" width="500" border="0" /&gt;&lt;/a&gt; &lt;strong&gt;     &lt;br /&gt;Figure 4: Storing the new data bit&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;By repeating this process 8 times a program can load a new pattern of 8 bits into the shift register. Then it is time to latch the new value to control the lights. This is the point at which the lights will appear to change. When the latch value is changed from 0 to 1 this causes the chip to copy the value in the Shift Register into the latch, as shown in Figure 5 below.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.coding4fun.net/images/8258df29ac59_13B9C/image_6.png"&gt;&lt;img title="image" style="display: inline" height="251" alt="image" src="http://www.coding4fun.net/images/8258df29ac59_13B9C/image_thumb_6.png" width="500" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 5: Copying the shift register pattern into the latch.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The latch is required so that the lights will not flicker as the new patterns are shifted into position. Each of the bits in the latch is connected to an output pin on the CD4094 which is used to switch a particular light colour on or off.&lt;/p&gt;  &lt;p&gt;We need to create some C# that will provide the appropriate sequence of signals. It turns out that using the .NET Micro Framework to achieve this is actually very easy. The &lt;b&gt;displayByte&lt;/b&gt; method below sends an 8 bit value into a shift register and then latches it into the output. If you read through the code you can see how the clock, data and latch values are all set to true (high) or false (low) to first clock the data out and then trigger the latch to display the pattern on the lights. The input is an 8 bit byte value and the program uses a mask to pick out the value of each bit in turn and set the data output accordingly.&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; displayByte(&lt;span class="kwrd"&gt;byte&lt;/span&gt; &lt;span class="kwrd"&gt;value&lt;/span&gt;)
{
    latchPort.Write(&lt;span class="kwrd"&gt;false&lt;/span&gt;);
    clockPort.Write(&lt;span class="kwrd"&gt;false&lt;/span&gt;);

    &lt;span class="kwrd"&gt;byte&lt;/span&gt; mask = 1;

    &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 0; i &amp;lt; 8; i++)
    {
        &lt;span class="kwrd"&gt;if&lt;/span&gt; ((&lt;span class="kwrd"&gt;value&lt;/span&gt; &amp;amp; mask) &amp;gt; 0)
        {
            dataPort.Write(&lt;span class="kwrd"&gt;true&lt;/span&gt;);
        }
        &lt;span class="kwrd"&gt;else&lt;/span&gt;
        {
            dataPort.Write(&lt;span class="kwrd"&gt;false&lt;/span&gt;);
        }
        clockPort.Write(&lt;span class="kwrd"&gt;true&lt;/span&gt;);
        clockPort.Write(&lt;span class="kwrd"&gt;false&lt;/span&gt;);
        mask &amp;lt;&amp;lt;= 1;
    }
    latchPort.Write(&lt;span class="kwrd"&gt;true&lt;/span&gt;);
    latchPort.Write(&lt;span class="kwrd"&gt;false&lt;/span&gt;);
}&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;The &lt;b&gt;dataPort&lt;/b&gt;, &lt;b&gt;clockPort&lt;/b&gt; and &lt;b&gt;latchPort&lt;/b&gt; variables are instances of the .NET Micro Framework class &lt;b&gt;OutputPort&lt;/b&gt;, which provides a method called &lt;b&gt;Write&lt;/b&gt; which can be used to control the state of the output signal. We will consider how these are created a little later in the article.&lt;/p&gt;

&lt;p&gt;The sample code for this project comes with a software emulator of the CD4094 which shows how it works. Figure 6 below shows that a new pattern is in the process of being shifted into the shift register, while the lights retain the previous one in the latch. The Clock and Data signals are high and the next statement will drop the Clock signal to add the next bit into the new pattern.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/8258df29ac59_13B9C/image_7.png"&gt;&lt;img title="image" style="display: inline" height="303" alt="image" src="http://www.coding4fun.net/images/8258df29ac59_13B9C/image_thumb_7.png" width="264" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Figure 6: The light emulator&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This figure also shows that I have two bits in the pattern controlling a strand of each colour. You can single step through the displayByte method above and watch it perform this output.&lt;/p&gt;

&lt;p&gt;You can use this technique every time you want to control a large number of outputs using a small number of output pins. The CD4094 has &amp;quot;daisy chain&amp;quot; inputs and outputs so that the devices can be connected in sequence. If I used two devices I could control 16 bits, with three I could control 24 and so on. This would require only minimal changes to the software.&lt;/p&gt;

&lt;h2&gt;Output Driver&lt;/h2&gt;

&lt;p&gt;The CD4094 device will produce a signal output, but it is not really powerful enough to drive things like lights. To do this we need an amplifier and the ULN2803 Octal Darlington Driver is perfect for this. It is packaged as a single chip which contains 8 pairs of transistors. Each transistor pair is wired in a &amp;quot;Darlington&amp;quot; configuration and can be used as a switch which is controlled by on output from the CD4094. When the transistors are turned on they allow current to pass through them and this will cause the lamps to light. The lights that I bought used a &amp;quot;pull down&amp;quot; arrangement to make them light up. All of the light emitting diode (LED) lamps had one end wired to a common line that was connected to the positive supply. To make the a chain of LEDs light the other end that controls that chain needed to be pulled down to the ground level. This is a common arrangement with lights like these. The ULN2803 driver has the transistors wired in an arrangement that allows it to pull signals low in this way. Figure 7 shows how this arrangement works. The resistor shown is actually wired into each LED in the set of lights that I used.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/8258df29ac59_13B9C/image_8.png"&gt;&lt;img title="image" style="display: inline" height="201" alt="image" src="http://www.coding4fun.net/images/8258df29ac59_13B9C/image_thumb_8.png" width="226" border="0" /&gt;&lt;/a&gt; 

  &lt;br /&gt;&lt;strong&gt;Figure 7: Lighting the LEDs&lt;/strong&gt;&lt;/p&gt;

&lt;h5&gt;Complete Circuit&lt;/h5&gt;

&lt;p&gt;The complete circuit shown in Figure 8 simply links each output of the CD4094 shift register to an input on the ULN2803 Darlington Driver. Note that there is no reason to link any particular bit with any other, the diagram shown is one which will translate most easily to a prototype &amp;quot;breadboard&amp;quot;.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/8258df29ac59_13B9C/image_9.png"&gt;&lt;img title="image" style="display: inline" height="260" alt="image" src="http://www.coding4fun.net/images/8258df29ac59_13B9C/image_thumb_9.png" width="500" border="0" /&gt;&lt;/a&gt; 

  &lt;br /&gt;&lt;strong&gt;Figure 8: The Complete Circuit&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The diagram just shows four lights connected to OUT1 from pin 18 of the ULN2803, the other 7 channels are connected in exactly the same way. Some of the pins can be left unconnected. Pins 9 and 10 of the CD4094 are only required if you are connecting multiple shift registers together and the common connection on pin 10 of the ULN2803 is not required. The Latch, Data and Clock signals on the CD4094 are connected to the output signals from the Micro Framework device. &lt;/p&gt;

&lt;p&gt;Figure 9 shows the completed circuit built up on a prototype breadboard. The chip on the left is the CD4094 and the one on the right is the ULN2803.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/8258df29ac59_13B9C/image_10.png"&gt;&lt;img title="image" style="display: inline" height="331" alt="image" src="http://www.coding4fun.net/images/8258df29ac59_13B9C/image_thumb_10.png" width="484" border="0" /&gt;&lt;/a&gt; &lt;strong&gt;
    &lt;br /&gt;Figure 9: The Completed Circuit&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The red wires carry the positive voltage from the power supply, which is connected to the top left of the circuit. The green wires are ground. Other coloured wires are used for signals. The Clock, Latch and Data signals are brought out to a connector which will fit a Digi-ME prototyping board.&lt;/p&gt;

&lt;h2&gt;Selecting Lights&lt;/h2&gt;

&lt;p&gt;Each bit in the value sent to the &lt;b&gt;displayByte&lt;/b&gt; method and then into the shift register will be mapped to a particular chain of lights. The mapping of these is not particularly important, since you can use program constants to represent particular values. I wired the red signals to output pins 4 and 8. To light up just the red lights I used the value 0x88 which is the appropriate bit pattern. I then set up constants for all the other colors:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;byte&lt;/span&gt; GREEN = 0x11;
&lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;byte&lt;/span&gt; BLUE = 0x22;
&lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;byte&lt;/span&gt; YELLOW = 0x44;
&lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;byte&lt;/span&gt; RED = 0x88;&lt;/pre&gt;

&lt;h2&gt;Setting Up the Hardware&lt;/h2&gt;

&lt;p&gt;The .NET Micro Framework provides a set of classes that can be used to represent the hardware in a system. The program uses instances of the &lt;b&gt;OutputPort&lt;/b&gt; class to represent the output pins. These are created in the method that sets up the hardware:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;const&lt;/span&gt; Cpu.Pin clockPin = Cpu.Pin.GPIO_Pin0;
&lt;span class="kwrd"&gt;const&lt;/span&gt; Cpu.Pin dataPin = Cpu.Pin.GPIO_Pin1;
&lt;span class="kwrd"&gt;const&lt;/span&gt; Cpu.Pin latchPin = Cpu.Pin.GPIO_Pin2;

&lt;span class="kwrd"&gt;static&lt;/span&gt; OutputPort clockPort;
&lt;span class="kwrd"&gt;static&lt;/span&gt; OutputPort dataPort;
&lt;span class="kwrd"&gt;static&lt;/span&gt; OutputPort latchPort;

&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; setupOutputs()
{
    clockPort = &lt;span class="kwrd"&gt;new&lt;/span&gt; OutputPort(clockPin, &lt;span class="kwrd"&gt;false&lt;/span&gt;);
    dataPort = &lt;span class="kwrd"&gt;new&lt;/span&gt; OutputPort(dataPin, &lt;span class="kwrd"&gt;false&lt;/span&gt;);
    latchPort = &lt;span class="kwrd"&gt;new&lt;/span&gt; OutputPort(latchPin, &lt;span class="kwrd"&gt;false&lt;/span&gt;);
}&lt;/pre&gt;

&lt;p&gt;In this version of the hardware I have connected pin 0 of the processor to the clock, pin 1 to the data and pin 2 to the latch. If you use different pins you can change the settings above.&lt;/p&gt;

&lt;h1&gt;Software&lt;/h1&gt;

&lt;p&gt;Now that we have working hardware we can consider how the software is to work. Note that this version of the program works correctly but lacks exception handlers that would make it truly robust. I've left these out to simplify the explanation. To make sense of this description you will need to have a copy of the program itself available for reference.&lt;/p&gt;

&lt;p&gt;You can develop the code using Visual Studio 2008 Express edition, which you can download from &lt;a href="http://www.microsoft.com/express/"&gt;http://www.microsoft.com/express/&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;The software is written for the .NET Micro Framework 3.0 which you can download from &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=9356ed6f-f1f0-43ef-b21a-4644dd089b4a&amp;amp;displaylang=en"&gt;http://www.microsoft.com/downloads/details.aspx?FamilyID=9356ed6f-f1f0-43ef-b21a-4644dd089b4a&amp;amp;displaylang=en&lt;/a&gt; &lt;/p&gt;

&lt;h2&gt;Reading the Blog&lt;/h2&gt;

&lt;p&gt;The program reads the RSS feed from a blog and looks for the &lt;b&gt;&amp;lt;pubDate&amp;gt;&lt;/b&gt; value. This contains the date when the feed was last updated. Whenever this date changes the lights must flash red for a few seconds before resuming a random display. Users of the full .NET Framework can use the &lt;b&gt;HTTPRequest&lt;/b&gt; class to build a &lt;b&gt;GET&lt;/b&gt; command to be sent to a server. Unfortunately the .NET Micro Framework does not support this, so we have to access the web feed using socket based communication. This part of the program is heavily based on the &lt;b&gt;SocketClient&lt;/b&gt; example supplied with the .NET Micro Framework.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;// This method requests a page from the specified server.&lt;/span&gt;
&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; String GetWebPage(String server, &lt;span class="kwrd"&gt;string&lt;/span&gt; webPage)
{
    &lt;span class="kwrd"&gt;const&lt;/span&gt; Int32 c_httpPort = 80;
    &lt;span class="kwrd"&gt;const&lt;/span&gt; Int32 c_microsecondsPerSecond = 1000000;

    &lt;span class="rem"&gt;// Create a socket connection to the specified server and port.&lt;/span&gt;
    &lt;span class="kwrd"&gt;using&lt;/span&gt; (Socket serverSocket = ConnectSocket(server, c_httpPort))
    {
        &lt;span class="rem"&gt;// Send request to the server.&lt;/span&gt;
        String request = &lt;span class="str"&gt;&amp;quot;GET &amp;quot;&lt;/span&gt;+ webPage + 
             &lt;span class="str"&gt;&amp;quot; HTTP/1.1\r\nHost: &amp;quot;&lt;/span&gt; + server + 
             &lt;span class="str"&gt;&amp;quot;\r\nConnection: Close\r\n\r\n&amp;quot;&lt;/span&gt;;
        Byte[] bytesToSend = Encoding.UTF8.GetBytes(request);
        serverSocket.Send(bytesToSend, bytesToSend.Length, 0);

        &lt;span class="rem"&gt;// Allocate a buffer to receive HTML chunks&lt;/span&gt;
        Byte[] buffer = &lt;span class="kwrd"&gt;new&lt;/span&gt; Byte[1024];

        &lt;span class="rem"&gt;// 'page' refers to the HTML data as it is built up.&lt;/span&gt;
        String page = String.Empty; 

        &lt;span class="rem"&gt;// Wait up to 30 seconds for initial data &lt;/span&gt;
        &lt;span class="rem"&gt;// Will throw exception if connection closed&lt;/span&gt;
        DateTime timeoutAt = DateTime.Now.AddSeconds(30);
        &lt;span class="kwrd"&gt;while&lt;/span&gt; (serverSocket.Available == 0 &amp;amp;&amp;amp; 
               DateTime.Now &amp;lt; timeoutAt)
        {
            System.Threading.Thread.Sleep(100);
        }

        &lt;span class="rem"&gt;// Poll for data until 30 second time out&lt;/span&gt;
        &lt;span class="rem"&gt;// Returns true for data and connection closed&lt;/span&gt;
        &lt;span class="kwrd"&gt;while&lt;/span&gt; (serverSocket.Poll(30 * c_microsecondsPerSecond,
                                 SelectMode.SelectRead))
        {
            &lt;span class="rem"&gt;// Zero all bytes in the re-usable buffer&lt;/span&gt;
            Array.Clear(buffer, 0, buffer.Length);

            &lt;span class="rem"&gt;// Read a buffer-sized HTML chunk&lt;/span&gt;
            Int32 bytesRead = serverSocket.Receive(buffer);

            &lt;span class="rem"&gt;// If 0 bytes in buffer, then connection is closed, &lt;/span&gt;
            &lt;span class="rem"&gt;// or we have timed out&lt;/span&gt;
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (bytesRead == 0)
                &lt;span class="kwrd"&gt;break&lt;/span&gt;;

            &lt;span class="rem"&gt;// Append the chunk to the string&lt;/span&gt;
            page += &lt;span class="kwrd"&gt;new&lt;/span&gt; String(Encoding.UTF8.GetChars(buffer));
        }

        &lt;span class="kwrd"&gt;return&lt;/span&gt; page;   &lt;span class="rem"&gt;// Return the complete string&lt;/span&gt;
    }
}&lt;/pre&gt;

&lt;p&gt;This method is called to fetch the journal RSS feed from my blog:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;string&lt;/span&gt; address = &lt;span class="str"&gt;&amp;quot;www.robmiles.com&amp;quot;&lt;/span&gt;;
&lt;span class="kwrd"&gt;string&lt;/span&gt; name = &lt;span class="str"&gt;&amp;quot;/journal/rss.xml&amp;quot;&lt;/span&gt;;

&lt;span class="kwrd"&gt;string&lt;/span&gt; html = GetWebPage(address, name);&lt;/pre&gt;

&lt;p&gt;You can use it to download from any RSS feed or page on the web. It will throw an exception if the page cannot be read. This version of my program does not perform exception handling however.&lt;/p&gt;

&lt;h2&gt;Getting the Published Date&lt;/h2&gt;

&lt;p&gt;The date is held in the form:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;pubDate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Wed, 05 Nov 2008 22:38:52 +0000&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;pubDate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;It would be enough just to record this content and check for changes in the text, but I decided that I might want to use the date information in a later version of the program and so I created some small helper methods to read numbers from the input string and a larger method to read the publish date itself:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; DateTime getRecentPubDate(&lt;span class="kwrd"&gt;string&lt;/span&gt; html, &lt;span class="kwrd"&gt;string&lt;/span&gt; startTag)
{
    &lt;span class="kwrd"&gt;int&lt;/span&gt; index = html.IndexOf(startTag) ;

    &lt;span class="kwrd"&gt;if&lt;/span&gt; (index &amp;lt; 0) 
        &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; Exception(&lt;span class="str"&gt;&amp;quot;Missing tag &amp;quot;&lt;/span&gt; + startTag);

    index += startTag.Length;

    &lt;span class="rem"&gt;// spin past the name of the day&lt;/span&gt;
    &lt;span class="kwrd"&gt;while&lt;/span&gt; (index &amp;lt; html.Length &amp;amp;&amp;amp; html[index] != &lt;span class="str"&gt;','&lt;/span&gt;) index++;
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (index == html.Length) 
        &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; Exception(&lt;span class="str"&gt;&amp;quot;Short publish date&amp;quot;&lt;/span&gt;);

    &lt;span class="kwrd"&gt;int&lt;/span&gt; dayValue = getInt(html, &lt;span class="kwrd"&gt;ref&lt;/span&gt; index, &lt;span class="str"&gt;' '&lt;/span&gt;);

    &lt;span class="kwrd"&gt;string&lt;/span&gt; monthName = getString(html, &lt;span class="kwrd"&gt;ref&lt;/span&gt; index, &lt;span class="str"&gt;' '&lt;/span&gt;);
    &lt;span class="kwrd"&gt;int&lt;/span&gt; monthValue = getMonth(monthName);

    &lt;span class="kwrd"&gt;int&lt;/span&gt; yearValue = getInt(html, &lt;span class="kwrd"&gt;ref&lt;/span&gt; index, &lt;span class="str"&gt;' '&lt;/span&gt;);
    &lt;span class="kwrd"&gt;int&lt;/span&gt; hourValue = getInt(html, &lt;span class="kwrd"&gt;ref&lt;/span&gt; index, &lt;span class="str"&gt;':'&lt;/span&gt;);
    &lt;span class="kwrd"&gt;int&lt;/span&gt; minuteValue = getInt(html, &lt;span class="kwrd"&gt;ref&lt;/span&gt; index, &lt;span class="str"&gt;':'&lt;/span&gt;);
    &lt;span class="kwrd"&gt;int&lt;/span&gt; secondValue = getInt(html, &lt;span class="kwrd"&gt;ref&lt;/span&gt; index, &lt;span class="str"&gt;' '&lt;/span&gt;);

    &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; DateTime(yearValue, monthValue, dayValue, 
                        hourValue, minuteValue, secondValue);
}&lt;/pre&gt;

&lt;p&gt;The main body of the program uses this method to extract the date out of the RSS feed. When a new date is found it is time to update the lights.&lt;/p&gt;

&lt;h2&gt;Lights and Threads&lt;/h2&gt;

&lt;p&gt;My first version of the program flashed the lights for a while and then checked to see if a new blog post had been made. This worked OK, but the process of loading the RSS feed from the server and checking the dates can take a few seconds, which meant that the flashing lights would freeze every now and then. This did not look very good, and so I decided to use two threads instead. One is in charge of flashing the lights in a random pattern and the other loads the RSS feed from my blog and checks the date of the most recent publication. &lt;/p&gt;

&lt;p&gt;Note that the threading I am using is exactly the same as threading in the full .NET Framework. &lt;/p&gt;

&lt;h2&gt;Thread Communication&lt;/h2&gt;

&lt;p&gt;The two threads communicate by means of a single boolean variable which is set to true when the blog alert is to take place. The display thread reads this flag and flashes the lights red if it is time to alert. &lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; alert = &lt;span class="kwrd"&gt;false&lt;/span&gt;;

&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; flasher()
{
    setupOutputs();

    &lt;span class="kwrd"&gt;while&lt;/span&gt; (&lt;span class="kwrd"&gt;true&lt;/span&gt;)
    {
        randomDisplay(400, 10);
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (alert)
        {
            alert = &lt;span class="kwrd"&gt;false&lt;/span&gt;;
            flashRed(600, 20);
        }
    }
}&lt;/pre&gt;

&lt;p&gt;The methods &lt;b&gt;randomDisplay&lt;/b&gt; and &lt;b&gt;flashRed&lt;/b&gt; do exactly what you would expect. Each of them gets two numbers to control the lights. The first number gives the delay in milliseconds between flashes (a few hundred milliseconds giving best results). The second gives the number of times that the lights should be flashed before the method finishes. &lt;b&gt;RandomDisplay&lt;/b&gt; displays random colors, whereas &lt;b&gt;flashRed&lt;/b&gt; is simply flashes the red lights. The &lt;b&gt;alert&lt;/b&gt; flag is cleared before the red lights are flashed so that the system will resume normal display after the alert.&lt;/p&gt;

&lt;p&gt;The second thread in the system performs the blog download and date test behaviour. This all happens inside the &lt;b&gt;Main&lt;/b&gt; method:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Main()
{
    flashThread = &lt;span class="kwrd"&gt;new&lt;/span&gt; System.Threading.Thread(flasher);

    flashThread.Start();

    &lt;span class="kwrd"&gt;string&lt;/span&gt; address = &lt;span class="str"&gt;&amp;quot;www.robmiles.com&amp;quot;&lt;/span&gt;;
    &lt;span class="kwrd"&gt;string&lt;/span&gt; name = &lt;span class="str"&gt;&amp;quot;/journal/rss.xml&amp;quot;&lt;/span&gt;;

    String html = GetWebPage(address, name);

    DateTime lastUpdate = getRecentPubDate(html, &lt;span class="str"&gt;&amp;quot;&amp;lt;pubDate&amp;gt;&amp;quot;&lt;/span&gt;);

    Debug.Print(&lt;span class="str"&gt;&amp;quot;Initial Update Value : &amp;quot;&lt;/span&gt; + lastUpdate.ToString());

    &lt;span class="kwrd"&gt;while&lt;/span&gt; (&lt;span class="kwrd"&gt;true&lt;/span&gt;)
    {
        System.Threading.Thread.Sleep(10000);

        html = GetWebPage(address, name);

        DateTime blogUpdate = getRecentPubDate(html, &lt;span class="str"&gt;&amp;quot;&amp;lt;pubDate&amp;gt;&amp;quot;&lt;/span&gt;);

        &lt;span class="kwrd"&gt;if&lt;/span&gt; (!blogUpdate.Equals(lastUpdate))
        {
            Debug.Print(&lt;span class="str"&gt;&amp;quot;Updated at : &amp;quot;&lt;/span&gt; + blogUpdate.ToString());
            lastUpdate = blogUpdate;
            alert = &lt;span class="kwrd"&gt;true&lt;/span&gt;;
        }
    }
}&lt;/pre&gt;

&lt;p&gt;To reduce the load on the network the system only checks the blog feed every 10 seconds.&lt;/p&gt;

&lt;h1&gt;Future Work&lt;/h1&gt;

&lt;p&gt;The program itself works fine, but the error handling is not wonderful. Although some of the methods used throw exceptions these are not caught anywhere, causing the blog reading thread to terminate. This does not stop the lights flashing, but it does mean that there will be no more alerts. However, it is not too hard to create a version which contains proper error handling and even flashes the lights different colors to indicate the alarm conditions. I have created a version that flashes the lights yellow every now and then if the network connection fails. There is also considerable scope for reading other web based sources and changing the output accordingly. Feel free to do all these things and make sure that you have fun.&lt;/p&gt;

&lt;h2&gt;Thanks&lt;/h2&gt;

&lt;p&gt;Thanks go to Ian Mitchell of Ormston Technology (&lt;a href="http://www.ormtec.co.uk/"&gt;http://www.ormtec.co.uk/&lt;/a&gt;) for doing such a great job of hardware design and build.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9149635" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/coding4fun/archive/tags/home+automation/default.aspx">home automation</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/robotics/default.aspx">robotics</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/hardware/default.aspx">hardware</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/hardwarehacks/default.aspx">hardwarehacks</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/holiday/default.aspx">holiday</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/.NET+Microframework/default.aspx">.NET Microframework</category></item><item><title>WiiEarthVR – A Fully Immersive 3D Experience with Virtual Earth 3D</title><link>http://blogs.msdn.com/coding4fun/archive/2008/11/14/9068804.aspx</link><pubDate>Fri, 14 Nov 2008 11:57:58 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9068804</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>9</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/9068804.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=9068804</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=9068804</wfw:comment><description>&lt;table border="0" cellspacing="0" cellpadding="1" width="100%"&gt;&lt;tbody&gt;     &lt;tr class="entry_overview"&gt;       &lt;td width="50"&gt;&lt;a href="http://www.coding4fun.net/images/WiiEarthVRAFullyImmersive3DExperiencewit_E86D/globe4.png"&gt;&lt;img style="border-right-width: 0px; margin: 0px 5px 0px 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="globe4" border="0" alt="globe4" src="http://www.coding4fun.net/images/WiiEarthVRAFullyImmersive3DExperiencewit_E86D/globe4_thumb.png" width="54" height="53" mce_src="http://www.coding4fun.net/images/WiiEarthWiimoteInterfaceforVirtualEarth_4B93/globe.png" /&gt;&lt;/a&gt; &lt;/td&gt;        &lt;td&gt;&lt;span class="entry_description"&gt;In this article, Brian Peek will demonstrate how to use a Nintendo Wii Remote (Wiimote), a Wii Fit Balance Board, and Vuzix VR920 glasses as input devices for Microsoft Virtual Earth 3D, providing a fully immersive, 3D experience.&lt;/span&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td colspan="2"&gt;         &lt;div class="entry_author"&gt;&lt;a href="http://www.brianpeek.com/" target="_blank" mce_href="http://www.brianpeek.com/"&gt;Brian Peek&lt;/a&gt;&lt;/div&gt;          &lt;div class="entry_company"&gt;&lt;a href="http://www.aspsoft.com/" mce_href="http://www.aspsoft.com/"&gt;ASPSOFT, Inc.&lt;/a&gt;&lt;/div&gt;          &lt;br /&gt;          &lt;div class="entry_details"&gt;&lt;b&gt;Difficulty: &lt;/b&gt;&lt;span class="entry_details_input"&gt;Intermediate&lt;/span&gt;&lt;/div&gt;          &lt;div class="entry_details"&gt;&lt;b&gt;Time Required:&lt;/b&gt; 2&lt;span class="entry_details_input"&gt;-3 hours&lt;/span&gt;&lt;/div&gt;          &lt;div class="entry_details"&gt;&lt;b&gt;Cost: &lt;/b&gt;&lt;span class="entry_details_input"&gt;$60 for Wiimote and Nunchuk, $90 for Wii Fit (which includes Balance Board), $400 for &lt;a href="http://www.vr920.com/" target="_blank"&gt;Vuzix VR920 glasses&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;          &lt;div class="entry_details"&gt;&lt;b&gt;Software: &lt;/b&gt;&lt;a href="http://www.codeplex.com/WiimoteLib" target="_blank"&gt;Managed Library for Nintendo's Wiimote&lt;/a&gt;, &lt;span class="entry_details_input"&gt;&lt;a href="http://msdn.com/express/" mce_href="http://msdn.com/express/"&gt;Visual Basic or Visual C# Express Editions&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;          &lt;div class="entry_details"&gt;&lt;b&gt;Hardware: &lt;/b&gt;&lt;a href="http://www.nintendo.com/wii/what/accessories"&gt;Nintendo Wii Remote (Wiimote) with Nunchuk&lt;/a&gt;, &lt;a href="http://www.nintendo.com/games/detail/hoiNtus4JvIcPtP8LQPyud4Kyy393oep" target="_blank"&gt;Wii Fit Balance Board&lt;/a&gt;, &lt;a href="http://www.vr920.com/iwear/products_vr920.html" target="_blank"&gt;Vuzix VR920 glasses&lt;/a&gt;, a compatible PC Bluetooth adapter and stack&lt;/div&gt;          &lt;div class="entry_details"&gt;&lt;b&gt;Download: &lt;/b&gt;&lt;a href="http://www.brianpeek.com/files/folders/source_code/entry3066.aspx" target="_blank"&gt;Download&lt;/a&gt;&lt;/div&gt;          &lt;div class="entry_details"&gt;&lt;strong&gt;Discussion Forum: &lt;/strong&gt;&lt;a href="http://www.brianpeek.com/forums/43.aspx" target="_blank"&gt;Forum&lt;/a&gt;&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Introduction&lt;/h3&gt;  &lt;p&gt;Virtual Earth is the 3D interface to &lt;a href="http://maps.live.com" target="_blank"&gt;Microsoft's Live Maps&lt;/a&gt; service.&amp;#160; Normally this control is loaded via the web browser and allows interaction with a keyboard, mouse, and Xbox 360 controller.&amp;#160; In this article, we will take the Virtual Earth 3D control out of the web browser, use it in a WinForms application, and control it with a Nintendo Wii Remote (Wiimote) and a pair of Vuzix VR920 glasses, while also providing a stereoscopic 3D image to the glasses, creating the illusion of a fully three dimensional environment.&amp;#160; Note that use of the Virtual Earth 3D control in this way is undocumented and unsupported at the moment.&amp;#160; Because of this, some of the descriptions in this article are educated guesses and may not be 100% accurate…&lt;/p&gt;  &lt;p&gt;Originally, this project started as a simple Wiimote interface to Virtual Earth 3D as shown in the video below.&amp;#160; Since I wrote that application, I learned of the VR920 glasses and the Wii Fit Balance Board was released, so I’ve decided to create a more immersive experience using all of these controls which was demonstrated at &lt;a href="http://www.microsoftpdc.com/" target="_blank"&gt;PDC2008&lt;/a&gt;, shown here:&lt;/p&gt; &lt;object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="320" height="240"&gt; &lt;param name="source" value="http://channel9.msdn.com/App_Themes/default/VideoPlayer.xap" /&gt; &lt;param name="initParams" value="m=mms://mschnlnine.wmod.llnwd.net/a1809/d1/ch9/3/1/2/1/4/4/WiiEarthVR_s_ch9.wmv,autostart=false,autohide=true,showembed=true, thumbnail=http://mschnlnine.vo.llnwd.net/d1/ch9/3/1/2/1/4/4/WiiEarthVR_large_ch9.jpg" /&gt; &lt;param name="background" value="#00FFFFFF" /&gt; &lt;a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;"&gt; &lt;img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none" /&gt; &lt;/a&gt; &lt;/object&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Setup&lt;/h3&gt;  &lt;p&gt;Before we get started, you will need to install the Virtual Earth 3D control.&amp;#160; If you haven't done this already, browse to &lt;a href="http://maps.live.com/" mce_href="http://maps.live.com/"&gt;http://maps.live.com/&lt;/a&gt; and click on the &lt;b&gt;3D&lt;/b&gt; link to install the control and supporting software.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.coding4fun.net/images/WiiEarthVRAFullyImmersive3DExperiencewit_E86D/captured_Image.png.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="captured_Image.png" border="0" alt="captured_Image.png" src="http://www.coding4fun.net/images/WiiEarthVRAFullyImmersive3DExperiencewit_E86D/captured_Image.png_thumb.png" width="459" height="107" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Additionally, if you haven't already, please review my &lt;a href="http://blogs.msdn.com/coding4fun/archive/2007/03/14/1879033.aspx" target="_blank" mce_href="http://blogs.msdn.com/coding4fun/archive/2007/03/14/1879033.aspx"&gt;Managed Library for Nintendo's Wiimote&lt;/a&gt; article on this site.&amp;#160; We will be using the library in this article, but I will not repeat the basic information that is located in the original article.&amp;#160; You will also need to have the &lt;a href="http://www.vr920.com/" target="_blank"&gt;Vuzix VR920&lt;/a&gt; glasses installed and setup according to its own user manual.&amp;#160; That will also not be covered here.&lt;/p&gt;  &lt;h3&gt;Implementation&lt;/h3&gt;  &lt;h4&gt;The Virtual Earth 3D Control&lt;/h4&gt;  &lt;p&gt;The Virtual Earth 3D (VE3D) control is intended to be used through a well documented JavaScript interface from a web page, however we would not be able to access the Wiimote or VR920 glasses from JavaScript.&amp;#160; Therefore, we will be using the VE3D control through its native, but wholly undocumented interface.&lt;/p&gt;  &lt;p&gt;Start by creating a new Windows Forms application named &lt;strong&gt;WiiEarthVR&lt;/strong&gt; in C# or VB.&amp;#160; As with all controls and 3rd party libraries, a reference needs to be set to the Virtual Earth 3D libraries.&amp;#160; Add references to the following items:&amp;#160; &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Microsoft.MapPoint.Data &lt;/li&gt;    &lt;li&gt;Microsoft.MapPoint.Data.VirtualEarthTileDataSource &lt;/li&gt;    &lt;li&gt;Microsoft.MapPoint.Geometry &lt;/li&gt;    &lt;li&gt;Microsoft.MapPoint.Rendering3D &lt;/li&gt;    &lt;li&gt;Microsoft.MapPoint.Rendering3D.Utility &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;If they do not show up in the .NET references, they can be found by selecting the Browse tab and navigating to C:\Program Files\Virtual Earth 3D\ or C:\Program Files (x86)\Virtual Earth 3D\ .&amp;#160; With the references in place, the project file can now be opened and the references will be seen in the References folder in the Solution Explorer as usual.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.coding4fun.net/images/WiiEarthVRAFullyImmersive3DExperiencewit_E86D/captured_Image.png11.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="captured_Image.png[11]" border="0" alt="captured_Image.png[11]" src="http://www.coding4fun.net/images/WiiEarthVRAFullyImmersive3DExperiencewit_E86D/captured_Image.png11_thumb.png" width="376" height="229" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Creating an instance of the control can be done in code just like any other control.&amp;#160; Used in the constructor or load event of the form, the following code will create a VE3D control and add it to the form as fully docked:&lt;/p&gt;  &lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; GlobeControl _globeControl;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; MainForm()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    InitializeComponent();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _globeControl = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; GlobeControl();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    SuspendLayout();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _globeControl.Location = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; System.Drawing.Point(0, 0);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _globeControl.Name = &lt;span style="color: #006080"&gt;&amp;quot;_globeControl&amp;quot;&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _globeControl.Size = ClientSize;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _globeControl.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _globeControl.TabIndex = 0;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _globeControl.SendToBack(); &lt;span style="color: #008000"&gt;// we want the button to be on top&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    pnlGlobe.Controls.Add(_globeControl);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    ResumeLayout(&lt;span style="color: #0000ff"&gt;false&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _globeControl &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; GlobeControl&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt;()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    InitializeComponent()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _globeControl = &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; GlobeControl()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    SuspendLayout()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _globeControl.Location = &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; System.Drawing.Point(0, 0)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _globeControl.Name = &lt;span style="color: #006080"&gt;&amp;quot;_globeControl&amp;quot;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _globeControl.Size = ClientSize&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _globeControl.Anchor = AnchorStyles.Left &lt;span style="color: #0000ff"&gt;Or&lt;/span&gt; AnchorStyles.Right &lt;span style="color: #0000ff"&gt;Or&lt;/span&gt; AnchorStyles.Top &lt;span style="color: #0000ff"&gt;Or&lt;/span&gt; AnchorStyles.Bottom&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _globeControl.TabIndex = 0&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _globeControl.SendToBack() &lt;span style="color: #008000"&gt;' we want the button to be on top&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    pnlGlobe.Controls.Add(_globeControl)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    ResumeLayout(&lt;span style="color: #0000ff"&gt;False&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;This sets up the VE3D control in its default state.&amp;#160; If you were to run an application with only this code, you would see nothing but the earth.&amp;#160; The navigation controls and other extras would be missing.&lt;/p&gt;

&lt;p&gt;We can start adding items to the VE3D control by listening for the &lt;strong&gt;FirstFrameRendered&lt;/strong&gt; event of the &lt;strong&gt;GlobeControl&lt;/strong&gt; and then setting the appropriate properties.&amp;#160; Setting these properties prior to this point can lead to some unexpected results.&lt;/p&gt;

&lt;p&gt;In the &lt;strong&gt;FirstFrameRendered&lt;/strong&gt; event handler, if you wish to add the default navigation controls to the screen, the &lt;b&gt;PlugInLoader&lt;/b&gt; object is used.&amp;#160; The &lt;b&gt;PlugInLoader&lt;/b&gt; is created by using the &lt;b&gt;CreateLoader&lt;/b&gt; static method, passing in an instance of the &lt;b&gt;GlobeControl&lt;/b&gt;'s &lt;b&gt;Host&lt;/b&gt; object.&amp;#160; Then, the &lt;b&gt;NavigationPlugIn&lt;/b&gt; can be loaded and activated as shown:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// load all the spiffy UI navigation goodies&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;PlugInLoader loader = PlugInLoader.CreateLoader(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.globeControl.Host);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;loader.LoadPlugIn(&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(NavigationPlugIn));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;loader.ActivatePlugIn(&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(NavigationPlugIn).GUID, &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' load all the spiffy UI navigation goodies&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; loader &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; PlugInLoader = PlugInLoader.CreateLoader(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.globeControl.Host)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;loader.LoadPlugIn(&lt;span style="color: #0000ff"&gt;GetType&lt;/span&gt;(NavigationPlugIn))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;loader.ActivatePlugIn(&lt;span style="color: #0000ff"&gt;GetType&lt;/span&gt;(NavigationPlugIn).GUID, &lt;span style="color: #0000ff"&gt;Nothing&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;The last thing to be added for basic functionality is the data.&amp;#160; As it stands, the only data that will appear on the globe is the image of the continents.&amp;#160; Zooming in only produces a blurry representation of that base image.&lt;/p&gt;

&lt;p&gt;Data layers are created from specially formatted data sources provided by maps.live.com known as content manifests.&amp;#160; These are XML files which tell the VE3D control how to load the data required for any view.&amp;#160; Content layers can be added by adding them to the &lt;strong&gt;DataSources&lt;/strong&gt; object of the &lt;strong&gt;GlobeControl&lt;/strong&gt;.&amp;#160; We can add any of the following layers (note that there may be other content manifests provided by maps.live.com, but these are the only 5 that I am aware of):&lt;/p&gt;

&lt;table border="1" cellspacing="0" cellpadding="2" width="516"&gt;&lt;tbody&gt;
    &lt;tr&gt;
      &lt;td valign="top" width="244"&gt;
        &lt;p align="center"&gt;&lt;b&gt;URL&lt;/b&gt;&lt;/p&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="163"&gt;
        &lt;p align="center"&gt;&lt;b&gt;DataSourceUsage Type&lt;/b&gt;&lt;/p&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="107"&gt;
        &lt;p align="center"&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="244"&gt;&lt;a title="http://local.live.com/Manifests/HighDemContentManifest.xml" href="http://local.live.com/Manifests/HD.xml" mce_href="http://local.live.com/Manifests/HD.xml"&gt;http://local.live.com/Manifests/HD.xml&lt;/a&gt;&lt;/td&gt;

      &lt;td valign="top" width="163"&gt;ElevationMap&lt;/td&gt;

      &lt;td valign="top" width="107"&gt;Terrain data&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="244"&gt;&lt;a title="http://local.live.com/Manifests/ModelContentManifest.xml" href="http://local.live.com/Manifests/MO.xml" mce_href="http://local.live.com/Manifests/MO.xml"&gt;http://local.live.com/Manifests/MO.xml&lt;/a&gt;&lt;/td&gt;

      &lt;td valign="top" width="163"&gt;Model&lt;/td&gt;

      &lt;td valign="top" width="107"&gt;3D buildings&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="244"&gt;&lt;a title="http://local.live.com/Manifests/AerialContentManifest.xml" href="http://local.live.com/Manifests/AT.xml" mce_href="http://local.live.com/Manifests/AT.xml"&gt;http://local.live.com/Manifests/AT.xml&lt;/a&gt;&lt;/td&gt;

      &lt;td valign="top" width="163"&gt;TextureMap&lt;/td&gt;

      &lt;td valign="top" width="107"&gt;Unlabeled aerial&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="244"&gt;&lt;a title="http://local.live.com/Manifests/HybridContentManifest.xml" href="http://local.live.com/Manifests/HT.xml" mce_href="http://local.live.com/Manifests/HT.xml"&gt;http://local.live.com/Manifests/HT.xml&lt;/a&gt;&lt;/td&gt;

      &lt;td valign="top" width="163"&gt;TextureMap&lt;/td&gt;

      &lt;td valign="top" width="107"&gt;Labeled aerial&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="244"&gt;&lt;a title="http://local.live.com/Manifests/RoadContentManifest.xml" href="http://local.live.com/Manifests/RT.xml" mce_href="http://local.live.com/Manifests/RT.xml"&gt;http://local.live.com/Manifests/RT.xml&lt;/a&gt;&lt;/td&gt;

      &lt;td valign="top" width="163"&gt;TextureMap&lt;/td&gt;

      &lt;td valign="top" width="107"&gt;Roads only&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;For the best display, add the &lt;b&gt;ElevationMap&lt;/b&gt;, &lt;b&gt;Model&lt;/b&gt; and &lt;b&gt;Aerial&lt;/b&gt; &lt;b&gt;TextureMap&lt;/b&gt; layers as shown:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; height: 81px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// set various data sources, here for elevation data, terrain data, and model data.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.DataSources.Add(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; DataSourceLayerData(&lt;span style="color: #006080"&gt;&amp;quot;Elevation&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;Elevation&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;@&amp;quot;http://maps.live.com//Manifests/HD.xml&amp;quot;&lt;/span&gt;, DataSourceUsage.ElevationMap));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.DataSources.Add(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; DataSourceLayerData(&lt;span style="color: #006080"&gt;&amp;quot;Texture&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;Texture&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;@&amp;quot;http://maps.live.com//Manifests/AT.xml&amp;quot;&lt;/span&gt;, DataSourceUsage.TextureMap));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.DataSources.Add(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; DataSourceLayerData(&lt;span style="color: #006080"&gt;&amp;quot;Models&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;Models&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;@&amp;quot;http://maps.live.com//Manifests/MO.xml&amp;quot;&lt;/span&gt;, DataSourceUsage.Model));&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; height: 83px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' set various data sources, here for elevation data, terrain data, and model data.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.DataSources.Add(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; DataSourceLayerData(&lt;span style="color: #006080"&gt;&amp;quot;Elevation&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;Elevation&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;http://maps.live.com//Manifests/HD.xml&amp;quot;&lt;/span&gt;, DataSourceUsage.ElevationMap))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.DataSources.Add(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; DataSourceLayerData(&lt;span style="color: #006080"&gt;&amp;quot;Texture&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;Texture&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;http://maps.live.com//Manifests/AT.xml&amp;quot;&lt;/span&gt;, DataSourceUsage.TextureMap))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.DataSources.Add(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; DataSourceLayerData(&lt;span style="color: #006080"&gt;&amp;quot;Models&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;Models&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;http://maps.live.com//Manifests/MO.xml&amp;quot;&lt;/span&gt;, DataSourceUsage.Model))&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;By passing the URL of the content manifest, a name for the layer, and what the manifest represents, a new &lt;b&gt;DataSource&lt;/b&gt; is created, which is in turn used to create a &lt;b&gt;DataSourceLayerData&lt;/b&gt; object which is then given to the VE3D control to consume.&amp;#160; This should be done in the &lt;strong&gt;FirstFrameRendered&lt;/strong&gt; event handler as well.&lt;/p&gt;

&lt;p&gt;We also need to setup VE3D to turn off any UI elements, turn on the atmosphere effects, and ensure we have a full unobstructed view. Again, in the &lt;strong&gt;FirstFrameRendered&lt;/strong&gt; event handler, we can use the following code to achieve this:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; height: 236px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// turn on the nice atmosphere&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.Environment.AtmosphereDisplay = Microsoft.MapPoint.Rendering3D.Atmospherics.EnvironmentManager.AtmosphereStyle.Scattering;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// default to all off&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.Display3DCursor = &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.SetWindowsCursor(&lt;span style="color: #0000ff"&gt;null&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.ShowNavigationControl = &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.ShowCursorLocationInformation = &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.ShowScale = &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.ShowUI = &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.Environment.SunPosition = &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.Environment.LocalWeatherEnabled = &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.BaseCopyrightText = &lt;span style="color: #006080"&gt;&amp;quot; &amp;quot;&lt;/span&gt;; // workaround &lt;span style="color: #0000ff"&gt;for&lt;/span&gt; a display issue&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;VB&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; height: 249px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' turn on the nice atmosphere&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.Environment.AtmosphereDisplay = Microsoft.MapPoint.Rendering3D.Atmospherics.EnvironmentManager.AtmosphereStyle.Scattering&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' default to all off&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.Display3DCursor = &lt;span style="color: #0000ff"&gt;False&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.SetWindowsCursor(&lt;span style="color: #0000ff"&gt;Nothing&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.ShowNavigationControl = &lt;span style="color: #0000ff"&gt;False&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.ShowCursorLocationInformation = &lt;span style="color: #0000ff"&gt;False&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.ShowScale = &lt;span style="color: #0000ff"&gt;False&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.ShowUI = &lt;span style="color: #0000ff"&gt;False&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.Environment.SunPosition = &lt;span style="color: #0000ff"&gt;Nothing&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.Environment.LocalWeatherEnabled = &lt;span style="color: #0000ff"&gt;True&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.WorldEngine.BaseCopyrightText = &lt;span style="color: #006080"&gt;&amp;quot; &amp;quot;&lt;/span&gt; ' workaround &lt;span style="color: #0000ff"&gt;for&lt;/span&gt; a display issue&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;If you were to run the application at this point, you would see a fully functioning Virtual Earth 3D control with proper data and navigation.&lt;/p&gt;

&lt;h4&gt;Control Scheme and Bindings&lt;/h4&gt;

&lt;p&gt;The user will control VE3D with the Wiimote by holding the nunchuk in the left hand, which will move the user forward/back/left/right using the joystick.&amp;#160; The C and Z buttons on the front of the nunchuk will be used to raise and lower the altitude of the camera.&amp;#160; The Wiimote, held in the right hand, will be used to toggle various things on or off and interact with menus.&amp;#160; The user will also stand on the Balance Board which will use their center of gravity to turn them in the environment.&lt;/p&gt;

&lt;p&gt;VE3D bindings allow you to change or create new control schemes for VE3D by placing an XML file in a specific directory as follows:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Vista:&lt;/strong&gt; C:\Users\&amp;lt;username&amp;gt;\AppData\LocalLow\Microsoft\Virtual Earth 3D &lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;XP:&lt;/strong&gt; C:\Documents and Settings\&amp;lt;username&amp;gt;\Local Settings\Microsoft\Virtual Earth 3D &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this directory you will find a &lt;b&gt;Bindings.xml &lt;/b&gt;file.&amp;#160; This XML schema defines the default keyboard, mouse, Gamepad and other input device properties.&amp;#160; Open the file to see the schema used to define events and parameters.&lt;/p&gt;

&lt;p&gt;By default, VE3D will load any file named Bindings*.xml from this directory.&amp;#160; For the Wiimote control scheme, create a new file named &lt;b&gt;BindingsWiiEarthVR.xml&lt;/b&gt; in this directory.&amp;#160; Set the contents of the file to the following:&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: #800000"&gt;xml&lt;/span&gt; &lt;span style="color: #ff0000"&gt;version&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;encoding&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;utf-8&amp;quot;&lt;/span&gt; ?&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bindings&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;BindingSet&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;WiiEarthVRBindings&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;AutoUse&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;True&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Cursor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Drag&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;&amp;lt;!-- Nunchuk joystick --&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote.NunchukX&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;0.5&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Strafe&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote.NunchukY&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;1&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Move&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;&amp;lt;!-- Nunchuk buttons --&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote.NunchukC&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;0.20&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Ascend&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote.NunchukZ&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;-0.20&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Ascend&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;&amp;lt;!-- Balance Board --&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote.BalanceBoardX&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;-0.0009&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Turn&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote.BalanceBoardY&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;0.0009&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Ascend&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;&amp;lt;!-- Wiimote buttons --&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote.Home&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ResetOnCenter&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote.A&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;1&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Locations, WiiEarthVR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote.Left&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;-1&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Locations, WiiEarthVR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote.Up&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;-1&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;LocationsMove, WiiEarthVR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote.Down&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;1&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;LocationsMove, WiiEarthVR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;&amp;lt;!-- FPS-style keyboard controls in case we don't have a nunchuk --&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Key.W&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;22&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Move&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Key.S&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;-22&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Move&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Key.D&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;22&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Strafe&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Key.A&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;-22&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Strafe&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Key.Space&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;20&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Ascend&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Key.C&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;-20&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Ascend&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;&amp;lt;!-- Other keys --&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Key.F1&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;VR920SetZero, WiiEarthVR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Key.F2&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;BalanceBoardSetZero, WiiEarthVR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Key.F3&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ToggleVR920Stereo, WiiEarthVR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote.Minus&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;-0.1&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;VR920SetEyeDistance, WiiEarthVR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote.Plus&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Factor&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;0.1&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;VR920SetEyeDistance, WiiEarthVR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote.One&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ToggleBalanceBoard, WiiEarthVR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote.Two&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ToggleVR920, WiiEarthVR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Key.B&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ToggleBalanceBoard, WiiEarthVR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Key.V&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ToggleVR920, WiiEarthVR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Key.F&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;FullScreen, WiiEarthVR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;BindingSet&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bindings&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;The &lt;b&gt;&amp;lt;BindingSet&amp;gt;&lt;/b&gt; tags wrap groups of control bindings.&amp;#160; It requires a &lt;b&gt;Name&lt;/b&gt; and optionally a &lt;b&gt;Cursor&lt;/b&gt;.&amp;#160; If the binding set is to be used automatically, as it would be in most cases, set the &lt;b&gt;AutoUse&lt;/b&gt; parameter to &lt;b&gt;True&lt;/b&gt;.&amp;#160; Inside of that are &lt;b&gt;&amp;lt;Bind&amp;gt;&lt;/b&gt; tags.&amp;#160; The tag requires the &lt;strong&gt;Event &lt;/strong&gt;parameter and optionally the &lt;b&gt;Factor&lt;/b&gt; parameter.&amp;#160; The &lt;b&gt;Event &lt;/b&gt;parameter will be used to match the binding to its handler which will be written later.&amp;#160; The syntax is &amp;lt;Handler Name&amp;gt;.&amp;lt;Event Name&amp;gt;.&amp;#160; The &lt;b&gt;Factor&lt;/b&gt; parameter is optional and can be used to scale the data value up or down to increase or decrease sensitivity of the input method.&amp;#160; The &lt;b&gt;Action&lt;/b&gt; tag inside the &lt;strong&gt;Bind&lt;/strong&gt; tag is used to map the specific binding to a particular method.&amp;#160; Once the handler is written, these will make more sense.&lt;/p&gt;

&lt;p&gt;The bindings above create the control scheme described above:&amp;#160; NunchukX/Y describe what happens when the analog joystick is moved, NunchukC/Z describe what happens with the C/Z buttons are pressed, and so on.&lt;/p&gt;

&lt;p&gt;The bindings also allow for several variations.&amp;#160; Bindings are defined for both the IR position (&lt;b&gt;IRX&lt;/b&gt;, &lt;b&gt;IRY&lt;/b&gt;) and accelerometer values (&lt;b&gt;AX&lt;/b&gt;, &lt;b&gt;AY&lt;/b&gt;).&amp;#160; If an IR sensor bar is not available, the accelerometer values of the Wiimote can be used instead.&amp;#160; Additionally, keyboard bindings are created in the style of a first person shooter using WASD.&amp;#160; These can be used if a Nunchuk is not available.&lt;/p&gt;

&lt;p&gt;Note that some bindings append two &lt;b&gt;Event&lt;/b&gt;s together with a + sign.&amp;#160; This allows for button combinations.&amp;#160; In this case, for the accelerometer and/or IR sensor, we only want to register the action if a button is pressed down.&amp;#160; So, those events which require the button to be held down contain &lt;b&gt;Wiimote.B+&lt;/b&gt; and the event it is combined with.&lt;/p&gt;

&lt;p&gt;For those events which require a custom action that will be written separately and not part of the VE3D control, the &lt;b&gt;Action&lt;/b&gt; parameter must contain the action name, followed by a comma, and then the full assembly name:&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; height: 83px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Event&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Wiimote.One&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Action&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;ToggleBalanceBoard, WiiEarthVR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Bind&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;br /&gt;You can change any of these button bindings simply by changing this XML file and deploying to the directory above.&lt;/div&gt;

&lt;h4&gt;Event Source&lt;/h4&gt;

&lt;p&gt;An &lt;b&gt;EventSource&lt;/b&gt; is needed which will grab data from the Wiimote and pass it along to VE3D as defined by the bindings file above.&amp;#160; Create a new class named &lt;b&gt;WiimoteEventSource&lt;/b&gt; which derives from &lt;b&gt;Microsoft.MapPoint.Binding.EventSource&lt;/b&gt;&amp;#160; as follows:&lt;/p&gt;

&lt;p&gt;Next, add an enumeration named &lt;b&gt;WiimoteEvent&lt;/b&gt; (the name isn't important) which contains all of the &lt;b&gt;Name&lt;/b&gt; items from the bindings XML file above.&amp;#160; It should look like this:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #008000"&gt;// all events handled by this event source from XML file&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;enum&lt;/span&gt; WiimoteEvent&lt;br /&gt;{&lt;br /&gt;    IRX,        &lt;span style="color: #008000"&gt;// IR X position&lt;/span&gt;&lt;br /&gt;    IRY,        &lt;span style="color: #008000"&gt;// IR Y position&lt;/span&gt;&lt;br /&gt;    NunchukX,    &lt;span style="color: #008000"&gt;// Nunchuk joystick X position&lt;/span&gt;&lt;br /&gt;    NunchukY,    &lt;span style="color: #008000"&gt;// Nunchuk joystick Y position&lt;/span&gt;&lt;br /&gt;    NunchukC,    &lt;span style="color: #008000"&gt;// Nunchuk C button&lt;/span&gt;&lt;br /&gt;    NunchukZ,    &lt;span style="color: #008000"&gt;// Nunchuk Z button&lt;/span&gt;&lt;br /&gt;    AX,            &lt;span style="color: #008000"&gt;// Wiimote accelerometer X&lt;/span&gt;&lt;br /&gt;    AY,            &lt;span style="color: #008000"&gt;// Wiimote accelerometer Y&lt;/span&gt;&lt;br /&gt;    Up,            &lt;span style="color: #008000"&gt;// Dpad up&lt;/span&gt;&lt;br /&gt;    Down,        &lt;span style="color: #008000"&gt;// Dpad down&lt;/span&gt;&lt;br /&gt;    Left,        &lt;span style="color: #008000"&gt;// Dpad left&lt;/span&gt;&lt;br /&gt;    Right,        &lt;span style="color: #008000"&gt;// Dpad right&lt;/span&gt;&lt;br /&gt;    A,            &lt;span style="color: #008000"&gt;// A button&lt;/span&gt;&lt;br /&gt;    B,            &lt;span style="color: #008000"&gt;// B button&lt;/span&gt;&lt;br /&gt;    Minus,        &lt;span style="color: #008000"&gt;// Minus button&lt;/span&gt;&lt;br /&gt;    Home,        &lt;span style="color: #008000"&gt;// Wiimote Home button&lt;/span&gt;&lt;br /&gt;    Plus,        &lt;span style="color: #008000"&gt;// Plus button&lt;/span&gt;&lt;br /&gt;    One,        &lt;span style="color: #008000"&gt;// Wiimote One button&lt;/span&gt;&lt;br /&gt;    Two,        &lt;span style="color: #008000"&gt;// Wiimote Two button&lt;/span&gt;&lt;br /&gt;    BalanceBoardX,    &lt;span style="color: #008000"&gt;// Balance Board COG X&lt;/span&gt;&lt;br /&gt;    BalanceBoardY    &lt;span style="color: #008000"&gt;// Balance Board COG Y&lt;/span&gt;&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #008000"&gt;' all events handled by this event source from XML file&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Enum&lt;/span&gt; WiimoteEvent&lt;br /&gt;    IRX &lt;span style="color: #008000"&gt;' IR X position&lt;/span&gt;&lt;br /&gt;    IRY &lt;span style="color: #008000"&gt;' IR Y position&lt;/span&gt;&lt;br /&gt;    NunchukX &lt;span style="color: #008000"&gt;' Nunchuk joystick X position&lt;/span&gt;&lt;br /&gt;    NunchukY &lt;span style="color: #008000"&gt;' Nunchuk joystick Y position&lt;/span&gt;&lt;br /&gt;    NunchukC &lt;span style="color: #008000"&gt;' Nunchuk C button&lt;/span&gt;&lt;br /&gt;    NunchukZ &lt;span style="color: #008000"&gt;' Nunchuk Z button&lt;/span&gt;&lt;br /&gt;    AX &lt;span style="color: #008000"&gt;' Wiimote accelerometer X&lt;/span&gt;&lt;br /&gt;    AY &lt;span style="color: #008000"&gt;' Wiimote accelerometer Y&lt;/span&gt;&lt;br /&gt;    Up &lt;span style="color: #008000"&gt;' Dpad up&lt;/span&gt;&lt;br /&gt;    Down &lt;span style="color: #008000"&gt;' Dpad down&lt;/span&gt;&lt;br /&gt;    Left &lt;span style="color: #008000"&gt;' Dpad left&lt;/span&gt;&lt;br /&gt;    Right &lt;span style="color: #008000"&gt;' Dpad right&lt;/span&gt;&lt;br /&gt;    A &lt;span style="color: #008000"&gt;' A button&lt;/span&gt;&lt;br /&gt;    B &lt;span style="color: #008000"&gt;' B button&lt;/span&gt;&lt;br /&gt;    Minus &lt;span style="color: #008000"&gt;' Minus button&lt;/span&gt;&lt;br /&gt;    Home &lt;span style="color: #008000"&gt;' Wiimote Home button&lt;/span&gt;&lt;br /&gt;    Plus &lt;span style="color: #008000"&gt;' Plus button&lt;/span&gt;&lt;br /&gt;    One &lt;span style="color: #008000"&gt;' Wiimote One button&lt;/span&gt;&lt;br /&gt;    Two &lt;span style="color: #008000"&gt;' Wiimote Two button&lt;/span&gt;&lt;br /&gt;    BalanceBoardX &lt;span style="color: #008000"&gt;' Balance Board COG X&lt;/span&gt;&lt;br /&gt;    BalanceBoardY &lt;span style="color: #008000"&gt;' Balance Board COG Y&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; Enum&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;Next, several methods from the &lt;b&gt;EventSource&lt;/b&gt; object need to be overridden:&amp;#160; &lt;b&gt;GetEventData&lt;/b&gt;, &lt;b&gt;IsModifier&lt;/b&gt;, &lt;b&gt;CanModify&lt;/b&gt;, &lt;b&gt;TryGetEventId&lt;/b&gt;, &lt;b&gt;TryGetEventName&lt;/b&gt;, &lt;b&gt;Name&lt;/b&gt;.&amp;#160; The methods do the following:&lt;/p&gt;

&lt;table border="1" cellspacing="0" cellpadding="2" width="400"&gt;&lt;tbody&gt;
    &lt;tr&gt;
      &lt;td valign="top" width="200"&gt;
        &lt;p align="center"&gt;&lt;b&gt;Method/Property&lt;/b&gt;&lt;/p&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="200"&gt;
        &lt;p align="center"&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="200"&gt;GetEventData&lt;/td&gt;

      &lt;td valign="top" width="200"&gt;Unsure at the moment...does not need to be implemented?&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="200"&gt;IsModifier&lt;/td&gt;

      &lt;td valign="top" width="200"&gt;Returns a boolean stating whether the passed in event ID is a modifier (such as the Wiimote.B event above)&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="200"&gt;CanModify&lt;/td&gt;

      &lt;td valign="top" width="200"&gt;Returns a boolean stating whether the current event is allowed as a modifier&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="200"&gt;TryGetEventID&lt;/td&gt;

      &lt;td valign="top" width="200"&gt;Maps a string event name from the bindings file to the integer value in the enumeration above&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="200"&gt;TryGetEventName&lt;/td&gt;

      &lt;td valign="top" width="200"&gt;Maps an integer event ID to the string name in the enumeration above&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="200"&gt;Name (property)&lt;/td&gt;

      &lt;td valign="top" width="200"&gt;Returns the name of the handler which must match the name in the XML file above (Wiimote in this case)&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;The code for these methods is presented below:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// return out value of the passed enum&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; TryGetEventId(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; eventName, &lt;span style="color: #0000ff"&gt;out&lt;/span&gt; &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; eventId)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    eventId = (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)Enum.Parse(&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(WiimoteEvent), eventName);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// return out the string name of the passed in enum value&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; TryGetEventName(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; eventId, &lt;span style="color: #0000ff"&gt;out&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; eventName)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    eventName = ((WiimoteEvent)eventId).ToString();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// unknown&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; EventData GetEventData(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; eventId, EventActivateState state)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;throw&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; NotImplementedException();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// can the event be used as a modifier?&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; IsModifier(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; eventId)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;// yes to all for now&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// can the supplied event be used as a modifier?&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; CanModify(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; eventId, EventKey other)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;// only if it's from us&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; (other.Source == &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// this must match the Source name in the bindings XML file&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; Name&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    get { &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #006080"&gt;&amp;quot;Wiimote&amp;quot;&lt;/span&gt;; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' return out value of the passed enum&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Overrides&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; TryGetEventId(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; eventName &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;String&lt;/span&gt;, &amp;lt;System.Runtime.InteropServices.Out()&amp;gt; &lt;span style="color: #0000ff"&gt;ByRef&lt;/span&gt; eventId &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    eventId = &lt;span style="color: #0000ff"&gt;CInt&lt;/span&gt;(Fix(System.&lt;span style="color: #0000ff"&gt;Enum&lt;/span&gt;.Parse(&lt;span style="color: #0000ff"&gt;GetType&lt;/span&gt;(WiimoteEvent), eventName)))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;True&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' return out the string name of the passed in enum value&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Overrides&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; TryGetEventName(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; eventId &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;, &amp;lt;System.Runtime.InteropServices.Out()&amp;gt; &lt;span style="color: #0000ff"&gt;ByRef&lt;/span&gt; eventName &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;String&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    eventName = (&lt;span style="color: #0000ff"&gt;CType&lt;/span&gt;(eventId, WiimoteEvent)).ToString()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;True&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' unknown&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Overrides&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; GetEventData(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; eventId &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; state &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; EventActivateState) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; EventData&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Throw&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; NotImplementedException()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' can the event be used as a modifier?&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Overrides&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; IsModifier(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; eventId &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;' yes to all for now&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;True&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' can the supplied event be used as a modifier?&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Overrides&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; CanModify(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; eventId &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; other &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; EventKey) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;' only if it's from us&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; (other.Source &lt;span style="color: #0000ff"&gt;Is&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' this must match the Source name in the bindings XML file&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Overrides&lt;/span&gt; &lt;span style="color: #0000ff"&gt;ReadOnly&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Property&lt;/span&gt; Name() &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;String&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Get&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; &lt;span style="color: #006080"&gt;&amp;quot;Wiimote&amp;quot;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Get&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Property&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;With that in place, the constructor can be implemented which will call the base constructor and connect to the Wiimote.&amp;#160; It is assumed you read the Wiimote article above and know how the library works.&lt;/p&gt;

&lt;p&gt;The constructor must take one argument passed from the main from:&amp;#160; an instance of the &lt;b&gt;GlobeControl&lt;/b&gt;'s &lt;b&gt;ActionSystem&lt;/b&gt;.&amp;#160; This just gets passed directly to the parent object's constructor untouched.&amp;#160; The constructor code looks like the following:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; WiimoteEventSource(ActionSystem actionSystem) : &lt;span style="color: #0000ff"&gt;base&lt;/span&gt;(actionSystem)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #008000"&gt;// get all connected Wiimotes&lt;/span&gt;&lt;br /&gt;    WiimoteCollection wc = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; WiimoteCollection();&lt;br /&gt;    wc.FindAllWiimotes();&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #008000"&gt;// setup wiimotes and event handlers&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt;(Wiimote wm &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; wc)&lt;br /&gt;    {&lt;br /&gt;        wm.WiimoteChanged += &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventHandler&amp;lt;WiimoteChangedEventArgs&amp;gt;(OnWiimoteChanged);&lt;br /&gt;        wm.WiimoteExtensionChanged += &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventHandler&amp;lt;WiimoteExtensionChangedEventArgs&amp;gt;(OnWiimoteExtensionChanged);&lt;br /&gt;        wm.Connect();&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: #008000"&gt;// if we don't have an extension, set the report type to IR and accel's only&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(!wm.WiimoteState.Extension &amp;amp;&amp;amp; wm.WiimoteState.ExtensionType != ExtensionType.BalanceBoard)&lt;br /&gt;            wm.SetReportType(InputReport.IRAccel, &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(wm.WiimoteState.ExtensionType == ExtensionType.BalanceBoard)&lt;br /&gt;            _bb = wm;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;br /&gt;            _wm = wm;&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: #008000"&gt;// turn off all LEDs&lt;/span&gt;&lt;br /&gt;        wm.SetLEDs(0x00);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; actionSystem &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; ActionSystem)&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;MyBase&lt;/span&gt;.&lt;span style="color: #0000ff"&gt;New&lt;/span&gt;(actionSystem)&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #008000"&gt;' get all connected Wiimotes&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; wc &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; WiimoteCollection()&lt;br /&gt;    wc.FindAllWiimotes()&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #008000"&gt;' setup wiimotes and event handlers&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;For&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Each&lt;/span&gt; wm &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; Wiimote &lt;span style="color: #0000ff"&gt;In&lt;/span&gt; wc&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;AddHandler&lt;/span&gt; wm.WiimoteChanged, &lt;span style="color: #0000ff"&gt;AddressOf&lt;/span&gt; OnWiimoteChanged&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;AddHandler&lt;/span&gt; wm.WiimoteExtensionChanged, &lt;span style="color: #0000ff"&gt;AddressOf&lt;/span&gt; OnWiimoteExtensionChanged&lt;br /&gt;        wm.Connect()&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: #008000"&gt;' if we don't have an extension, set the report type to IR and accel's only&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;Not&lt;/span&gt; wm.WiimoteState.Extension) &lt;span style="color: #0000ff"&gt;AndAlso&lt;/span&gt; wm.WiimoteState.ExtensionType &amp;lt;&amp;gt; ExtensionType.BalanceBoard &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;br /&gt;            wm.SetReportType(InputReport.IRAccel, &lt;span style="color: #0000ff"&gt;True&lt;/span&gt;)&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; wm.WiimoteState.ExtensionType = ExtensionType.BalanceBoard &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;br /&gt;            _bb = wm&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;Else&lt;/span&gt;&lt;br /&gt;            _wm = wm&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: #008000"&gt;' turn off all LEDs&lt;/span&gt;&lt;br /&gt;        wm.SetLEDs(&amp;amp;H00)&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;Next&lt;/span&gt; wm&lt;br /&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;The &lt;b&gt;OnWiimoteExtensionChanged&lt;/b&gt; method simply sets the report mode for the Wiimote based on whether or not a Nunchuk is inserted as shown:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; OnWiimoteExtensionChanged(&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; sender, WiimoteExtensionChangedEventArgs args)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(_wm == &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;return&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #008000"&gt;// if nunchuk inserted, set the report type to return extension data&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(args.ExtensionType == ExtensionType.Nunchuk &amp;amp;&amp;amp; args.Inserted)&lt;br /&gt;        _wm.SetReportType(InputReport.IRExtensionAccel, &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;);&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;else&lt;/span&gt; &lt;span style="color: #008000"&gt;// in all other cases, set it to the default IR and accel's&lt;/span&gt;&lt;br /&gt;        _wm.SetReportType(InputReport.IRAccel, &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;);&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; OnWiimoteExtensionChanged(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Object&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; args &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; WiimoteExtensionChangedEventArgs)&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; _wm &lt;span style="color: #0000ff"&gt;Is&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Nothing&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #008000"&gt;' if nunchuk inserted, set the report type to return extension data&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; args.ExtensionType = ExtensionType.Nunchuk &lt;span style="color: #0000ff"&gt;AndAlso&lt;/span&gt; args.Inserted &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;br /&gt;        _wm.SetReportType(InputReport.IRExtensionAccel, &lt;span style="color: #0000ff"&gt;True&lt;/span&gt;)&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;Else&lt;/span&gt; &lt;span style="color: #008000"&gt;' in all other cases, set it to the default IR and accel's&lt;/span&gt;&lt;br /&gt;        _wm.SetReportType(InputReport.IRAccel, &lt;span style="color: #0000ff"&gt;True&lt;/span&gt;)&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;The &lt;b&gt;OnWiimoteChanged&lt;/b&gt; event handler is where the Wiimote data is handled and sent off to the VE3D control to reflect the changes.&amp;#160; First, we handle the Balance Board.&amp;#160; If the Balance Board is the controller reporting data, we take the center of gravity values and pass them to VE3D.&amp;#160; This code looks at the appropriate values, determines if they are beyond the specified thresholds for the dead zones, and, if they are, activates the event for that value using the &lt;b&gt;Execute &lt;/b&gt;method.&amp;#160; &lt;b&gt;Execute &lt;/b&gt;is a method in the base &lt;b&gt;EventSource&lt;/b&gt; class.&amp;#160; This method will activate the event specified from the enumeration (which, remember, is contained in the bindings XML file) with the value associated with that event.&amp;#160; An &lt;b&gt;EventData&lt;/b&gt; object of some type must be created and passed to the &lt;b&gt;Execute&lt;/b&gt; method.&amp;#160; There are two &lt;b&gt;EventData&lt;/b&gt; types to know about:&amp;#160; &lt;b&gt;AxisEventData&lt;/b&gt; and &lt;b&gt;ButtonEventData&lt;/b&gt;.&amp;#160; &lt;b&gt;AxisEventData&lt;/b&gt; should be used when an event is activated that will modify the map position in some way.&amp;#160; That is, if the map is being turned, elevation is changing, etc.&amp;#160; &lt;b&gt;ButtonEventData&lt;/b&gt; should be used if the event is a simple toggle like pressing a button down and releasing it.&lt;/p&gt;

&lt;p&gt;The Balance Board code can be seen below:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(ws.ExtensionType == ExtensionType.BalanceBoard &amp;amp;&amp;amp; &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.BalanceBoardEnabled)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;float&lt;/span&gt; x1 = ws.BalanceBoardState.CenterOfGravity.X;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(x1 &amp;gt; Properties.Settings.Default.BBDeadX || x1 &amp;lt; -Properties.Settings.Default.BBDeadX)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)WiimoteEvent.BalanceBoardX), x1 - _zero.X));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;float&lt;/span&gt; y1 = ws.BalanceBoardState.CenterOfGravity.Y;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(y1 &amp;gt; Properties.Settings.Default.BBDeadY || y1 &amp;lt; -Properties.Settings.Default.BBDeadY)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)WiimoteEvent.BalanceBoardY), y1 - _zero.Y));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;VB&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;If&lt;/span&gt; ws.ExtensionType = ExtensionType.BalanceBoard &lt;span style="color: #0000ff"&gt;AndAlso&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.BalanceBoardEnabled &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; x1 &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Single&lt;/span&gt; = ws.BalanceBoardState.CenterOfGravity.X&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; x1 &amp;gt; My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.BBDeadX &lt;span style="color: #0000ff"&gt;OrElse&lt;/span&gt; x1 &amp;lt; -My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.BBDeadX &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.BalanceBoardX))), x1 - _zero.X))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; y1 &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Single&lt;/span&gt; = ws.BalanceBoardState.CenterOfGravity.Y&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; y1 &amp;gt; My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.BBDeadY &lt;span style="color: #0000ff"&gt;OrElse&lt;/span&gt; y1 &amp;lt; -My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.BBDeadY &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.BalanceBoardY))), y1 - _zero.Y))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; If&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Next, let's handle the IR and accelerometer data.&amp;#160; The IR midpoint of the X and Y axes will be used from the &lt;b&gt;WiimoteState&lt;/b&gt; object to activate the &lt;b&gt;IRX&lt;/b&gt; and &lt;b&gt;IRY&lt;/b&gt; events we defined above in the bindings XML file.&amp;#160; The accelerometer X and Y values will be used to activate the &lt;b&gt;AX &lt;/b&gt;and &lt;b&gt;AY&lt;/b&gt; events.&lt;/p&gt;

&lt;p&gt;This snippet assumes that there is a boolean property named &lt;b&gt;UseIR&lt;/b&gt; created in the project to determine whether IR or motion values are used.&amp;#160; Additionally, it assumes there are property settings created which contain values for the X/Y &amp;quot;dead zones&amp;quot; for the IR and accelerometers.&amp;#160; These dead zones are used as a way to only activate the event when the values are pushed beyond the thresholds.&amp;#160; This allows there to be a margin where the user's hand will not be read as movement, allowing the user to not have to worry about keeping a steady hand.&lt;/p&gt;

&lt;p&gt;The application linked above uses the following default values for dead zones:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;NunchukDeadX/Y -&amp;gt; 0.025 &lt;/li&gt;

  &lt;li&gt;WiimoteDeadX/Y -&amp;gt; 0.15 &lt;/li&gt;

  &lt;li&gt;IRDeadX/Y -&amp;gt; 0.1 &lt;/li&gt;

  &lt;li&gt;BBDeadX/Y –&amp;gt; 3 &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// if we're using the IR&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(Properties.Settings.Default.UseIR)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;// and both LEDs are found&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(ws.IRState.Found1 &amp;amp;&amp;amp; ws.IRState.Found2)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;// normalize the midpoints to -0.5 to 0.5 (from 0 to 1.0)&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;float&lt;/span&gt; x = ws.IRState.MidX - 0.5f;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;float&lt;/span&gt; y = ws.IRState.MidY - 0.5f;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;// if we're beyond the thresholds, activate the events&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(x &amp;gt; Properties.Settings.Default.IRDeadX || x &amp;lt; -Properties.Settings.Default.IRDeadX)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)WiimoteEvent.IRX), x));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(y &amp;gt; Properties.Settings.Default.IRDeadY || y &amp;lt; -Properties.Settings.Default.IRDeadY)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)WiimoteEvent.IRY), y));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;// save the last IR settings...these get used if we go beyond the range of the IRs.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;// in that case, the last used positions will be used until the Wiimote comes back in range&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;._lastIRX = x;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;._lastIRY = y;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;else&lt;/span&gt; &lt;span style="color: #008000"&gt;// one or both LEDs aren't seen&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;// activate events based on the last known positions&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;._lastIRX &amp;gt; Properties.Settings.Default.IRDeadX || &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;._lastIRX &amp;lt; -Properties.Settings.Default.IRDeadX)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)WiimoteEvent.IRX), &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;._lastIRX));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;._lastIRY &amp;gt; Properties.Settings.Default.IRDeadY || &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;._lastIRY &amp;lt; -Properties.Settings.Default.IRDeadY)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)WiimoteEvent.IRY), &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;._lastIRY));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;else&lt;/span&gt; &lt;span style="color: #008000"&gt;// we're using motion controls&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;// activate the events based on the accelerometer values&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(ws.AccelState.X &amp;gt; Properties.Settings.Default.WiimoteDeadX || ws.AccelState.X &amp;lt; -Properties.Settings.Default.WiimoteDeadX)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)WiimoteEvent.AX), ws.AccelState.X));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(ws.AccelState.Y &amp;gt; Properties.Settings.Default.WiimoteDeadY || ws.AccelState.Y &amp;lt; -Properties.Settings.Default.WiimoteDeadY)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)WiimoteEvent.AY), ws.AccelState.Y));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' if we're using the IR&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;If&lt;/span&gt; My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.UseIR &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;' and both LEDs are found&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; ws.IRState.Found1 &lt;span style="color: #0000ff"&gt;AndAlso&lt;/span&gt; ws.IRState.Found2 &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;' normalize the midpoints to -0.5 to 0.5 (from 0 to 1.0)&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; x &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Single&lt;/span&gt; = ws.IRState.MidX - 0.5f&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; y &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Single&lt;/span&gt; = ws.IRState.MidY - 0.5f&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;' if we're beyond the thresholds, activate the events&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; x &amp;gt; My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.IRDeadX &lt;span style="color: #0000ff"&gt;OrElse&lt;/span&gt; x &amp;lt; -My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.IRDeadX &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.IRX))), x))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; y &amp;gt; My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.IRDeadY &lt;span style="color: #0000ff"&gt;OrElse&lt;/span&gt; y &amp;lt; -My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.IRDeadY &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.IRY))), y))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;' save the last IR settings...these get used if we go beyond the range of the IRs.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;' in that case, the last used positions will be used until the Wiimote comes back in range&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;._lastIRX = x&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;._lastIRY = y&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Else&lt;/span&gt; &lt;span style="color: #008000"&gt;' one or both LEDs aren't seen&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;' activate events based on the last known positions&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;._lastIRX &amp;gt; My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.IRDeadX &lt;span style="color: #0000ff"&gt;OrElse&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;._lastIRX &amp;lt; -My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.IRDeadX &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.IRX))), &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;._lastIRX))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;._lastIRY &amp;gt; My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.IRDeadY &lt;span style="color: #0000ff"&gt;OrElse&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;._lastIRY &amp;lt; -My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.IRDeadY &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.IRY))), &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;._lastIRY))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Else&lt;/span&gt; &lt;span style="color: #008000"&gt;' we're using motion controls&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;' activate the events based on the accelerometer values&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; ws.AccelState.X &amp;gt; My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.WiimoteDeadX &lt;span style="color: #0000ff"&gt;OrElse&lt;/span&gt; ws.AccelState.X &amp;lt; -My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.WiimoteDeadX &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.AX))), ws.AccelState.X))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; ws.AccelState.Y &amp;gt; My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.WiimoteDeadY &lt;span style="color: #0000ff"&gt;OrElse&lt;/span&gt; ws.AccelState.Y &amp;lt; -My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.WiimoteDeadY &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.AY))), ws.AccelState.Y))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; If&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Next, the nunchuk values need to be read and the associated events activated.&amp;#160; This is done as follows:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// if the nunchuk is connected&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(ws.Extension &amp;amp;&amp;amp; ws.ExtensionType == ExtensionType.Nunchuk)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;// activate the nunchuk-based events&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(ws.NunchukState.X &amp;gt; Properties.Settings.Default.NunchukDeadX || ws.NunchukState.X &amp;lt; -Properties.Settings.Default.NunchukDeadX)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)WiimoteEvent.NunchukX), ws.NunchukState.X));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(ws.NunchukState.Y &amp;gt; Properties.Settings.Default.NunchukDeadY || ws.NunchukState.Y &amp;lt; -Properties.Settings.Default.NunchukDeadY)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)WiimoteEvent.NunchukY), ws.NunchukState.Y));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(ws.NunchukState.C)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)WiimoteEvent.NunchukC), 1.0f));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(ws.NunchukState.Z)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)WiimoteEvent.NunchukZ), 1.0f));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' if the nunchuk is connected&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;If&lt;/span&gt; ws.Extension &lt;span style="color: #0000ff"&gt;AndAlso&lt;/span&gt; ws.ExtensionType = ExtensionType.Nunchuk &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;' activate the nunchuk-based events&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; ws.NunchukState.X &amp;gt; My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.NunchukDeadX &lt;span style="color: #0000ff"&gt;OrElse&lt;/span&gt; ws.NunchukState.X &amp;lt; -My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.NunchukDeadX &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.NunchukX))), ws.NunchukState.X))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; ws.NunchukState.Y &amp;gt; My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.NunchukDeadY &lt;span style="color: #0000ff"&gt;OrElse&lt;/span&gt; ws.NunchukState.Y &amp;lt; -My.Settings.&lt;span style="color: #0000ff"&gt;Default&lt;/span&gt;.NunchukDeadY &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.NunchukY))), ws.NunchukState.Y))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; ws.NunchukState.C &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.NunchukC))), 1.0f))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; ws.NunchukState.Z &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.NunchukZ))), 1.0f))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; If&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Finally, the button events need to be activated.&amp;#160; A helper method which will check the current button state will be used for determining which button of all the Wiimote buttons is pressed.&amp;#160; For those that are, the appropriate event is activated with a call to &lt;b&gt;Execute&lt;/b&gt;.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; HandleButton(WiimoteEvent we, &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; buttonState, &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; lastButtonState)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(buttonState == lastButtonState)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;return&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(buttonState)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ButtonEventData(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)we), EventActivateState.Activate));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ButtonEventData(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)we), EventActivateState.Deactivate));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// handle all the Wiimote buttons&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.Up, ws.ButtonState.Up, _lastBS.Up);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.Down, ws.ButtonState.Down, _lastBS.Down);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.Left, ws.ButtonState.Left, _lastBS.Left);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.Right, ws.ButtonState.Right, _lastBS.Right);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.A, ws.ButtonState.A, _lastBS.A);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.B, ws.ButtonState.B, _lastBS.B);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.Minus, ws.ButtonState.Minus, _lastBS.Minus);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.Home, ws.ButtonState.Home, _lastBS.Home);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.Plus, ws.ButtonState.Plus, _lastBS.Plus);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.One, ws.ButtonState.One, _lastBS.One);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.Two, ws.ButtonState.Two, _lastBS.Two);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;...&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// save off the current button state for next time&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_lastBS = ws.ButtonState;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_lastNunchuk = ws.NunchukState;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; HandleButton(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; we &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; WiimoteEvent, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; buttonState &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; lastButtonState &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; buttonState = lastButtonState &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Else&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; buttonState &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; ButtonEventData(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;CInt&lt;/span&gt;(Fix(we))), EventActivateState.Activate))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Else&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; ButtonEventData(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;CInt&lt;/span&gt;(Fix(we))), EventActivateState.Deactivate))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;...&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' handle all the Wiimote buttons&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.Up, ws.ButtonState.Up, _lastBS.Up)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.Down, ws.ButtonState.Down, _lastBS.Down)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.Left, ws.ButtonState.Left, _lastBS.Left)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.Right, ws.ButtonState.Right, _lastBS.Right)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.A, ws.ButtonState.A, _lastBS.A)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.B, ws.ButtonState.B, _lastBS.B)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.Minus, ws.ButtonState.Minus, _lastBS.Minus)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.Home, ws.ButtonState.Home, _lastBS.Home)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.Plus, ws.ButtonState.Plus, _lastBS.Plus)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.One, ws.ButtonState.One, _lastBS.One)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;HandleButton(WiimoteEvent.Two, ws.ButtonState.Two, _lastBS.Two)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' save off the current button state for next time&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_lastBS = ws.ButtonState&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_lastNunchuk = ws.NunchukState&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;And, the current button values are stored away to check on the next event so button events are only fired once.&lt;/p&gt;

&lt;p&gt;Now that the event source object is written, it needs to be hooked up to the &lt;b&gt;GlobeControl&lt;/b&gt; so it can be used.&amp;#160; This can be done by creating an instance of the &lt;b&gt;WiimoteEventSource&lt;/b&gt; object, passing in the VE3D's &lt;b&gt;ActionSystem &lt;/b&gt;from the &lt;b&gt;BindingsManager&lt;/b&gt; object.&amp;#160; Then, the event source instance is passed to the &lt;b&gt;ActionSystem&lt;/b&gt;'s &lt;b&gt;EventSourceManager&lt;/b&gt; and registered using the &lt;b&gt;RegisterEventSource&lt;/b&gt; method.&amp;#160; Event sources should re registered before the control is added to the form.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// wiimote events&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; WiimoteEventSource _wiimoteEventSource;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;...&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// create a new instance of the Wiimote event handler&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_wiimoteEventSource = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; WiimoteEventSource(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.globeControl.Host.BindingsManager.ActionSystem, &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// register it in the event source list&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.ActionSystem.EventSourceManager.RegisterEventSource(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;._wiimoteEventSource);&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' wiimote events&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _wiimoteEventSource &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; WiimoteEventSource&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;...&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' create a new instance of the Wiimote event handler&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_wiimoteEventSource = &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; WiimoteEventSource(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;.globeControl.Host.BindingsManager.ActionSystem, &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' register it in the event source list&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.ActionSystem.EventSourceManager.RegisterEventSource(&lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;._wiimoteEventSource)&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;h4&gt;Actions and the BindingManager&lt;/h4&gt;

&lt;p&gt;Our binding list contains several action types that are not defined by the default VE3D actions.&amp;#160; These actions and their handlers must be registered with the VE3D control.&amp;#160; The actions can be registered as follows in the &lt;strong&gt;FirstFrameRendered&lt;/strong&gt; event handler:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;BindingsSource bs = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; BindingsSource(&lt;span style="color: #0000ff"&gt;base&lt;/span&gt;.GetType());&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;Locations&amp;quot;&lt;/span&gt;, LocationsHandler);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;LocationsMove&amp;quot;&lt;/span&gt;, LocationsMoveHandler);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;ToggleVR920&amp;quot;&lt;/span&gt;, ToggleVR920Handler);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;VR920SetZero&amp;quot;&lt;/span&gt;, VR920SetZero);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;BalanceBoardSetZero&amp;quot;&lt;/span&gt;, BalanceBoardSetZero);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;ToggleBalanceBoard&amp;quot;&lt;/span&gt;, ToggleBalanceBoardHandler);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;FullScreen&amp;quot;&lt;/span&gt;, FullScreenHandler);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;ToggleVR920Stereo&amp;quot;&lt;/span&gt;, ToggleVR920Stereo);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;VR920SetEyeDistance&amp;quot;&lt;/span&gt;, VR920SetEyeDistance);&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;BindingsSource bs = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; BindingsSource(base.&lt;span style="color: #0000ff"&gt;GetType&lt;/span&gt;());&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;Locations&amp;quot;&lt;/span&gt;, LocationsHandler);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;LocationsMove&amp;quot;&lt;/span&gt;, LocationsMoveHandler);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;ToggleVR920&amp;quot;&lt;/span&gt;, ToggleVR920Handler);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;VR920SetZero&amp;quot;&lt;/span&gt;, VR920SetZero);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;BalanceBoardSetZero&amp;quot;&lt;/span&gt;, BalanceBoardSetZero);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;ToggleBalanceBoard&amp;quot;&lt;/span&gt;, ToggleBalanceBoardHandler);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;FullScreen&amp;quot;&lt;/span&gt;, FullScreenHandler);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;ToggleVR920Stereo&amp;quot;&lt;/span&gt;, ToggleVR920Stereo);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.BindingsManager.RegisterAction(bs, &lt;span style="color: #006080"&gt;&amp;quot;VR920SetEyeDistance&amp;quot;&lt;/span&gt;, VR920SetEyeDistance);&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;With the actions registered and handlers associated with them, the actual handlers need to be implemented.&amp;#160; All event handler methods must be of the following signature:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;

&lt;div&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;bool&lt;/span&gt; EventHandler(EventData cause)&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;

&lt;div&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: rgb(0,0,255)"&gt;Public&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Function&lt;/span&gt; EventHandler(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; cause &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; EventData) &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; Boolean&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Let’s take a look at the &lt;strong&gt;FullScreen &lt;/strong&gt;binding which simply turns the status bar at the bottom of the window on and off:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; height: 146px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; FullScreenHandler(EventData eventData)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(eventData.Activate)&lt;br /&gt;        BeginInvoke(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; UIEventHandlerDelegate(FullScreen), eventData);&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;VB&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; FullScreenHandler(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; eventData &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; EventData) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; eventData.Activate &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;br /&gt;        BeginInvoke(&lt;span style="color: #0000ff"&gt;New&lt;/span&gt; UIEventHandlerDelegate(&lt;span style="color: #0000ff"&gt;AddressOf&lt;/span&gt; FullScreen), eventData)&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;True&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; FullScreen(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; eventData &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; EventData)&lt;br /&gt;    statusStrip1.Visible = &lt;span style="color: #0000ff"&gt;Not&lt;/span&gt; statusStrip1.Visible&lt;br /&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;Because we are in the VE3D thread when this handler is called, we need to use &lt;strong&gt;BeginInvoke&lt;/strong&gt; to call the real method on the UI thread.&lt;/p&gt;

&lt;p&gt;Be sure to check the source code for the full demo linked above for the location handler methods.&amp;#160; I omitted them here since it is just more of the same type of code above.&lt;/p&gt;

&lt;h3&gt;&lt;/h3&gt;

&lt;h3&gt;&lt;/h3&gt;

&lt;h3&gt;&lt;b&gt;VR920 Head Tracker&lt;/b&gt;&lt;/h3&gt;

&lt;p&gt;Once the VR920 glasses and driver are installed on your PC, getting the data required from the glasses is quite easy.&amp;#160; We are going to create an object named &lt;strong&gt;VR920Tracker&lt;/strong&gt; which will pull data from the device and send it to VE3D.&lt;/p&gt;

&lt;p&gt;First we need to setup a few P/Invoke signatures to talk to the glasses as follows:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[DllImport(&lt;span style="color: #006080"&gt;&amp;quot;IWEARDRV.dll&amp;quot;&lt;/span&gt;, SetLastError = &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;, CharSet = CharSet.&lt;span style="color: #0000ff"&gt;Auto&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; extern int IWROpenTracker();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[DllImport(&lt;span style="color: #006080"&gt;&amp;quot;IWEARDRV.dll&amp;quot;&lt;/span&gt;, SetLastError = &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;, CharSet = CharSet.&lt;span style="color: #0000ff"&gt;Auto&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; extern void IWRZeroSet();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[DllImport(&lt;span style="color: #006080"&gt;&amp;quot;IWEARDRV.dll&amp;quot;&lt;/span&gt;, SetLastError = &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;, CharSet = CharSet.&lt;span style="color: #0000ff"&gt;Auto&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; extern int IWRGetTracking(out int yaw, out int pitch, out int roll);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;const&lt;/span&gt; int ERROR_SUCCESS  = 0;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;VB&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;DllImport(&lt;span style="color: #006080"&gt;&amp;quot;IWEARDRV.dll&amp;quot;&lt;/span&gt;, SetLastError := &lt;span style="color: #0000ff"&gt;True&lt;/span&gt;, CharSet := CharSet.&lt;span style="color: #0000ff"&gt;Auto&lt;/span&gt;)&amp;gt; _&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Shared&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; IWROpenTracker() &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;DllImport(&lt;span style="color: #006080"&gt;&amp;quot;IWEARDRV.dll&amp;quot;&lt;/span&gt;, SetLastError := &lt;span style="color: #0000ff"&gt;True&lt;/span&gt;, CharSet := CharSet.&lt;span style="color: #0000ff"&gt;Auto&lt;/span&gt;)&amp;gt; _&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Shared&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; IWRZeroSet()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;DllImport(&lt;span style="color: #006080"&gt;&amp;quot;IWEARDRV.dll&amp;quot;&lt;/span&gt;, SetLastError := &lt;span style="color: #0000ff"&gt;True&lt;/span&gt;, CharSet := CharSet.&lt;span style="color: #0000ff"&gt;Auto&lt;/span&gt;)&amp;gt; _&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Shared&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; IWRGetTracking(&amp;lt;System.Runtime.InteropServices.Out()&amp;gt; &lt;span style="color: #0000ff"&gt;ByRef&lt;/span&gt; yaw &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;, &amp;lt;System.Runtime.InteropServices.Out()&amp;gt; &lt;span style="color: #0000ff"&gt;ByRef&lt;/span&gt; pitch &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;, &amp;lt;System.Runtime.InteropServices.Out()&amp;gt; &lt;span style="color: #0000ff"&gt;ByRef&lt;/span&gt; roll &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;const&lt;/span&gt; int ERROR_SUCCESS  = 0;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;These 3 methods will allows to open access to the glasses, set its zero position, and get the roll, pitch and yaw information from the sensors.&lt;/p&gt;

&lt;p&gt;In the constructor for this object, we will open a handle to the glasses and startup a timer that will poll the glasses at a regular interval to get the sensor data as shown below:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;const&lt;/span&gt; int TimerPeriod = 1;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; MainForm _mainForm;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; Timer _timer;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; VR920Tracker(MainForm mainForm)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _mainForm = mainForm;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    int openResult = IWROpenTracker();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(openResult != ERROR_SUCCESS)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;throw&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ApplicationException(&lt;span style="color: #006080"&gt;&amp;quot;Could not connect to VR920: &amp;quot;&lt;/span&gt; + openResult);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _timer = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Timer(VR920Poller, null, Timeout.Infinite, TimerPeriod);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;VB&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Const&lt;/span&gt; TimerPeriod &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt; = 1&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _mainForm &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; MainForm&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _timer &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; Timer&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; mainForm &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; MainForm)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _mainForm = mainForm&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; openResult &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt; = IWROpenTracker()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; openResult &amp;lt;&amp;gt; ERROR_SUCCESS &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Throw&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; ApplicationException(&lt;span style="color: #006080"&gt;&amp;quot;Could not connect to VR920: &amp;quot;&lt;/span&gt; &amp;amp; openResult)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _timer = &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; Timer(&lt;span style="color: #0000ff"&gt;AddressOf&lt;/span&gt; VR920Poller, &lt;span style="color: #0000ff"&gt;Nothing&lt;/span&gt;, Timeout.Infinite, TimerPeriod)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;The &lt;strong&gt;VR920Poller&lt;/strong&gt; method referenced above will be called at a specific interval and read the values from the glasses as shown below:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;// collection of values &lt;span style="color: #0000ff"&gt;for&lt;/span&gt; averaging&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; List&amp;lt;&lt;span style="color: #0000ff"&gt;double&lt;/span&gt;&amp;gt; _yawValues = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; List&amp;lt;&lt;span style="color: #0000ff"&gt;double&lt;/span&gt;&amp;gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; List&amp;lt;&lt;span style="color: #0000ff"&gt;double&lt;/span&gt;&amp;gt; _rollValues = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; List&amp;lt;&lt;span style="color: #0000ff"&gt;double&lt;/span&gt;&amp;gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; List&amp;lt;&lt;span style="color: #0000ff"&gt;double&lt;/span&gt;&amp;gt; _pitchValues = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; List&amp;lt;&lt;span style="color: #0000ff"&gt;double&lt;/span&gt;&amp;gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;// last calculated values&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; _lastYaw;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; _lastPitch;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; _lastRoll;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; void VR920Poller(&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; state)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    lock(this)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        int yaw, pitch, roll;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        int result = IWRGetTracking(out yaw, out pitch, out roll);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(result != ERROR_SUCCESS)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;throw&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ApplicationException(&lt;span style="color: #006080"&gt;&amp;quot;Could not get VR920 tracking information: &amp;quot;&lt;/span&gt; + result);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        _yawValues.Add(VR920ToRadians(yaw));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        _rollValues.Add(VR920ToRadians(roll));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        _pitchValues.Add(VR920ToRadians(pitch));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(_yawValues.Count == 5)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; y = Average(_yawValues, _lastYaw);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(Math.Abs(y - _lastYaw) &amp;gt; 0.026)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                _lastYaw = y;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; p = Average(_pitchValues, _lastPitch);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(Math.Abs(p - _lastPitch) &amp;gt; 0.017)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                _lastPitch = p;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _lastRoll = Average(_rollValues, _lastRoll);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _yawValues.Clear();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _pitchValues.Clear();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _rollValues.Clear();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            RollPitchYaw rollPitchYaw = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; RollPitchYaw(_lastRoll, _lastPitch, _lastYaw);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _mainForm.SetRollPitchYaw(rollPitchYaw);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _mainForm.lblAxes.Text = VR920ToDegrees(yaw) + &lt;span style="color: #006080"&gt;&amp;quot;, &amp;quot;&lt;/span&gt; + VR920ToDegrees(pitch) + &lt;span style="color: #006080"&gt;&amp;quot;, &amp;quot;&lt;/span&gt; + VR920ToDegrees(roll);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; Average(List&amp;lt;&lt;span style="color: #0000ff"&gt;double&lt;/span&gt;&amp;gt; values, &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; last)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; total = 0;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    foreach(&lt;span style="color: #0000ff"&gt;double&lt;/span&gt; value &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; values)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        total += value;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    total += last;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; total / (values.Count+1);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; VR920ToRadians(int vr920Value)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; (vr920Value * .00549) * (Math.PI/180);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; VR920ToDegrees(int vr920Value)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; (vr920Value * .00549);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;VB&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' collection of values for averaging&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _yawValues &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; List(Of &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;) = &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; List(Of &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;)()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _rollValues &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; List(Of &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;) = &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; List(Of &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;)()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _pitchValues &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; List(Of &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;) = &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; List(Of &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;)()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;' last calculated values&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _lastYaw &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _lastPitch &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _lastRoll &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; VR920Poller(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; state &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Object&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;SyncLock&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Me&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; yaw, pitch, roll &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; result &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt; = IWRGetTracking(yaw, pitch, roll)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; result &amp;lt;&amp;gt; ERROR_SUCCESS &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;Throw&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; ApplicationException(&lt;span style="color: #006080"&gt;&amp;quot;Could not get VR920 tracking information: &amp;quot;&lt;/span&gt; &amp;amp; result)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        _yawValues.Add(VR920ToRadians(yaw))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        _rollValues.Add(VR920ToRadians(roll))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        _pitchValues.Add(VR920ToRadians(pitch))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; _yawValues.Count = 5 &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; y &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt; = Average(_yawValues, _lastYaw)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; Math.Abs(y - _lastYaw) &amp;gt; 0.026 &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                _lastYaw = y&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; p &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt; = Average(_pitchValues, _lastPitch)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; Math.Abs(p - _lastPitch) &amp;gt; 0.017 &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                _lastPitch = p&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _lastRoll = Average(_rollValues, _lastRoll)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _yawValues.Clear()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _pitchValues.Clear()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _rollValues.Clear()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; rollPitchYaw &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; RollPitchYaw(_lastRoll, _lastPitch, _lastYaw)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _mainForm.SetRollPitchYaw(rollPitchYaw)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _mainForm.lblAxes.Text = VR920ToDegrees(yaw) &amp;amp; &lt;span style="color: #006080"&gt;&amp;quot;, &amp;quot;&lt;/span&gt; &amp;amp; VR920ToDegrees(pitch) &amp;amp; &lt;span style="color: #006080"&gt;&amp;quot;, &amp;quot;&lt;/span&gt; &amp;amp; VR920ToDegrees(roll)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;SyncLock&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; Average(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; values &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; List(Of &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;), &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; last &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; total &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt; = 0&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;For&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Each&lt;/span&gt; value &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt; &lt;span style="color: #0000ff"&gt;In&lt;/span&gt; values&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        total += value&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Next&lt;/span&gt; value&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    total += last&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; total / (values.Count+1)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; VR920ToRadians(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; vr920Value &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; (vr920Value *.00549) * (Math.PI/180)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; VR920ToDegrees(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; vr920Value &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Integer&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; (vr920Value *.00549)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; Function&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;This chunk calls the &lt;strong&gt;IWRGetTracking&lt;/strong&gt; method and tosses the results in 3 lists for roll, pitch and yaw.&amp;#160; then, when the list has 5 members in it, the values are averaged and, if that resulting values is past a certain threshold, the values are passed back to the &lt;strong&gt;MainForm&lt;/strong&gt;’s &lt;strong&gt;SetRollPitchYaw&lt;/strong&gt; method as shown below:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; _lastYaw;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; SetRollPitchYaw(RollPitchYaw rollPitchYaw)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(!_initialized || _globeControl.IsDisposed || (_globeControl.Host) == &lt;span style="color: #0000ff"&gt;null&lt;/span&gt; || _globeControl.Host.CameraControllers.Current == &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;return&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; y = ((_globeControl.Host.CameraControllers.Current &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; ActionCameraController).LastReportedViewpoint.LocalOrientation.Yaw - _lastYaw) + rollPitchYaw.Yaw;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    RollPitchYaw rpw = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; RollPitchYaw(rollPitchYaw.Roll, rollPitchYaw.Pitch, y);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    (_globeControl.Host.CameraControllers.Current &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; ActionCameraController).LastReportedViewpoint.LocalOrientation.RollPitchYaw = rpw;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _lastYaw = rollPitchYaw.Yaw;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;VB&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _lastYaw &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; SetRollPitchYaw(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; rollPitchYaw &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; RollPitchYaw)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;Not&lt;/span&gt; _initialized) &lt;span style="color: #0000ff"&gt;OrElse&lt;/span&gt; _globeControl.IsDisposed &lt;span style="color: #0000ff"&gt;OrElse&lt;/span&gt; (_globeControl.Host) &lt;span style="color: #0000ff"&gt;Is&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Nothing&lt;/span&gt; &lt;span style="color: #0000ff"&gt;OrElse&lt;/span&gt; _globeControl.Host.CameraControllers.Current &lt;span style="color: #0000ff"&gt;Is&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Nothing&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; y &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt; = ((&lt;span style="color: #0000ff"&gt;TryCast&lt;/span&gt;(_globeControl.Host.CameraControllers.Current, ActionCameraController)).LastReportedViewpoint.LocalOrientation.Yaw - _lastYaw) + rollPitchYaw.Yaw&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt; rpw &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; RollPitchYaw(rollPitchYaw.Roll, rollPitchYaw.Pitch, y)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;TryCast&lt;/span&gt;(_globeControl.Host.CameraControllers.Current, ActionCameraController).LastReportedViewpoint.LocalOrientation.RollPitchYaw = rpw&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _lastYaw = rollPitchYaw.Yaw&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;This method takes the roll, pitch and yaw values provided and applies them to the current &lt;strong&gt;CameraController&lt;/strong&gt; used by VE3D (which, by default, is an &lt;strong&gt;ActionCameraController&lt;/strong&gt;).&lt;/p&gt;

&lt;p&gt;So, this code ultimately takes the roll, yaw and pitch of the user’s head and translates that directly to the roll, yaw and pitch of the camera in VE3D providing an accurate, real-time view into the VE3D world.&lt;/p&gt;

&lt;h3&gt;&lt;/h3&gt;

&lt;h1&gt;&lt;/h1&gt;

&lt;h3&gt;Stereoscopic Images&lt;/h3&gt;

&lt;p&gt;The final piece of the puzzle is drawing frames to the VR920 glasses in such a way that the final view to the user will be three dimensional.&amp;#160; This works similarly to those &lt;a href="http://www.magiceye.com/3dfun/stwkdisp.shtml" target="_blank"&gt;Magic Eye puzzles&lt;/a&gt; you may have seen.&amp;#160; Essentially, for every frame, we want to take the current VE3D camera position and move it several units to the left, render that to the left eye of the glasses, and then move the camera several units to the right and render that to the right eye of the glasses.&amp;#160; To handle this we,&amp;#160; can create an object named &lt;strong&gt;VR920StereoStep&lt;/strong&gt; which derives from the &lt;strong&gt;Step&lt;/strong&gt; class provided by VE3D and add this to the &lt;strong&gt;StepManager&lt;/strong&gt;.&amp;#160; When this is done, the &lt;strong&gt;VR920StereoStep&lt;/strong&gt; will be called at the end of every frame drawn by VE3D.&lt;/p&gt;

&lt;p&gt;As with the &lt;strong&gt;VR920Tracker&lt;/strong&gt; class, we will need to setup a few P/Invoke method signatures to talk to the stereo driver as shown below:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[DllImport(&lt;span style="color: #006080"&gt;&amp;quot;iWrstDrv.dll&amp;quot;&lt;/span&gt;, EntryPoint = &lt;span style="color: #006080"&gt;&amp;quot;IWRSTEREO_Open&amp;quot;&lt;/span&gt;, SetLastError=&lt;span style="color: #0000ff"&gt;true&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;extern&lt;/span&gt; IntPtr OpenStereo();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[DllImport(&lt;span style="color: #006080"&gt;&amp;quot;iWrstDrv.dll&amp;quot;&lt;/span&gt;, EntryPoint = &lt;span style="color: #006080"&gt;&amp;quot;IWRSTEREO_SetStereo&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;extern&lt;/span&gt; Boolean SetStereoEnabled(IntPtr handle, Boolean enabled);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[DllImport(&lt;span style="color: #006080"&gt;&amp;quot;iWrstDrv.dll&amp;quot;&lt;/span&gt;, EntryPoint = &lt;span style="color: #006080"&gt;&amp;quot;IWRSTEREO_SetLR&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;extern&lt;/span&gt; Boolean SetStereoLR(IntPtr handle, Boolean eye);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[DllImport(&lt;span style="color: #006080"&gt;&amp;quot;iWrstDrv.dll&amp;quot;&lt;/span&gt;, EntryPoint = &lt;span style="color: #006080"&gt;&amp;quot;IWRSTEREO_WaitForAck&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;extern&lt;/span&gt; Byte WaitForOpenFrame(IntPtr handle, Boolean eye);&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;VB&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;DllImport(&lt;span style="color: #006080"&gt;&amp;quot;iWrstDrv.dll&amp;quot;&lt;/span&gt;, EntryPoint := &lt;span style="color: #006080"&gt;&amp;quot;IWRSTEREO_Open&amp;quot;&lt;/span&gt;, SetLastError:=&lt;span style="color: #0000ff"&gt;True&lt;/span&gt;)&amp;gt; _&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Shared&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; OpenStereo() &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; IntPtr&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;DllImport(&lt;span style="color: #006080"&gt;&amp;quot;iWrstDrv.dll&amp;quot;&lt;/span&gt;, EntryPoint := &lt;span style="color: #006080"&gt;&amp;quot;IWRSTEREO_SetLR&amp;quot;&lt;/span&gt;)&amp;gt; _&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Shared&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; SetStereoLR(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; handle &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; IntPtr, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; eye &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;DllImport(&lt;span style="color: #006080"&gt;&amp;quot;iWrstDrv.dll&amp;quot;&lt;/span&gt;, EntryPoint := &lt;span style="color: #006080"&gt;&amp;quot;IWRSTEREO_SetStereo&amp;quot;&lt;/span&gt;)&amp;gt; _&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Shared&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; SetStereoEnabled(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; handle &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; IntPtr, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; enabled &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;DllImport(&lt;span style="color: #006080"&gt;&amp;quot;iWrstDrv.dll&amp;quot;&lt;/span&gt;, EntryPoint := &lt;span style="color: #006080"&gt;&amp;quot;IWRSTEREO_WaitForAck&amp;quot;&lt;/span&gt;)&amp;gt; _&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Shared&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt; WaitForOpenFrame(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; handle &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; IntPtr, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; eye &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Byte&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Function&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;In the constructor for this object, we will open a handle to the stereo driver and turn on the stereo functionality of the glasses as shown below:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;readonly&lt;/span&gt; IntPtr INVALID_FILE_HANDLE = (IntPtr)(-1);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; IntPtr _hStereo = INVALID_FILE_HANDLE;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; Host _host;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; bool _stereoEnabled = &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; EyeDistance { &lt;span style="color: #0000ff"&gt;get&lt;/span&gt;; &lt;span style="color: #0000ff"&gt;set&lt;/span&gt;; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; VR920StereoStep(StepManager manager, Host host) : base(manager)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    EyeDistance = 10;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _host = host;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _hStereo = OpenStereo();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(_hStereo != INVALID_FILE_HANDLE)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        SetStereoEnabled(_hStereo, &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        _stereoEnabled = &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;VB&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Shared&lt;/span&gt; &lt;span style="color: #0000ff"&gt;ReadOnly&lt;/span&gt; INVALID_FILE_HANDLE &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; IntPtr = &lt;span style="color: #0000ff"&gt;CType&lt;/span&gt;(-1, IntPtr)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _hStereo &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; IntPtr = INVALID_FILE_HANDLE&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _host &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; Host&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _stereoEnabled &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt; = &lt;span style="color: #0000ff"&gt;True&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; privateEyeDistance &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Property&lt;/span&gt; EyeDistance() &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Get&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Return&lt;/span&gt; privateEyeDistance&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Get&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Set&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; value &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Double&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        privateEyeDistance = value&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Set&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Property&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; &lt;span style="color: #0000ff"&gt;New&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; manager &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; StepManager, &lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; host &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; Host)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;MyBase&lt;/span&gt;.&lt;span style="color: #0000ff"&gt;New&lt;/span&gt;(manager)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    EyeDistance = 10&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _host = host&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _hStereo = OpenStereo()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; _hStereo &amp;lt;&amp;gt; INVALID_FILE_HANDLE &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        SetStereoEnabled(_hStereo, &lt;span style="color: #0000ff"&gt;True&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;Else&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        _stereoEnabled = &lt;span style="color: #0000ff"&gt;False&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Next, we need to override the &lt;strong&gt;OnExecute&lt;/strong&gt; method provided by the base &lt;strong&gt;Step &lt;/strong&gt;class as shown below:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; _rightEye = &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; Vector3D _position;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; OnExecute(SceneState state)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(_hStereo != INVALID_FILE_HANDLE &amp;amp;&amp;amp; _stereoEnabled &amp;amp;&amp;amp; (_host.CameraControllers.Current &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; ActionCameraController).LastReportedViewpoint != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt;(!_rightEye)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _position = (_host.CameraControllers.Current &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; ActionCameraController).LastReportedViewpoint.Position.Vector;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            (_host.CameraControllers.Current &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; ActionCameraController).LastReportedViewpoint.Position.Vector = _position + &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Vector3D(-EyeDistance, 0, 0);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _position = (_host.CameraControllers.Current &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; ActionCameraController).LastReportedViewpoint.Position.Vector;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            (_host.CameraControllers.Current &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; ActionCameraController).LastReportedViewpoint.Position.Vector = _position + &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Vector3D(EyeDistance, 0, 0);;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        SetStereoLR(_hStereo, _rightEye);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        WaitForOpenFrame(_hStereo, _rightEye);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        _rightEye = !_rightEye;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;VB&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _rightEye &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Boolean&lt;/span&gt; = &lt;span style="color: #0000ff"&gt;True&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _position &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; Vector3D&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Overrides&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Sub&lt;/span&gt; OnExecute(&lt;span style="color: #0000ff"&gt;ByVal&lt;/span&gt; state &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; SceneState)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; _hStereo &amp;lt;&amp;gt; INVALID_FILE_HANDLE &lt;span style="color: #0000ff"&gt;AndAlso&lt;/span&gt; _stereoEnabled &lt;span style="color: #0000ff"&gt;AndAlso&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;TryCast&lt;/span&gt;(_host.CameraControllers.Current, ActionCameraController)).LastReportedViewpoint IsNot &lt;span style="color: #0000ff"&gt;Nothing&lt;/span&gt; &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;If&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;Not&lt;/span&gt; _rightEye) &lt;span style="color: #0000ff"&gt;Then&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _position = (&lt;span style="color: #0000ff"&gt;TryCast&lt;/span&gt;(_host.CameraControllers.Current, ActionCameraController)).LastReportedViewpoint.Position.Vector&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;TryCast&lt;/span&gt;(_host.CameraControllers.Current, ActionCameraController).LastReportedViewpoint.Position.Vector = _position + &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; Vector3D(-EyeDistance, 0, 0)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;Else&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            _position = (&lt;span style="color: #0000ff"&gt;TryCast&lt;/span&gt;(_host.CameraControllers.Current, ActionCameraController)).LastReportedViewpoint.Position.Vector&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            &lt;span style="color: #0000ff"&gt;TryCast&lt;/span&gt;(_host.CameraControllers.Current, ActionCameraController).LastReportedViewpoint.Position.Vector = _position + &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; Vector3D(EyeDistance, 0, 0)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        SetStereoLR(_hStereo, _rightEye)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        WaitForOpenFrame(_hStereo, _rightEye)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        _rightEye = &lt;span style="color: #0000ff"&gt;Not&lt;/span&gt; _rightEye&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;End&lt;/span&gt; &lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;OnExecute&lt;/strong&gt; will be called at the end of each VE3D frame rendered.&amp;#160; In this method, we obtain the current position of the VE3D camera and then set its position several units to the left or right (- or + &lt;strong&gt;EyeDistance&lt;/strong&gt;).&amp;#160; &lt;strong&gt;SetStereoLR&lt;/strong&gt; from the VR920 API is called, setting the appropriate eye to be active (left = false, right = true).&amp;#160; Then &lt;strong&gt;WaitForOpenFrame&lt;/strong&gt; is called which will pause the action long enough for the glasses to draw the entire frame to eye to avoid image tearing.&amp;#160; Essentially, this call “sits and spins” at this location until the glasses report back that the entire frame is drawn in the proper eye and that we can continue on drawing the opposite eye for the next frame.&amp;#160; Finally, the &lt;strong&gt;_rightEye&lt;/strong&gt; member variable is togged to the opposite value, so the next time through this method the opposite eye is drawn.&lt;/p&gt;

&lt;p&gt;With this class in place, back in our &lt;strong&gt;MainForm&lt;/strong&gt; in the &lt;strong&gt;FirstFrameRendered&lt;/strong&gt; event handler, we can instantiate the object and add it to the &lt;strong&gt;StepManager&lt;/strong&gt; as shown below:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; VR920StereoStep _vr920StereoStep;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_vr920StereoStep = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; VR920StereoStep(_globeControl.Host.RenderEngine.StepManager, _globeControl.Host);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.RenderEngine.StepManager.Add(_vr920StereoStep);&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;VB&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;Private&lt;/span&gt; _vr920StereoStep &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; VR920StereoStep&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_vr920StereoStep = &lt;span style="color: #0000ff"&gt;New&lt;/span&gt; VR920StereoStep(_globeControl.Host.RenderEngine.StepManager, _globeControl.Host)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;_globeControl.Host.RenderEngine.StepManager.Add(_vr920StereoStep)&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h3&gt;&lt;b&gt;Running the Application&lt;/b&gt;&lt;/h3&gt;

&lt;p&gt;To run the demo, do the following:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Copy &lt;b&gt;BindingsWiimote.xml&lt;/b&gt; to the appropriate directory listed above &lt;/li&gt;

  &lt;li&gt;Pair the Wiimote and Balance Board to the computer.&amp;#160; See the &lt;a href="http://blogs.msdn.com/coding4fun/archive/2007/03/14/1879033.aspx" target="_blank" mce_href="http://blogs.msdn.com/coding4fun/archive/2007/03/14/1879033.aspx"&gt;WiimoteLib article&lt;/a&gt; for more information on how to do that &lt;/li&gt;

  &lt;li&gt;Run the executable &lt;/li&gt;

  &lt;li&gt;Stand on the Balance Board &lt;/li&gt;

  &lt;li&gt;Put on the glasses &lt;/li&gt;

  &lt;li&gt;Zero both the Balance Board and glasses &lt;/li&gt;

  &lt;li&gt;Toggle everything on or off at will &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Controls&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;F1 – Set VR920 glasses to zero position &lt;/li&gt;

  &lt;li&gt;F2 – Set Balance Board to zero position &lt;/li&gt;

  &lt;li&gt;F3 – Toggle stereo mode on and off &lt;/li&gt;

  &lt;li&gt;Wiimote 1 or B – Toggle Balance Board on or off &lt;/li&gt;

  &lt;li&gt;Wiimote 2 or V – Toggle VR920 head tracking on or off &lt;/li&gt;

  &lt;li&gt;F – Toggle full-screen on or off &lt;/li&gt;

  &lt;li&gt;Nunchuk joystick X/Y – Strafe/Move &lt;/li&gt;

  &lt;li&gt;Nunchuk C/Z buttons – Raise/lower altitude &lt;/li&gt;

  &lt;li&gt;Wiimote A – Open location menu/Select location (note that if a new location is selected, the Balance Board is turned off and must be re-enabled after “landing” &lt;/li&gt;

  &lt;li&gt;Wiimote Dpad Up/Down – Move through List &lt;/li&gt;

  &lt;li&gt;Balance Board – Lean your body left or right to turn in the VE3D environment &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;&lt;b&gt;Conclusion&lt;/b&gt;&lt;/h3&gt;

&lt;p&gt;With the above code, we have created a very interesting interface for Virtual Earth 3D.&amp;#160; The demo and source code linked above contain a few more features and bindings which enhance the application a bit more.&amp;#160; Be sure to give the full demo a try and check out the full source code for a few more implementation details.&lt;/p&gt;

&lt;h3&gt;&lt;/h3&gt;

&lt;h3&gt;Additional Information&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href="http://www.vr920.com/" target="_blank"&gt;Vuzix VR920 Glasses&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://blogs.msdn.com/coding4fun/archive/2007/03/14/1879033.aspx" target="_blank" mce_href="http://blogs.msdn.com/coding4fun/archive/2007/03/14/1879033.aspx"&gt;Managed Library for Nintendo's Wiimote&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://heptazane.spaces.live.com/default.aspx" target="_blank" mce_href="http://heptazane.spaces.live.com/default.aspx"&gt;Heptazane's Blog&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://virtualearth.spaces.live.com/" target="_blank" mce_href="http://virtualearth.spaces.live.com/"&gt;Virtual Earth Blog&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://blogs.msdn.com/virtualearth/" target="_blank" mce_href="http://blogs.msdn.com/virtualearth/"&gt;Virtual Earth Developer's Blog&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Bio&lt;/h3&gt;

&lt;p&gt;Brian is a &lt;a href="https://mvp.support.microsoft.com/profile/Brian.Peek"&gt;Microsoft C# MVP&lt;/a&gt; who has been actively developing in .NET since its early betas in 2000, and who has been developing solutions using Microsoft technologies and platforms for even longer. Along with .NET, Brian is particularly skilled in the languages of C, C++ and assembly language for a variety of CPUs. He is also well-versed in a wide variety of technologies including web development, document imaging, GIS, graphics, game development, and hardware interfacing. Brian has a strong background in developing applications for the health-care industry, as well as developing solutions for portable devices, such as tablet PCs and PDAs. Additionally, Brian has co-authored the book &amp;quot;&lt;a href="http://www.amazon.com/dp/0735711410/"&gt;Debugging ASP.NET&lt;/a&gt;&amp;quot; published by New Riders, and is currently co-authoring a book titled &amp;quot;&lt;a href="http://www.amazon.com/exec/obidos/ASIN/0596520743/brianpcom-20"&gt;Coding4Fun: 10 .NET Programming Projects for Wiimote, YouTube, World of Warcraft, and More&lt;/a&gt;&amp;quot; to be published by &lt;a href="http://www.oreilly.com/"&gt;O'Reilly&lt;/a&gt; in December 2008. Brian is also an author for MSDN's &lt;a href="http://blogs.msdn.com/coding4fun/"&gt;Coding4Fun&lt;/a&gt; website.&amp;#160; You can reach Brian via vis website at &lt;a href="http://www.brianpeek.com/"&gt;http://www.brianpeek.com/&lt;/a&gt; .&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9068804" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/coding4fun/archive/tags/mash+up/default.aspx">mash up</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/hardware+miscellaneous/default.aspx">hardware miscellaneous</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/windows/default.aspx">windows</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/hardware/default.aspx">hardware</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/hardwarehacks/default.aspx">hardwarehacks</category></item><item><title>Want more cowbell? Yes please!</title><link>http://blogs.msdn.com/coding4fun/archive/2008/11/10/9059259.aspx</link><pubDate>Tue, 11 Nov 2008 07:49:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9059259</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/9059259.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=9059259</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=9059259</wfw:comment><description>
&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;TABLE class="" cellSpacing=0 cellPadding=2 width=470 border=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=105&gt;&lt;STRONG&gt;Author:&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=363&gt;Clint Rutkas: &lt;A href="http://twitter.com/crutkas" mce_href="http://twitter.com/crutkas"&gt;twitter&lt;/A&gt;, &lt;A href="http://betterthaneveryone.com/" mce_href="http://betterthaneveryone.com/"&gt;blog&lt;/A&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=105&gt;&lt;STRONG&gt;Download:&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=363&gt;&lt;A class="" href="http://peacelovecode.com/code/cowbell/cowbell.zip" mce_href="http://peacelovecode.com/code/cowbell/cowbell.zip"&gt;http://peacelovecode.com/code/cowbell/cowbell.zip&lt;/A&gt; &lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=105&gt;&lt;STRONG&gt;Software:&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=363&gt;&lt;A href="http://msdn.microsoft.com/en-us/evalcenter/bb655861.aspx" mce_href="http://msdn.microsoft.com/en-us/evalcenter/bb655861.aspx"&gt;Visual Studio 2008 Standard&lt;/A&gt; or better (Trial Download) &lt;BR&gt;&lt;A href="http://www.microsoft.com/downloads/details.aspx?familyid=06111A3A-A651-4745-88EF-3D48091A390B&amp;amp;displaylang=en" mce_href="http://www.microsoft.com/downloads/details.aspx?familyid=06111A3A-A651-4745-88EF-3D48091A390B&amp;amp;displaylang=en"&gt;Windows Mobile 6.0 SDK &lt;BR&gt;Windows Mobile 6.1 Emulator Images (Optional)&lt;/A&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=105&gt;&lt;STRONG&gt;Hardware:&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=363&gt;Windows Mobile Pro (Optional)&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=105&gt;&lt;STRONG&gt;Time Required:&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=363&gt;2 hours&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=105&gt;&lt;STRONG&gt;Cost:&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD class="" vAlign=top width=363&gt;Free-ish&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P&gt;After playing way too much guitar hero, bought a guitar only to quickly realize I’m horrible.&amp;nbsp; Asking my friends, I decided to adopt the world’s hardest instrument to play, that’s right, the cow bell.&amp;nbsp; It takes years to master and I decide to turn my cell phone, an HTC Touch Diamond&amp;nbsp; into this magical instrument too.&lt;/P&gt;
&lt;P&gt;This is a fairly straight forward application.&amp;nbsp; We’ll touch on altering the volume of a cell phone along with interacting with a touch screen and how to do a deploy for Windows Mobile so you can have a cowbell band of your own.&amp;nbsp; The application will also properly resize an image to match the screen proportions, however you’ll have to download the source code for that.&lt;/P&gt;
&lt;P&gt;You’ll see while getting your system up and working with the emulator may take a few additional steps, it will code mostly like a typical windows application for this instance.&lt;/P&gt;
&lt;P&gt;The source code shown isn’t everything you need to get the application running, please download the source code to get the rest.&amp;nbsp; The link is at the top of the article.&lt;/P&gt;
&lt;H2&gt;Getting up and running with baby steps&lt;/H2&gt;
&lt;P&gt;&lt;A href="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image.png" mce_href="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image.png"&gt;&lt;IMG title=image style="DISPLAY: inline; MARGIN: 0px 0px 0px 10px" height=351 alt=image src="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image_thumb.png" width=229 align=right border=0 mce_src="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image_thumb.png"&gt;&lt;/A&gt;After you get Visual Studio 2008 up and running, if you don’t have the Windows Mobile 6.0 SDK, please download it and install it.&amp;nbsp; The link is at the top of this article.&amp;nbsp; Visual Studio 2008 only comes with the Windows mobile 5.0 SDK.&lt;/P&gt;
&lt;P&gt;On the right is a picture of the emulator in one of styling forms.&amp;nbsp; On top of just being able to test on an emulator, you can do a direct deploy to your cell phone.&amp;nbsp; Now a Windows Mobile Professional phone can do this directly, however a Windows Mobile Standard (non-touch screen) does require a few extra steps.&amp;nbsp; I blogged about these steps over on my blog.&amp;nbsp; After your phone is properly configured, all you need to do is change your target deployment.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image_3.png" mce_href="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image_3.png"&gt;&lt;IMG title=image style="DISPLAY: inline" height=155 alt=image src="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image_thumb_3.png" width=378 border=0 mce_src="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image_thumb_3.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;I highlighted the device deploy instead of the emulator.&lt;/P&gt;
&lt;H2&gt;Smart Device Creation&lt;/H2&gt;
&lt;P&gt;To create a new solution we go to File –&amp;gt; New –&amp;gt; Project.&amp;nbsp; We’ll select the language of our choice (c# for me) then go to “Smart Device”&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.betterthaneveryone.com/images/WindowsMobileDevelopmentGettingStartedS_223A/image.png" mce_href="http://www.betterthaneveryone.com/images/WindowsMobileDevelopmentGettingStartedS_223A/image.png"&gt;&lt;IMG title=image height=313 alt=image src="http://www.betterthaneveryone.com/images/WindowsMobileDevelopmentGettingStartedS_223A/image_thumb.png" width=500 border=0 mce_src="http://www.betterthaneveryone.com/images/WindowsMobileDevelopmentGettingStartedS_223A/image_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Easy so far, right?&amp;nbsp; Next comes selecting the framework along with your target platform.&amp;nbsp; Select “Windows Mobile 6 Professional SDK” then click OK and you’re good to start.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image_4.png" mce_href="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image_4.png"&gt;&lt;IMG title=image style="DISPLAY: inline" height=243 alt=image src="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image_thumb_4.png" width=500 border=0 mce_src="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image_thumb_4.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;H2&gt;Altering Volume&lt;/H2&gt;
&lt;P&gt;To alter your volume currently in the compact framework, you have to do some pinvokes to call native API calls.&amp;nbsp; This is scary for some but don’t fret.&amp;nbsp; There is a site called &lt;A href="http://pinvoke.net/" mce_href="http://pinvoke.net"&gt;pinvoke.net&lt;/A&gt; that makes doing these calls simple as pie.&amp;nbsp; We’ll create a new class called Audio to encapsulate all audio functions.&amp;nbsp; This includes playing a file and altering the volume.&amp;nbsp; First we’ll do the simple ability to play an audio file.&amp;nbsp; Since we’ll be grabbing our data from the resources, we’ll use a &lt;STRONG&gt;MemoryStream&lt;/STRONG&gt; object convert the bytes to a stream so we can read it in.&amp;nbsp; We’ll need to include the &lt;STRONG&gt;System.Media &lt;/STRONG&gt;namespace to be able to play audio.&amp;nbsp; To do the pinvokes, we’ll include the &lt;STRONG&gt;System.Runtime.InteropServices.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;C#&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;readonly&lt;/SPAN&gt; SoundPlayer sp;

    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; Audio(&lt;SPAN class=kwrd&gt;byte&lt;/SPAN&gt;[] AudioResource)
    {
        sp = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; SoundPlayer(&lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; MemoryStream(AudioResource));
        sp.Load();
    }

    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; Play()
    {
        sp.Play();
    }

    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; PlayLoop()
    {
        sp.PlayLooping();
    }

    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; Stop()
    {
        sp.Stop();
    }&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;VB&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;    &lt;SPAN class=kwrd&gt;Private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;ReadOnly&lt;/SPAN&gt; sp &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; SoundPlayer

    &lt;SPAN class=kwrd&gt;Public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Sub&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;New&lt;/SPAN&gt;(&lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; AudioResource &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Byte&lt;/SPAN&gt;())
        sp = &lt;SPAN class=kwrd&gt;New&lt;/SPAN&gt; SoundPlayer(&lt;SPAN class=kwrd&gt;New&lt;/SPAN&gt; MemoryStream(AudioResource))
        sp.Load()
    &lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Sub&lt;/SPAN&gt;

    &lt;SPAN class=kwrd&gt;Public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Sub&lt;/SPAN&gt; Play()
        sp.Play()
    &lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Sub&lt;/SPAN&gt;

    &lt;SPAN class=kwrd&gt;Public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Sub&lt;/SPAN&gt; PlayLoop()
        sp.PlayLooping()
    &lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Sub&lt;/SPAN&gt;

    &lt;SPAN class=kwrd&gt;Public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Sub&lt;/SPAN&gt; [&lt;SPAN class=kwrd&gt;Stop&lt;/SPAN&gt;]()
        sp.[&lt;SPAN class=kwrd&gt;Stop&lt;/SPAN&gt;]()
    &lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; Sub&lt;/PRE&gt;
&lt;P&gt;And in the application, we’ll call the audio file like the following:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;c#&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;    &lt;SPAN class=kwrd&gt;private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;readonly&lt;/SPAN&gt; Audio audio = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Audio(Properties.Resources.CowBellAudio);&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;VB&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;    &lt;SPAN class=kwrd&gt;Private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;ReadOnly&lt;/SPAN&gt; audio &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;New&lt;/SPAN&gt; Audio(My.Resources.CowBellAudio)&lt;/PRE&gt;
&lt;P&gt;Next we’ll add in the ability to alter the volume with the pinvokes.&amp;nbsp; Sadly, I’m not sure why the set volume numbers act as they do.&amp;nbsp; After searching the internet, these numbers kept appearing.&amp;nbsp; In a perfect world, I would have liked to see 0 to 100 or something like that but it isn’t so.&amp;nbsp; We’ll create get / sets in the wrapper to make a more seamless wrapper object to hide the pinvoke calls.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;C#&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;    [DllImport(&lt;SPAN class=str&gt;"coredll.dll"&lt;/SPAN&gt;)]
    &lt;SPAN class=kwrd&gt;private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;static&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;extern&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; waveOutGetVolume(IntPtr hwo, &lt;SPAN class=kwrd&gt;out&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;uint&lt;/SPAN&gt; dwVolume);

    [DllImport(&lt;SPAN class=str&gt;"coredll.dll"&lt;/SPAN&gt;)]
    &lt;SPAN class=kwrd&gt;private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;static&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;extern&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; waveOutSetVolume(IntPtr hwo, &lt;SPAN class=kwrd&gt;uint&lt;/SPAN&gt; dwVolume);

    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;static&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;uint&lt;/SPAN&gt; Volume
    {
        get
        {
            &lt;SPAN class=kwrd&gt;uint&lt;/SPAN&gt; _volume;
            waveOutGetVolume(IntPtr.Zero, &lt;SPAN class=kwrd&gt;out&lt;/SPAN&gt; _volume);
            &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; _volume;
        }

        set
        {
            waveOutSetVolume(IntPtr.Zero, &lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt;);
        }
    }

    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;enum&lt;/SPAN&gt; Volumes
    {
        OFF = 0,
        LOW = 858993459,
        NORMAL = 1717986918,
        MEDIUM = -1717986919,
        HIGH = -858993460,
        VERY_HIGH = -1
    }&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;VB&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;    &lt;SPAN class=kwrd&gt;Declare&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Function&lt;/SPAN&gt; waveOutGetVolume &lt;SPAN class=kwrd&gt;Lib&lt;/SPAN&gt; &lt;SPAN class=str&gt;"coredll.dll"&lt;/SPAN&gt; (&lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; uDeviceID &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Integer&lt;/SPAN&gt;, &lt;SPAN class=kwrd&gt;ByRef&lt;/SPAN&gt; lpdwVolume &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Integer&lt;/SPAN&gt;) &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Integer&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;Declare&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Function&lt;/SPAN&gt; waveOutSetVolume &lt;SPAN class=kwrd&gt;Lib&lt;/SPAN&gt; &lt;SPAN class=str&gt;"coredll.dll"&lt;/SPAN&gt; (&lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; device &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; IntPtr, &lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; volume &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Integer&lt;/SPAN&gt;) &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Integer&lt;/SPAN&gt;

    &lt;SPAN class=kwrd&gt;Public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Shared&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Property&lt;/SPAN&gt; AudioVolume() &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Integer&lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;Get&lt;/SPAN&gt;
            &lt;SPAN class=kwrd&gt;Dim&lt;/SPAN&gt; _volume &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Integer&lt;/SPAN&gt;
            waveOutGetVolume(IntPtr.Zero, _volume)
            &lt;SPAN class=kwrd&gt;Return&lt;/SPAN&gt; _volume
        &lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Get&lt;/SPAN&gt;

        &lt;SPAN class=kwrd&gt;Set&lt;/SPAN&gt;(&lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; value &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Integer&lt;/SPAN&gt;)
            waveOutSetVolume(IntPtr.Zero, value)
        &lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Set&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Property&lt;/SPAN&gt;

    &lt;SPAN class=kwrd&gt;Public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Enum&lt;/SPAN&gt; Volumes
        OFF = 0
        LOW = 858993459
        NORMAL = 1717986918
        MEDIUM = -1717986919
        HIGH = -858993460
        VERY_HIGH = -1
    &lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; Enum&lt;/PRE&gt;
&lt;H2&gt;Creating the Cowbell&lt;/H2&gt;
&lt;H3&gt;Pretty Pictures and sounds&lt;/H3&gt;
&lt;P&gt;This is a cowbell application so we need an actual cowbell on it.&amp;nbsp; After a quick image search, I found the cowbell image on the internet and the X is from the &lt;A href="http://www.famfamfam.com/lab/icons/silk/" mce_href="http://www.famfamfam.com/lab/icons/silk/"&gt;Famfamfam Silk icon collection&lt;/A&gt;.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;We’ll want to embed these images to make deployment easier and have everything self-contained so we’ll use the resource in the project’s property tab.&amp;nbsp; To reach this, you go to &lt;STRONG&gt;Project-&amp;gt;Properties &lt;/STRONG&gt;or right click on your project and at the bottom, there is the Properties menu option.&lt;/P&gt;
&lt;P&gt;In here, we’ll want to use the Images section along with the audio section.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image_5.png" mce_href="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image_5.png"&gt;&lt;IMG title=image style="DISPLAY: inline" height=178 alt=image src="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image_thumb_5.png" width=200 border=0 mce_src="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image_thumb_5.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;When you select the section you want, click the &lt;STRONG&gt;Add Resource&lt;/STRONG&gt; button and track down the file you need.&amp;nbsp; Referencing these resources is pretty straight forward now but each language has a slightly different way to do it.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;C#&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;    Properties.Resources.cowBellImage;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;VB&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;    My.Resources.cowBellImage&lt;/PRE&gt;
&lt;P&gt;Easy no?&lt;/P&gt;
&lt;H3&gt;Items on the form&lt;/H3&gt;
&lt;P&gt;We’ll want to turn off some elements on the form to maximize the cowbell.&amp;nbsp; We’ll set the &lt;STRONG&gt;WindowState&lt;/STRONG&gt; to Maximum, &lt;STRONG&gt;TopMost&lt;/STRONG&gt; to True, &lt;STRONG&gt;MinimizeBox&lt;/STRONG&gt; to False and &lt;STRONG&gt;FormBorder&lt;/STRONG&gt; to None.&lt;/P&gt;
&lt;P&gt;We’ll drag on two picture boxes on the form naming them &lt;STRONG&gt;picCowbell &lt;/STRONG&gt;and &lt;STRONG&gt;picClose&lt;/STRONG&gt;.&amp;nbsp; We’ll set the background to both elements to be transparent.&amp;nbsp; We’ll also want to double click on each picture boxes to create a Click event.&amp;nbsp; For the &lt;STRONG&gt;picClose &lt;/STRONG&gt;element, we’ll add in the &lt;STRONG&gt;Close()&lt;/STRONG&gt; method to shut down the application.&lt;/P&gt;
&lt;P&gt;We’ll also create a MouseDown event on the picCowbell.&amp;nbsp; Here we’ll determine how loud to play then play the sound.&amp;nbsp; We’ll create the Audio object during the form creation so it is already loaded into memory and will only be created once.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;C#&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;readonly&lt;/SPAN&gt; Audio audio = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Audio(Properties.Resources.CowBellAudio);
&lt;SPAN class=kwrd&gt;private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; picCowbell_MouseDown(&lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; sender, MouseEventArgs e)
{
    Audio.Volumes &lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt;;
    &lt;SPAN class=kwrd&gt;switch&lt;/SPAN&gt; ((&lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt;)Math.Round((e.Y / (Height * 1.0)) * 5))
    {
        &lt;SPAN class=rem&gt;//case 0: // implied with default;&lt;/SPAN&gt;
        &lt;SPAN class=rem&gt;//case 1:&lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;default&lt;/SPAN&gt;:
            &lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt; = Audio.Volumes.LOW;
            &lt;SPAN class=kwrd&gt;break&lt;/SPAN&gt;;
        &lt;SPAN class=kwrd&gt;case&lt;/SPAN&gt; 2:
            &lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt; = Audio.Volumes.NORMAL;
            &lt;SPAN class=kwrd&gt;break&lt;/SPAN&gt;;
        &lt;SPAN class=kwrd&gt;case&lt;/SPAN&gt; 3:
            &lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt; = Audio.Volumes.MEDIUM;
            &lt;SPAN class=kwrd&gt;break&lt;/SPAN&gt;;
        &lt;SPAN class=kwrd&gt;case&lt;/SPAN&gt; 4:
            &lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt; = Audio.Volumes.HIGH;
            &lt;SPAN class=kwrd&gt;break&lt;/SPAN&gt;;
        &lt;SPAN class=kwrd&gt;case&lt;/SPAN&gt; 5:
            &lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt; = Audio.Volumes.VERY_HIGH;
            &lt;SPAN class=kwrd&gt;break&lt;/SPAN&gt;;
    }

    &lt;SPAN class=rem&gt;// no need to take the performance hit of changing the volume&lt;/SPAN&gt;
    &lt;SPAN class=rem&gt;// if the values aren't different&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt;( oldValue != &lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt;)
    {
        Audio.Volume = (&lt;SPAN class=kwrd&gt;uint&lt;/SPAN&gt;) &lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt;;
        oldValue = &lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt;;
    }
    audio.Play();
}&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;VB&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;Private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;ReadOnly&lt;/SPAN&gt; audio &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;New&lt;/SPAN&gt; Audio(My.Resources.CowBellAudio)
&lt;SPAN class=kwrd&gt;Private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Sub&lt;/SPAN&gt; picCowbell_MouseDown(&lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; sender &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; System.&lt;SPAN class=kwrd&gt;Object&lt;/SPAN&gt;, &lt;SPAN class=kwrd&gt;ByVal&lt;/SPAN&gt; e &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; System.Windows.Forms.MouseEventArgs)
    &lt;SPAN class=kwrd&gt;Dim&lt;/SPAN&gt; value &lt;SPAN class=kwrd&gt;As&lt;/SPAN&gt; Audio.Volumes
    &lt;SPAN class=kwrd&gt;Select&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Case&lt;/SPAN&gt; Convert.ToInt32(Math.Round((e.Y / (Height * 1)) * 5))
        &lt;SPAN class=kwrd&gt;Case&lt;/SPAN&gt; 2
            value = audio.Volumes.NORMAL
            &lt;SPAN class=kwrd&gt;Exit&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Select&lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;Case&lt;/SPAN&gt; 3
            value = audio.Volumes.MEDIUM
            &lt;SPAN class=kwrd&gt;Exit&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Select&lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;Case&lt;/SPAN&gt; 4
            value = audio.Volumes.HIGH
            &lt;SPAN class=kwrd&gt;Exit&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Select&lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;Case&lt;/SPAN&gt; 5
            value = audio.Volumes.VERY_HIGH
            &lt;SPAN class=kwrd&gt;Exit&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Select&lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;Case&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Else&lt;/SPAN&gt;
            &lt;SPAN class=rem&gt;'case 0: // implied with default;&lt;/SPAN&gt;
            &lt;SPAN class=rem&gt;'case 1:&lt;/SPAN&gt;
            value = audio.Volumes.LOW
            &lt;SPAN class=kwrd&gt;Exit&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Select&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;Select&lt;/SPAN&gt;

    &lt;SPAN class=rem&gt;' no need to take the performance hit of changing the volume&lt;/SPAN&gt;
    &lt;SPAN class=rem&gt;' if the values aren't different&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;If&lt;/SPAN&gt; oldValue &amp;lt;&amp;gt; value &lt;SPAN class=kwrd&gt;Then&lt;/SPAN&gt;
        audio.AudioVolume = Convert.ToInt32(value)
        oldValue = value
    &lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;If&lt;/SPAN&gt;
    audio.Play()
&lt;SPAN class=kwrd&gt;End&lt;/SPAN&gt; Sub&lt;/PRE&gt;
&lt;H2&gt;Hailing a CAB for deployment&lt;/H2&gt;
&lt;P&gt;We’ll right click on the solution in the solution explorer or we can go to File-&amp;gt;New-&amp;gt;Project.&amp;nbsp; If you do the file menu route, you’ll have a screen that is slightly different than mine.&amp;nbsp; At the bottom you’ll have a drop down menu where you’ll want to change it from “Create a new solution” to “Add to Solution”.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.betterthaneveryone.com/images/DeployingafinishedapplicationtoaWindowsM_9DFA/image.png" mce_href="http://www.betterthaneveryone.com/images/DeployingafinishedapplicationtoaWindowsM_9DFA/image.png"&gt;&lt;IMG title=image style="DISPLAY: inline" height=298 alt=image src="http://www.betterthaneveryone.com/images/DeployingafinishedapplicationtoaWindowsM_9DFA/image_thumb.png" width=500 border=0 mce_src="http://www.betterthaneveryone.com/images/DeployingafinishedapplicationtoaWindowsM_9DFA/image_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Since I want a CAB install, I’ll go to the “Other Project Types” then to “Setup and Deployment” and select a Smart Device CAB Project”.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From there, right click on “Application Folder” and go to “Add”.&amp;nbsp; Select “Primary Output” and hit OK.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.betterthaneveryone.com/images/DeployingafinishedapplicationtoaWindowsM_9DFA/image_3.png" mce_href="http://www.betterthaneveryone.com/images/DeployingafinishedapplicationtoaWindowsM_9DFA/image_3.png"&gt;&lt;IMG title=image style="DISPLAY: inline" height=435 alt=image src="http://www.betterthaneveryone.com/images/DeployingafinishedapplicationtoaWindowsM_9DFA/image_thumb_3.png" width=377 border=0 mce_src="http://www.betterthaneveryone.com/images/DeployingafinishedapplicationtoaWindowsM_9DFA/image_thumb_3.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;So with the output added in now, we’ll need to do some more magic.&amp;nbsp; In the “File System” window, we’ll right-click on “File System on Target Machine” and go “Add Special Folder” then to “Start Menu Folder”.&lt;/P&gt;
&lt;P&gt;Now that we have our start menu, we’ll go back to the “Application Menu” and right click on the “Primary output from Cowbell”.&amp;nbsp; Select “Create Shortcut” and drag that shortcut to your start menu folder.&amp;nbsp; I suggest you rename it too.&lt;/P&gt;
&lt;P&gt;Then you can build it, drag the CAB over and install on your device.&lt;/P&gt;
&lt;H2&gt;Rocking out&lt;/H2&gt;
&lt;P&gt;To download the application’s full source code, please download it from &lt;A class="" href="http://peacelovecode.com/code/cowbell/cowbell.zip" mce_href="http://peacelovecode.com/code/cowbell/cowbell.zip"&gt;http://peacelovecode.com/code/cowbell/cowbell.zip&lt;/A&gt; &lt;/TD&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image14.png" mce_href="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image14.png"&gt;&lt;IMG title=image style="DISPLAY: inline; MARGIN-LEFT: 0px; MARGIN-RIGHT: 0px" height=334 alt=image src="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image14_thumb.png" width=240 border=0 mce_src="http://www.coding4fun.net/images/Wantmorecowbell_9C36/image14_thumb.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;H2&gt;About the Author&lt;/H2&gt;
&lt;P&gt;Clint Rutkas works for Microsoft and has created a few cool projects in the past like a Disco Dance Floor, an automated bartender system and a self-balancing skateboard.&amp;nbsp; His blog is &lt;A href="http://betterthaneveryone.com/" mce_href="http://BetterThanEveryone.com"&gt;http://BetterThanEveryone.com&lt;/A&gt; where he posts about what crazy application idea he is working on next.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9059259" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/coding4fun/archive/tags/hardware/default.aspx">hardware</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/windows+mobile/default.aspx">windows mobile</category></item><item><title>BlueBoss - Bluetooth Proximity Detection</title><link>http://blogs.msdn.com/coding4fun/archive/2008/06/26/8658548.aspx</link><pubDate>Fri, 27 Jun 2008 01:09:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8658548</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>12</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/8658548.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=8658548</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=8658548</wfw:comment><description>&lt;h3&gt;Summary:&lt;/h3&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt; Bluetooth is now found in a variety of devices and enable the user to use wireless accessories.&amp;#160; The Bluetooth protocol allows a user to “discover” any device that is in proximity to your Bluetooth radio.&amp;#160; Why not see who is in proximity to you?&amp;#160; Why not have the presence of a device execute programs or alert you?&lt;/p&gt;  &lt;p&gt;Andy Konkol – &lt;u&gt;&lt;a href="http://copyandwaste.com/"&gt;http://copyandwaste.com&lt;/a&gt;&lt;/u&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Hardware:&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;Bluetooth radio (USB dongle)&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;SMA Female Jack&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;SMA male to N-male pigtail&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;2.4 GHz antenna (with N-female connector)&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Software:&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;&lt;u&gt;&lt;a href="http://www.microsoft.com/express/samples/c4fdevkit/default.aspx"&gt;Coding4fun Developer Kit&lt;/a&gt;&lt;/u&gt;&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;u&gt;&lt;a href="http://www.codeproject.com/KB/miscctrl/RobMisNotifyWindow.aspx"&gt;Robert Misiak's Notify Window&lt;/a&gt;&lt;/u&gt;&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Download:&lt;/strong&gt; &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;&lt;a href="http://www.codeplex.com/blueboss/Release/ProjectReleases.aspx?ReleaseId=14662"&gt;Source / Binary Download&lt;/a&gt;&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;u&gt;&lt;/u&gt;&lt;/p&gt;  &lt;h3&gt;&lt;strong&gt;Bluetooth and Hardware:&lt;/strong&gt;&lt;/h3&gt;  &lt;br /&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;Bluetooth was designed for devices to communicate wirelessly over short distances.&amp;#160; However, with a very simple hardware modification you can extend the range of your Bluetooth radio with standard 2.4ghz antennas used in wireless networking (802.11 a/b/g). &lt;/p&gt;  &lt;p&gt;Modifying Bluetooth dongles to accept external antennas is documented all over the Internet.&amp;#160; In principle it is very easy: find the antenna lead and solder on a connector/antenna.&amp;#160; I purchased a very cheap Bluetooth USB dongle on eBay and opened the casing.&amp;#160; After finding the antenna trace on the circuit board I soldered on a SMA Female connector to it.&amp;#160; After soldering the antenna jack in place I slipped a 3 inch chunk of heatshrink and heated it to cover the exposed circuit board.&amp;#160; Now I had a Bluetooth radio that accepts external antennas. Adding an antenna simply increases the range of your radio, allowing you to “see” devices from a farther distance. &lt;/p&gt;  &lt;p&gt;To connect an external antenna to the dongle I needed to use a connector converter called a pigtail.&amp;#160; I used a SMA male to N-male pigtail.&amp;#160; I connected one end of the pigtail to my dongle and the other to an omni-directional 9dbi panel antenna that had an N-female connector.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.coding4fun.net/images/BlueBoss_F144/IMG_20701.jpg"&gt;&lt;img title="IMG_2070[1]" height="180" alt="IMG_2070[1]" src="http://www.coding4fun.net/images/BlueBoss_F144/IMG_20701_thumb.jpg" width="240" border="0" /&gt;&lt;/a&gt; &lt;a href="http://www.coding4fun.net/images/BlueBoss_F144/IMG_20711.jpg"&gt;&lt;img title="IMG_2071[1]" height="180" alt="IMG_2071[1]" src="http://www.coding4fun.net/images/BlueBoss_F144/IMG_20711_thumb.jpg" width="240" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h3&gt;&lt;strong&gt;Software:&lt;/strong&gt;&lt;/h3&gt;  &lt;br /&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;To take advantage of my newly modified hardware I needed to download the Coding4Fun Toolkit.&amp;#160; Included in the toolkit is an API for Bluetooth devices.&amp;#160; This API allows you to do a wide variety of things with your Bluetooth radio but I focused on two methods from the ServiceAndDeviceDiscovery library: DiscoverAllDevices and DiscoverDeviceByName. &lt;/p&gt;  &lt;p&gt;DiscoverAllDevices allows you to “scan” the airwaves on the 2.4 GHz band and report back what devices your radio sees. &lt;/p&gt;  &lt;p&gt;DiscoverDeviceByName allows you to scan for a particular device with a specified name and report back if it is present or not.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;i&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; DevicePresent()
{
    BluetoothDeviceServicesManager workerBTMgr = &lt;span class="kwrd"&gt;new&lt;/span&gt; BluetoothDeviceServicesManager();
    Device workerDevice = workerBTMgr.DiscoverDeviceByName(_watchItem.DeviceName);

    &lt;span class="kwrd"&gt;return&lt;/span&gt; (workerDevice != &lt;span class="kwrd"&gt;null&lt;/span&gt;);
}

&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Run(String Operation)
{
    &lt;span class="kwrd"&gt;switch&lt;/span&gt; (Operation)
    {
        &lt;span class="kwrd"&gt;case&lt;/span&gt; &lt;span class="str"&gt;&amp;quot;SingleDevice&amp;quot;&lt;/span&gt;:
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (DevicePresent())
            {
                _parentForm.Invoke(_parentForm.AddToDeviceSeenList, &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt;[] { _watchItem });
            }
            &lt;span class="kwrd"&gt;else&lt;/span&gt;
            {
                _parentForm.Invoke(_parentForm.RemoveFromDeviceSeenList, &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt;[] { _watchItem });
            }
            &lt;span class="kwrd"&gt;break&lt;/span&gt;;
        &lt;span class="kwrd"&gt;case&lt;/span&gt; &lt;span class="str"&gt;&amp;quot;AllDevices&amp;quot;&lt;/span&gt;:
            BluetoothDeviceServicesManager workerBTMgr = &lt;span class="kwrd"&gt;new&lt;/span&gt; BluetoothDeviceServicesManager();
            List&amp;lt;Device&amp;gt; Devices = workerBTMgr.DiscoverAllDevices();
            _parentForm.Invoke(_parentForm.ThreadUpdateDiscoverBox, &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt;[] { Devices });
            &lt;span class="kwrd"&gt;break&lt;/span&gt;;
    }
}&lt;/pre&gt;

&lt;p&gt;Both of these methods require that the device you are scanning for is in discoverable mode (which most manufacturers enable by default).&amp;#160; Using the two methods described above I was able to tell if a device is in proximity. And ultimately enabling me create alerts and execute programs based on what device is present. &lt;/p&gt;

&lt;p&gt;To perform device discovery and not have my UI lag I had to create two worker threads.&amp;#160; One worker thread to discover all devices and display it under my devices listbox, and another to discover devices by name specified in the “watchlist.”&amp;#160; I am not an expert at multi-threaded programs but I managed to implement them without any major headaches.&lt;/p&gt;

&lt;h3&gt;User Interface:&lt;/h3&gt;

&lt;p&gt;Since the “Add to watchlist” and “Edit” buttons essentially do the same thing, I decided to overload a windows form.&amp;#160; I also wanted to keep track of the parent form and disable it when the WatchItemForm was shown. &lt;/p&gt;

&lt;p&gt;The second overload allows me to fill in the form control's text based on the data that is already set for the WatchItem that has been selected (the Edit button).&amp;#160; &lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; WatchItemForm(Form1 f, String DeviceName)
{
    InitializeComponent();
    &lt;span class="kwrd"&gt;this&lt;/span&gt;._parentForm = f;
    lblDeviceName.Text = DeviceName;
}

&lt;span class="kwrd"&gt;public&lt;/span&gt; WatchItemForm(Form1 f, WatchItem item)
{
    InitializeComponent();
    &lt;span class="kwrd"&gt;this&lt;/span&gt;._parentForm = f;

    lblDeviceName.Text = item.DeviceName;
    tbxPicturePath.Text = item.ImagePath;
    tbxProgramPath.Text = item.ProgramPath;
    &lt;span class="kwrd"&gt;this&lt;/span&gt;._parentForm.Enabled = &lt;span class="kwrd"&gt;true&lt;/span&gt;;
}&lt;/pre&gt;
&lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;I wanted to have a pop up notify window similar to outlook and was able to find Robert Misiak's &lt;a href="http://www.codeproject.com/KB/miscctrl/RobMisNotifyWindow.aspx"&gt;NotifyWindow&lt;/a&gt;. This is a very simple library which allows you to create pop up notify windows very easily. I edited &lt;strong&gt;NotifyWindow&lt;/strong&gt; to include a “picturepath” variable as well as picturebox on the form. As you can see creating a &lt;strong&gt;NotifyWindow&lt;/strong&gt; is quite easy:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; NotifyDeviceWindow(WatchItem x)
{
    NotifyWindow nw;
    nw = &lt;span class="kwrd"&gt;new&lt;/span&gt; NotifyWindow();
    &lt;span class="rem"&gt;//validate Alert Message&lt;/span&gt;
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (x.AlertMessage == &lt;span class="kwrd"&gt;null&lt;/span&gt;)
    {
        nw.Text = x.DeviceName;
    }
    &lt;span class="kwrd"&gt;else&lt;/span&gt;
    {
        nw.Text = x.AlertMessage;
    }
    &lt;span class="rem"&gt;//validate picture&lt;/span&gt;
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (x.ImagePath != &lt;span class="kwrd"&gt;null&lt;/span&gt;)
    {
        FileInfo imgfile = &lt;span class="kwrd"&gt;new&lt;/span&gt; FileInfo(x.ImagePath);
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (imgfile.Exists)
        {
            nw.PicturePath = x.ImagePath;
        }
        &lt;span class="kwrd"&gt;else&lt;/span&gt;
        {
            MessageBox.Show(&lt;span class="str"&gt;&amp;quot;Image does not exist&amp;quot;&lt;/span&gt;);
        }
    }
    nw.Notify();

    &lt;span class="kwrd"&gt;if&lt;/span&gt; (x.ProgramPath != &lt;span class="kwrd"&gt;null&lt;/span&gt;)
    {
        RunProcess(x.ProgramPath);
    }
}&lt;/pre&gt;
&lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;strong&gt;Process Flow/Software Operation:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;User clicks the “Discover” button, a thread is spawned which enumerates all Bluetooth devices in proximity &lt;/li&gt;

  &lt;li&gt;Thread finishes and updates the Devices listbox &lt;/li&gt;

  &lt;li&gt;User selects a discovered device and clicks “Add to watchlist” A watch item form is spawned and asks you for an alert message, a picture path, and an executable path &lt;/li&gt;

  &lt;li&gt;User clicks save , a WatchItem object is created and added to the watchList object &lt;/li&gt;

  &lt;li&gt;A timer starts and every 10 seconds a thread is spawned to discover that device by name &lt;/li&gt;

  &lt;li&gt;If the device is discovered, it is added to the “deviceSeenList” and a notify alert is sent and the executable is executed. &lt;/li&gt;

  &lt;li&gt;If that device is still present after the next timer click, no notification is sent, If that device is not present it is removed from the “deviceSeenList” &lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;Screenshots:&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/BlueBoss_F144/bbmain1.jpg"&gt;&lt;img title="bb-main[1]" height="319" alt="bb-main[1]" src="http://www.coding4fun.net/images/BlueBoss_F144/bbmain1_thumb.jpg" width="470" border="0" /&gt;&lt;/a&gt;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&lt;a href="http://www.coding4fun.net/images/BlueBoss_F144/bbwatchitem1.jpg"&gt;&lt;img title="bb-watchitem[1]" height="210" alt="bb-watchitem[1]" src="http://www.coding4fun.net/images/BlueBoss_F144/bbwatchitem1_thumb.jpg" width="257" border="0" /&gt;&lt;/a&gt; &lt;a href="http://www.coding4fun.net/images/BlueBoss_F144/bbnotify_11.jpg"&gt;&lt;img title="bb-notify_1[1]" height="173" alt="bb-notify_1[1]" src="http://www.coding4fun.net/images/BlueBoss_F144/bbnotify_11_thumb.jpg" width="226" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;ol&gt;&lt;/ol&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8658548" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/coding4fun/archive/tags/utility/default.aspx">utility</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/productivity/default.aspx">productivity</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/windows/default.aspx">windows</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/hardware/default.aspx">hardware</category></item><item><title>Home Automation with Microsoft Robotics Developer Studio 2008</title><link>http://blogs.msdn.com/coding4fun/archive/2008/05/23/8544962.aspx</link><pubDate>Sat, 24 May 2008 09:56:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8544962</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>20</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/8544962.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=8544962</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=8544962</wfw:comment><description>&lt;span id="c4fmetadata"&gt;   &lt;table cellspacing="0" cellpadding="1" width="100%" border="0"&gt;&lt;tbody&gt;       &lt;tr class="entry_overview"&gt;         &lt;td width="50"&gt;&lt;/td&gt;          &lt;td&gt;           &lt;p&gt;Typically we think of robots as machines from science fiction or as industrial robots such as those that build and paint cars. In the world of Microsoft Robotics Developer Studio, anything that has sensors and/or actuators can be considered a robot. In this article, we look at an automated house as a robot and apply the Decentralized Software Services model of Microsoft Robotics Studio to implementing some home automation tasks.&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td colspan="2"&gt;           &lt;div class="entry_author"&gt;Charles Stacy Harris III&lt;/div&gt;            &lt;br /&gt;            &lt;div class="entry_details"&gt;&lt;b&gt;Difficulty: &lt;/b&gt;&lt;span class="entry_details_input"&gt;Intermediate&lt;/span&gt;&lt;/div&gt;            &lt;div class="entry_details"&gt;&lt;b&gt;Time Required:&lt;/b&gt; &lt;span class="entry_details_input"&gt;6-10 hours&lt;/span&gt;&lt;/div&gt;            &lt;div class="entry_details"&gt;&lt;b&gt;Cost: &lt;/b&gt;&lt;span class="entry_details_input"&gt;$100-$200 for hardware (Optional, $0 if using only simulation)&lt;/span&gt;&lt;/div&gt;            &lt;div class="entry_details"&gt;&lt;b&gt;Software: &lt;/b&gt;&lt;span class="entry_details_input"&gt;Visual Studio or Visual Studio Express, Microsoft Robotics Developer Studio 2008 CTP April, &lt;a href="http://www.controlthink.com/zwavesdk.htm"&gt;ControlThink Z-Wave PC SDK&lt;/a&gt; &lt;/span&gt;&lt;/div&gt;            &lt;div class="entry_details"&gt;&lt;b&gt;Hardware: &lt;/b&gt;&lt;span class="entry_details_input"&gt;(All Optional) Elk M1G/M1EZ Security and Automation Panel, Z-Wave Dimmer Switches, Z-Wave Controller such as the ControlThink ThinkStick or equivalent.&lt;/span&gt;&lt;/div&gt;            &lt;div class="entry_details"&gt;&lt;b&gt;Download: &lt;/b&gt;&lt;a href="http://www.codeplex.com/houserobot"&gt;Download&lt;/a&gt;               &lt;ul&gt;&lt;/ul&gt;           &lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;     &lt;/tbody&gt;&lt;/table&gt; &lt;/span&gt;  &lt;h3&gt;House, Robot&lt;/h3&gt;  &lt;p&gt;Those of you who know me or who have read my previous Coding4Fun article &lt;a href="http://blogs.msdn.com/coding4fun/archive/2007/10/05/5296972.aspx"&gt;Home Automation with Windows Workflow&lt;/a&gt;, know that I’m nuts about home automation. I’m even more passionate about robotics and I’ve wanted to try out some things with Microsoft Robotics Studio since the very first version. Recently I had a long weekend, so I spent a few hours putting together some simple home automation examples using Microsoft Robotics Developer Studio 2008 CTP April. Check out the &lt;a href="http://msdn2.microsoft.com/en-us/robotics/default.aspx"&gt;Microsoft Robotics Developer Center&lt;/a&gt; for details on how to get the CTP.&lt;/p&gt;  &lt;p&gt;The examples in this article duplicate what I did using Windows Workflow in my previous article, but instead use the Decentralized Software Services (DSS) approach of Microsoft Robotics, and Microsoft Visual Programming Language (VPL) for a simple way to write automation tasks. The &lt;a href="http://msdn2.microsoft.com/en-us/robotics/default.aspx"&gt;Microsoft Robotics Developer Center&lt;/a&gt; contains a lot of detailed information about DSS, VPL, and the other technologies found in Microsoft Robotics Developer Studio. For now, let’s just cover some basics. To get further along with the code in this article, you’ll want to check out some of the excellent tutorials presented by the Microsoft Robotics team.&lt;/p&gt;  &lt;h3&gt;Services, Messages, and Ports&lt;/h3&gt;  &lt;p&gt;A DSS Service is the basic component upon which Microsoft Robotics applications are built. In fact, DSS services are a generic construct that can and have been used outside of the context of robotics. DSS services contain state and the service state is manipulated via messages sent to the service on a service port.&lt;/p&gt;  &lt;p&gt;Messages sent to a service are structured .NET classes that may contain a message payload that determines how or even if state will be modified, or what part of a service state should be retrieved. There are also message that do not directly manipulate state, but may have some other side-effects. Services respond to messages such as CREATE, LOOKUP, UPDATE, etc. In addition, you can define messages that extend the semantics of the core messages.&lt;/p&gt;  &lt;p&gt;Ports are the mechanism through which services communicate. Ports accept a set of message types that are defined by the service itself. In addition, ports are also used for outbound communication in situations such as subscribing to event notification from a service.&lt;/p&gt;  &lt;p&gt;Again, there are excellent online resources for learning the details of Microsoft Robotics, DSS, and the underlying technologies for Microsoft Robotics developer Studio. You’ll probably want basic familiarity with the Microsoft Robotics architecture including the Concurrency and Coordination Runtime (CCR) along with the notion of Arbiters and iterators.&lt;/p&gt;  &lt;h3&gt;Robo-Moose&lt;/h3&gt;  &lt;p&gt;The security and automation system in my house is centered on an Elk M1G alarm panel from &lt;a href="http://www.elkproducts.com/index.html"&gt;Elk Products Incorporated&lt;/a&gt; . This panel allows for up to 208 input zones in the form of contact switches, motion sensors, and so on. It also allows for up to 208 outputs, on-board task scripting and many other features. One of the key features for my use is the capability of being able to monitor and control the panel via an Ethernet adaptor. So, my first order of business was to write a DSS service – the ElkService – to communicate with the Elk M1G via sockets. This ElkService exchanges messages with the Elk M1G via an ASCII protocol that is documented &lt;a href="http://www.elkproducts.com/products/m1/m1documentation.htm"&gt;here&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;The code that the ElkService uses to read from the Elk M1G hardware is shown below. Note that the code looks sequential, but is actually asynchronous. The StreamAdapter.Read method sets up a task to do an asynchronous IO operation and the line “yield return (Choice)ioResultPort;” returns this task to the runtime which is iterating over all tasks returned by ElkReader.&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;span class="rem"&gt;/// ElkReader opens a socket connection to the hardware panel. It then&lt;/span&gt;
&lt;span class="rem"&gt;/// enters a loop that&lt;/span&gt;
&lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;span class="rem"&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;public&lt;/span&gt; IEnumerator&amp;lt;ITask&amp;gt; ElkReader()
{
    Connect();

    &lt;span class="rem"&gt;// Send a request to the Elk panel get a report of the entire zone status.&lt;/span&gt;
    SendElkMessage(RequestStrings.ZoneStatus);

    &lt;span class="kwrd"&gt;byte&lt;/span&gt;[] buffer = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;byte&lt;/span&gt;[256];

    &lt;span class="kwrd"&gt;int&lt;/span&gt; bytesRead = -1;
    Exception ex = &lt;span class="kwrd"&gt;null&lt;/span&gt;;

     &lt;span class="kwrd"&gt;do&lt;/span&gt;
    {
        var ioResultPort = StreamAdapter.Read(networkStream, buffer, 0, buffer.Length);

        &lt;span class="kwrd"&gt;yield&lt;/span&gt; &lt;span class="kwrd"&gt;return&lt;/span&gt; (Choice)ioResultPort;

        ex = ioResultPort;
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (ex != &lt;span class="kwrd"&gt;null&lt;/span&gt;)
            &lt;span class="kwrd"&gt;throw&lt;/span&gt; ex;

        bytesRead = ioResultPort;
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (bytesRead != 0)
            ProcessRawElkMessage(Encoding.ASCII.GetString(buffer, 0, bytesRead));

    } &lt;span class="kwrd"&gt;while&lt;/span&gt; (bytesRead != 0);
}&lt;/pre&gt;
&lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;When the ElkService receives a packet from the hardware panel, it converts the packet from a string to a custom message containing the raw sensor data and posts the message to the main port of the ElkService itself. For example, when the service receives a “ZC” message from the hardware, it converts this to an UpdateRawZone message that contains the raw data from the security panel. This happens in the method ProcessRawElkMessage. Here is a fragment of that code:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ProcessRawElkMessage(&lt;span class="kwrd"&gt;string&lt;/span&gt; message)
{
    &lt;span class="kwrd"&gt;string&lt;/span&gt; messageType = message.Substring(2, 2);

    &lt;span class="kwrd"&gt;switch&lt;/span&gt; (messageType)
    {
        &lt;span class="kwrd"&gt;case&lt;/span&gt; &lt;span class="str"&gt;&amp;quot;ZC&amp;quot;&lt;/span&gt;: &lt;span class="rem"&gt;// Zone status change&lt;/span&gt;
            var zoneState = &lt;span class="kwrd"&gt;new&lt;/span&gt; UpdateRawZoneRequest
            {
                Id = &lt;span class="kwrd"&gt;byte&lt;/span&gt;.Parse(message.Substring(4, 3)),
                State = &lt;span class="kwrd"&gt;byte&lt;/span&gt;.Parse(message.Substring(7, 1),
                              NumberStyles.HexNumber)
            };

            var updateZoneMessage = &lt;span class="kwrd"&gt;new&lt;/span&gt; UpdateRawZone();
            updateZoneMessage.Body = zoneState;

            _mainPort.Post(updateZoneMessage);
            &lt;span class="kwrd"&gt;break&lt;/span&gt;;
…&lt;/pre&gt;

&lt;p&gt;UpdateRawZoneRequest is the message payload and is used to send data about a zone change event to a subscriber. UpdateRawZone is the actual message type that is transmitted on the port for the ElkService.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;[DataContract]
[Description(&lt;span class="str"&gt;&amp;quot;UpdateRawZone Request Message Payload&amp;quot;&lt;/span&gt;)]
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; UpdateRawZoneRequest
{
    [DataMember]
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;byte&lt;/span&gt; Id { get; set; }

    [DataMember]
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;byte&lt;/span&gt; State { get; set; }
}


&lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;span class="rem"&gt;/// Update Elk zone status&lt;/span&gt;
&lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
[Description(&lt;span class="str"&gt;&amp;quot;UpdateZone request message&amp;quot;&lt;/span&gt;)]
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; UpdateRawZone : Update&amp;lt;UpdateRawZoneRequest,
        PortSet&amp;lt;DefaultUpdateResponseType, Fault&amp;gt;&amp;gt;
{
}&lt;/pre&gt;

&lt;p&gt;The message processing code can also be written a bit more compactly as:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ProcessRawElkMessage(&lt;span class="kwrd"&gt;string&lt;/span&gt; message)
{
    &lt;span class="kwrd"&gt;string&lt;/span&gt; messageType = message.Substring(2, 2);

    &lt;span class="kwrd"&gt;switch&lt;/span&gt; (messageType)
    {
        &lt;span class="kwrd"&gt;case&lt;/span&gt; &lt;span class="str"&gt;&amp;quot;ZC&amp;quot;&lt;/span&gt;: &lt;span class="rem"&gt;// Zone status change&lt;/span&gt;
            var updateZoneMessage = &lt;span class="kwrd"&gt;new&lt;/span&gt; UpdateRawZone
            {
                Body = &lt;span class="kwrd"&gt;new&lt;/span&gt; UpdateRawZoneRequest
                {
                    Id = &lt;span class="kwrd"&gt;byte&lt;/span&gt;.Parse(message.Substring(4, 3)),
                    State = &lt;span class="kwrd"&gt;byte&lt;/span&gt;.Parse(message.Substring(7, 1),
                          NumberStyles.HexNumber)
                }
            };

            _mainPort.Post(updateZoneMessage);
            &lt;span class="kwrd"&gt;break&lt;/span&gt;;
…&lt;/pre&gt;

&lt;p&gt;UpdateRawZoneHandler is a message receiver that is active on the main port and which responds to the update message by updating internal state, and notifying subscribers of the change in state.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;[ServiceHandler(ServiceHandlerBehavior.Exclusive)]
&lt;span class="kwrd"&gt;public&lt;/span&gt; IEnumerator&amp;lt;ITask&amp;gt; UpdateRawZoneHandler(UpdateRawZone message)
{
    _state.ZoneStates[message.Body.Id - 1] = message.Body.State;

    SendNotification(_submgrPort, message);

    message.ResponsePort.Post(DefaultUpdateResponseType.Instance);

    &lt;span class="kwrd"&gt;yield&lt;/span&gt; &lt;span class="kwrd"&gt;break&lt;/span&gt;;
}&lt;/pre&gt;

&lt;h3&gt;In the Zone&lt;/h3&gt;

&lt;p&gt;The ElkService represents the core service that communicates with the Elk M1G hardware. The next service – ElkZoneSensor – represents a higher level “sensor array” that is attached to the Elk hardware. ElkZoneSensor “partners” with the ElkService. This means that the ElkZoneSensor relies on the ElkService to function. The DSS infrastructure will ensure that the ElkService is started if needed when starting the ElkZoneSensor service.&lt;/p&gt;

&lt;p&gt;The ElkZoneSensor subscribes to updates from the ElkService for changes in the hardware zones. When these changes occur, the ElkService notifies the ElkZoneSensor which updates its state and notifies any of its subscribers. The ElkZoneSensor uses a higher level message – UpdateZone – that contains a sensor ID and an enumeration that describes the state of the sensor.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;[DataContract]
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Zone
{
    [DataMember]
    [Description(&lt;span class="str"&gt;&amp;quot;The Elk hardware zone id of the sensor&amp;quot;&lt;/span&gt;)]
    [DataMemberConstructor]
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;byte&lt;/span&gt; Id { get; set; }

    [DataMember]
    [Description(&lt;span class="str"&gt;&amp;quot;The Elk defined state of the sensor&amp;quot;&lt;/span&gt;)]
    &lt;span class="kwrd"&gt;public&lt;/span&gt; ZoneStatus Status { get; set; }
}&lt;/pre&gt;

&lt;h3&gt;Candlepower&lt;/h3&gt;

&lt;p&gt;The next services that we need for the robotic house are services to control the lights. In this case, I started with a &lt;i&gt;generic&lt;/i&gt; contract for the DSS service. A generic contract in DSS terms just defines the set of messages to which a service will respond and defines the port type on which those messages will be sent. The generic contract does not contain code to actually implement the service behavior. One of the benefits of a generic service contract is that you can specify the contract, write algorithms that use the contract, and later connect the generic service contracts to code that actually implements the behavior. This is very much like programming to an abstract interface in the object oriented world, and having multiple classes that actually implement the interface.&lt;/p&gt;

&lt;p&gt;We start off with a generic service called the GenericDimmer that represents a dimmer switch and we implement two concrete services: the SimulatedDimmer and the ZWaveDimmer. SimulatedDimmer just logs a message to represent its state change. The ZWaveDimmer actually controls the lights via a hardware Z-Wave controller.&lt;/p&gt;

&lt;p&gt;Here’s what the GenericDimmer contract looks like:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; Robotics.GenericHouseControls.Dimmer
{


    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span class="rem"&gt;/// GenericDimmer Contract class&lt;/span&gt;
    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;sealed&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Contract
    {
        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class="rem"&gt;/// The Dss Service contract&lt;/span&gt;
        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        [DataMember]
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;const&lt;/span&gt; String Identifier = &lt;span class="str"&gt;&amp;quot;http://schemas.tempuri.org/2008/04/generichousecontrolsdimmer.html&amp;quot;&lt;/span&gt;;
    }

    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span class="rem"&gt;/// The GenericDimmer State&lt;/span&gt;
    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
    [DataContract]
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; GenericDimmerState
    {
        [DataMember]
        [DataMemberConstructor(Order = 1)]
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; Id;

        [DataMember]
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; Level;
    }

    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span class="rem"&gt;/// GenericDimmer Main Operations Port&lt;/span&gt;
    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
    [ServicePort(AllowMultipleInstances = &lt;span class="kwrd"&gt;true&lt;/span&gt;)]
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; GenericDimmerOperations : PortSet&amp;lt;DsspDefaultLookup, DsspDefaultDrop, Get, HttpGet, On, Off, SetLevel&amp;gt;
    {
    }

    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span class="rem"&gt;/// GenericDimmer Get Operation&lt;/span&gt;
    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Get : Get&amp;lt;GetRequestType, PortSet&amp;lt;GenericDimmerState, Fault&amp;gt;&amp;gt;
    {

        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class="rem"&gt;/// GenericDimmer Get Operation&lt;/span&gt;
        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;public&lt;/span&gt; Get()
        {
        }

        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class="rem"&gt;/// GenericDimmer Get Operation&lt;/span&gt;
        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;public&lt;/span&gt; Get(Microsoft.Dss.ServiceModel.Dssp.GetRequestType body) :
            &lt;span class="kwrd"&gt;base&lt;/span&gt;(body)
        {
        }

        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class="rem"&gt;/// GenericDimmer Get Operation&lt;/span&gt;
        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;public&lt;/span&gt; Get(Microsoft.Dss.ServiceModel.Dssp.GetRequestType body, Microsoft.Ccr.Core.PortSet&amp;lt;GenericDimmerState, W3C.Soap.Fault&amp;gt; responsePort) :
            &lt;span class="kwrd"&gt;base&lt;/span&gt;(body, responsePort)
        {
        }
    }

    [DataContract]
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; OnRequest
    {
    }

    [Description(&lt;span class="str"&gt;&amp;quot;Turn the switch on&amp;quot;&lt;/span&gt;)]
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; On : Update&amp;lt;OnRequest, PortSet&amp;lt;DefaultUpdateResponseType, Fault&amp;gt;&amp;gt;
    {
    }

    [DataContract]
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; OffRequest
    {
    }

    [Description(&lt;span class="str"&gt;&amp;quot;Turn the switch off&amp;quot;&lt;/span&gt;)]
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Off : Update&amp;lt;OffRequest, PortSet&amp;lt;DefaultUpdateResponseType, Fault&amp;gt;&amp;gt;
    {
    }

    [DataContract]
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; SetLevelRequest
    {
        [DataMember]
        [DataMemberConstructor]
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; Level { get; set; }
    }

    [Description(&lt;span class="str"&gt;&amp;quot;Set the dim level&amp;quot;&lt;/span&gt;)]
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; SetLevel : Update&amp;lt;SetLevelRequest, PortSet&amp;lt;DefaultUpdateResponseType, Fault&amp;gt;&amp;gt;
    {
    }
}&lt;/pre&gt;

&lt;p&gt;This code defines the contract only. Now to implement that contract we can run the DssNewService utility with the /implement switch and generate a service based on this contract. For example: &lt;/p&gt;

&lt;p&gt;dssnewservice /s:SimulatedDimmer /n:Robotics.HouseControls.SimulatedDimmer /i:GenericHouseControls.Y2008.M04.Proxy.dll&lt;/p&gt;

&lt;p&gt;will generate a new service called SimulatedDimmer in the .NET namespace Robotics.HouseControls.SimulatedDimmer. The service will have a stubbed out implementation of the GenericDimmer contract including service startup code, state, and stubbed out message handlers.&lt;/p&gt;

&lt;p&gt;Here’s what the main service file looks like for the simulated dimmer after I added logging to the generated methods. I’ve also deleted some of the using statements for easier reading.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; pxdimmer = Robotics.GenericHouseControls.Dimmer.Proxy;

&lt;span class="kwrd"&gt;namespace&lt;/span&gt; Robotics.HouseControls.SimulatedDimmer
{


    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span class="rem"&gt;/// House Controls Service&lt;/span&gt;
    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
    [DisplayName(&lt;span class="str"&gt;&amp;quot;Simulated Dimmer&amp;quot;&lt;/span&gt;)]
    [Description(&lt;span class="str"&gt;&amp;quot;The Simulated Dimmer Switch Service&amp;quot;&lt;/span&gt;)]
    [Contract(Contract.Identifier)]
    [AlternateContract(pxdimmer.Contract.Identifier)]
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; SimulatedDimmerService : DsspServiceBase
    {

        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class="rem"&gt;/// _state&lt;/span&gt;
        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        [ServiceState]
        [InitialStatePartner(Optional = &lt;span class="kwrd"&gt;true&lt;/span&gt;)]
        &lt;span class="kwrd"&gt;private&lt;/span&gt; pxdimmer.GenericDimmerState _state = &lt;span class="kwrd"&gt;new&lt;/span&gt; pxdimmer.GenericDimmerState();

        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class="rem"&gt;/// _main Port&lt;/span&gt;
        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        [ServicePort(&lt;span class="str"&gt;&amp;quot;/simulateddimmer&amp;quot;&lt;/span&gt;, AllowMultipleInstances = &lt;span class="kwrd"&gt;true&lt;/span&gt;)]
        &lt;span class="kwrd"&gt;private&lt;/span&gt; pxdimmer.GenericDimmerOperations _mainPort = &lt;span class="kwrd"&gt;new&lt;/span&gt; pxdimmer.GenericDimmerOperations();


        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class="rem"&gt;/// Default Service Constructor&lt;/span&gt;
        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;public&lt;/span&gt; SimulatedDimmerService(DsspServiceCreationPort creationPort) :
            &lt;span class="kwrd"&gt;base&lt;/span&gt;(creationPort)
        {
        }

        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class="rem"&gt;/// Service Start&lt;/span&gt;
        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Start()
        {
            &lt;span class="kwrd"&gt;base&lt;/span&gt;.Start();

            &lt;span class="rem"&gt;// Add service specific initialization here.&lt;/span&gt;
            LogInfo(&lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;&amp;quot;Dimmer State =&amp;gt; Id:{0} Level:{1}&amp;quot;&lt;/span&gt;, _state.Id, _state.Level));
        }

        [ServiceHandler(ServiceHandlerBehavior.Concurrent)]
        &lt;span class="kwrd"&gt;public&lt;/span&gt; IEnumerator&amp;lt;ITask&amp;gt; OnHandler(pxdimmer.On update)
        {
            LogInfo(&lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;&amp;quot;Simulated Dimmer =&amp;gt; Id:{0} On&amp;quot;&lt;/span&gt;, _state.Id));

            update.ResponsePort.Post(DefaultUpdateResponseType.Instance);
            &lt;span class="kwrd"&gt;yield&lt;/span&gt; &lt;span class="kwrd"&gt;break&lt;/span&gt;;
        }

        [ServiceHandler(ServiceHandlerBehavior.Concurrent)]
        &lt;span class="kwrd"&gt;public&lt;/span&gt; IEnumerator&amp;lt;ITask&amp;gt; OffHandler(pxdimmer.Off update)
        {
            LogInfo(&lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;&amp;quot;Simulated Dimmer =&amp;gt; Id:{0} Off&amp;quot;&lt;/span&gt;, _state.Id));

            update.ResponsePort.Post(DefaultUpdateResponseType.Instance);
            &lt;span class="kwrd"&gt;yield&lt;/span&gt; &lt;span class="kwrd"&gt;break&lt;/span&gt;;
        }

        [ServiceHandler(ServiceHandlerBehavior.Exclusive)]
        &lt;span class="kwrd"&gt;public&lt;/span&gt; IEnumerator&amp;lt;ITask&amp;gt; SetLevelHandler(pxdimmer.SetLevel update)
        {           
            _state.Level = update.Body.Level;
            LogInfo(&lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;&amp;quot;Simulated Dimmer =&amp;gt; Id:{0} Level:{1}&amp;quot;&lt;/span&gt;, _state.Id, update.Body.Level));

            update.ResponsePort.Post(DefaultUpdateResponseType.Instance);            
            &lt;span class="kwrd"&gt;yield&lt;/span&gt; &lt;span class="kwrd"&gt;break&lt;/span&gt;;
        }
    }
}&lt;/pre&gt;
&lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Check the code download for the implementation of the ZWaveDimmer. You’ll find that it’s pretty straightforward. It should be simple to write similar code if you use a different technology for lighting control. You just write a service that matches the GenericDimmer contract, and you should be able to configure the GenericDimmer using a manifest to point to the actual dimmer service. Check out the documentation in Microsoft Robotics Developer Studio for more information on manifests and how to use the manifest editor.&lt;/p&gt;

&lt;h3&gt;Bulb On, Bulb Off!&lt;/h3&gt;

&lt;p&gt;The “Hello, World” application for any home automation software that I’ve tested in my house has always been the automating of my pantry light. The pantry has a Z-Wave light switch inside and the pantry door has a contact switch that is connected to the Elk M1G. When the door is open, we want the light to turn on, and when the door is closed we want the light to turn off. Now that we have all the pieces for this, here’s what the VPL diagram for this looks like:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/HomeAutomationwithMicrosoftRoboticsDevel_13D2/image.png"&gt;&lt;img title="image" style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="259" alt="image" src="http://www.coding4fun.net/images/HomeAutomationwithMicrosoftRoboticsDevel_13D2/image_thumb.png" width="500" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;As you can see, it was also a relatively easy matter to add text-to-speech to announce the opening and closing of the pantry door. You may find out quickly that this is an annoyance to those in the testing areas – for me that was my kitchen – so it’s nice to know that two quick hits of the delete key will also remove the text-to-speech. This is part of the beauty of the Microsoft Robotics programming model!&lt;/p&gt;

&lt;p&gt;The second example shows how you can use a motion detector – in this case connected to zone 19 on the Elk – to trigger a light. The light comes on at a level that you control from the VPL code, and stays on for a duration that you can also control from the code. For the example, I set the timer to a pretty low level, but you can customize it. You could also add additional rules to only turn on the light at certain times, or better still connect an ambient light sensor to decide whether you should turn the light on.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/HomeAutomationwithMicrosoftRoboticsDevel_13D2/image_3.png"&gt;&lt;img title="image" style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="319" alt="image" src="http://www.coding4fun.net/images/HomeAutomationwithMicrosoftRoboticsDevel_13D2/image_thumb_3.png" width="500" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;In this diagram, if motion is detected – that is zone 19 is triggered with a status of ViolatedOpen – the light is turned on at a low dim level and a timer is set. When the timer completes, the light is turned off. If, however, there is more motion before the timer completes, the SetTimer message will cancel the old timeout and restart the timer.&lt;/p&gt;

&lt;p&gt;There are more VPL examples included in the download including an extra service that you can use to send email from your VPL code. I’m experimenting with using the email service to send me a text message whenever my alarm is armed or disarmed.&lt;/p&gt;

&lt;h3&gt;Miscellanea&lt;/h3&gt;

&lt;p&gt;Since I haven’t had a lot of time to study the testing framework and simulation environments used by Microsoft Robotics, I included a service called the ElkTestDataPlayback service that allows me to replay the contents of a text file to simulate the ElkService getting actual data. This works pretty well for testing. The contents of the file are merely raw data captures that I made from the data sent by the Elk M1G panel. To use this service in VPL, you just drop it onto your diagram, configure it’s TestDataFileName via “Set initial configuration” to point to a data file, and send it a message to start playback.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;font color="#ff0000"&gt;Important&lt;/font&gt;:&lt;/b&gt; If you have the Elk hardware, you will want to uncomment the &lt;i&gt;SpawnIterator(ElkReader)&lt;/i&gt; line in the ElkService.Start method. I know this is a hack for now. It would probably be better to write a SimulatedElk service based on a generic service contract. If I have time, I will do that in the future. That would involve a lot more work than I had for this weekend project!&lt;/p&gt;

&lt;h3&gt;TODO List&lt;/h3&gt;

&lt;p&gt;Since this was my first foray into Microsoft Robotics Developer Studio and I had limited time to really explore the features in depth, there are a few things that I’ve left unimplemented. Here are some of the things that I would like to expand on in the future:&lt;/p&gt;

&lt;p&gt;1. &lt;b&gt;Support for more of the Elk features:&lt;/b&gt; Currently, I only support Zone Change notifications. Fuller support of the Elk hardware would not be difficult and would be beneficial to anyone wanting to use this on an ongoing basis. There’s some stub code for a few other notifications if you want to add to the service.&lt;/p&gt;

&lt;p&gt;2. &lt;b&gt;Generic contracts for the Elk M1G:&lt;/b&gt; I didn’t base the Elk services on generic contract because I’m not familiar with enough other types of security and automation panels to make the needed generalizations. It would be interesting to try to come up with something more generic. I thought about using the Generic Contact Sensor array, but I’m not sure that it models what we need. For example, a door contact is considered &lt;b&gt;&lt;i&gt;violated&lt;/i&gt;&lt;/b&gt; when it’s open, but a water sensor is considered &lt;b&gt;&lt;i&gt;violated&lt;/i&gt;&lt;/b&gt; when it’s closed.&lt;/p&gt;

&lt;p&gt;3. &lt;b&gt;Additional Z-Wave features:&lt;/b&gt; I’ve left out notification for lighting level changes, support for scenes and a host of other features. There’s so much more that’s possible with full Z-Wave support.&lt;/p&gt;

&lt;p&gt;4. &lt;b&gt;Refined Generic Contracts:&lt;/b&gt; Generic contracts allow developers to write code that is independent of the final hardware. That is one of the major benefits of the model used by Microsoft Robotics. You could for example have a generic light switch for simulation and testing, and based on configuration you could plug in a Z-Wave switch or an Insteon switch when it’s time to deploy the actual solution.&lt;/p&gt;

&lt;p&gt;5. &lt;b&gt;Simulation Support:&lt;/b&gt; One of the major benefits of Microsoft Robotics Developer Studio is the simulation environment. For example, if we had a motion detector in the simulation environment, we could test some of the algorithms that I presented above by having a simulated mobile robot “violate” the motion detector’s zone and trigger the corresponding VPL code.&lt;/p&gt;

&lt;p&gt;6. &lt;b&gt;Exception Handling:&lt;/b&gt; As I build more on the code in this article, I’ll add exception handling and retry logic. Microsoft Robotics has some extremely robust features such as Causalities that make handling exceptions in a concurrent environment much easier.&lt;/p&gt;

&lt;p&gt;7. &lt;b&gt;HttpHandlers:&lt;/b&gt; I have a start at code for handling HTTP requests in the ZWaveController service. Handling HTTP requests is handy for building client applications that access your services without themselves having to be DSS services.&lt;/p&gt;

&lt;p&gt;Other experiments that might be fun to try include integrating your Microsoft Robotics controlled home with remote control applications that are based on WPF or Silverlight, or perhaps integrating control from a Windows Media Center PC or Windows Home Server.&lt;/p&gt;

&lt;p&gt;I hope you enjoy Microsoft Robotics Developer Studio as much as I have. I look forward to seeing what other people build with this fantastic technology. If people are interested, I can continue to share my home automation experiments. I think Microsoft Robotics Developer Studio will be the major tool in my home automation toolbox for quite some time.&lt;/p&gt;

&lt;h3&gt;Project Settings Note:&lt;/h3&gt;

&lt;p&gt;You will have to modify the project settings for the projects included in the House.Robot solution since your installation of Microsoft Robotics Developer Studio will be in a different directory than mine. The DssProjectMigration.exe command line tool will make short work of this. Just run it with a parameter that specifies the directory you want it to search, and it will find all of the project files in that directory and subdirectories and convert them to be buildable with your installation settings.&lt;/p&gt;

&lt;p&gt;If you use the ElkTestDataPlayback service, in the examples, you’ll need to set the path to the location of the test data file either in the initial configuration for the component, or in a manifest that configures the component. Make sure that you &lt;b&gt;do not&lt;/b&gt; put quotes around the path name. I included a test data file from my system.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8544962" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/coding4fun/archive/tags/home+automation/default.aspx">home automation</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/robotics/default.aspx">robotics</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/hardware/default.aspx">hardware</category></item><item><title>Animated Musical Holiday Light Show - Version 2.0</title><link>http://blogs.msdn.com/coding4fun/archive/2007/12/23/1230660.aspx</link><pubDate>Mon, 24 Dec 2007 01:25:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1230660</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>27</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/1230660.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=1230660</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=1230660</wfw:comment><description>&lt;span id="c4fmetadata"&gt;
&lt;table border="0" cellpadding="1" cellspacing="0" width="100%"&gt;
&lt;tbody&gt;
&lt;tr class="entry_overview"&gt;
&lt;td width="50"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&lt;span class="entry_description"&gt;Create an animated holiday light show for indoor or outdoor use using some &lt;a href="http://www.phidgets.com/" target="_blank" mce_href="http://www.phidgets.com/"&gt;Phidget Interface Kits&lt;/a&gt;, extension cords, and .NET.&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="2"&gt;
&lt;div class="entry_author"&gt;&lt;a href="http://www.brianpeek.com/" target="_blank" mce_href="http://www.brianpeek.com/"&gt;Brian Peek&lt;/a&gt;&lt;/div&gt;
&lt;div class="entry_company"&gt;&lt;a href="http://www.aspsoft.com" target="_blank" mce_href="http://www.aspsoft.com"&gt;ASPSOFT, Inc.&lt;/a&gt;&lt;/div&gt;&lt;br&gt;
&lt;div class="entry_details"&gt;&lt;b&gt;Difficulty: &lt;/b&gt;&lt;span class="entry_details_input"&gt;Intermediate&lt;/span&gt;&lt;/div&gt;
&lt;div class="entry_details"&gt;&lt;b&gt;Time Required:&lt;/b&gt; &lt;span class="entry_details_input"&gt;3-6 hours&lt;/span&gt;&lt;/div&gt;
&lt;div class="entry_details"&gt;&lt;b&gt;Cost: &lt;/b&gt;&lt;span class="entry_details_input"&gt;$100-$200&lt;/span&gt;&lt;/div&gt;
&lt;div class="entry_details"&gt;&lt;b&gt;Software: &lt;/b&gt;&lt;span class="entry_details_input"&gt;&lt;a href="http://msdn.microsoft.com/express/" target="_blank" mce_href="http://msdn.microsoft.com/express/"&gt;Visual Basic or Visual C# 2008 Express Editions&lt;/a&gt;, &lt;a href="http://www.phidgets.com/downloads.php?os_id=1" target="_blank" mce_href="http://www.phidgets.com/downloads.php?os_id=1"&gt;Phidgets .NET libraries&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="entry_details"&gt;&lt;b&gt;Hardware: &lt;/b&gt;&lt;span class="entry_details_input"&gt;&lt;a href="http://www.trossenrobotics.com/store/p/3203-InterfaceKit-0-0-4.aspx" target="_blank" mce_href="http://www.trossenrobotics.com/store/p/3203-InterfaceKit-0-0-4.aspx"&gt;Phidget Interface Kit 0/0/4&lt;/a&gt;, extension cords, wire nuts, spare wire&lt;/span&gt;&lt;/div&gt;
&lt;div class="entry_details"&gt;&lt;b&gt;Download:&amp;nbsp;&lt;/b&gt;&lt;b&gt; &lt;/b&gt;&lt;a href="http://www.c4fbook.com/media/p/42.aspx" target="_blank" mce_href="http://www.c4fbook.com/media/p/42.aspx"&gt;Download&lt;/a&gt;&lt;/div&gt;&lt;div class="entry_details"&gt;&lt;b&gt;Discussion Forum: &lt;/b&gt;&lt;a href="http://www.c4fbook.com/forums/30.aspx" mce_href="http://www.c4fbook.com/forums/30.aspx"&gt;Forum&lt;/a&gt; &lt;br&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/span&gt;
&lt;p&gt;Welcome to version 2.0 of the software and article!&amp;nbsp; I have rewritten the key points of this article to address the new features in the latest version of the software.&amp;nbsp; Read on for a full explanation...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New Features for 2.0&lt;/b&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;MIDI support 
&lt;ul&gt;
&lt;li&gt;Load a MIDI file and a sequence will be automatically created based on the data contained in the file.&amp;nbsp; You can automatically create your own show with barely any effort at all! &lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Playlists 
&lt;ul&gt;
&lt;li&gt;Load up several sequences and have them play in order to create a multi-song show! &lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;More accurate timing 
&lt;ul&gt;
&lt;li&gt;The timing algorithm used in the last version was very imprecise...it worked, but it wasn't perfect.&amp;nbsp; The new version uses a method which gives millisecond precision timing &lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Cut/Copy/Paste 
&lt;ul&gt;
&lt;li&gt;One can now cut/copy/paste cells on the grid...makes it easy to repeat chunks of sequences without having to tap out the rhythm by hand over and over again &lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Edit existing sequences 
&lt;ul&gt;
&lt;li&gt;After loading a sequence created by someone else (or yourself), you can now re-assign Phidget boards, serial numbers, output ports, etc. to get them to run on your setup. &lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Note that any sequences created with the old version will continue to play just fine, but editing them could be troublesome due to the new timing method.&lt;/p&gt;
&lt;p&gt;And now back to the article with updates.&amp;nbsp; The hardware section remains the same, but the &lt;a href="http://blogs.msdn.com/controlpanel/blogs/posteditor.aspx?SelectedNavItem=Posts&amp;amp;sectionid=4539&amp;amp;postid=1230660#software" mce_href="http://blogs.msdn.com/controlpanel/blogs/posteditor.aspx?SelectedNavItem=Posts&amp;amp;sectionid=4539&amp;amp;postid=1230660#software"&gt;software&lt;/a&gt; discussion below is updated with new information. &lt;/p&gt;
&lt;hr&gt;

&lt;p&gt;I'm sure by now everyone with a computer has seen the videos of holiday light shows timed to holiday music such as &lt;a href="http://www.youtube.com/watch?v=nD8_7c36yfw" target="_blank" mce_href="http://www.youtube.com/watch?v=nD8_7c36yfw"&gt;this one&lt;/a&gt;.&amp;nbsp; For this holiday season, I decided to create my own indoor show using some off-the-shelf components and .NET.&lt;/p&gt;
&lt;h3&gt;&lt;embed src="http://www.youtube.com/v/B83uajiZHo4" type="application/x-shockwave-flash" mce_src="http://www.youtube.com/v/B83uajiZHo4" height="350" width="600"&gt;&lt;/h3&gt;
&lt;p&gt;&lt;b&gt;&lt;/b&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;WARNING:&amp;nbsp; The hardware portion of this project uses standard 120V AC current.&amp;nbsp; As you are likely aware, this is enough voltage to seriously hurt or kill you.&amp;nbsp; Please be careful and follow the instructions closely.&lt;/b&gt;&lt;/p&gt;
&lt;h3&gt;What You Will Need&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.trossenrobotics.com/store/p/3203-InterfaceKit-0-0-4.aspx" mce_href="http://www.trossenrobotics.com/store/p/3203-InterfaceKit-0-0-4.aspx"&gt;Phidget Interface Kit&lt;/a&gt; 0/0/4 – a USB-controlled board with 4 relays.&amp;nbsp; I used 2 kits for a total of 8 channels.&amp;nbsp; Any number can be used. &lt;/li&gt;
&lt;li&gt;5 6' (or longer/shorter for your needs) indoor or outdoor 2-prong extension cords for each Phidget board used.&amp;nbsp; I was able to find these at the local home improvement store for about $1 each.&amp;nbsp; If you will be creating an outdoor show, be sure to purchase extension cords that are meant for outdoor use. &lt;/li&gt;&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/extension_cord14.jpg" mce_href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/extension_cord14.jpg"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/extension_cord_thumb12.jpg" style="border-width: 0px;" mce_src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/extension_cord_thumb12.jpg" border="0" height="180" width="240"&gt;&lt;/a&gt; &lt;/p&gt;&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Some 14-16 gauge wire.&amp;nbsp; If in doubt, simply buy one additional extension cord to use for the additional wire. &lt;/li&gt;
&lt;li&gt;2 wire nuts that can handle the wire gauge selected above for each Phidget board used. &lt;/li&gt;&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/wirenuts1.jpg" mce_href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/wirenuts1.jpg"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/wirenuts.jpg" style="border-width: 0px;" mce_src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/wirenuts.jpg" border="0" height="180" width="240"&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;A project box large enough to hold one or many Phidget boards and associated wiring.&amp;nbsp; I chose a 7"L x 5"W x 3"H enclosure from Radio Shack which provides ample room to hold 2 Phidget Interface Kits and wiring. &lt;/li&gt;
&lt;li&gt;Some holiday lights &lt;/li&gt;
&lt;li&gt;External speakers (or possibly an FM transmitter for an outdoor show) &lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.phidgets.com/downloads.php?os_id=1" target="_blank" mce_href="http://www.phidgets.com/downloads.php?os_id=1"&gt;Phidgets .NET libraries&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="http://msdn.com/express/" mce_href="http://msdn.com/express/"&gt;Microsoft Visual Basic or Visual C# Express Editions&lt;/a&gt; &lt;/li&gt;&lt;/ul&gt;
&lt;h3&gt;Building the Hardware&lt;/h3&gt;
&lt;p&gt;The hardware we are going to build will allow for one Phidget board to be plugged into a single AC outlet and provide 4 output outlets that can be switched off and on by the Phidget board's relays.&amp;nbsp; By building two of these and placing them in a project box, I have a neat and tidy control box with 2 USB inputs, 2 AC male plugs for the wall, and 8 AC female plugs for my lights.&amp;nbsp; The following description will be for building a single unit.&lt;/p&gt;
&lt;p&gt;Let's start by preparing the extension cords.&amp;nbsp; Cut the female end off of one extension cord.&amp;nbsp; Split the cord up the center and strip the insulation off each of the wires to expose the ends.&amp;nbsp; Twist the ends with your fingers to create a neat, twisted wire as shown:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/male_end1.jpg" mce_href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/male_end1.jpg"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/male_end.jpg" style="border-width: 0px;" mce_src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/male_end.jpg" border="0" height="180" width="240"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Next, take the remaining four extension cords and cut the male ends off each.&amp;nbsp; As before, split the cord up the center a small bit, strip off some insulation, and twist the exposed ends as shown:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/female_end1.jpg" mce_href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/female_end1.jpg"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/female_end.jpg" style="border-width: 0px;" mce_src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/female_end.jpg" border="0" height="180" width="240"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Now, cut 4 equal lengths of your 14-16 gauge wire.&amp;nbsp; These should be no longer than 2-4 inches in length.&amp;nbsp; Strip some insulation off each end and twist up any loose wires.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/wire1.jpg" mce_href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/wire1.jpg"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/wire.jpg" style="border-width: 0px;" mce_src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/wire.jpg" border="0" height="180" width="240"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;For the next part, you will need to pay close attention.&amp;nbsp; Each extension cord &lt;b&gt;should&lt;/b&gt; have two different types of insulation around the wires.&amp;nbsp; One side should have a ribbed edge, and one side should have a smooth edge shown below:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/smooth5.jpg" mce_href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/smooth5.jpg"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/smooth_thumb3.jpg" style="border-width: 0px;" mce_src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/smooth_thumb3.jpg" border="0" height="337" width="450"&gt;&lt;/a&gt; &lt;a href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/ribbed2.jpg" mce_href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/ribbed2.jpg"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/ribbed_thumb.jpg" style="border-width: 0px;" mce_src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/ribbed_thumb.jpg" border="0" height="337" width="450"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;The ribbed side should be in line with the "fat" prong/receptacle (the neutral side) and the smooth side should be in line with the smaller prong/receptacle (the active/"hot" side).&amp;nbsp; It is important that the next steps be followed carefully, noting which wires I am referring to.&amp;nbsp; Using the wrong wire can lead to a short, blown fuses, kicked circuit breakers, or even worse things.&lt;/p&gt;
&lt;p&gt;Take the 4 short wires you cut earlier and twist them all together along with the ribbed/neutral wire from the extension cord with the male end still attached.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/twisted_wires1.jpg" mce_href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/twisted_wires1.jpg"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/twisted_wires.jpg" style="border-width: 0px;" mce_src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/twisted_wires.jpg" border="0" height="180" width="240"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Twist a wire nut over the exposed ends to keep them together and covered.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/wires_nut1.jpg" mce_href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/wires_nut1.jpg"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/wires_nut.jpg" style="border-width: 0px;" mce_src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/wires_nut.jpg" border="0" height="180" width="240"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Next, twist together the smooth/"hot" wire from the four extension cords with the female ends still attached along with the smooth/"hot" wire from the extension cord with the male end attached (i.e. the other wire from the male cord used above).&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/cords_twisted1.jpg" mce_href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/cords_twisted1.jpg"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/cords_twisted.jpg" style="border-width: 0px;" mce_src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/cords_twisted.jpg" border="0" height="180" width="240"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Again, twist on a wire nut to keep things covered and safe.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/cords_nut1.jpg" mce_href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/cords_nut1.jpg"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/cords_nut.jpg" style="border-width: 0px;" mce_src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/cords_nut.jpg" border="0" height="180" width="240"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;You should now be left with the opposite ends of the 4 cut wires exposed, and the 4 ribbed/neutral wires of the female extension exposed.&amp;nbsp; These will all be put into the screw terminals of the Phidget Interface Kit.&lt;/p&gt;
&lt;p&gt;The Phidget Interface Kit board has 4 groups of screw terminals.&amp;nbsp; Each group contains 3 items:&amp;nbsp; NO, XC, and NC, where X is the relay number in question.&amp;nbsp; These stand for "Normally Open", "Common", and "Normally Closed".&amp;nbsp; For this project, the lights should normally be off and switched on via the software, so the NO (Normally Open) and XC (Common) ports will be used.&lt;/p&gt;
&lt;p&gt;Place one wire from each exposed bundle into each NO and XC port.&amp;nbsp; Note that it does not matter which wire you plug into which terminal of each group, just that each group has only one short wire and only one extension cord wire.&lt;/p&gt;
&lt;p&gt;In the end, there will be one each of the 4 short wires in each group on the board, and one each of the extension cord wires in each group on the board as pictured:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/phidget_done1.jpg" mce_href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/phidget_done1.jpg"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/phidget_done.jpg" style="border-width: 0px;" mce_src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/phidget_done.jpg" border="0" height="180" width="240"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Below is a very simple schematic of the wiring of a single board:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/Schematic8.png" mce_href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/Schematic8.png"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/Schematic_thumb4.png" style="border-width: 0px;" mce_src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/Schematic_thumb4.png" border="0" height="124" width="240"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;I decided to keep things neat and tidy and mount the Phidget boards into a project box.&amp;nbsp; Since I have 2 boards to manage, I placed both inside a single, large box.&amp;nbsp; I drilled holes in the short sides to expose the boards' USB ports.&amp;nbsp; I then notched out some spaces on the top edge and lid for the extension cords to pass through.&amp;nbsp; I mounted the boards inside the box with some carefully placed two-sided foam tape.&lt;/p&gt;
&lt;p&gt;The finished product can be seen below:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/internals1.jpg" mce_href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/internals1.jpg"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/internals.jpg" style="border-width: 0px;" mce_src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/internals.jpg" border="0" height="180" width="240"&gt;&lt;/a&gt;&amp;nbsp;&lt;a href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/finished1.jpg" mce_href="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/finished1.jpg"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/finished.jpg" style="border-width: 0px;" mce_src="http://www.coding4fun.net/images/AnimatedHolidayLights_EC1E/finished.jpg" border="0" height="180" width="240"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;And that's it!&amp;nbsp; If this box will be placed outside, take the time to properly weatherproof the box so the elements cannot damage anything inside.&lt;/p&gt;
&lt;h3&gt;A Word on Amperages&lt;/h3&gt;
&lt;p&gt;Your individual light strings will be plugged into each extension cord outlet.&amp;nbsp; An average strand of mini-lights draws about .3 amps. An average string of larger bulbs will draw 1-2 amps.&amp;nbsp; The relays on the Phidget board are rated at 10 amps.&amp;nbsp; Additionally, a standard house circuit will allow up to 15-20 amps before overloading.&amp;nbsp; Check the circuit breaker in your home on which the outlet you'll be using lives for the allowed amperage.&amp;nbsp; Also, keep in mind that any other devices that are plugged into that circuit elsewhere in the house will be drawing power, so you may not be able to draw a full 15 amps from it.&amp;nbsp; So, be sure to not draw more than 10A per channel, nor more than 15-20A in total, &lt;b&gt;including&lt;/b&gt; all additional devices plugged into that circuit.&amp;nbsp; Keep this in mind as you string your lights together on each channel.&lt;/p&gt;&lt;a class="" title="software" name="software"&gt;&lt;/a&gt;
&lt;h3&gt;Writing the Software&lt;/h3&gt;
&lt;p&gt;Ensure the &lt;a href="http://www.phidgets.com" target="_blank" mce_href="http://www.phidgets.com"&gt;Phidgets libraries for .NET&lt;/a&gt; are installed on the development machine.&amp;nbsp; To compile the source code, &lt;a href="http://msdn.microsoft.com/express/" target="_blank" mce_href="http://msdn.microsoft.com/express/"&gt;Visual Basic and/or Visual C# Express 2005&lt;/a&gt; will also be need to be installed and working.&lt;/p&gt;
&lt;p&gt;The &lt;b&gt;Light Sequencer&lt;/b&gt; application uses a grid-style interface to show the list of channels and when each channel is switched on and off.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/AnimatedMusicalHolidayLightShowVersion.0_E701/image.png" mce_href="http://www.coding4fun.net/images/AnimatedMusicalHolidayLightShowVersion.0_E701/image.png"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedMusicalHolidayLightShowVersion.0_E701/image_thumb.png" style="border: 0px none ;" alt="image" mce_src="http://www.coding4fun.net/images/AnimatedMusicalHolidayLightShowVersion.0_E701/image_thumb.png" border="0" height="339" width="454"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Squares can be toggled on or off by highlighting them, right-clicking with the mouse and selecting On or Off from the context menu.&amp;nbsp; They can also be toggled by pressing the O (for on) or F (for off) keys on the keyboard.&lt;/p&gt;
&lt;p&gt;Additionally, sequences can be "recorded" by pressing the Record button in the toolbar.&amp;nbsp; This will start the music and allow the user to tap out the rhythm for each channel by pressing the number key on the keyboard corresponding to the channel.&lt;/p&gt;
&lt;p&gt;Sequences can be saved at any time and reloaded for editing or play with the Phidgets devices connected.&lt;/p&gt;
&lt;p&gt;When I first started the software for this project, the first problem I ran into was the fact that the &lt;b&gt;DataGridView&lt;/b&gt; control does no support multiple headers.&amp;nbsp; As is shown in the screenshot above, the grid is broken down into seconds and then milliseconds.&amp;nbsp; For display purposes. it is easier to break the header down into two segments, one showing the labeled second markers, and one showing the subdivisions per second.&lt;/p&gt;
&lt;p&gt;To accomplish this, I created two DataGridViews:&amp;nbsp; one for the header, which contains no data and is only as tall as the header row, and one for the sub-header and the data below it.&amp;nbsp; This works great except for scrolling.&amp;nbsp; To accomplish this, I simply listen for the &lt;b&gt;Scroll&lt;/b&gt; event on the main grid and apply the scrolling offset to the header grid:&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Visual C#&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; dgvMain_Scroll(&lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt; sender, ScrollEventArgs e)&lt;br&gt;{&lt;br&gt;    dgvHeader.HorizontalScrollingOffset = e.NewValue;&lt;br&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;b&gt;Visual Basic&lt;/b&gt;&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Sub&lt;/span&gt; dgvMain_Scroll(&lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Object&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; e &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; ScrollEventArgs) &lt;span style="color: rgb(0, 0, 255);"&gt;Handles&lt;/span&gt; dgvMain.Scroll&lt;br&gt;    dgvHeader.HorizontalScrollingOffset = e.NewValue&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;&lt;/div&gt;
&lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }

.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Additionally, I ran into some performance issues drawing the grid.&amp;nbsp; At first, drawing a grid with so many columns was quite slow.&amp;nbsp; By setting the grid's &lt;b&gt;Visible&lt;/b&gt; property to false before adding the rows and columns and then returning the &lt;b&gt;Visible&lt;/b&gt; property to true, the grid now draws quite quickly.&lt;/p&gt;
&lt;p&gt;The next issue tackled was starting and stopping a music file.&amp;nbsp; In version 2, the software supports sampled music (MP3, WAV, etc.) as well as MIDI files.&amp;nbsp; As I was attempting to write a MIDI file parser and player (so I could have access to the internal data for auto-generating a sequence) I found a fantastic MIDI library written by Leslie Sanford.&amp;nbsp; This library is used by the Light Sequencer application.&lt;/p&gt;
&lt;p&gt;With two playback libraries in place, I created an interface which contains Start, Stop, Load, etc. methods so that the front-end could use any playback engine interchangeably.&amp;nbsp; The MCIPlayback engine uses standard MCI commands for playing sampled music.&amp;nbsp; Commands are executed by passing them to the &lt;b&gt;mciSendString&lt;/b&gt; function exported by winmm.dll.&amp;nbsp; In order to use this function from .NET, we must import the method and setup its signature as follows:&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Visual C#&lt;/b&gt;&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;[DllImport(&lt;span style="color: rgb(0, 96, 128);"&gt;"winmm.dll"&lt;/span&gt;)]&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;extern&lt;/span&gt; Int32 mciSendString(String command, StringBuilder buffer, Int32 bufferSize, IntPtr hwndCallback);&lt;/pre&gt;&lt;/div&gt;
&lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;b&gt;Visual Basic&lt;/b&gt;&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Declare&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Function&lt;/span&gt; mciSendString &lt;span style="color: rgb(0, 0, 255);"&gt;Lib&lt;/span&gt; &lt;span style="color: rgb(0, 96, 128);"&gt;"winmm.dll"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Alias&lt;/span&gt; &lt;span style="color: rgb(0, 96, 128);"&gt;"mciSendStringA"&lt;/span&gt; (&lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; command &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;String&lt;/span&gt;, _&lt;br&gt;   &lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; buffer &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; StringBuilder, &lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; bufferSize &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; Int32, _&lt;br&gt;   &lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; hwndCallback &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; IntPtr) &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; Int32&lt;/pre&gt;&lt;/div&gt;
&lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;To open a music file, the &lt;b&gt;open&lt;/b&gt; command is used as follows:&lt;/p&gt;
&lt;p&gt;open "&amp;lt;path to file&amp;gt;" type mpegvideo alias MediaFile&lt;/p&gt;
&lt;p&gt;This opens the file and creates an alias named MediaFile which can be used to refer to the file for all future commands.&amp;nbsp; Send the above command using the &lt;b&gt;mciSendString&lt;/b&gt; method would look as follows:&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Visual C#&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; cmd = &lt;span style="color: rgb(0, 96, 128);"&gt;"open \""&lt;/span&gt; + _musicFile + &lt;span style="color: rgb(0, 96, 128);"&gt;"\" type mpegvideo alias MediaFile"&lt;/span&gt;;&lt;br&gt;mciSendString(cmd, &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;, 0, IntPtr.Zero);&lt;/pre&gt;&lt;/div&gt;
&lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;b&gt;Visual Basic&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Dim&lt;/span&gt; cmd &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;String&lt;/span&gt; = &lt;span style="color: rgb(0, 96, 128);"&gt;"open "&lt;/span&gt;&lt;span style="color: rgb(0, 96, 128);"&gt;""&lt;/span&gt; + file + &lt;span style="color: rgb(0, 96, 128);"&gt;""&lt;/span&gt;&lt;span style="color: rgb(0, 96, 128);"&gt;" type mpegvideo alias MediaFile"&lt;/span&gt;&lt;br&gt;mciSendString(cmd, &lt;span style="color: rgb(0, 0, 255);"&gt;Nothing&lt;/span&gt;, 0, IntPtr.Zero)&lt;/pre&gt;&lt;/div&gt;
&lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;The remaining commands we will need are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;play MediaFile from 0 -- Play loaded file from beginning &lt;/li&gt;
&lt;li&gt;stop MediaFile -- Stop playing current file &lt;/li&gt;
&lt;li&gt;close MediaFile -- Close the file&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Next, the Phidget boards behavior needed to be implemented.&amp;nbsp; Talking to the Phidget board is very easy.&amp;nbsp; After creating an instance of the &lt;b&gt;InterfaceKit&lt;/b&gt; object, a specific device can be opened by calling the &lt;b&gt;open&lt;/b&gt; method, passing in the serial number of the device to be opened.&lt;/p&gt;
&lt;p&gt;The serial numbers for each attached Phidget device can be determined by creating an instance of the &lt;b&gt;Phidgets.Manager&lt;/b&gt; class, setting up the &lt;b&gt;Attach&lt;/b&gt; event handler, and listening for the attach events as follows:&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Visual C#&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;...&lt;br&gt;Phidgets.Manager phidgetsManager = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; Phidgets.Manager();&lt;br&gt;phidgetsManager.Attach += &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; AttachEventHandler(phidgetsManager_Attach);&lt;br&gt;phidgetsManager.open();&lt;br&gt;...&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; phidgetsManager_Attach(&lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt; sender, AttachEventArgs e)&lt;br&gt;{&lt;br&gt;    Debug.WriteLine(e.Device.Name + &lt;span style="color: rgb(0, 96, 128);"&gt;" - "&lt;/span&gt; + e.Device.SerialNumber)&lt;br&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;b&gt;Visual Basic&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;...&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Dim&lt;/span&gt; phidgetsManager &lt;span style="color: rgb(0, 0, 255);"&gt;as&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; Phidgets.Manager&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;AddHandler&lt;/span&gt; phidgetsManager.Attach, &lt;span style="color: rgb(0, 0, 255);"&gt;AddressOf&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.phidgetsManager_Attach&lt;br&gt;phidgetsManager.open()&lt;br&gt;...&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Sub&lt;/span&gt; phidgetsManager_Attach(&lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Object&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; e &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; AttachEventArgs)&lt;br&gt;    Debug.WriteLine(e.Device.Name &amp;amp; &lt;span style="color: rgb(0, 96, 128);"&gt;" - "&lt;/span&gt; &amp;amp; e.device.SerialNumber)&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;&lt;/div&gt;
&lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Setting the relay state is as easy as indexing into the &lt;b&gt;outputs &lt;/b&gt;array of the &lt;b&gt;InterfaceKit&lt;/b&gt; object and setting the indexed output to &lt;b&gt;true &lt;/b&gt;or &lt;b&gt;false&lt;/b&gt;.&lt;/p&gt;
&lt;p&gt;In code, all of this would look like:&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Visual C#&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;InterfaceKit ik = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; InterfaceKit();&lt;br&gt;ik.open(1234);&lt;br&gt;ik.outputs[0] = &lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;/div&gt;
&lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;b&gt;Visual Basic&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Dim&lt;/span&gt; ik &lt;span style="color: rgb(0, 0, 255);"&gt;as&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; InterfaceKit&lt;br&gt;ik.open(1234)&lt;br&gt;ik.outputs(0) = True&lt;/pre&gt;&lt;/div&gt;
&lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;In order to maintain precise timing, the &lt;b&gt;Stopwatch&lt;/b&gt; class from the&lt;b&gt; System.Diagnostics&lt;/b&gt; namespace is used.&amp;nbsp; This internally uses the &lt;b&gt;QueryPerformanceCounter&lt;/b&gt; Win32 API method to give extremely precise time values.&lt;/p&gt;
&lt;p&gt;When it is time to playback a sequence, a thread is started which starts the music using the appropriate playback engine, and then sits in a loop, waiting for the number of milliseconds to pass specified in the sequence (50ms as default).&amp;nbsp; When that amount of time has elapsed, we send the channel states of the current tick to the relays connected.&lt;/p&gt;
&lt;p&gt;Recording a sequence with the keyboard works in a similar fashion.&amp;nbsp; A thread is started and the music is played.&amp;nbsp; While the music is playing, &lt;b&gt;KeyDown&lt;/b&gt; and &lt;b&gt;KeyUp&lt;/b&gt; events are listened for.&amp;nbsp; After translating the &lt;b&gt;KeyCode&lt;/b&gt; of the pressed key to the channel number, an internal array of which keys are "on and off" are maintained.&amp;nbsp; When the number of milliseconds elapsed hits the appropriate mark, every channel is updated with the current value of that array.&amp;nbsp; That is, which keys are up and down.&lt;/p&gt;
&lt;p&gt;When the user stops playback, or the song ends, the channel data is returned to the main form and displayed in the main grid.&lt;/p&gt;
&lt;p&gt;If a MIDI file is selected, sequence data is automatically generated based on the MIDI data.&amp;nbsp; A MIDI file contains a series of tracks or channels with a series of commands.&amp;nbsp; These commands tell the MIDI hardware what note to turn on, when, and for how long (among other things).&amp;nbsp; When the MIDI file is loaded, every command from every channel is enumerated and its time values are converted into milliseconds.&amp;nbsp; Once all the commands are gathered and organized, they are placed into this application's channel structure and displayed on the grid.&amp;nbsp; This allows the lights to flash in precise time to the MIDI file being played.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Using the Software&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;Ensure that the Phidget devices you will be using are attached to the PC.&amp;nbsp; Start by creating a new sequence from the &lt;b&gt;File&lt;/b&gt; menu or by clicking the &lt;b&gt;New Sequence&lt;/b&gt; button.&amp;nbsp; In the dialog that appears, locate a music file to play back and enter the length of time that the sequence should run.&amp;nbsp; Be sure to note which Phidget devices are attached and which channels they map to on the grid.&amp;nbsp; Click &lt;b&gt;OK&lt;/b&gt; when complete.&lt;/p&gt;
&lt;p&gt;The screen will redraw and present the grid interface for the length of time specified.&amp;nbsp; At this point, cells can be turned on and off by highlighting a cell and right-clicking, or by pressing the "O" key to turn the cell On, and the "F" key to turn the cell off.&amp;nbsp; Multiple cells can be selected and changed at once.&lt;/p&gt;
&lt;p&gt;To use the recording interface, click the &lt;b&gt;Record Sequence&lt;/b&gt; button or choose &lt;b&gt;Record Sequence&lt;/b&gt; from the &lt;b&gt;Sequence&lt;/b&gt; menu.&amp;nbsp; Be sure to select the correct choice of "Overwrite channel data" or "Append channel data."&amp;nbsp; As you record additional channels, you will almost always want to append and not overwrite.&lt;/p&gt;
&lt;p&gt;Click the start button and a brief countdown will begin.&amp;nbsp; When the countdown reaches 0, the music will begin.&amp;nbsp; A channel can be recorded by pressing the keyboard key of the channel number.&amp;nbsp; For example, to tap out the rhythm of channel 1, press the 1 key at the appropriate times.&lt;/p&gt;
&lt;p&gt;When complete, press the Escape key, or click the Stop button.&amp;nbsp; When the Record window is closed, the main grid will be updated with the sequence recorded.&lt;/p&gt;
&lt;p&gt;Creating a sequence is certainly a time consuming task since each channel needs to be recorded.&amp;nbsp; While the rhythm interface allows one to record many channels simultaneously, I think it would be impossible for anyone to type out an entire sequence for all channels in one go.&amp;nbsp; In my opinion, it is easiest to record one or two channels at a time and append the data as you go.&amp;nbsp; In the end, you can use the grid interface to tweak the values and clean up any mistakes.&lt;/p&gt;
&lt;p&gt;The sequence can be played back at any time. Simply press the &lt;b&gt;Play&lt;/b&gt; button and watch your holiday lights play back to the timing you created.&amp;nbsp; Press the &lt;b&gt;Stop&lt;/b&gt; button to end the current playback.&lt;/p&gt;
&lt;p&gt;Sequences can be saved at any time by selecting &lt;b&gt;Save&lt;/b&gt; from the file menu.&lt;/p&gt;
&lt;p&gt;To test the channels by hand, select "Test Channels" from the "Tools" menu.&amp;nbsp; As with the recording screen, press the number keys associated with the channel to turn on or off to test that channel.&lt;/p&gt;
&lt;p&gt;I found it was much easier to also have the lights plugged into the appropriate channels as I created my sequence.&amp;nbsp; That way I could see the results of my recordings immediately.&lt;/p&gt;
&lt;p&gt;To create a playlist of many sequences, select &lt;b&gt;New Playlist&lt;/b&gt; from the &lt;b&gt;File&lt;/b&gt; menu.&amp;nbsp; Add your existing sequence files, order them as you wish, and save the playlist.&amp;nbsp; From this screen you can also play the playlist, set it up to repeat, advance tracks, etc.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.coding4fun.net/images/AnimatedMusicalHolidayLightShowVersion.0_E701/image_3.png" mce_href="http://www.coding4fun.net/images/AnimatedMusicalHolidayLightShowVersion.0_E701/image_3.png"&gt;&lt;img src="http://www.coding4fun.net/images/AnimatedMusicalHolidayLightShowVersion.0_E701/image_thumb_3.png" style="border: 0px none ;" alt="image" mce_src="http://www.coding4fun.net/images/AnimatedMusicalHolidayLightShowVersion.0_E701/image_thumb_3.png" border="0" height="379" width="454"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;To edit data on an existing sequence (Phidget serial numbers, mapped MIDI channels, etc.) select &lt;b&gt;Edit Sequence Properties&lt;/b&gt; from the &lt;b&gt;Sequence&lt;/b&gt; menu.&amp;nbsp; This will display the &lt;b&gt;New Sequence&lt;/b&gt; dialog box and allow you to edit the existing setup.&lt;/p&gt;
&lt;h3&gt;Setting It All Up&lt;/h3&gt;
&lt;p&gt;So now that you have hardware, music and an animated sequence, it's time to hook it all up!&amp;nbsp; If you are doing an indoor show, a set of external speakers should be more than ample for playing the music for your light show.&amp;nbsp; For an outdoor show, you may wish to purchase an FM transmitter to output the music over a very low-powered FM frequency so that visitors can listen to the music on their car radios.&amp;nbsp; I personally have not gone this route, however you can find a variety of FM transmitters for sale around the 'net.&amp;nbsp; In a quick search, I found &lt;a href="http://www.ramseyelectronics.com/site/default.asp?search=fm+transmitter&amp;amp;page=search&amp;amp;x=0&amp;amp;y=0" target="_blank" mce_href="http://www.ramseyelectronics.com/site/default.asp?search=fm+transmitter&amp;amp;page=search&amp;amp;x=0&amp;amp;y=0"&gt;Ramsey Electronics&lt;/a&gt; which sells a variety of FM transmission hardware that is more than appropriate depending on your budget.&amp;nbsp; I am certain there are plenty of other devices that fit the bill as well.&lt;/p&gt;
&lt;p&gt;To fire up the show, just plug in your USB Phidget devices, plug the lights into the appropriate channels, load the Light Sequencer application, and press the Play button!&lt;/p&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;And there we have it!&amp;nbsp; Holiday lights timed to your favorite holiday song.&amp;nbsp; Take your time in creating a sequence and show us what you've created!&lt;/p&gt;
&lt;p&gt;I plan on maintaining and updating this article as we get closer and closer to the holidays, so please check back often for updates.&amp;nbsp; I will note updates at the top of the article.&amp;nbsp; Additionally, please send me any and all feedback, bug reports, feature requests, or anything else you have to say!&amp;nbsp; You can find my contact info in the readme.txt file located in the source code download linked above, or visit &lt;a href="http://www.brianpeek.com/" target="_blank" mce_href="http://www.brianpeek.com/"&gt;my website&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;Thanks&lt;/h3&gt;
&lt;p&gt;Special thanks to Michelle Leavitt for help setting up lights and sequence ideas, and my dad for advice on wiring up the relays.&lt;/p&gt;
&lt;p&gt;Thanks to &lt;a href="http://www.lesliesanford.com/" target="_blank" mce_href="http://www.lesliesanford.com/"&gt;Leslie Sanford&lt;/a&gt; for the incredible &lt;a href="http://www.lesliesanford.com/Programming/MIDIToolkit.shtml" target="_blank" mce_href="http://www.lesliesanford.com/Programming/MIDIToolkit.shtml"&gt;MIDI Toolkit&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;And, a big thank you to the beta testers for version 2: Allen Leno, Steve Runion, Steve Trueman, Corey Emmert.&lt;/p&gt;
&lt;h3&gt;Bio&lt;/h3&gt;
&lt;p&gt;Brian is a Microsoft C# MVP and a recognized .NET expert with over 6 years experience developing .NET solutions, and over 9 years of professional experience architecting and developing solutions using Microsoft technologies and platforms, although he has been "coding for fun" for as long as he can remember.&amp;nbsp; Outside the world of .NET and business applications, Brian enjoys developing both hardware and software projects in the areas of gaming, robotics, and whatever else strikes his fancy for the next ten minutes. He rarely passes up an opportunity to dive into a C/C++ or assembly language project.&amp;nbsp; You can reach Brian via his blog at &lt;a href="http://www.brianpeek.com/" mce_href="http://www.brianpeek.com/"&gt;http://www.brianpeek.com/&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1230660" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/coding4fun/archive/tags/windows/default.aspx">windows</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/hardware/default.aspx">hardware</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/holiday/default.aspx">holiday</category></item><item><title>WiiEarth -- Wiimote Interface for Virtual Earth</title><link>http://blogs.msdn.com/coding4fun/archive/2007/10/18/5506286.aspx</link><pubDate>Thu, 18 Oct 2007 12:30:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5506286</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>21</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/5506286.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=5506286</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=5506286</wfw:comment><description>&lt;table border="0" cellpadding="1" cellspacing="0" width="100%"&gt; &lt;tbody&gt; &lt;tr class="entry_overview"&gt; &lt;td width="50"&gt;&lt;img src="http://www.coding4fun.net/images/WiiEarthWiimoteInterfaceforVirtualEarth_4B93/globe.png" style="border-width: 0px;" alt="globe" mce_src="http://www.coding4fun.net/images/WiiEarthWiimoteInterfaceforVirtualEarth_4B93/globe.png" border="0" height="49" width="50"&gt; &lt;/td&gt; &lt;td&gt;&lt;span class="entry_description"&gt;In this article, Brian Peek will demonstrate how to use a Nintendo Wii Remote (Wiimote) as a controller for Microsoft Virtual Earth 3D.&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2"&gt; &lt;div class="entry_author"&gt;&lt;a href="http://www.brianpeek.com/" target="_blank" mce_href="http://www.brianpeek.com/"&gt;Brian Peek&lt;/a&gt;&lt;/div&gt; &lt;div class="entry_company"&gt;&lt;a href="http://www.aspsoft.com/" mce_href="http://www.aspsoft.com/"&gt;ASPSOFT, Inc.&lt;/a&gt;&lt;/div&gt;&lt;br&gt; &lt;div class="entry_details"&gt;&lt;b&gt;Difficulty: &lt;/b&gt;&lt;span class="entry_details_input"&gt;Intermediate&lt;/span&gt;&lt;/div&gt; &lt;div class="entry_details"&gt;&lt;b&gt;Time Required:&lt;/b&gt; 2&lt;span class="entry_details_input"&gt;-3 hours&lt;/span&gt;&lt;/div&gt; &lt;div class="entry_details"&gt;&lt;b&gt;Cost: &lt;/b&gt;&lt;span class="entry_details_input"&gt;$60 for Wiimote and Nunchuk&lt;/span&gt;&lt;/div&gt; &lt;div class="entry_details"&gt;&lt;b&gt;Software: &lt;/b&gt;&lt;a href="http://blogs.msdn.com/coding4fun/archive/2007/03/14/1879033.aspx" target="_blank" mce_href="http://blogs.msdn.com/coding4fun/archive/2007/03/14/1879033.aspx"&gt;Managed Library for Nintendo's Wiimote&lt;/a&gt;, &lt;span class="entry_details_input"&gt;&lt;a href="http://msdn.com/express/" mce_href="http://msdn.com/express/"&gt;Visual Basic or Visual C# Express Editions&lt;/a&gt;&lt;/span&gt;&lt;/div&gt; &lt;div class="entry_details"&gt;&lt;b&gt;Hardware: &lt;/b&gt;&lt;a href="http://wii.nintendo.com/controller.jsp" mce_href="http://wii.nintendo.com/controller.jsp"&gt;Nintendo Wii Remote (Wiimote) with Nunchuk&lt;/a&gt;, a compatible PC Bluetooth adapter and stack, optional IR sensor bar&lt;/div&gt;&lt;div class="entry_details"&gt;&amp;nbsp;&lt;/div&gt; &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="color: red;"&gt;Note:&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(31, 73, 125);"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;As of April 18, 2008 this
code no longer works due to API changes in VE 3D. We will keep this article up
on Coding4Fun.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;

 &lt;h3&gt;Introduction&lt;/h3&gt; &lt;p&gt;Virtual Earth is the 3D interface to Microsoft's Live Maps service.&amp;nbsp; Normally this control is loaded via the web browser and allows interaction with a keyboard, mouse, and Xbox 360 controller.&amp;nbsp; In this article, we will take the Virtual Earth control out of the web browser, use it in a WinForms application, and control it with a Nintendo Wii Remote (Wiimote).&amp;nbsp; Note that use of the Virtual Earth 3D control in this way is undocumented and unsupported at the moment.&amp;nbsp; Because of this, some of the descriptions in this article are educated guesses and may not be 100% accurate.&lt;/p&gt; &lt;div class="wlWriterSmartContent" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:e9f4ae58-121a-4714-8c7c-43889b09e716" style="margin: 0px; padding: 0px; display: inline;"&gt;&lt;div id="6313e96e-b536-4726-87a0-f47e6317b3ed" style="margin: 0px; padding: 0px; display: inline;"&gt;&lt;div&gt;&lt;a href="http://soapbox.msn.com/video.aspx?vid=998298e7-d246-4e8b-8f26-e01112d44bc1&amp;amp;from=writer" target="_new"&gt;&lt;img src="http://www.coding4fun.net/images/WiiEarthWiimoteInterfaceforVirtualEarth_4B93/videoaf38cdeadf94.jpg" galleryimg="no" onload="var downlevelDiv = document.getElementById('6313e96e-b536-4726-87a0-f47e6317b3ed'); downlevelDiv.innerHTML = &amp;quot;&lt;div&gt;&lt;embed mce_tsrc=\&amp;quot;http://images.soapbox.msn.com/flash/soapbox1_1.swf\&amp;quot; quality=\&amp;quot;high\&amp;quot; width=\&amp;quot;432\&amp;quot; height=\&amp;quot;364\&amp;quot; wmode=\&amp;quot;transparent\&amp;quot; type=\&amp;quot;application/x-shockwave-flash\&amp;quot; pluginspage=\&amp;quot;http://macromedia.com/go/getflashplayer\&amp;quot; flashvars=\&amp;quot;c=v&amp;v=998298e7-d246-4e8b-8f26-e01112d44bc1&amp;from=writer\&amp;quot; &gt;&lt;\/embed&gt;&lt;\/div&gt;&amp;quot;;" alt=""&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3&gt;Setup&lt;/h3&gt; &lt;p&gt;Before we get started, you will need to install the Virtual Earth 3D control.&amp;nbsp; If you haven't done this already, browse to &lt;a href="http://maps.live.com/" mce_href="http://maps.live.com/"&gt;http://maps.live.com/&lt;/a&gt; and click on the &lt;b&gt;Install 3D&lt;/b&gt; link to install the control and supporting software.&lt;/p&gt; &lt;p&gt;Additionally, if you haven't already, please review my &lt;a href="http://blogs.msdn.com/coding4fun/archive/2007/03/14/1879033.aspx" target="_blank" mce_href="http://blogs.msdn.com/coding4fun/archive/2007/03/14/1879033.aspx"&gt;Managed Library for Nintendo's Wiimote&lt;/a&gt; article on this site.&amp;nbsp; We will be using the library in this article, but I will not repeat the basic information that is located in the original article.&amp;nbsp; Note that this application uses a newer version of the Wiimote library which is not yet uploaded.&amp;nbsp; It will be available in a few days.&lt;/p&gt; &lt;h3&gt;Implementation&lt;/h3&gt; &lt;div&gt;&lt;b&gt;The Virtual Earth 3D Control&lt;/b&gt;&lt;/div&gt; &lt;p&gt;The Virtual Earth 3D (VE3D) control is intended to be used through a well documented JavaScript interface from a web page, however we would not be able to access the Wiimote from a web browser.&amp;nbsp; Therefore, we will be using the VE3D control through its native, but wholly undocumented interface.&amp;nbsp; Note that on 10/15/07 a new version of VE3D was released that changed the API drastically from the previous version.&amp;nbsp; This article reflects the newer version.&lt;/p&gt; &lt;p&gt;Start by creating a new Windows Forms application named WiiEarth in C# or VB.&amp;nbsp; As with all controls and 3rd party libraries, a reference needs to be set to the Virtual Earth 3D libraries.&amp;nbsp; Unfortunately this cannot be done from the Visual Studio IDE because of the way the control is installed to the Global Assembly Cache.&amp;nbsp; So, to set reference to the necessary assemblies, ensure the project is not open in Visual Studio and open the .csproj/.vbproj file in notepad.&amp;nbsp; Add the following XML in the &lt;b&gt;&amp;lt;ItemGroup&amp;gt;&lt;/b&gt; which contains the base references, such as System and System.Data:&lt;/p&gt; &lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Reference&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Include&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Microsoft.MapPoint.Data"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;  &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;False&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Reference&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Reference&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Include&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Microsoft.MapPoint.Data.CompactMapFile"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;  &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;False&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Reference&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Reference&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Include&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Microsoft.MapPoint.Data.VirtualEarthTileDataSource"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;  &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;False&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Reference&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Reference&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Include&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Microsoft.MapPoint.Geometry"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;  &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;False&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Reference&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Reference&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Include&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Microsoft.MapPoint.Graphics3D"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;  &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;False&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Reference&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Reference&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Include&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Microsoft.MapPoint.GraphicsAPI"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;  &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;False&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Reference&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Reference&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Include&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Microsoft.MapPoint.Rendering3D"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;  &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;False&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Reference&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Reference&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Include&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Microsoft.MapPoint.Utility"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;  &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;False&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Reference&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Reference&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Include&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Microsoft.MapPoint.Rendering3D.Utility"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;  &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;False&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Reference&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Reference&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Include&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Microsoft.MapPoint.Rendering3D.WorldMemoryDataSource"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;  &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;False&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Reference&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;With the references in place, the project file can now be opened and the references will be seen in the References folder in the Solution Explorer as usual.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.coding4fun.net/images/WiiEarthWiimoteInterfaceforVirtualEarth_4B93/image.png" style="border-width: 0px;" alt="image" mce_src="http://www.coding4fun.net/images/WiiEarthWiimoteInterfaceforVirtualEarth_4B93/image.png" border="0" height="303" width="439"&gt; &lt;/p&gt;
&lt;p&gt;Creating an instance of the control can be done in code just like any other control.&amp;nbsp; Used in the constructor or load event of the form, the following code will create a VE3D control and add it to the form as fully docked:&lt;/p&gt;
&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;// the Virtual Earth 3D control&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; GlobeControl globeControl;&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; MainForm_Load(&lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;br&gt;{&lt;br&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;// create a new instance of the VE control&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.globeControl = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; GlobeControl();&lt;br&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;// setup the globeControl to fill the window&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.globeControl.Dock = DockStyle.Fill;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.globeControl.Location = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; System.Drawing.Point(0, 0);&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.globeControl.Name = &lt;span style="color: rgb(0, 96, 128);"&gt;"Globe"&lt;/span&gt;;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.pnlGlobe.Controls.Add(globeControl);&lt;br&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;' the Virtual Earth 3D control&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Private&lt;/span&gt; globeControl &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; GlobeControl&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Sub&lt;/span&gt; MainForm_Load(&lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Object&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; e &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; EventArgs) &lt;span style="color: rgb(0, 0, 255);"&gt;Handles&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;MyBase&lt;/span&gt;.Load&lt;br&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;' create a new instance of the VE control&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.globeControl = &lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; GlobeControl()&lt;br&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;' setup the globeControl to fill the window&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.globeControl.Dock = DockStyle.Fill&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.globeControl.Location = &lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; System.Drawing.Point(0, 0)&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.globeControl.Name = &lt;span style="color: rgb(0, 96, 128);"&gt;"Globe"&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.pnlGlobe.Controls.Add(globeControl)&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This sets up the VE3D control in its default state.&amp;nbsp; If you were to run an application with only this code, you would see nothing but the earth.&amp;nbsp; The navigation controls and other extras would be missing.&amp;nbsp; If you wish to add the default navigation controls to the screen, the &lt;b&gt;PlugInLoader&lt;/b&gt; object is used.&amp;nbsp; The &lt;b&gt;PlugInLoader&lt;/b&gt; is created by using the &lt;b&gt;CreateLoader&lt;/b&gt; static method, passing in an instance of the &lt;b&gt;GlobeControl&lt;/b&gt;'s &lt;b&gt;Host&lt;/b&gt; object.&amp;nbsp; Then, the &lt;b&gt;NavigationPlugIn&lt;/b&gt; can be loaded and activated as shown:&lt;/p&gt;
&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;// load all the spiffy UI navigation goodies&lt;/span&gt;&lt;br&gt;PlugInLoader loader = PlugInLoader.CreateLoader(&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.globeControl.Host);&lt;br&gt;loader.LoadPlugIn(&lt;span style="color: rgb(0, 0, 255);"&gt;typeof&lt;/span&gt;(NavigationPlugIn));&lt;br&gt;loader.ActivatePlugIn(&lt;span style="color: rgb(0, 0, 255);"&gt;typeof&lt;/span&gt;(NavigationPlugIn).GUID, &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;);&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;' load all the spiffy UI navigation goodies&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Dim&lt;/span&gt; loader &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; PlugInLoader = PlugInLoader.CreateLoader(&lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.globeControl.Host)&lt;br&gt;loader.LoadPlugIn(&lt;span style="color: rgb(0, 0, 255);"&gt;GetType&lt;/span&gt;(NavigationPlugIn))&lt;br&gt;loader.ActivatePlugIn(&lt;span style="color: rgb(0, 0, 255);"&gt;GetType&lt;/span&gt;(NavigationPlugIn).GUID, &lt;span style="color: rgb(0, 0, 255);"&gt;Nothing&lt;/span&gt;)&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The last thing to be added for basic functionality is the data.&amp;nbsp; As it stands, the only data that will appear on the globe is the image of the continents.&amp;nbsp; Zooming in only produces a blurry representation of that base image.&lt;/p&gt;
&lt;p&gt;Data layers are created from specially formatted data sources provided by local.live.com known as content manifests.&amp;nbsp; These are XML files which tell the VE3D control how to load the data required for any view.&amp;nbsp; The following helper method can be used to easily load data layers:&lt;/p&gt;
&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; AddFeederSource(&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; uri, &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; layerId, &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; id, DataSourceUsage usage)&lt;br&gt;{&lt;br&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;// create a data source from a URL&lt;/span&gt;&lt;br&gt;    DataSource dataSource = VirtualEarthTileDataSource.ConnectTo(&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; Uri(uri),&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.globeControl.Host.WebProxy,&lt;br&gt;        WorldMemoryDataSource.DataPath);&lt;br&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;// create a layer from that data source&lt;/span&gt;&lt;br&gt;    DataSourceLayerData layer = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; DataSourceLayerData(layerId, id, dataSource, usage);&lt;br&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;// add it to the globe&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.globeControl.Host.DataSources.Add(layer);&lt;br&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Sub&lt;/span&gt; AddFeederSource(&lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; uri &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;String&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; layerId &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;String&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; id &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;String&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; usage &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; DataSourceUsage)&lt;br&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;' create a data source from a URL&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;Dim&lt;/span&gt; dataSource &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; DataSource = VirtualEarthTileDataSource.ConnectTo(&lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; Uri(uri), &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.globeControl.Host.WebProxy, WorldMemoryDataSource.DataPath)&lt;br&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;' create a layer from that data source&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;Dim&lt;/span&gt; layer &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; DataSourceLayerData = &lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; DataSourceLayerData(layerId, id, dataSource, usage)&lt;br&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;' add it to the globe&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.globeControl.Host.DataSources.Add(layer)&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;By passing the URL of the content manifest, a name for the layer, and what the manifest represents, a new &lt;b&gt;DataSource&lt;/b&gt; is created, which is in turn used to create a &lt;b&gt;DataSourceLayerData&lt;/b&gt; object which is then given to the VE3D control to consume.&lt;/p&gt;
&lt;p&gt;With this helper method in place, we can add any of the following layers (note that there may be other content manifests provided by local.live.com, but these are the only 5 that I am aware of):&lt;/p&gt;
&lt;table border="1" cellpadding="2" cellspacing="0" width="626"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top" width="256"&gt;
&lt;p align="center"&gt;&lt;b&gt;URL&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="160"&gt;
&lt;p align="center"&gt;&lt;b&gt;DataSourceUsage Type&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="207"&gt;
&lt;p align="center"&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="258"&gt;&lt;a href="http://local.live.com/Manifests/HD.xml" title="http://local.live.com/Manifests/HighDemContentManifest.xml" mce_href="http://local.live.com/Manifests/HD.xml"&gt;http://local.live.com/Manifests/HD.xml&lt;/a&gt;&lt;/td&gt;
&lt;td valign="top" width="160"&gt;ElevationMap&lt;/td&gt;
&lt;td valign="top" width="207"&gt;Terrain data&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="259"&gt;&lt;a href="http://local.live.com/Manifests/MO.xml" title="http://local.live.com/Manifests/ModelContentManifest.xml" mce_href="http://local.live.com/Manifests/MO.xml"&gt;http://local.live.com/Manifests/MO.xml&lt;/a&gt;&lt;/td&gt;
&lt;td valign="top" width="160"&gt;Model&lt;/td&gt;
&lt;td valign="top" width="207"&gt;3D buildings&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="260"&gt;&lt;a href="http://local.live.com/Manifests/AT.xml" title="http://local.live.com/Manifests/AerialContentManifest.xml" mce_href="http://local.live.com/Manifests/AT.xml"&gt;http://local.live.com/Manifests/AT.xml&lt;/a&gt;&lt;/td&gt;
&lt;td valign="top" width="160"&gt;TextureMap&lt;/td&gt;
&lt;td valign="top" width="207"&gt;Unlabeled aerial&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="260"&gt;&lt;a href="http://local.live.com/Manifests/HT.xml" title="http://local.live.com/Manifests/HybridContentManifest.xml" mce_href="http://local.live.com/Manifests/HT.xml"&gt;http://local.live.com/Manifests/HT.xml&lt;/a&gt;&lt;/td&gt;
&lt;td valign="top" width="160"&gt;TextureMap&lt;/td&gt;
&lt;td valign="top" width="207"&gt;Labeled aerial&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="260"&gt;&lt;a href="http://local.live.com/Manifests/RT.xml" title="http://local.live.com/Manifests/RoadContentManifest.xml" mce_href="http://local.live.com/Manifests/RT.xml"&gt;http://local.live.com/Manifests/RT.xml&lt;/a&gt;&lt;/td&gt;
&lt;td valign="top" width="160"&gt;TextureMap&lt;/td&gt;
&lt;td valign="top" width="207"&gt;Roads only&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;For the best display, add the &lt;b&gt;ElevationMap&lt;/b&gt;, &lt;b&gt;Model&lt;/b&gt; and &lt;b&gt;Aerial&lt;/b&gt; &lt;b&gt;TextureMap&lt;/b&gt; layers as shown:&lt;/p&gt;
&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;// setup the default aerial layer, buildings, and elevation data&lt;/span&gt;&lt;br&gt;AddFeederSource(&lt;span style="color: rgb(0, 96, 128);"&gt;"&lt;a href="http://local.live.com/Manifests/HD.xml" class="linkification-ext" title="Linkification: http://local.live.com/Manifests/HD.xml"&gt;http://local.live.com/Manifests/HD.xml&lt;/a&gt;"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"Terrain"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"Terrain"&lt;/span&gt;, DataSourceUsage.ElevationMap);&lt;br&gt;AddFeederSource(&lt;span style="color: rgb(0, 96, 128);"&gt;"&lt;a href="http://local.live.com/Manifests/MO.xml" class="linkification-ext" title="Linkification: http://local.live.com/Manifests/MO.xml"&gt;http://local.live.com/Manifests/MO.xml&lt;/a&gt;"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"Model"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"Model"&lt;/span&gt;, DataSourceUsage.Model);&lt;br&gt;AddFeederSource(&lt;span style="color: rgb(0, 96, 128);"&gt;"&lt;a href="http://local.live.com/Manifests/AT.xml" class="linkification-ext" title="Linkification: http://local.live.com/Manifests/AT.xml"&gt;http://local.live.com/Manifests/AT.xml&lt;/a&gt;"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"Roads"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"Roads"&lt;/span&gt;, DataSourceUsage.TextureMap);&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;' setup the default aerial layer, buildings, and elevation data&lt;/span&gt;&lt;br&gt;AddFeederSource(&lt;span style="color: rgb(0, 96, 128);"&gt;"http:'&lt;a href="http://local.live.com/Manifests/HD.xml" class="linkification-ext" title="Linkification: http://local.live.com/Manifests/HD.xml"&gt;local.live.com/Manifests/HD.xml&lt;/a&gt;"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"Terrain"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"Terrain"&lt;/span&gt;, DataSourceUsage.ElevationMap)&lt;br&gt;AddFeederSource(&lt;span style="color: rgb(0, 96, 128);"&gt;"http:'&lt;a href="http://local.live.com/Manifests/MO.xml" class="linkification-ext" title="Linkification: http://local.live.com/Manifests/MO.xml"&gt;local.live.com/Manifests/MO.xml&lt;/a&gt;"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"Model"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"Model"&lt;/span&gt;, DataSourceUsage.Model)&lt;br&gt;AddFeederSource(&lt;span style="color: rgb(0, 96, 128);"&gt;"http:'&lt;a href="http://local.live.com/Manifests/AT.xml" class="linkification-ext" title="Linkification: http://local.live.com/Manifests/AT.xml"&gt;local.live.com/Manifests/AT.xml&lt;/a&gt;"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"Roads"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"Roads"&lt;/span&gt;, DataSourceUsage.TextureMap)&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If you were to run the application at this point, you would see a fully functioning Virtual Earth 3D control with proper data and navigation.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Control Scheme and Bindings&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;Controlling VE3D with the Wiimote will be accomplished using a control scheme that is very similar to most first person shooter (FPS) games on the Wii.&amp;nbsp; The nunchuk, held in the left hand, will move the camera forward/back/left/right using the joystick.&amp;nbsp; The C and Z buttons on the front of the nunchuk will be used to raise and lower the altitude of the camera.&amp;nbsp; The Wiimote, held in the right hand, will be used to change the tilt and turn of the camera.&amp;nbsp; The buttons on the Wiimote will also be hooked up to several VE3D functions.&amp;nbsp; Home will center the map to an overhead view at the current camera position.&amp;nbsp; The 1 button will toggle through the road layers.&amp;nbsp; The 2 button will toggle the overlaid UI off and on.&lt;/p&gt;
&lt;p&gt;VE3D bindings allow you to change or create new control schemes for VE3D.&amp;nbsp; Open your &lt;b&gt;%APPDATA%\Microsoft\Virtual Earth 3D&lt;/b&gt; directory.&amp;nbsp; On Windows XP, &lt;b&gt;%APPDATA%&lt;/b&gt; should resolve to &lt;b&gt;\Documents and Settings\&amp;lt;user&amp;gt;\Application Data&lt;/b&gt; .&amp;nbsp; On Windows Vista, it should resolve to &lt;b&gt;\Users\&amp;lt;user&amp;gt;\AppData\Roaming &lt;/b&gt;.&amp;nbsp; In this directory you will find a &lt;b&gt;Bindings.xml &lt;/b&gt;file.&amp;nbsp; This XML schema defines the default keyboard, mouse, Gamepad and other input device properties.&amp;nbsp; Open the file to see the schema used to define events and parameters.&lt;/p&gt;
&lt;p&gt;By default, VE3D will load any file named Bindings*.xml from this directory.&amp;nbsp; For the Wiimote control scheme, create a new file named &lt;b&gt;BindingsWiimote.xml&lt;/b&gt; in this directory.&amp;nbsp; Set the contents of the file to the following:&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;xml&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;version&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="1.0"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;encoding&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="utf-8"&lt;/span&gt; ?&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Bindings&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;BindingSet&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Name&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="wiimoteBindings"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;AutoUse&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="True"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Cursor&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Drag"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;&amp;lt;!-- Nunchuk joystick --&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Bind&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Event&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Wiimote.NunchukX"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Action&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Strafe"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Factor&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="1"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Bind&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Event&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Wiimote.NunchukY"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Action&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Move"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Factor&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="1"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;&amp;lt;!-- Nunchuk joystick with modifier since we can move and turn at the same time --&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Bind&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Event&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Wiimote.B+Wiimote.NunchukX"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Action&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Strafe"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Factor&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="1"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Bind&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Event&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Wiimote.B+Wiimote.NunchukY"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Action&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Move"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Factor&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="1"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;&amp;lt;!-- Nunchuk buttons --&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Bind&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Event&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Wiimote.NunchukC"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Action&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Ascend"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Factor&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="0.3"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Bind&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Event&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Wiimote.NunchukZ"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Action&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Ascend"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Factor&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="-0.3"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;&amp;lt;!-- Nunchuk joystick with modifier since we can move and change altitude --&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Bind&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Event&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Wiimote.B+Wiimote.NunchukC"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Action&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Ascend"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Factor&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="0.3"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Bind&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Event&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Wiimote.B+Wiimote.NunchukZ"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Action&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Ascend"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Factor&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="-0.3"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;&amp;lt;!-- Wiimote buttons --&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Bind&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Event&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Wiimote.Home"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Action&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="ResetOnCenter"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Bind&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Event&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Wiimote.One"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Action&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="ToggleRoads,WiiEarth, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Bind&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Event&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Wiimote.Two"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Action&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="ToggleUI,WiiEarth, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Bind&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Event&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Wiimote.A"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Factor&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="1"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Action&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Locations,WiiEarth, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;&amp;lt;!-- Wiimote IR for pitch/turn --&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Bind&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Event&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Wiimote.B+Wiimote.IRX"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Action&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Turn"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Factor&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="0.05"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Bind&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Event&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Wiimote.B+Wiimote.IRY"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Action&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Pitch"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Factor&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="-0.05"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;&amp;lt;!-- Wiimote accel for pitch/turn --&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Bind&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Event&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Wiimote.B+Wiimote.AX"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Action&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Turn"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Factor&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="-0.025"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Bind&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Event&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Wiimote.B+Wiimote.AY"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Action&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Pitch"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Factor&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="-0.025"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Bind&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Event&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Wiimote.Left"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Factor&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="-1"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Action&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Locations,WiiEarth, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Bind&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Event&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Wiimote.Up"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Factor&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="-1"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Action&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="LocationsMove,WiiEarth, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Bind&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Event&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Wiimote.Down"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Factor&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="1"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Action&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="LocationsMove,WiiEarth, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;&amp;lt;!-- FPS-style keyboard controls in case we don't have a nunchuk --&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Bind&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Event&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Key.W"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Action&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Move"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Factor&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="22"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Bind&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Event&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Key.S"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Action&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Move"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Factor&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="-22"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Bind&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Event&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Key.D"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Action&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Strafe"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Factor&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="22"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Bind&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Event&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Key.A"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Action&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Strafe"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Factor&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="-22"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Bind&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Event&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Key.Space"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Action&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Ascend"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Factor&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="20"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Bind&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Event&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Key.C"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Action&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Ascend"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Factor&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="-20"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Bind&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Event&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Key.Z"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Action&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="ToggleRoads,WiiEarth, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Bind&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Event&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Key.X"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Action&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="ToggleUI,WiiEarth, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;BindingSet&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Bindings&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The &lt;b&gt;&amp;lt;BindingSet&amp;gt;&lt;/b&gt; tags wrap groups of control bindings.&amp;nbsp; It requires a &lt;b&gt;Name&lt;/b&gt; and optionally a &lt;b&gt;Cursor&lt;/b&gt;.&amp;nbsp; If the binding set is to be used automatically, as it would be in most cases, set the &lt;b&gt;AutoUse&lt;/b&gt; parameter to &lt;b&gt;True&lt;/b&gt;.&amp;nbsp; Inside of that are &lt;b&gt;&amp;lt;Bind&amp;gt;&lt;/b&gt; tags.&amp;nbsp; The tag requires the &lt;b&gt;Event&lt;/b&gt;, &lt;b&gt;Action&lt;/b&gt; parameters and optionally the &lt;b&gt;Factor&lt;/b&gt; parameter.&amp;nbsp; The &lt;b&gt;Event &lt;/b&gt;parameter will be used to match the binding to its handler which will be written later.&amp;nbsp; The syntax is &amp;lt;Handler Name&amp;gt;.&amp;lt;Event Name&amp;gt;.&amp;nbsp; The &lt;b&gt;Action&lt;/b&gt; parameter is used to map the specific binding to a particular method.&amp;nbsp; The &lt;b&gt;Factor&lt;/b&gt; parameter is optional and can be used to scale the data value up or down to increase or decrease sensitivity of the input method.&amp;nbsp; Once the handler is written, these will make more sense.&lt;/p&gt;
&lt;p&gt;The bindings above create the control scheme described above:&amp;nbsp; NunchukX/Y describe what happens when the analog joystick is moved, NunchukC/Z describe what happens with the C/Z buttons are pressed, and so on.&lt;/p&gt;
&lt;p&gt;The bindings also allow for several variations.&amp;nbsp; Bindings are defined for both the IR position (&lt;b&gt;IRX&lt;/b&gt;, &lt;b&gt;IRY&lt;/b&gt;) and accelerometer values (&lt;b&gt;AX&lt;/b&gt;, &lt;b&gt;AY&lt;/b&gt;).&amp;nbsp; If an IR sensor bar is not available, the accelerometer values of the Wiimote can be used instead.&amp;nbsp; Additionally, keyboard bindings are created in the style of a first person shooter using WASD.&amp;nbsp; These can be used if a Nunchuk is not available.&lt;/p&gt;
&lt;p&gt;Note that some bindings append two &lt;b&gt;Event&lt;/b&gt;s together with a + sign.&amp;nbsp; This allows for button combinations.&amp;nbsp; In this case, for the accelerometer and/or IR sensor, we only want to register the action if a button is pressed down.&amp;nbsp; So, those events which require the button to be held down contain &lt;b&gt;Wiimote.B+&lt;/b&gt; and the event it is combined with.&amp;nbsp; Also note that the combination events override other events that don't have a combination listed.&amp;nbsp; So, for example, NunchukC is listed as working alone and with the &lt;b&gt;Wiimote.B&lt;/b&gt; event.&lt;/p&gt;
&lt;p&gt;For those events which require a custom action that will be written separately and not part of the VE3D control, the &lt;b&gt;Action&lt;/b&gt; parameter must contain the action name, followed by a comma, and then the full assembly name:&lt;/p&gt;
&lt;div&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Bind&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Event&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Wiimote.One"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;Action&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="ToggleRoads,&lt;br&gt;        WiiEarth, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can change any of these button bindings simply by changing this XML file and deploying to the directory above.&amp;nbsp; So, for example, if you wanted the trigger button to be A, you would just change &lt;b&gt;Wiimote.B&lt;/b&gt; to &lt;b&gt;Wiimote.A&lt;/b&gt; in the above lines and re-deploy the bindings file.&lt;/p&gt;
&lt;p&gt;The XML file also binds several keyboard keys in a first-person shooter style layout in the event the user does not have a nunchuk for the left hand functions.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Event Source&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;An &lt;b&gt;EventSource&lt;/b&gt; is needed which will grab data from the Wiimote and pass it along to VE3D as defined by the bindings file above.&amp;nbsp; Create a new class named &lt;b&gt;WiimoteEventSource&lt;/b&gt; which derives from &lt;b&gt;Microsoft.MapPoint.Binding.EventSource&lt;/b&gt;&amp;nbsp; as follows:&lt;/p&gt;
&lt;p&gt;Next, add an enumeration named &lt;b&gt;WiimoteEvent&lt;/b&gt; (the name isn't important) which contains all of the &lt;b&gt;Name&lt;/b&gt; items from the bindings XML file above.&amp;nbsp; It should look like this:&lt;/p&gt;
&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;// all events handled by this event source from XML file&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;enum&lt;/span&gt; WiimoteEvent&lt;br&gt;{&lt;br&gt;    IRX,        &lt;span style="color: rgb(0, 128, 0);"&gt;// IR X position&lt;/span&gt;&lt;br&gt;    IRY,        &lt;span style="color: rgb(0, 128, 0);"&gt;// IR Y position&lt;/span&gt;&lt;br&gt;    NunchukX,    &lt;span style="color: rgb(0, 128, 0);"&gt;// Nunchuk joystick X position&lt;/span&gt;&lt;br&gt;    NunchukY,    &lt;span style="color: rgb(0, 128, 0);"&gt;// Nunchuk joystick Y position&lt;/span&gt;&lt;br&gt;    NunchukC,    &lt;span style="color: rgb(0, 128, 0);"&gt;// Nunchuk C button&lt;/span&gt;&lt;br&gt;    NunchukZ,    &lt;span style="color: rgb(0, 128, 0);"&gt;// Nunchuk Z button&lt;/span&gt;&lt;br&gt;    AX,            &lt;span style="color: rgb(0, 128, 0);"&gt;// Wiimote accelerometer X&lt;/span&gt;&lt;br&gt;    AY,            &lt;span style="color: rgb(0, 128, 0);"&gt;// Wiimote accelerometer Y&lt;/span&gt;&lt;br&gt;    Up,            &lt;span style="color: rgb(0, 128, 0);"&gt;// Dpad up&lt;/span&gt;&lt;br&gt;    Down,        &lt;span style="color: rgb(0, 128, 0);"&gt;// Dpad down&lt;/span&gt;&lt;br&gt;    Left,        &lt;span style="color: rgb(0, 128, 0);"&gt;// Dpad left&lt;/span&gt;&lt;br&gt;    Right,        &lt;span style="color: rgb(0, 128, 0);"&gt;// Dpad right&lt;/span&gt;&lt;br&gt;    A,            &lt;span style="color: rgb(0, 128, 0);"&gt;// A button&lt;/span&gt;&lt;br&gt;    B,            &lt;span style="color: rgb(0, 128, 0);"&gt;// B button&lt;/span&gt;&lt;br&gt;    Minus,        &lt;span style="color: rgb(0, 128, 0);"&gt;// Minus button&lt;/span&gt;&lt;br&gt;    Home,        &lt;span style="color: rgb(0, 128, 0);"&gt;// Wiimote Home button&lt;/span&gt;&lt;br&gt;    Plus,        &lt;span style="color: rgb(0, 128, 0);"&gt;// Plus button&lt;/span&gt;&lt;br&gt;    One,        &lt;span style="color: rgb(0, 128, 0);"&gt;// Wiimote One button&lt;/span&gt;&lt;br&gt;    Two,        &lt;span style="color: rgb(0, 128, 0);"&gt;// Wiimote Two button&lt;/span&gt;&lt;br&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Enum&lt;/span&gt; WiimoteEvent&lt;br&gt;    IRX &lt;span style="color: rgb(0, 128, 0);"&gt;' IR X position&lt;/span&gt;&lt;br&gt;    IRY &lt;span style="color: rgb(0, 128, 0);"&gt;' IR Y position&lt;/span&gt;&lt;br&gt;    NunchukX &lt;span style="color: rgb(0, 128, 0);"&gt;' Nunchuk joystick X position&lt;/span&gt;&lt;br&gt;    NunchukY &lt;span style="color: rgb(0, 128, 0);"&gt;' Nunchuk joystick Y position&lt;/span&gt;&lt;br&gt;    NunchukC &lt;span style="color: rgb(0, 128, 0);"&gt;' Nunchuk C button&lt;/span&gt;&lt;br&gt;    NunchukZ &lt;span style="color: rgb(0, 128, 0);"&gt;' Nunchuk Z button&lt;/span&gt;&lt;br&gt;    AX &lt;span style="color: rgb(0, 128, 0);"&gt;' Wiimote accelerometer X&lt;/span&gt;&lt;br&gt;    AY &lt;span style="color: rgb(0, 128, 0);"&gt;' Wiimote accelerometer Y&lt;/span&gt;&lt;br&gt;    Up &lt;span style="color: rgb(0, 128, 0);"&gt;' Dpad up&lt;/span&gt;&lt;br&gt;    Down &lt;span style="color: rgb(0, 128, 0);"&gt;' Dpad down&lt;/span&gt;&lt;br&gt;    Left &lt;span style="color: rgb(0, 128, 0);"&gt;' Dpad left&lt;/span&gt;&lt;br&gt;    Right &lt;span style="color: rgb(0, 128, 0);"&gt;' Dpad right&lt;/span&gt;&lt;br&gt;    A &lt;span style="color: rgb(0, 128, 0);"&gt;' A button&lt;/span&gt;&lt;br&gt;    B &lt;span style="color: rgb(0, 128, 0);"&gt;' B button&lt;/span&gt;&lt;br&gt;    Minus &lt;span style="color: rgb(0, 128, 0);"&gt;' Minus button&lt;/span&gt;&lt;br&gt;    Home &lt;span style="color: rgb(0, 128, 0);"&gt;' Wiimote Home button&lt;/span&gt;&lt;br&gt;    Plus &lt;span style="color: rgb(0, 128, 0);"&gt;' Plus button&lt;/span&gt;&lt;br&gt;    One &lt;span style="color: rgb(0, 128, 0);"&gt;' Wiimote One button&lt;/span&gt;&lt;br&gt;    Two &lt;span style="color: rgb(0, 128, 0);"&gt;' Wiimote Two button&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; Enum&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Next, several methods from the &lt;b&gt;EventSource&lt;/b&gt; object need to be overridden:&amp;nbsp; &lt;b&gt;GetEventData&lt;/b&gt;, &lt;b&gt;IsModifier&lt;/b&gt;, &lt;b&gt;CanModify&lt;/b&gt;, &lt;b&gt;TryGetEventId&lt;/b&gt;, &lt;b&gt;TryGetEventName&lt;/b&gt;, &lt;b&gt;Name&lt;/b&gt;.&amp;nbsp; The methods do the following:&lt;/p&gt;
&lt;table border="1" cellpadding="2" cellspacing="0" width="400"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top" width="200"&gt;
&lt;p align="center"&gt;&lt;b&gt;Method/Property&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td valign="top" width="200"&gt;
&lt;p align="center"&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="200"&gt;GetEventData&lt;/td&gt;
&lt;td valign="top" width="200"&gt;Unsure at the moment...does not need to be implemented?&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="200"&gt;IsModifier&lt;/td&gt;
&lt;td valign="top" width="200"&gt;Returns a boolean stating whether the passed in event ID is a modifier (such as the Wiimote.B event above)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="200"&gt;CanModify&lt;/td&gt;
&lt;td valign="top" width="200"&gt;Returns a boolean stating whether the current event is allowed as a modifier&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="200"&gt;TryGetEventID&lt;/td&gt;
&lt;td valign="top" width="200"&gt;Maps a string event name from the bindings file to the integer value in the enumeration above&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="200"&gt;TryGetEventName&lt;/td&gt;
&lt;td valign="top" width="200"&gt;Maps an integer event ID to the string name in the enumeration above&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="200"&gt;Name (property)&lt;/td&gt;
&lt;td valign="top" width="200"&gt;Returns the name of the handler which must match the name in the XML file above (Wiimote in this case)&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;The code for these methods is presented below:&lt;/p&gt;
&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;// return out value of the passed enum&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;override&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;bool&lt;/span&gt; TryGetEventId(&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; eventName, &lt;span style="color: rgb(0, 0, 255);"&gt;out&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt; eventId)&lt;br&gt;{&lt;br&gt;    eventId = (&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt;)Enum.Parse(&lt;span style="color: rgb(0, 0, 255);"&gt;typeof&lt;/span&gt;(WiimoteEvent), eventName);&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;;&lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;// return out the string name of the passed in enum value&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;override&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;bool&lt;/span&gt; TryGetEventName(&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt; eventId, &lt;span style="color: rgb(0, 0, 255);"&gt;out&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; eventName)&lt;br&gt;{&lt;br&gt;    eventName = ((WiimoteEvent)eventId).ToString();&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;;&lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;// unknown&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;override&lt;/span&gt; EventData GetEventData(&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt; eventId, EventActivateState state)&lt;br&gt;{&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;throw&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; NotImplementedException();&lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;// can the event be used as a modifier?&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;override&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;bool&lt;/span&gt; IsModifier(&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt; eventId)&lt;br&gt;{&lt;br&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;// yes to all for now&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;;&lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;// can the supplied event be used as a modifier?&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;override&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;bool&lt;/span&gt; CanModify(&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt; eventId, EventKey other)&lt;br&gt;{&lt;br&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;// only if it's from us&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; (other.Source == &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;);&lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;// this must match the Source name in the bindings XML file&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;override&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; Name&lt;br&gt;{&lt;br&gt;    get { &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 96, 128);"&gt;"Wiimote"&lt;/span&gt;; }&lt;br&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;' return out value of the passed enum&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Overrides&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Function&lt;/span&gt; TryGetEventId(&lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; eventName &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;String&lt;/span&gt;, &amp;lt;System.Runtime.InteropServices.Out()&amp;gt; &lt;span style="color: rgb(0, 0, 255);"&gt;ByRef&lt;/span&gt; eventId &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Integer&lt;/span&gt;) &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Boolean&lt;/span&gt;&lt;br&gt;    eventId = &lt;span style="color: rgb(0, 0, 255);"&gt;CInt&lt;/span&gt;(Fix(System.&lt;span style="color: rgb(0, 0, 255);"&gt;Enum&lt;/span&gt;.Parse(&lt;span style="color: rgb(0, 0, 255);"&gt;GetType&lt;/span&gt;(WiimoteEvent), eventName)))&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;Return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;True&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Function&lt;/span&gt;&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;' return out the string name of the passed in enum value&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Overrides&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Function&lt;/span&gt; TryGetEventName(&lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; eventId &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Integer&lt;/span&gt;, &amp;lt;System.Runtime.InteropServices.Out()&amp;gt; &lt;span style="color: rgb(0, 0, 255);"&gt;ByRef&lt;/span&gt; eventName &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;String&lt;/span&gt;) &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Boolean&lt;/span&gt;&lt;br&gt;    eventName = (&lt;span style="color: rgb(0, 0, 255);"&gt;CType&lt;/span&gt;(eventId, WiimoteEvent)).ToString()&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;Return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;True&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Function&lt;/span&gt;&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;' unknown&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Overrides&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Function&lt;/span&gt; GetEventData(&lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; eventId &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Integer&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; state &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; EventActivateState) &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; EventData&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;Throw&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; NotImplementedException()&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Function&lt;/span&gt;&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;' can the event be used as a modifier?&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Overrides&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Function&lt;/span&gt; IsModifier(&lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; eventId &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Integer&lt;/span&gt;) &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Boolean&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;' yes to all for now&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;Return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;True&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Function&lt;/span&gt;&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;' can the supplied event be used as a modifier?&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Overrides&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Function&lt;/span&gt; CanModify(&lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; eventId &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Integer&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; other &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; EventKey) &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Boolean&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;' only if it's from us&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;Return&lt;/span&gt; (other.Source &lt;span style="color: rgb(0, 0, 255);"&gt;Is&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;)&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Function&lt;/span&gt;&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;' this must match the Source name in the bindings XML file&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Overrides&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;ReadOnly&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Property&lt;/span&gt; Name() &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;String&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;Get&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;Return&lt;/span&gt; &lt;span style="color: rgb(0, 96, 128);"&gt;"Wiimote"&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Get&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; Property&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;With that in place, the constructor can be implemented which will call the base constructor and connect to the Wiimote.&amp;nbsp; It is assumed you read the Wiimote article above and know how the library works.&lt;/p&gt;
&lt;p&gt;The constructor must take one argument passed from the main from:&amp;nbsp; an instance of the &lt;b&gt;GlobeControl&lt;/b&gt;'s &lt;b&gt;ActionSystem&lt;/b&gt;.&amp;nbsp; This just gets passed directly to the parent object's constructor untouched.&amp;nbsp; The constructor code looks like the following:&lt;/p&gt;
&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; WiimoteEventSource(ActionSystem actionSystem, MainForm form) : &lt;span style="color: rgb(0, 0, 255);"&gt;base&lt;/span&gt;(actionSystem)&lt;br&gt;{&lt;br&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;// store away an instance of the main form&lt;/span&gt;&lt;br&gt;    _form = form;&lt;br&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;// setup wiimote and event handlers&lt;/span&gt;&lt;br&gt;    _wm = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; Wiimote();&lt;br&gt;    _wm.OnWiimoteChanged += &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; WiimoteChangedEventHandler(OnWiimoteChanged);&lt;br&gt;    _wm.OnWiimoteExtensionChanged += &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; WiimoteExtensionChanged(OnWiimoteExtensionChanged);&lt;br&gt;    _wm.Connect();&lt;br&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;// if we don't have an extension, set the report type to IR and accel's only&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;(!_wm.WiimoteState.Extension)&lt;br&gt;        _wm.SetReportType(Wiimote.InputReport.IRAccel, &lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;);&lt;br&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;// turn off all LEDs&lt;/span&gt;&lt;br&gt;    _wm.SetLEDs(0x00);&lt;br&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Sub&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt;(&lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; actionSystem &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; ActionSystem, &lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; form &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; MainForm)&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;MyBase&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt;(actionSystem)&lt;br&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;' store away an instance of the main form&lt;/span&gt;&lt;br&gt;    _form = form&lt;br&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;' setup wiimote and event handlers&lt;/span&gt;&lt;br&gt;    _wm = &lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; Wiimote()&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;AddHandler&lt;/span&gt; _wm.OnWiimoteChanged, &lt;span style="color: rgb(0, 0, 255);"&gt;AddressOf&lt;/span&gt; OnWiimoteChanged&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;AddHandler&lt;/span&gt; _wm.OnWiimoteExtensionChanged, &lt;span style="color: rgb(0, 0, 255);"&gt;AddressOf&lt;/span&gt; OnWiimoteExtensionChanged&lt;br&gt;    _wm.Connect()&lt;br&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;' if we don't have an extension, set the report type to IR and accel's only&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt; (&lt;span style="color: rgb(0, 0, 255);"&gt;Not&lt;/span&gt; _wm.WiimoteState.Extension) &lt;span style="color: rgb(0, 0, 255);"&gt;Then&lt;/span&gt;&lt;br&gt;        _wm.SetReportType(Wiimote.InputReport.IRAccel, &lt;span style="color: rgb(0, 0, 255);"&gt;True&lt;/span&gt;)&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt;&lt;br&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;' turn off all LEDs&lt;/span&gt;&lt;br&gt;    _wm.SetLEDs(&amp;amp;H00)&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The &lt;b&gt;OnWiimoteExtensionChanged&lt;/b&gt; method simply sets the report mode for the Wiimote based on whether or not a Nunchuk is inserted as shown:&lt;/p&gt;
&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; OnWiimoteExtensionChanged(&lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt; sender, WiimoteExtensionChangedEventArgs args)&lt;br&gt;{&lt;br&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;// if nunchuk inserted, set the report type to return extension data&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;(args.ExtensionType == ExtensionType.Nunchuk &amp;amp;&amp;amp; args.Inserted)&lt;br&gt;        _wm.SetReportType(Wiimote.InputReport.IRExtensionAccel, &lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;);&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;else&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0);"&gt;// in all other cases, set it to the default IR and accel's&lt;/span&gt;&lt;br&gt;        _wm.SetReportType(Wiimote.InputReport.IRAccel, &lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;);&lt;br&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Sub&lt;/span&gt; OnWiimoteExtensionChanged(&lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Object&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; args &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; WiimoteExtensionChangedEventArgs)&lt;br&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;' if nunchuk inserted, set the report type to return extension data&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt; args.ExtensionType = ExtensionType.Nunchuk &lt;span style="color: rgb(0, 0, 255);"&gt;AndAlso&lt;/span&gt; args.Inserted &lt;span style="color: rgb(0, 0, 255);"&gt;Then&lt;/span&gt;&lt;br&gt;        _wm.SetReportType(Wiimote.InputReport.IRExtensionAccel, &lt;span style="color: rgb(0, 0, 255);"&gt;True&lt;/span&gt;)&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;Else&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0);"&gt;' in all other cases, set it to the default IR and accel's&lt;/span&gt;&lt;br&gt;        _wm.SetReportType(Wiimote.InputReport.IRAccel, &lt;span style="color: rgb(0, 0, 255);"&gt;True&lt;/span&gt;)&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The &lt;b&gt;OnWiimoteChanged&lt;/b&gt; event handler is where the Wiimote data is handled and sent off to the VE3D control to reflect the changes.&amp;nbsp; First, let's handle the IR and accelerometer data.&amp;nbsp; The IR midpoint of the X and Y axes will be used from the &lt;b&gt;WiimoteState&lt;/b&gt; object to activate the &lt;b&gt;IRX&lt;/b&gt; and &lt;b&gt;IRY&lt;/b&gt; events we defined above in the bindings XML file.&amp;nbsp; The accelerometer X and Y values will be used to activate the &lt;b&gt;AX &lt;/b&gt;and &lt;b&gt;AY&lt;/b&gt; events.&lt;/p&gt;
&lt;p&gt;This snippet assumes that there is a boolean property named &lt;b&gt;UseIR&lt;/b&gt; created in the project to determine whether IR or motion values are used.&amp;nbsp; Additionally, it assumes there are property settings created which contain values for the X/Y "dead zones" for the IR and accelerometers.&amp;nbsp; These dead zones are used as a way to only activate the event when the values are pushed beyond the thresholds.&amp;nbsp; This allows there to be a margin where the user's hand will not be read as movement, allowing the user to not have to worry about keeping a steady hand.&lt;/p&gt;
&lt;p&gt;The application linked above uses the following values for dead zones:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;NunchukDeadX/Y -&amp;gt; 0.025 
&lt;/li&gt;&lt;li&gt;WiimoteDeadX/Y -&amp;gt; 0.15 
&lt;/li&gt;&lt;li&gt;IRDeadX/Y -&amp;gt; 0.1&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;// if we're using the IR&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;(Properties.Settings.Default.UseIR)&lt;br&gt;{&lt;br&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;// and both LEDs are found&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;(ws.IRState.Found1 &amp;amp;&amp;amp; ws.IRState.Found2)&lt;br&gt;    {&lt;br&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;// normalize the midpoints to -0.5 to 0.5 (from 0 to 1.0)&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;float&lt;/span&gt; x = ws.IRState.MidX - 0.5f;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;float&lt;/span&gt; y = ws.IRState.MidY - 0.5f;&lt;br&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;// if we're beyond the thresholds, activate the events&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;(x &amp;gt; Properties.Settings.Default.IRDeadX || x &amp;lt; -Properties.Settings.Default.IRDeadX)&lt;br&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;, (&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt;)WiimoteEvent.IRX), x));&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;(y &amp;gt; Properties.Settings.Default.IRDeadY || y &amp;lt; -Properties.Settings.Default.IRDeadY)&lt;br&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;, (&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt;)WiimoteEvent.IRY), y));&lt;br&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;// save the last IR settings...these get used if we go beyond the range of the IRs.&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;// in that case, the last used positions will be used until the Wiimote comes back in range&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;._lastIRX = x;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;._lastIRY = y;&lt;br&gt;    }&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;else&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0);"&gt;// one or both LEDs aren't seen&lt;/span&gt;&lt;br&gt;    {&lt;br&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;// activate events based on the last known positions&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;(&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;._lastIRX &amp;gt; Properties.Settings.Default.IRDeadX || &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;._lastIRX &amp;lt; -Properties.Settings.Default.IRDeadX)&lt;br&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;, (&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt;)WiimoteEvent.IRX), &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;._lastIRX));&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;(&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;._lastIRY &amp;gt; Properties.Settings.Default.IRDeadY || &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;._lastIRY &amp;lt; -Properties.Settings.Default.IRDeadY)&lt;br&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;, (&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt;)WiimoteEvent.IRY), &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;._lastIRY));&lt;br&gt;    }&lt;br&gt;}&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;else&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0);"&gt;// we're using motion controls&lt;/span&gt;&lt;br&gt;{&lt;br&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;// activate the events based on the accelerometer values&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;(ws.AccelState.X &amp;gt; Properties.Settings.Default.WiimoteDeadX || ws.AccelState.X &amp;lt; -Properties.Settings.Default.WiimoteDeadX)&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;, (&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt;)WiimoteEvent.AX), ws.AccelState.X));&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;(ws.AccelState.Y &amp;gt; Properties.Settings.Default.WiimoteDeadY || ws.AccelState.Y &amp;lt; -Properties.Settings.Default.WiimoteDeadY)&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;, (&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt;)WiimoteEvent.AY), ws.AccelState.Y));&lt;br&gt;}&lt;br&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;' if we're using the IR&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt; My.Settings.&lt;span style="color: rgb(0, 0, 255);"&gt;Default&lt;/span&gt;.UseIR &lt;span style="color: rgb(0, 0, 255);"&gt;Then&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;' and both LEDs are found&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt; ws.IRState.Found1 &lt;span style="color: rgb(0, 0, 255);"&gt;AndAlso&lt;/span&gt; ws.IRState.Found2 &lt;span style="color: rgb(0, 0, 255);"&gt;Then&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;' normalize the midpoints to -0.5 to 0.5 (from 0 to 1.0)&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;Dim&lt;/span&gt; x &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Single&lt;/span&gt; = ws.IRState.MidX - 0.5f&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;Dim&lt;/span&gt; y &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Single&lt;/span&gt; = ws.IRState.MidY - 0.5f&lt;br&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;' if we're beyond the thresholds, activate the events&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt; x &amp;gt; My.Settings.&lt;span style="color: rgb(0, 0, 255);"&gt;Default&lt;/span&gt;.IRDeadX &lt;span style="color: rgb(0, 0, 255);"&gt;OrElse&lt;/span&gt; x &amp;lt; -My.Settings.&lt;span style="color: rgb(0, 0, 255);"&gt;Default&lt;/span&gt;.IRDeadX &lt;span style="color: rgb(0, 0, 255);"&gt;Then&lt;/span&gt;&lt;br&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.IRX))), x))&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt; y &amp;gt; My.Settings.&lt;span style="color: rgb(0, 0, 255);"&gt;Default&lt;/span&gt;.IRDeadY &lt;span style="color: rgb(0, 0, 255);"&gt;OrElse&lt;/span&gt; y &amp;lt; -My.Settings.&lt;span style="color: rgb(0, 0, 255);"&gt;Default&lt;/span&gt;.IRDeadY &lt;span style="color: rgb(0, 0, 255);"&gt;Then&lt;/span&gt;&lt;br&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.IRY))), y))&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt;&lt;br&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;' save the last IR settings...these get used if we go beyond the range of the IRs.&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;' in that case, the last used positions will be used until the Wiimote comes back in range&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;._lastIRX = x&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;._lastIRY = y&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;Else&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0);"&gt;' one or both LEDs aren't seen&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;' activate events based on the last known positions&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;._lastIRX &amp;gt; My.Settings.&lt;span style="color: rgb(0, 0, 255);"&gt;Default&lt;/span&gt;.IRDeadX &lt;span style="color: rgb(0, 0, 255);"&gt;OrElse&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;._lastIRX &amp;lt; -My.Settings.&lt;span style="color: rgb(0, 0, 255);"&gt;Default&lt;/span&gt;.IRDeadX &lt;span style="color: rgb(0, 0, 255);"&gt;Then&lt;/span&gt;&lt;br&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.IRX))), &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;._lastIRX))&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;._lastIRY &amp;gt; My.Settings.&lt;span style="color: rgb(0, 0, 255);"&gt;Default&lt;/span&gt;.IRDeadY &lt;span style="color: rgb(0, 0, 255);"&gt;OrElse&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;._lastIRY &amp;lt; -My.Settings.&lt;span style="color: rgb(0, 0, 255);"&gt;Default&lt;/span&gt;.IRDeadY &lt;span style="color: rgb(0, 0, 255);"&gt;Then&lt;/span&gt;&lt;br&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.IRY))), &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;._lastIRY))&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Else&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0);"&gt;' we're using motion controls&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;' activate the events based on the accelerometer values&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt; ws.AccelState.X &amp;gt; My.Settings.&lt;span style="color: rgb(0, 0, 255);"&gt;Default&lt;/span&gt;.WiimoteDeadX &lt;span style="color: rgb(0, 0, 255);"&gt;OrElse&lt;/span&gt; ws.AccelState.X &amp;lt; -My.Settings.&lt;span style="color: rgb(0, 0, 255);"&gt;Default&lt;/span&gt;.WiimoteDeadX &lt;span style="color: rgb(0, 0, 255);"&gt;Then&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.AX))), ws.AccelState.X))&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt; ws.AccelState.Y &amp;gt; My.Settings.&lt;span style="color: rgb(0, 0, 255);"&gt;Default&lt;/span&gt;.WiimoteDeadY &lt;span style="color: rgb(0, 0, 255);"&gt;OrElse&lt;/span&gt; ws.AccelState.Y &amp;lt; -My.Settings.&lt;span style="color: rgb(0, 0, 255);"&gt;Default&lt;/span&gt;.WiimoteDeadY &lt;span style="color: rgb(0, 0, 255);"&gt;Then&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.AY))), ws.AccelState.Y))&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This code looks at the appropriate values, determines if they are beyond the specified thresholds for the dead zones, and, if they are, activates the event for that value using the &lt;b&gt;Execute &lt;/b&gt;method.&amp;nbsp; &lt;b&gt;Execute &lt;/b&gt;is a method in the base &lt;b&gt;EventSource&lt;/b&gt; class.&amp;nbsp; This method will activate the event specified from the enumeration (which, remember, is contained in the bindings XML file) with the value associated with that event.&amp;nbsp; An &lt;b&gt;EventData&lt;/b&gt; object of some type must be created and passed to the &lt;b&gt;Execute&lt;/b&gt; method.&amp;nbsp; There are two &lt;b&gt;EventData&lt;/b&gt; types to know about:&amp;nbsp; &lt;b&gt;AxisEventData&lt;/b&gt; and &lt;b&gt;ButtonEventData&lt;/b&gt;.&amp;nbsp; &lt;b&gt;AxisEventData&lt;/b&gt; should be used when an event is activated that will modify the map position in some way.&amp;nbsp; That is, if the map is being turned, elevation is changing, etc.&amp;nbsp; &lt;b&gt;ButtonEventData&lt;/b&gt; should be used if the event is a simple toggle like pressing a button down and releasing it.&lt;/p&gt;
&lt;p&gt;Next, the nunchuk values need to be read and the associated events activated.&amp;nbsp; This is done as follows:&lt;/p&gt;
&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;// if the nunchuk is connected&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;(ws.Extension &amp;amp;&amp;amp; ws.ExtensionType == ExtensionType.Nunchuk)&lt;br&gt;{&lt;br&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;// activate the nunchuk-based events&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;(ws.NunchukState.X &amp;gt; Properties.Settings.Default.NunchukDeadX || ws.NunchukState.X &amp;lt; -Properties.Settings.Default.NunchukDeadX)&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;, (&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt;)WiimoteEvent.NunchukX), ws.NunchukState.X));&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;(ws.NunchukState.Y &amp;gt; Properties.Settings.Default.NunchukDeadY || ws.NunchukState.Y &amp;lt; -Properties.Settings.Default.NunchukDeadY)&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;, (&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt;)WiimoteEvent.NunchukY), ws.NunchukState.Y));&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;(ws.NunchukState.C)&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;, (&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt;)WiimoteEvent.NunchukC), 1.0f));&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;(ws.NunchukState.Z)&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; AxisEventData(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;, (&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt;)WiimoteEvent.NunchukZ), 1.0f));&lt;br&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;' if the nunchuk is connected&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt; ws.Extension &lt;span style="color: rgb(0, 0, 255);"&gt;AndAlso&lt;/span&gt; ws.ExtensionType = ExtensionType.Nunchuk &lt;span style="color: rgb(0, 0, 255);"&gt;Then&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;' activate the nunchuk-based events&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt; ws.NunchukState.X &amp;gt; My.Settings.&lt;span style="color: rgb(0, 0, 255);"&gt;Default&lt;/span&gt;.NunchukDeadX &lt;span style="color: rgb(0, 0, 255);"&gt;OrElse&lt;/span&gt; ws.NunchukState.X &amp;lt; -My.Settings.&lt;span style="color: rgb(0, 0, 255);"&gt;Default&lt;/span&gt;.NunchukDeadX &lt;span style="color: rgb(0, 0, 255);"&gt;Then&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.NunchukX))), ws.NunchukState.X))&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt; ws.NunchukState.Y &amp;gt; My.Settings.&lt;span style="color: rgb(0, 0, 255);"&gt;Default&lt;/span&gt;.NunchukDeadY &lt;span style="color: rgb(0, 0, 255);"&gt;OrElse&lt;/span&gt; ws.NunchukState.Y &amp;lt; -My.Settings.&lt;span style="color: rgb(0, 0, 255);"&gt;Default&lt;/span&gt;.NunchukDeadY &lt;span style="color: rgb(0, 0, 255);"&gt;Then&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.NunchukY))), ws.NunchukState.Y))&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt; ws.NunchukState.C &lt;span style="color: rgb(0, 0, 255);"&gt;Then&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.NunchukC))), 1.0f))&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt; ws.NunchukState.Z &lt;span style="color: rgb(0, 0, 255);"&gt;Then&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; AxisEventData(&lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;CInt&lt;/span&gt;(Fix(WiimoteEvent.NunchukZ))), 1.0f))&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Finally, the button events need to be activated.&amp;nbsp; A helper method which will check the current button state will be used for determining which button of all the Wiimote buttons is pressed.&amp;nbsp; For those that are, the appropriate event is activated with a call to &lt;b&gt;Execute&lt;/b&gt;.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; HandleButton(WiimoteEvent we, &lt;span style="color: rgb(0, 0, 255);"&gt;bool&lt;/span&gt; buttonState, &lt;span style="color: rgb(0, 0, 255);"&gt;bool&lt;/span&gt; lastButtonState)&lt;br&gt;{&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;(buttonState == lastButtonState)&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt;;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;else&lt;/span&gt;&lt;br&gt;    {&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;(buttonState)&lt;br&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; ButtonEventData(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;, (&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt;)we), EventActivateState.Activate));&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;else&lt;/span&gt;&lt;br&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.Execute(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; ButtonEventData(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; EventKey(&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;, (&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt;)we), EventActivateState.Deactivate));&lt;br&gt;    }&lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;// handle all the Wiimote buttons&lt;/span&gt;&lt;br&gt;HandleButton(WiimoteEvent.Up, ws.ButtonState.Up, _lastBS.Up);&lt;br&gt;HandleButton(WiimoteEvent.Down, ws.ButtonState.Down, _lastBS.Down);&lt;br&gt;HandleButton(WiimoteEvent.Left, ws.ButtonState.Left, _lastBS.Left);&lt;br&gt;HandleButton(WiimoteEvent.Right, ws.ButtonState.Right, _lastBS.Right);&lt;br&gt;HandleButton(WiimoteEvent.A, ws.ButtonState.A, _lastBS.A);&lt;br&gt;HandleButton(WiimoteEvent.B, ws.ButtonState.B, _lastBS.B);&lt;br&gt;HandleButton(WiimoteEvent.Minus, ws.ButtonState.Minus, _lastBS.Minus);&lt;br&gt;HandleButton(WiimoteEvent.Home, ws.ButtonState.Home, _lastBS.Home);&lt;br&gt;HandleButton(WiimoteEvent.Plus, ws.ButtonState.Plus, _lastBS.Plus);&lt;br&gt;HandleButton(WiimoteEvent.One, ws.ButtonState.One, _lastBS.One);&lt;br&gt;HandleButton(WiimoteEvent.Two, ws.ButtonState.Two, _lastBS.Two);&lt;br&gt;&lt;br&gt;...&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;// save off the current button state for next time&lt;/span&gt;&lt;br&gt;_lastBS = ws.ButtonState;&lt;br&gt;_lastNunchuk = ws.NunchukState;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Sub&lt;/span&gt; HandleButton(&lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; we &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; WiimoteEvent, &lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; buttonState &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Boolean&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; lastButtonState &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Boolean&lt;/span&gt;)&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt; buttonState = lastButtonState &lt;span style="color: rgb(0, 0, 255);"&gt;Then&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;Return&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;Else&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt; buttonState &lt;span style="color: rgb(0, 0, 255);"&gt;Then&lt;/span&gt;&lt;br&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; ButtonEventData(&lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;CInt&lt;/span&gt;(Fix(we))), EventActivateState.Activate))&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;Else&lt;/span&gt;&lt;br&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.Execute(&lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; ButtonEventData(&lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; EventKey(&lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;CInt&lt;/span&gt;(Fix(we))), EventActivateState.Deactivate))&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Sub&lt;/span&gt;&lt;br&gt;&lt;br&gt;...&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;' handle all the Wiimote buttons&lt;/span&gt;&lt;br&gt;HandleButton(WiimoteEvent.Up, ws.ButtonState.Up, _lastBS.Up)&lt;br&gt;HandleButton(WiimoteEvent.Down, ws.ButtonState.Down, _lastBS.Down)&lt;br&gt;HandleButton(WiimoteEvent.Left, ws.ButtonState.Left, _lastBS.Left)&lt;br&gt;HandleButton(WiimoteEvent.Right, ws.ButtonState.Right, _lastBS.Right)&lt;br&gt;HandleButton(WiimoteEvent.A, ws.ButtonState.A, _lastBS.A)&lt;br&gt;HandleButton(WiimoteEvent.B, ws.ButtonState.B, _lastBS.B)&lt;br&gt;HandleButton(WiimoteEvent.Minus, ws.ButtonState.Minus, _lastBS.Minus)&lt;br&gt;HandleButton(WiimoteEvent.Home, ws.ButtonState.Home, _lastBS.Home)&lt;br&gt;HandleButton(WiimoteEvent.Plus, ws.ButtonState.Plus, _lastBS.Plus)&lt;br&gt;HandleButton(WiimoteEvent.One, ws.ButtonState.One, _lastBS.One)&lt;br&gt;HandleButton(WiimoteEvent.Two, ws.ButtonState.Two, _lastBS.Two)&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;' save off the current button state for next time&lt;/span&gt;&lt;br&gt;_lastBS = ws.ButtonState&lt;br&gt;_lastNunchuk = ws.NunchukState&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And, the current button values are stored away to check on the next event so button events are only fired once.&lt;/p&gt;
&lt;p&gt;Now that the event source object is written, it needs to be hooked up to the &lt;b&gt;globeControl&lt;/b&gt; so it can be used.&amp;nbsp; This can be done by creating an instance of the &lt;b&gt;WiimoteEventSource&lt;/b&gt; object, passing in the VE3D's &lt;b&gt;ActionSystem &lt;/b&gt;from the &lt;b&gt;BindingsManager&lt;/b&gt; object.&amp;nbsp; Then, the event source instance is passed to the &lt;b&gt;ActionSystem&lt;/b&gt;'s &lt;b&gt;EventSourceManager&lt;/b&gt; and registered using the &lt;b&gt;RegisterEventSource&lt;/b&gt; method.&amp;nbsp; Event sources should re registered before the control is added to the form.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;// wiimote events&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; WiimoteEventSource _wiimoteEventSource;&lt;br&gt;&lt;br&gt;...&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;// create a new instance of the Wiimote event handler&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;._wiimoteEventSource = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; WiimoteEventSource(&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.globeControl.Host.BindingsManager.ActionSystem, &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;);&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;// register it in the event source list&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.globeControl.Host.BindingsManager.ActionSystem.EventSourceManager.RegisterEventSource(&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;._wiimoteEventSource);&lt;br&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;' wiimote events&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Private&lt;/span&gt; _wiimoteEventSource &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; WiimoteEventSource&lt;br&gt;&lt;br&gt;...&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;' create a new instance of the Wiimote event handler&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;._wiimoteEventSource = &lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; WiimoteEventSource(&lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.globeControl.Host.BindingsManager.ActionSystem, &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;)&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;' register it in the event source list&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.globeControl.Host.BindingsManager.ActionSystem.EventSourceManager.RegisterEventSource(&lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;._wiimoteEventSource)&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Our binding list contains three action types that are not defined by the default VE3D actions:&amp;nbsp; &lt;b&gt;ToggleRoads&lt;/b&gt;, &lt;b&gt;Locations&lt;/b&gt;,&lt;b&gt; LocationsMove&lt;/b&gt;, and &lt;b&gt;ToggleUI&lt;/b&gt;.&amp;nbsp; These actions and their handlers must be registered with the VE3D control.&amp;nbsp; After the &lt;b&gt;WiimoteEventSource&lt;/b&gt; is registered, the four actions can be registered as follows:&lt;/p&gt;
&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.globeControl.Host.BindingsManager.RegisterAction(asmName, &lt;span style="color: rgb(0, 96, 128);"&gt;"ToggleRoads"&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; Action(&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.ToggleRoadsHandler));&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.globeControl.Host.BindingsManager.RegisterAction(asmName, &lt;span style="color: rgb(0, 96, 128);"&gt;"Locations"&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; Action(&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.LocationsHandler));&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.globeControl.Host.BindingsManager.RegisterAction(asmName, &lt;span style="color: rgb(0, 96, 128);"&gt;"LocationsMove"&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; Action(&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.LocationsMoveHandler));&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.globeControl.Host.BindingsManager.RegisterAction(asmName, &lt;span style="color: rgb(0, 96, 128);"&gt;"ToggleUI"&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; Action(&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.ToggleUIHandler));&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.globeControl.Host.BindingsManager.RegisterAction(asmName, &lt;span style="color: rgb(0, 96, 128);"&gt;"ToggleRoads"&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; Action(&lt;span style="color: rgb(0, 0, 255);"&gt;AddressOf&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.ToggleRoadsHandler))&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.globeControl.Host.BindingsManager.RegisterAction(asmName, &lt;span style="color: rgb(0, 96, 128);"&gt;"Locations"&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; Action(&lt;span style="color: rgb(0, 0, 255);"&gt;AddressOf&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.LocationsHandler))&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.globeControl.Host.BindingsManager.RegisterAction(asmName, &lt;span style="color: rgb(0, 96, 128);"&gt;"LocationsMove"&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; Action(&lt;span style="color: rgb(0, 0, 255);"&gt;AddressOf&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.LocationsMoveHandler))&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.globeControl.Host.BindingsManager.RegisterAction(asmName, &lt;span style="color: rgb(0, 96, 128);"&gt;"ToggleUI"&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; Action(&lt;span style="color: rgb(0, 0, 255);"&gt;AddressOf&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.ToggleUIHandler))&lt;br&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;With the actions registered and handlers associated with them, the actual handlers need to be implemented.&amp;nbsp; All event handler methods must be of the following signature:&lt;/p&gt;
&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;bool&lt;/span&gt; EventHandler(EventData cause)&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;
&lt;div&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Function&lt;/span&gt; EventHandler(&lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; cause &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; EventData) &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; Boolean&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Let's look at the &lt;b&gt;ToggleRoads&lt;/b&gt; event implementation:&lt;/p&gt;
&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;delegate&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; UIEventHandlerDelegate(EventData cause);&lt;br&gt;&lt;br&gt;...&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;bool&lt;/span&gt; ToggleRoadsHandler(EventData cause)&lt;br&gt;{&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;(cause.Activate)&lt;br&gt;    {&lt;br&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;// toggle through road types&lt;/span&gt;&lt;br&gt;        _roadState++;&lt;br&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;(_roadState &amp;gt; RoadState.Roads)&lt;br&gt;            _roadState = RoadState.Aerial;&lt;br&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;// remove whatever one is currently there&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.globeControl.Host.DataSources.Remove(&lt;span style="color: rgb(0, 96, 128);"&gt;"Roads"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"Roads"&lt;/span&gt;);&lt;br&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;// add the new one&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;switch&lt;/span&gt;(_roadState)&lt;br&gt;        {&lt;br&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;case&lt;/span&gt; RoadState.Aerial:&lt;br&gt;                AddFeederSource(&lt;span style="color: rgb(0, 96, 128);"&gt;"&lt;a href="http://local.live.com/Manifests/AT.xml" class="linkification-ext" title="Linkification: http://local.live.com/Manifests/AT.xml"&gt;http://local.live.com/Manifests/AT.xml&lt;/a&gt;"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"Roads"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"Roads"&lt;/span&gt;, DataSourceUsage.TextureMap);&lt;br&gt;                &lt;span style="color: rgb(0, 0, 255);"&gt;break&lt;/span&gt;;&lt;br&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;case&lt;/span&gt; RoadState.Hybrid:&lt;br&gt;                AddFeederSource(&lt;span style="color: rgb(0, 96, 128);"&gt;"&lt;a href="http://local.live.com/Manifests/HT.xml" class="linkification-ext" title="Linkification: http://local.live.com/Manifests/HT.xml"&gt;http://local.live.com/Manifests/HT.xml&lt;/a&gt;"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"Roads"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"Roads"&lt;/span&gt;, DataSourceUsage.TextureMap);&lt;br&gt;                &lt;span style="color: rgb(0, 0, 255);"&gt;break&lt;/span&gt;;&lt;br&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;case&lt;/span&gt; RoadState.Roads:&lt;br&gt;                AddFeederSource(&lt;span style="color: rgb(0, 96, 128);"&gt;"&lt;a href="http://local.live.com/Manifests/RT.xml" class="linkification-ext" title="Linkification: http://local.live.com/Manifests/RT.xml"&gt;http://local.live.com/Manifests/RT.xml&lt;/a&gt;"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"Roads"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"Roads"&lt;/span&gt;, DataSourceUsage.TextureMap);&lt;br&gt;                &lt;span style="color: rgb(0, 0, 255);"&gt;break&lt;/span&gt;;&lt;br&gt;        }&lt;br&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;// update the status bar&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.BeginInvoke(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; UIEventHandlerDelegate(ToggleRoadsUI), cause);&lt;br&gt;    }&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;;&lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; ToggleRoadsUI(EventData cause)&lt;br&gt;{&lt;br&gt;    lblRoads.Text = _roadState.ToString();&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.globeControl.Refresh();&lt;br&gt;}&lt;br&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Delegate&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Sub&lt;/span&gt; UIEventHandlerDelegate(&lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; cause &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; EventData)&lt;br&gt;&lt;br&gt;...&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Function&lt;/span&gt; ToggleRoadsHandler(&lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; cause &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; EventData) &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Boolean&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt; cause.Activate &lt;span style="color: rgb(0, 0, 255);"&gt;Then&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;' toggle through road types&lt;/span&gt;&lt;br&gt;        _roadState += 1&lt;br&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt; _roadState &amp;gt; RoadState.Roads &lt;span style="color: rgb(0, 0, 255);"&gt;Then&lt;/span&gt;&lt;br&gt;            _roadState = RoadState.Aerial&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt;&lt;br&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;' remove whatever one is currently there&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.globeControl.Host.DataSources.Remove(&lt;span style="color: rgb(0, 96, 128);"&gt;"Roads"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"Roads"&lt;/span&gt;)&lt;br&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;' add the new one&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;Select&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Case&lt;/span&gt; _roadState&lt;br&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;Case&lt;/span&gt; RoadState.Aerial&lt;br&gt;                AddFeederSource(&lt;span style="color: rgb(0, 96, 128);"&gt;"http:'&lt;a href="http://local.live.com/Manifests/AT.xml" class="linkification-ext" title="Linkification: http://local.live.com/Manifests/AT.xml"&gt;local.live.com/Manifests/AT.xml&lt;/a&gt;"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"Roads"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"Roads"&lt;/span&gt;, DataSourceUsage.TextureMap)&lt;br&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;Case&lt;/span&gt; RoadState.Hybrid&lt;br&gt;                AddFeederSource(&lt;span style="color: rgb(0, 96, 128);"&gt;"http:'&lt;a href="http://local.live.com/Manifests/HT.xml" class="linkification-ext" title="Linkification: http://local.live.com/Manifests/HT.xml"&gt;local.live.com/Manifests/HT.xml&lt;/a&gt;"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"Roads"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"Roads"&lt;/span&gt;, DataSourceUsage.TextureMap)&lt;br&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;Case&lt;/span&gt; RoadState.Roads&lt;br&gt;                AddFeederSource(&lt;span style="color: rgb(0, 96, 128);"&gt;"http:'&lt;a href="http://local.live.com/Manifests/RT.xml" class="linkification-ext" title="Linkification: http://local.live.com/Manifests/RT.xml"&gt;local.live.com/Manifests/RT.xml&lt;/a&gt;"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"Roads"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"Roads"&lt;/span&gt;, DataSourceUsage.TextureMap)&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Select&lt;/span&gt;&lt;br&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 128, 0);"&gt;' update the status bar&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.BeginInvoke(&lt;span style="color: rgb(0, 0, 255);"&gt;New&lt;/span&gt; UIEventHandlerDelegate(&lt;span style="color: rgb(0, 0, 255);"&gt;AddressOf&lt;/span&gt; ToggleRoadsUI), cause)&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;Return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;True&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Function&lt;/span&gt;&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Sub&lt;/span&gt; ToggleRoadsUI(&lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; cause &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; EventData)&lt;br&gt;    lblRoads.Text = _roadState.ToString()&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.globeControl.Refresh()&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Sub&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The implementations above simply check to see if the event is being activated and, if so, removes the current road layer and adds the next one in the series.&amp;nbsp; The one thing to keep in mind is that the event handler methods are called inside the rendering thread of the VE3D control, which is not the thread the windows form UI is located on.&amp;nbsp; Therefore, if the form UI needs to be updated in any way, one must use the &lt;b&gt;BeginInvoke&lt;/b&gt; method and a delegate method to update any UI controls.&lt;/p&gt;
&lt;p&gt;Next, let's look at the implementation of &lt;b&gt;ToggleUI&lt;/b&gt;:&lt;/p&gt;
&lt;p&gt;&lt;b&gt;C#&lt;/b&gt;&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;// toggle UI items off/on&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;bool&lt;/span&gt; ToggleUIHandler(EventData cause)&lt;br&gt;{&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;(cause.Activate)&lt;br&gt;    {&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.globeControl.Host.WorldEngine.ShowNavigationControl = !&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.globeControl.Host.WorldEngine.ShowNavigationControl;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.globeControl.Host.WorldEngine.ShowCursorLocationInformation = !&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.globeControl.Host.WorldEngine.ShowCursorLocationInformation;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.globeControl.Host.WorldEngine.ShowScale = !&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.globeControl.Host.WorldEngine.ShowScale;&lt;br&gt;    }&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;;&lt;br&gt;}&lt;br&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;b&gt;VB&lt;/b&gt;&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;' toggle UI items off/on&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Function&lt;/span&gt; ToggleUIHandler(&lt;span style="color: rgb(0, 0, 255);"&gt;ByVal&lt;/span&gt; cause &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; EventData) &lt;span style="color: rgb(0, 0, 255);"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Boolean&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt; cause.Activate &lt;span style="color: rgb(0, 0, 255);"&gt;Then&lt;/span&gt;&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.globeControl.Host.WorldEngine.ShowNavigationControl = &lt;span style="color: rgb(0, 0, 255);"&gt;Not&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.globeControl.Host.WorldEngine.ShowNavigationControl&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.globeControl.Host.WorldEngine.ShowCursorLocationInformation = &lt;span style="color: rgb(0, 0, 255);"&gt;Not&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.globeControl.Host.WorldEngine.ShowCursorLocationInformation&lt;br&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.globeControl.Host.WorldEngine.ShowScale = &lt;span style="color: rgb(0, 0, 255);"&gt;Not&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Me&lt;/span&gt;.globeControl.Host.WorldEngine.ShowScale&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;If&lt;/span&gt;&lt;br&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;Return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;True&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;Function&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This code simply changes the boolean values of several UI items.&amp;nbsp; The &lt;b&gt;WorldEngine&lt;/b&gt; object contains several other UI elements.&amp;nbsp; The &lt;b&gt;ShowUI&lt;/b&gt; property overrides all other properties and determines if anything is shown at all.&amp;nbsp; This property also determines whether the globe in the lower-left corner is displayed.&lt;/p&gt;
&lt;p&gt;Be sure to check the source code for the full demo linked above for the location handler methods.&amp;nbsp; I omitted them here since it is just more of the same type of code above.&lt;/p&gt;
&lt;h3&gt;&lt;/h3&gt;
&lt;h3&gt;&lt;b&gt;Running the Demo&lt;/b&gt;&lt;/h3&gt;
&lt;p&gt;To run the demo, do the following:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Copy &lt;b&gt;BindingsWiimote.xml&lt;/b&gt; to the &lt;b&gt;%APPDATA%\Microsoft\Virtual Earth 3D&lt;/b&gt; directory 
&lt;/li&gt;&lt;li&gt;Pair the Wiimote to the computer.&amp;nbsp; See the &lt;a href="http://blogs.msdn.com/coding4fun/archive/2007/03/14/1879033.aspx" target="_blank" mce_href="http://blogs.msdn.com/coding4fun/archive/2007/03/14/1879033.aspx"&gt;WiimoteLib article&lt;/a&gt; for more information on how to do that 
&lt;/li&gt;&lt;li&gt;Run the executable&lt;/li&gt;&lt;/ol&gt;
&lt;h3&gt;&lt;b&gt;Conclusion&lt;/b&gt;&lt;/h3&gt;
&lt;p&gt;With the above code, we have written a Wiimote-driven interface for Virtual Earth 3D.&amp;nbsp; The demo and source code linked above contain a few more features and bindings which enhance the application a bit more.&amp;nbsp; Be sure to give the full demo a try and check out the full source code for a few more implementation details.&lt;/p&gt;
&lt;h3&gt;&lt;/h3&gt;
&lt;h3&gt;Additional Information&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://blogs.msdn.com/coding4fun/archive/2007/03/14/1879033.aspx" target="_blank" mce_href="http://blogs.msdn.com/coding4fun/archive/2007/03/14/1879033.aspx"&gt;Managed Library for Nintendo's Wiimote&lt;/a&gt; - Updated version with this article! 
&lt;/li&gt;&lt;li&gt;&lt;a href="http://heptazane.spaces.live.com/default.aspx" target="_blank" mce_href="http://heptazane.spaces.live.com/default.aspx"&gt;Heptazane's Blog&lt;/a&gt; 
&lt;/li&gt;&lt;li&gt;&lt;a href="http://virtualearth.spaces.live.com/" target="_blank" mce_href="http://virtualearth.spaces.live.com/"&gt;Virtual Earth Blog&lt;/a&gt; 
&lt;/li&gt;&lt;li&gt;&lt;a href="http://blogs.msdn.com/virtualearth/" target="_blank" mce_href="http://blogs.msdn.com/virtualearth/"&gt;Virtual Earth Developer's Blog&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;h3&gt;Thanks&lt;/h3&gt;
&lt;p&gt;Thanks to Michelle Leavitt and Giovanni Montrone for testing the control scheme and helping to determine the best feel using the Wiimote.&lt;/p&gt;
&lt;h3&gt;Bio&lt;/h3&gt;
&lt;p&gt;Brian is a Microsoft C# MVP and a recognized .NET expert with over 6 years experience developing .NET solutions, and over 9 years of professional experience architecting and developing solutions using Microsoft technologies and platforms, although he has been "coding for fun" for as long as he can remember.&amp;nbsp; Outside the world of .NET and business applications, Brian enjoys developing both hardware and software projects in the areas of gaming, robotics, and whatever else strikes his fancy for the next ten minutes. He rarely passes up an opportunity to dive into a C/C++ or assembly language project.&amp;nbsp; You can reach Brian via his blog at &lt;a href="http://www.brianpeek.com/" mce_href="http://www.brianpeek.com/"&gt;http://www.brianpeek.com/&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5506286" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/coding4fun/archive/tags/windows/default.aspx">windows</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/gaming/default.aspx">gaming</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/hardware/default.aspx">hardware</category><category domain="http://blogs.msdn.com/coding4fun/archive/tags/audiovideo/default.aspx">audiovideo</category></item><item><title>Going Paperless</title><link>http://blogs.msdn.com/coding4fun/archive/2007/09/25/5121856.aspx</link><pubDate>Tue, 25 Sep 2007 17:42:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5121856</guid><dc:creator>Coding4Fun</dc:creator><slash:comments>18</slash:comments><comments>http://blogs.msdn.com/coding4fun/comments/5121856.aspx</comments><wfw:commentRss>http://blogs.msdn.com/coding4fun/commentrss.aspx?PostID=5121856</wfw:commentRss><wfw:comment>http://blogs.msdn.com/coding4fun/rsscomments.aspx?PostID=5121856</wfw:comment><description>&lt;p&gt;&lt;/p&gt;&lt;span id="c4fmetadata"&gt; &lt;table cellspacing="0" cellpadding="1" width="100%" border="0"&gt; &lt;tbody&gt; &lt;tr class="entry_overview"&gt; &lt;td width="50"&gt;&lt;a href="http://www.coding4fun.net/images/GoingPaperlessbackup_39A/paperless.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="36" alt="paperless" src="http://www.coding4fun.net/images/GoingPaperlessbackup_39A/paperless_thumb.jpg" width="36" border="0"&gt;&lt;/a&gt; &lt;/td&gt; &lt;td&gt;&lt;span class="entry_description"&gt;Are you tired of battling piles of papers at home?&amp;nbsp; From work, to your kid's school, to old bills and receipts, it can be too much to keep up with!&amp;nbsp; In this article, learn about how to scan, crop, and set metadata for your documents.&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2"&gt; &lt;div class="entry_author"&gt;Arian Kulp&lt;/div&gt; &lt;div class="entry_company"&gt;&lt;a href="http://www.ariankulp.com"&gt;Arian's Blog&lt;/a&gt;&lt;/div&gt;&lt;br&gt; &lt;div class="entry_details"&gt;&lt;b&gt;Difficulty: &lt;/b&gt;&lt;span class="entry_details_input"&gt;Intermediate&lt;/span&gt;&lt;/div&gt; &lt;div class="entry_details"&gt;&lt;b&gt;Time Required:&lt;/b&gt; &lt;span class="entry_details_input"&gt;1-3 hours&lt;/span&gt;&lt;/div&gt; &lt;div class="entry_details"&gt;&lt;b&gt;Cost: &lt;/b&gt;&lt;span class="entry_details_input"&gt;$50 and up (depending on hardware choice)&lt;/span&gt;&lt;/div&gt; &lt;div class="entry_details"&gt;&lt;b&gt;Software: &lt;/b&gt;&lt;span class="entry_details_input"&gt;&lt;a href="http://msdn.com/express/"&gt;Visual Basic or Visual C# Express Editions&lt;/a&gt;, DSOFile: &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=9BA6FAC6-520B-4A0A-878A-53EC8300C4C2" target="_blank"&gt;Developer Support OLE File Property Reader 2.1 Sample (KB 224351)&lt;/a&gt;&lt;/span&gt;&lt;/div&gt; &lt;div class="entry_details"&gt;&lt;span class="entry_details_input"&gt;&lt;strong&gt;Hardware: &lt;/strong&gt;Any WIA-compliant document scanner&lt;/span&gt;&lt;/div&gt; &lt;div class="entry_details"&gt;&lt;b&gt;Download: &lt;/b&gt;&lt;/div&gt; &lt;div class="entry_details"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://channel9.msdn.com/ShowPost.aspx?PostID=343934"&gt;C# Download&lt;/a&gt;  &lt;li&gt;&lt;a href="http://channel9.msdn.com/ShowPost.aspx?PostID=343937"&gt;VB Download&lt;/a&gt; &lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/span&gt; &lt;h2&gt;Introduction&lt;/h2&gt; &lt;p&gt;In my last article, I worked with GPS.&amp;nbsp; I decided to try another device, so this time I'm working with an image scanner.&amp;nbsp; For a long time, I've been wanting to try to go (more) paperless around the house.&amp;nbsp; Too many piles of papers, and no way to really find them later when I need to.&amp;nbsp; Scanning is the way to go, though it's time-consuming enough just feeding documents in, but then home scanners are rarely full-duplex (two-sided), and then the tools aren't so great.&lt;/p&gt; &lt;p&gt;The simple things that I wanted were: easy-scan, metadata, and auto-cropping of the images.&amp;nbsp; More than that, I wanted standard image formats with standard metadata.&amp;nbsp; Too many document scanning solutions use proprietary ways to get around limitations such as using database instead of files, or using sidecar files for metadata.&amp;nbsp; This sample will create plain ol' image files with metadata.&amp;nbsp; Use any application (such as Windows Desktop Search or Picasa) to manage and search for documents.&lt;/p&gt; &lt;p&gt;I've included source code for Visual Basic and C#.&amp;nbsp; Both versions are identical.&amp;nbsp; You'll need to download the appropriate version of &lt;a href="http://msdn.microsoft.com/vstudio/express"&gt;Visual Studio 2005 Express Edition&lt;/a&gt; to open the source code, and you will need to download the DSOFile MSDN sample referenced in the article header.&amp;nbsp; The dsofile.dll must be registered before the project will startup.&amp;nbsp; Presumably the application will work on any supported operating system for DSOFile (2000/XP/Vista).&lt;/p&gt; &lt;h2&gt;A User Interface You Can Live With&lt;/h2&gt; &lt;p&gt;User interfaces are always challenging.&amp;nbsp; You want to capture all of your functionality, yet make everything accessible without being overwhelming or confusing.&amp;nbsp;&amp;nbsp; One design goal of mine is to always create windows that will resize well.&amp;nbsp; This interface consists of two splitters.&amp;nbsp; A vertical splitter separates the commands and options on the left from the properties and image on the right.&amp;nbsp; A horizontal splitter then separates the properties from the image region.&lt;/p&gt; &lt;p align="center"&gt;&lt;a href="http://www.coding4fun.net/images/GoingPaperlessbackup_39A/image.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="484" alt="Image 1 - The user interface" src="http://www.coding4fun.net/images/GoingPaperlessbackup_39A/image_thumb.png" width="528" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p align="center"&gt;&lt;em&gt;Image 1: The user interface&lt;/em&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;The &lt;strong&gt;Scan New Document &lt;/strong&gt;button initiates the scan, using standard Windows scanning dialogs.&amp;nbsp; Once the image is transferred to the application, it appears in the &lt;strong&gt;Source &lt;/strong&gt;tab.&amp;nbsp; You can crop away any borders automatically by clicking &lt;strong&gt;Crop&lt;/strong&gt;.&amp;nbsp; It will look for the color in &lt;strong&gt;Crop Color&lt;/strong&gt;, based on the specified &lt;strong&gt;Threshold.&amp;nbsp; &lt;/strong&gt;You can click on the image to choose the crop color, or use the value that it auto-selects from the bottom of the image.&amp;nbsp; Use the &lt;strong&gt;Properties &lt;/strong&gt;region to enter metadata.&amp;nbsp; The &lt;strong&gt;From &lt;/strong&gt;field becomes the &lt;strong&gt;Author &lt;/strong&gt;field in metadata, and &lt;strong&gt;Type &lt;/strong&gt;becomes &lt;strong&gt;Subject&lt;/strong&gt;.&amp;nbsp; The rest are direct mappings.&amp;nbsp; Finally, select the image format (codec), destination folder, and compression level and click &lt;strong&gt;Save&lt;/strong&gt;.&amp;nbsp; Not that not all formats can hold metadata (such as BMP).&lt;/p&gt; &lt;h2&gt;Talking to the Scanner &lt;/h2&gt; &lt;p&gt;Working with scanners with .NET isn't as smooth as it could be, but the COM-interop works well enough.&amp;nbsp; It would be nice to be able to use &lt;strong&gt;Image.FromScanner&lt;/strong&gt;, but it's not an option!&lt;/p&gt; &lt;p&gt;The first step is to create a reference to &lt;strong&gt;Microsoft Windows Image Acquisition 1.01 Type Library&lt;/strong&gt;.&amp;nbsp; This creates wrappers in the &lt;strong&gt;WiaLib &lt;/strong&gt;namespace.&amp;nbsp; Then, you need to create a &lt;strong&gt;WiaClass&lt;/strong&gt; instance.&amp;nbsp; With that object, you can enumerate the scanners using the &lt;strong&gt;Devices &lt;/strong&gt;property, or create an instance of a particular scanner.&amp;nbsp; If you call the &lt;strong&gt;Create &lt;/strong&gt;method without a scanner &lt;strong&gt;DeviceInfoClass &lt;/strong&gt;object and there are more than one scanner attached, the standard "Select Device" dialog is shown.&lt;/p&gt; &lt;p align="center"&gt;&lt;a href="http://www.coding4fun.net/images/GoingPaperlessbackup_39A/image11.png"&gt;&lt;em&gt;&lt;a href="http://www.coding4fun.net/images/GoingPaperlessbackup_39A/image9_thumb.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="306" alt="Image 2 - The Select Device dialog" src="http://www.coding4fun.net/images/GoingPaperlessbackup_39A/image9_thumb_thumb.png" width="463" border="0"&gt;&lt;/a&gt;&lt;/em&gt;&lt;/p&gt; &lt;p align="center"&gt;&lt;em&gt;Image 2: The Select Device dialog&lt;/em&gt;&lt;/p&gt; &lt;p&gt;Once this returns, you have a &lt;strong&gt;ItemClass &lt;/strong&gt;