The BAC Wii project has come to an end for now – we delivered our final report yesterday. Hopefully word of what we’ve done will spread and we’ll be ask to share it with more groups. It was a really cool project to be on – the potential of the Wii and kinesthetic learning is an interesting area – and I don’t think that many people are doing much with it yet. Replacing the mouse with a Wii remote is a great way to increase engagement – I wonder if I could find a way to apply to compliance training? Would make for an interesting course assessment.
Anyway, I’m posting my outline of the Wii controller class that I spent all of January developing. It makes programming for WiiFlash super simple – just instantiate it and boom – Wii support in any Flash app. Works with all typical mouse events.
Wii Controller Engine
- Is an interface between Wii controllers (Remote and Nunchuk) WiiFlash and the application or game
- Enables quick ramp up for a developer without having to learn the intricacies of the Wii controllers or their data
- Can add simple Wii controller to an app in as little as 3 lines of code
- Contains about 1000 lines of code (not including virtual mouse or WiiFlash itself)
- WiiFlash returns raw data â€“ engine normalizes it up to make it useful for a developer
- The Wii controllers return small, but long numbers â€“ 0.000000007199879823173
- â€œSmoothingâ€ out the data â€“ eliminates the hand jitter by throwing out small changes and/or averaging data over time
- Accesses the cursorâ€™s X and Y position â€“ WiiFlash gives you the location of the IR points (prefers 2 of them) as the Remote sees them on a scale from 0-1 â€“ not in relation to your screen area.Â Engine handles switching from 2 IR points visible to 1 IR point and convert the data to exact X and Y coordinates of where youâ€™re pointing
- Creates a secondary â€œvirtual mouseâ€ that allows the Wii mote to act as your normal mouse (separate from WiiFlashâ€™s built-in â€œmouse controlâ€ mode) within the boundaries of your Flash movie
- Uses Senocluarâ€™s VirtualMouse class
- A button is single click, B is double click
- Makes it simple to add Wii capabilities to your app since it works with the mouse controls that youâ€™re used to developing for
- Allows for custom mouse cursors and the ability to switch between them with 1 line of code
- Mouse cursors are contained in an external SWF
- Creates a standard way to getbutton press and release state information for the Remote and the Nunchuk.Provides â€œisDownâ€ data for major buttons on the Remote and Nunchuk: A, B,C and Z
- Controls rumble â€“ set the duration
- Provides Nunchuk data in the same way as the Remote: rotation, acceleration, etc.
- Nunchuk thumb stick â€“ returns the position of the nub from -100 to +100
- Also can use the 8 corners as buttons, names represent a compass: N, E, S and W
- Created (but not tested) with multiple Wii motes in mind â€“ should easily scale to up to 4 Wii motes
When are you releasing this? I want a peek so i can see how you are handling going from 1 point to two etc.
I canâ€™t release the code as it is since itâ€™s property of my employer (I developed it at work for work). But I don’t mind showing pieces and answering questions. I want to continue developing it and write in new features – I may eventually release that version since it would be on my own time.
My IR tracking code is a slightly modified version of Andes Santos’ code which he has posted on his web site:
It’s his wiimoteIR class. His did such a better job than my code did, I used it.
Hi and congratulations for your website and the very helpful example u provide. I use the version provided by Andes Santos and it works well. But i have noticed that my wiimote quickly lost the contact with the sensor bar (located at the top of my monitor) in such way that my cursor only covers the first 3/4 of my screen !!!
Have u notice such behaviors ?
As i use the andes Santos example, i have declared for each IR point
sbIRi.x = stageW-(wiimote.ir.pointi.x*stageW);
sbIRi.y = (wiimote.ir.pointi.y*stageH);
where stageW & stageH are the size of my screen.
Thanks in advance for your help.
@dougi I found that I had to stand about 4 feet (or a little over 1 meter) away from my screen to get it to work well, any closer and the Wiimote lost sight of the points. I also have a laptop and placed the sensor bar under the display. That helped with the visibility.
Thanks for these infos. I had made a mistake.