MIX 08 WPF/Wiimote Show Off Video
Thought I’d take a moment and toss up the WPF/Wiimote video that we submitted to the MIX 08 Show Off competition:
Matthias Shapiro’s WPF Blog - Because Developers Get All The Good Blogs
Archive for the ‘Wii’ Category.
Thought I’d take a moment and toss up the WPF/Wiimote video that we submitted to the MIX 08 Show Off competition:
This is an extension of my previous post, WPF Wiimote Library (Now With Project Files!), which has links to the WPF Wiimote Binding Library project files as well as some information vital to getting you started in connecting your application to the Wiimote.
And now for the IR properties:
The Wiimote can track up to 4 infrared (IR) LEDs at a time. If I were a programmer, I would have created an IR LED enum with the following properties as part of each IR LED. But since I’m not, these properties can be accessed with the following convention: IR[#][propertyName]. Each IR LED has the following properties:
Type: Point
Summary: The IR camera has a X,Y resolution of 1024, 768. This property will give you the raw X,Y position that the Wiimote is tracking this LED at.
Binding Usage Example:
<Grid Canvas.Left=”{Binding Source={StaticResource WiiData}, Path=”IR1RawPosition.X, Mode=OneWay}”
Canvas.Top=”{Binding Source={StaticResource WiiData}, Path=”IR1RawPosition.Y, Mode=OneWay}” />
Additional Info: This will work best if your Canvas is the exact dimensions of the Wiimote camera (1024, 768). These properties are automatically converted to take into account the IsMultiPoint setting (described in the Miscellaneous Properties (coming soon)).
Type: Point
Summary: This is the X,Y ratio of the position of your IR LED. The best way to use this is in a multi-binding with the width and height of your target Canvas. Fortunately for you, I’ve added a converter that will help with this. Simply add the following code in your resources:
<Wii:VariableCanvasPointConverter x:Key=”VariableCanvasConverter” />
And follow the binding example below.
Binding Usage Example:
<Grid>
<Canvas.Left>
<MultiBinding Converter=”{StaticResource VariableCanvasConverter}“>
<Binding Source=”{StaticResource WiiData}” Path=”IR1Position.X” Mode=”OneWay” />
<Binding ElementName=”MyCanvas” Path=”ActualWidth” Mode=”Default” />
</MultiBinding>
</Canvas.Left>
<Canvas.Top>
<MultiBinding Converter=”{StaticResource VariableCanvasConverter}“>
<Binding Source=”{StaticResource WiiData}” Path=”IR1Position.Y” Mode=”OneWay” />
<Binding ElementName=”MyCanvas” Path=”ActualHeight” Mode=”Default” />
</MultiBinding>
</Canvas.Top>
</Grid>
Additional Info: These properties are automatically converted to take into account the IsMultiPoint setting (described in the Miscellaneous Properties (coming soon)).
Type: boolean
Summary: This is a property that is “true” if the Wiimote can see the target LED and “false” if it cannot.
Binding Usage Example:
<Grid IsEnabled=”{Binding Source={StaticResource WiiData}, Path=IR2Found, Mode=OneWay}” />
Additional Info: This property is also available for the midpoint between the first and second infrared light (MidPointFound) and for the target point (TargetFound) which displays a calculated position of where the Wiimote is being pointed.
Type: double
Summary: The Wiimote naturally picks up the size of the LED it is tracking. To get larger sizes (which translates into better reliability) use a small cluster of LEDs (three should do the trick) rather than a single one.
Binding Usage Example:
<Grid Width=”{Binding Source={StaticResource WiiData}, Path=IR1Size, Mode=OneWay}” />
Type: bool
Summary: This item is meant for two way binding. If you want a way to programmatically choose whether or not to show the item that is bound to your IR interface, use this property. It is most useful when used in conjunction with the BoolToVisibility Converter, which can be used by placing this XAML in your resources:
<BooleanToVisibilityConverter x:Key=”boolToVis” />
Binding Usage Example:
<Grid Visibility=”{Binding Source={StaticResource WiiData}, Path=IsIR3Visible, Mode=OneWay, Converter={StaticResource boolToVis}“/>
<CheckBox IsChecked=”{Binding Source={StaticResource WiiData}, Path=IsIR3Visible, Mode=TwoWay}“/>
Additional Info: This is a great property to attach to a checkbox (as seen above) to allow user control over which items are to be shown.
In addition to the infrared lights, the WPF Wii library is set up to display two calculated points as well:
These two calculated points still have the position properties listed above (TargetRawPosition, MidPoint RawPosition, TargetPosition, MidPointPosition) as well as the visibility booleans (IsTargetVisible and IsMidPointVisible) and the “found” boolean properties (MidPointFound and IsTargetPossible).
Of course, you can also play around with the items in Intellisense is also a great way to discover all the available properties.
They’ve just posted the Show Off winners from MIX 08, and my Wiimote Visualization squeaked in at number 3. Here is the complete list of winners:
I’ll post the full video on this blog and on the Veracity blog by Monday. Thank you for everyone who attended and voted… and go check out the other videos! There was alot of cool stuff besides physics and Wiimote hacking in those videos. (I’ll post a link when they post one on the MIX site.)
Now that we’ve successfully demoed the Wiimote visualizer in the Open Space at MIX 08 and shown off what we can do at the Show Off event, I need to be a responsible blogger and put the project up… files and all. I have, with Brian Peek’s permission, packaged his managed library in here as well. Please read and respect his licencing agreements.
WPF Wii Binding Library (dlls only)
WPF Wii Binding Library (source)
There are really two parts to the WPF Wiimote Visualizer. The first part is the WPF Wiimote Binding Library, which we’ll cover in this post (or at least make this post the hub of that information). The second part is the Visualizer program itself, which is basically just the WPF Wiimote Library bound to a bunch of XAML elements.
The WPF Wiimote Binding Library will allow simple binding between your Wiimote and your WPF application (I’ve got a whole post on that here). But let me extrapolate a little on what the library has to offer. I’ve seperated out the data into different posts to make it a little more digestible.
Button Data (coming soon)
Misc Data (Rumble, Battery, Accelerometers) (coming soon)
Nunchuk Data (coming soon)