SilverWii - That is connecting a WiiMote to a Silverlight OOB app via NESL (Native Extensions For Microsoft Silverlight)
Yeah, I know... Silverlight, Silverlight, Silverlight... I know I've been doing a good bit of Silverlight recently, and will back off it soon, but I saw this and well I just couldn't pass this up (I tried, but every time I re-org'ed my list of possible posts this one just kept bubbling all by itself to the top... lol).
Hooking up a Wiimote to a Silverlight app? Come on, you know that's officially "fun"...
The first time I heard about the Native Extension for Silverlight, I wondered: well, in what context can I use this? In what kind of scenario? And overall, is it something really usable? In this article I will try to test one of the features included in NESL, i.e. the capability of interacting with motion sensors. At the end I used the popular wiimote controller since it has a built-in accelerometer. Read the rest of the story to find out the test result.
What is this NESL project?
"While Silverlight 4 supports accessing COM automation components from elevated trust OOB applications, many Windows platform features are currently not available through COM automation. This makes them inaccessible to such Silverlight OOB apps. Native Extensions for Microsoft Silverlight(NESL) is an effort to incrementally build a library of components that expose select Windows 7 features through COM automation, making them easily available to Silverlight 4 OOB applications running with elevated trust. The current version of NESL provides access to Windows 7 features like Sensors, Portable Devices, Speech, Taskbar and more. NESL is made up of a set of COM automation based runtime libraries, Silverlight wrapper libraries usable from Silverlight 4 OOB applications, sample applications with source, API documentation, and a developer's guide.
- New Features
- Touch Features
- Gesture support
- Manipulation processing support
- Inertia processing support
- Touch hardware information
- Windows 7 Notification Area (System Tray) support
- Add/Update/Remove notification icons to the notification area
- Add/Remove notification information balloons
- Respond to notification and notification balloon events
- Add/Update/Remove context menus to notification icons
- Respond to context menu selections
- “Minimize to tray”/”Restore from tray”
- “Single application instance” pattern support
- Allow only a single instance of the application to run at any time
- Be notified when a subsequent launch is attempted
- Aids in applications that add themselves to the system tray, and hence needs to maintain a single running instance.
What APIs are covered in NESL v1 ?
- Windows Sensor API
- Integrate sensors in you Silverlight app – Accelerometers, Light sensors, compasses, gyroscopes etc.
- Microsoft Speech API
- Text to Speech (Speech Synthesis)
- Speech to Text (Speech Recognition)
- Windows Portable Devices API
- Enumerate and access content from connected portable devices (cameras, phones, music players, scanners etc.)
- Windows 7 Taskbar Integration
- Jump lists, overlay icons, overlay progress display, Thumbnail toolbars etc.
- Webcam Local Encoding and Window Capture
- Encode webcam capture into mp4 (H.264/AAC-LC) media
- Capture user interface interaction as video
- Window Message Interception
- Intercept and act on Window messages sent to the Silverlight OOB host window
It's funny how simple some things can be in hindsight. The hardest part of this entire project is getting the WiiMote connected to your PC. The rest, as you can see in the code, is pretty simple once you harness the power of NESL
The article does a great job in walking you through the code and NEST. Yes, Silverlight 5, with its PInvoke feature, should make stuff like this easier, but today is today and if all you have is Silverlight 4 and need to get a little closer to the hardware, then NESL and this article will be well worth a read.
In this article we have seen that virtually there are no limits to what Silverlight actually can do; we can even make it speak with a wiimote. The key tool behind that is NESL, a library which provides friendly Silverlight wrapper classes and a runtime which exposes COM automation for most of the features of windows 7 platform. How efficient and practical is this approach? In the article we have tested the NESL Sensors API and the results appear to be encouraging. ...