I wrote a little program to experiment with the wiimote and the nunchuk of the Nintendo's Wii. I saw many commercials promise great things (as always), but when I tried out the wiimote I was a bit disappointed. "Can't we do any better with this kind of technology?" was the first thing I asked myself.
The answer is yes and no. As you know, the wiimote has an (infrared) camera and three accelerometers. The nunchuk also has three accelerometers. The problem with those accelerometers is that they are not very precise.
Anyway, I wanted to be able to play my favorite FPS like Call of Duty 4: Modern Warfare, Bioshock and Crysis with the wiimote and I was also wondering whether the accelerometers could be used to recognize complex gestures such as circles, rectangles, the letters of the alphabet, etc...
I know there are other programs like, for instance, GlovePie out there, but I think you should give my little program a try.
My little program does two things:
- it adds the support for an infinite number of infrared sources, and
- it supports the recording and recognition of complex gestures.
You can download the program here:
Version 0.2: (98 Kb) [see "Checking your lights"]
wiipc02.zip (on keepandshare)
wiipc02.zip (on mediafire)
Version 0.1: (98 Kb)
wiipc01.zip (on keepandshare)
wiipc01.zip (mediafire)
(Note: this program was tested only on Windows XP.)
Some videos
Simple recognition of circles and squares
High quality: (1.3 MB)
final_geom.avi (on keepandshare)
final_geom.avi (on mediafire)
Low quality:
Recognition of all the letters of the alphabet.
High quality: (2.31 MB)
final_alpha.avi (on keepandshare)
final_alpha.avi (on mediafire)
Low quality:
Mouse Emulation
Do you have any Christmas tree lights? Cover the walls of your room with them and start playing! :-)
I assume your wiimote is already connected to your PC. You can find many guides about that. All you need to do is start my little program and press the key 'm'. My program should work even with wiimotes that keep blinking after they've been connected to the PC.
What do you do when your mouse reaches the edge of the table?
And with your wiimote?
Whenever you shake (gently!) your nunchuk, you have N ms to move your wiimote without affecting your in-game pointer. This choice might sound odd and absurd, but give it a try (well, you'll need some time to get used to it).
You can modify N by pressing '+', '-', 'd' or 't'.
These are the key bindings:
wiimote | keyboard |
---|---|
1 | 1 |
2 | 2 |
up | v |
down | r |
left | q |
right | e |
- | g |
+ | 4 |
home | f |
wiimote | mouse |
---|---|
b | left |
a | right |
nunchuck | mouse |
---|---|
up | w |
down | s |
left | a |
right | d |
c | space |
z | clctrl |
Gesture Recognition
I don't have time to write a manual, so here is some information.
Run the program and type the following:
c
lr:x
ud:z
yyyyyy
Now move your nunchuck and
- The analog stick must always be perpendicular to the ground.
- Do not rotate the nunchuck while you're performing a gesture.
- Points 1 and 2 are a consequence of my recordings, not of the algorithm per se.
- Perform the movements quickly and precisely.
- You can see the starting time, the ending time and the intensity of each recognized gesture.
- Since the recorded gestures may have many shapes, the name of the same gesture might appear more than once even if you performed the gesture just once.
- If the intensity of a gesture is very small, that gesture can be ignored (your gestures are never perfect, so, every time you move your nunchuck, you influence all the accelerometers).
- Gestures performed by different people may differ quite significantly. To cope with that, the same gesture should be recorded by many people (ten people should be enough). Unfortunately for you, the gestures were all recorded by me alone (it took me thirty minutes).
- I've almost forgotten: my program is not optimized, but, if optimized, it could handle thousands of gestures without any problem.
geom:xz
Try to move the nunchuck in the following ways:
right, up, left, down - left, up, right, down
- Draw a circle by moving clockwise starting from its lowest point (i.e. the one closest to the ground).
- Do as in 3 but counterclockwise.
To see the "shape" of the gestures, run the program and type:
g
geom:xz
n
circlecw
Now press '-' on the wiimote and try to draw a circle by moving clockwise.
Here are the other keys:
keyboard | wiimote | function |
---|---|---|
l | lists the gestures | |
n | asks for the name of the current gesture | |
c | - | clears the graph |
p | home | pauses/resumes the recording session |
A | A | updates the current gesture by saving the current shape |
R | B | saves the changes to disk |
Numpad keys:-,+,/,* = changes the tolerances (green rectangles)
Checking your lights
If you stay too far from the lights, the mouse pointer will become "unstable" and start moving by itself! Version 0.2 solves this issue. If you had this annoying problem and want to see if version 0.2 really solves it for you, do the following:
- Run the program (instance A)
- (in A) Press 'r'
- Run the program (instance B)
- (in B) Press 'm'
- (in A) Bring the "Graphic Test" window on top
- Check your lights!