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.
dir_nrmvariable 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_nrmthe instant that
dir_nrm_pass_countexceeds a certain value.
swingdemo, the color of the arrows change from red to yellow to blue with elapsed time.
dir_nrmvariable is a 3D vector variable, but the
swingdemo is specialized for two dimensions and so in this demo, Z is always
The following table shows simple descriptions of the functions defined in
||Function that initializes load settings and other settings for KPAD acceleration data.|
||Function that is called once per game frame to perform recognition processing.|
||This function draws the result of recognition.|
DIR_VEC_DAMPor decreasing the value of
DIR_SPEED_MIN, it is possible to recognize weak swings, but the number of false positives also increases. For reference, the following table provides example parameter settings for detecting weak swings.
||0.93f||Speed vector decay rate (0 to 1)|
||1.00f||Minimum speed required for recognition|
||0.99f||Speed recording decay rate (0 to 1)|
DIR_SPEED_DAMP. Note, however, that the time from one recognition to the next increases.
2013/05/08 Automated cleanup pass.