$REVOLUTION_SDK_ROOT/build/demos/kpaddemo
In this demo, the program recognizes the direction in which the Wii Remote is swung and displays that direction as an arrow on the TV screen.
Note: Swing the Wii Remote in such a way that its top side (the side with the A Button) remains parallel to the floor. If you tilt the Wii Remote when you swing it, the program will not recognize the correct direction.
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.hgraphic.c |
The collection of subroutines for simple graphics drawing. |
kfont.hkfont.c |
The collection of subroutines that display text and values on the screen. |
dir_nrm variable is continually refreshed with the value of the direction the Wii Remote is swung in (in the KPAD library's acceleration coordinate system). In an application, this is used by referencing dir_nrm the instant that dir_nrm_pass_count exceeds a certain value.
swing demo, the color of the arrows change from red to yellow to blue with elapsed time.
dir_nrm variable is a 3D vector variable, but the swing demo is specialized for two dimensions and so in this demo Z is always 0.
The following table shows simple descriptions of the functions defined in swing.c.
init_sample() |
Function that initializes load settings and other settings for KPAD acceleration data |
work_sample() |
Function that is called once per game frame to perform recognition processing |
draw_sample() |
This function draws the result of recognition. |
DIR_VEC_DAMP or decreasing the value of DIR_SPEED_MIN, it is possible to recognize weak swings, but the number of false positives also increases. 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.
None.
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