$REVOLUTION_SDK_ROOT/build/demos/kpaddemo
In this demo, the program recognizes the direction the Wii Remote has been waved and displays the direction on the TV screen using an arrow.
Note: Be sure to swing the Wii Remote so that its top surface (the side where A Button and others are located) remains parallel with the floor. The correct direction will not be recognized if the Wii Remote is swung at a tilted angle.
| swing.c | This source file contains the algorithm for detecting the direction of swing. It is possible to adjust the feel of recognition by editing the values of macro constants defined in this file. |
graphic.h, graphic.c |
The collection of subroutines for simple graphics drawing. |
kfont.h, kfont.c |
The collection of subroutines that displays text and numerals onscreen. |
dir_nrm variable is constantly updated to the value (in the acceleration coordinate system of the KPAD library) associated with the direction the Wii Remote is being swung. Applications can use this code to access dir_nrm at the instant dir_nrm_pass_count goes beyond a certain value.
dir_nrm is a 3D vector variable, where Z is constantly held at 0, because the swing demo is especially designed for 2D.
The following table gives a simple description of the functions defined in swing.c.
init_sample() |
This function initializes settings for loading KPAD acceleration data. |
work_sample() |
This function is called once per frame to perform recognition. |
draw_sample() |
This function draws the result of recognition. |
DIR_VEC_DAMP or reducing the value of DIR_SPEED_MIN, cases of misrecognition will increase. For your reference, the following table gives example parameter settings for detecting weak swings.
DIR_VEC_DAMP |
0.93f | Speed vector decay rate (0 to 1) |
DIR_SPEED_MIN |
1.00f | Minimum speed required for recognition |
DIR_SPEED_DAMP |
0.99f | Speed recording decay rate (0 to 1) |
DIR_SPEED_DAMP. Note, however, that the time from one recognition to the next increases.
2007/04/11 Used red letters to emphasize the note giving conditions for correct recognition.
2007/03/05 Included example parameter settings for detecting weak swings.
2007/03/02 Initial version.
CONFIDENTIAL