KPADSetBtnRepeat

Syntax

#include <cafe/pads/kpad/kpad.h>

void KPADSetBtnRepeat( s32 chan, f32 delay_sec, f32 pulse_sec );

Parameters

chan One of the WPAD_CHANn values.
delay_sec Specifies the time for holding down the button before the KPAD_BUTTON_RPT flag is set.
pulse_sec If the KPAD_BUTTON_RPT flag is enabled delay_sec seconds after a button is pressed and held down, pulse_sec will specify the time interval (in seconds) at which the KPAD_BUTTON_RPT flag should be enabled thereafter. If you do not want this flag enabled, set pulse_sec to 0.

Return Values

None.

Description

Sets the repeat feature of the digital button (described in the KPADStatus structure). When a button is pressed and held, the KPAD_BUTTON_RPT flag can be periodically enabled in the hold member variable of KPADStatus. delay_sec seconds after a button is pressed, the KPAD_BUTTON_RPT flag gets set every pulse_sec seconds. In the example shown below, a program is created (using the flags) to perform an action periodically when a button is pressed and held down.

if ( (hold & (KPAD_BUTTON_RPT | KPAD_BUTTON_A) ) == (KPAD_BUTTON_RPT | KPAD_BUTTON_A) ) {Your routine}

Note that repeat settings are not maintained for each button. In this example, if another button is pressed while the A Button is held, the repeat status will be completely reset. On the Cafe Menu, delay_sec is set to 0.5, and pulse_sec is set to 0.1. Set these values to match Cafe Menu behavior.

Nunchuk and Classic Controller

A repeat feature is available for both the Nunchuk and Classic Controller buttons. The Nunchuk as well as Wii remote buttons are included in the KPADStatus structure's hold member variable; repeat management is common between the two.

The Classic Controller buttons, which are included in the KPADEXStatus structure's hold member variable, can set the KPAD_BUTTON_RPT flag. The repeat management for the Wii remote buttons is independent of that for the Classic Controller buttons.

Do Not Call From

Background Do not call this function from the background.
Interrupt handler Do not call this function from any interrupt handler.
Exception handler Do not call this function from any exception handler.
Multiple Cores Do not call this function from more than one Core.

Revision History

2013/05/08 Automated cleanup pass.
2008/07/08 Added information on settings in the Cafe Menu.
2006/10/25 Revised the description to match KPAD version 2.
2006/03/01 Initial version.


CONFIDENTIAL