kpadsample

Location

$CAFE_ROOT/system/src/demo/kpad

Description

This sample program verifies KPAD library functionality. Using it, you can display onscreen any value that is possible to obtain from the library, and you can edit any value it is possible to modify in the library.

NOTE:
The Cafe controller must be paired before this demo can be used.

Screen Display

POINTING The scaling value used for determining the on-screen position; it is the factor by which you multiply the pos member variable of the KPADStatus structure. The blue frame displayed on the screen shows a range of ±1 for pos.
POS HOR DIS ACC - PLAY SENS MODE Shows the play radius (play_radius), sensitivity (sensitivity), and play mode (play_mode) set for the pos,horizon,dist, and acc in the KPADStatus structure.
RPT - DLAY PLUS Indicates the repeat start time (delay_sec) and the repeat interval (pulse_sec) of the digital button.
HLD Displays the binary value of the flag set when a digital button is held down (hold).
TRG Displays the binary value of the flag set when a digital button is pressed (trig).
REL Displays the binary value of the flag set when a digital button is released (release).
ACC Displays the KPADStatus structure's acc information as a 2D vector on the XY plane and a 2D vector on the ZY plane (red arrows). When a Nunchuk is installed, the fs.acc information from the KPADEXStatus structure is displayed the same way (solid orange arrows).
VALID Indicates the dpd_valid_fg value of the KPADStatus structure.
DIST Indicates the dist value of the KPADStatus structure.
OBJ Indicates the position of the object captured by the DPD. The rectangle is the sensor range.
DPDCB It will be displayed together with the reason value when a callback registered with KPADSetControlDpdCallback is called. The display from the last call will stay on the screen.
AIM Displays the aiming mode.
CIRCLE CLAMP / CROSS CLAMP Displays the stick clamp mode.
SMP.RATE Displays how many registered callbacks of the KPADSetSamplingCallback function are called per second.

Parameter Adjustment

The values can be edited using the digital buttons. Use the +Control Pad to move the cursor; A Button to increment the value for that digit or to change play_mode to KPAD_PLAY_MODE_TIGHT; and B Button to decrement it or change play_mode to KPAD_PLAY_MODE_LOOSE.

Calibration

Calibration is required if the Sensor Bar is not level or if the accelerometer returns values that are off by a large amount. One example of this is when the Wii remote is held in a horizontal position but the acceleration sensor returns values that differ considerably from those of a horizontal position. The calibration process corrects the value of the KPADStatus structure's horizon member variable; the acc member variable is not affected.

To activate calibration, press the - Button. Be sure that the controller is in a horizontal position and that only two sensors are detected. If one or three sensors are detected, calibration will fail. If calibration succeeds, CALIBRATE is displayed on the screen; if calibration fails, ERROR is displayed.

Nunchuk

When the Nunchuk controller's Control Stick is moved, the movement is displayed on the TV screen as an orange, dashed-line arrow.

Classic Controller

The kpadsample demo supports the Classic Controller. When a Classic Controller is connected to a Wii remote, the state of the digital buttons (pressed/not pressed) and analog trigger on the Classic Controller are displayed in the lower part of the TV screen. Movements of the Classic Controller L Stick and R Stick are displayed on the screen using green arrows.

DPD ON/OFF

Press the 1 Button on the Wii remote to turn the DPD ON and press the 2 Button to turn it OFF.

Aiming Mode ON/OFF

When the + Button on the Wii remote is pressed, the aiming mode, which can be set using the KPADEnableAimingMode and KPADDisableAimingMode functions, is switched.

Stick Clamp Mode

Allows the switching of clamp mode of the Nunchuk or Classic Controller stick. The clamp mode is configured using the KPADEnableStickCrossClamp and KPADDisableStickCrossClamp functions. This is switched every time a C Button on the Nunchuk Unit or the -/SELECT Button on the Classic Controller is pressed. This is also switched while the Z Button on the Nunchuk or the +/SELECT on the Classic Controller is pressed.

Switching the Button Processing Method

Pressing the Z Button on the Nintendo GameCube controller connected to 1P calls the KPADSetButtonProcMode function and changes the button-processing method. In the kpadsample demo, cursor movements use the button trigger information in the starting element of the sample buffer of the KPADReadEx function. Note that when the button processing method is KPAD_BUTTON_PROC_MODE_TIGHT, there will be times when the cursor does not move even if the button is pressed because there is no button trigger information in the starting element of the sampling buffer.

Miscellaneous Test Features

Miscellaneous tests may be performed by connecting a Nintendo GameCube Controller to 1P.

Source Code Files

main.h
main.c
Contains the application startup and framework source.
sample.h
sample.c
This application performs a variety of operations with the controller values. These application files initialize and load controllers and contain the source code for the CPU processing and rendering that is performed every frame.
graphic.h
graphic.c
The collection of subroutines for simple graphics drawing.

Revision History

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


CONFIDENTIAL