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.

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. The Cafe controller must be paired before this demo can be used.

Description of swing.c

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.
  • DPD information is not used to recognize the swinging motion.
  • By default, the Wii remote parameters are calibrated in such a way that it must be swung with some speed in order for the direction of the swing to be recognized. By increasing the value of the macro constant 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 reference, the following table provides 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)
  • If you wish to improve recognition accuracy, try increasing the value of the macro constant DIR_SPEED_DAMP. Note, however, that the time from one recognition to the next increases.

Revision History

2013/05/08 Automated cleanup pass.
2011/02/21 DRAFT