WPADSetConnectCallback

Syntax

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

#define WPAD_CHAN0                 0
#define WPAD_CHAN1                 1
#define WPAD_CHAN2                 2
#define WPAD_CHAN3                 3

#define WPAD_ERR_NONE              0
#define WPAD_ERR_NO_CONTROLLER    -1
#define WPAD_ERR_BUSY             -2

typedef void (* WPADConnectCallback )( s32 chan, s32 reason );

WPADConnectCallback WPADSetConnectCallback( s32 chan, WPADConnectCallback callback );

Parameters

chan One of the WPAD_CHANn values.
callback The callback function that notifies whether the Wii remote for the specified channel was connected or disconnected.

Return Values

Pointer to the most recently registered callback function.

Description

Registers the callback function that provides notification when a Wii Remote or Wii Balance Board is connected or disconnected to the specified channel. If NULL is specified, no notifications are made.

When a Wii remote or Wii Balance Board has been connected, the callback argument reason passes WPAD_ERR_NONE to the callback function; at disconnection, it passes WPAD_ERR_NO_CONTROLLER.

The callback function registered through this function will be cleared by the WPADInit function and so connection callbacks are typically registered shortly after WPADInit (and it is requisite WPADGetStatus readiness check) is called.

After a controller is connected, game applications can call WPADProbe to get the connection status and device type of each controller. See WPADProbe for a description of limitations about knowing the controller type.

To detect the insertion and removal of an external extension controller, use the WPADSetExtensionCallback function to register a callback function for these events.

WARNING:
Some WPAD and KPAD APIs that use callback functions will not execute when run in the context of another WPAD/KPAD callback function. For example:
  • IF callback1 is a WPAD callback function,
  • AND another WPAD API is called from within callback1, setting callback2 as the callback function
  • THEN callback2 cannot execute until callback1 returns, regardless of how long it takes.
In this case, callback2 may execute, but only after callback1 completes. It would be an error to wait for the callback2 event from inside callback1 as the event will not take place.

WPAD APIs that use callbacks include: WPADSetSyncDeviceCallback, WPADIsMplsAttached, WPADSetSamplingCallback, WPADSetConnectCallback, WPADSetExtensionCallback, WPADGetInfo, WPADGetInfoAsync, WPADControlSpeaker, WPADControlDpd, and WPADControlBLC.

KPAD APIs that use callbacks include: KPADSetConnectCallback, KPADSetSamplingCallback, KPADSetControlDpdCallback, and KPADSetControlMplsCallback.

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.

See Also

WPADInit
WPADProbe
WPADSetExtensionCallback

Revision History

2013/05/08 Automated cleanup pass.
2008/04/16 Added description of the Wii Balance Board.
2006/10/23 Added a description for the connection event immediately after library initialization completes.
2006/09/18 Added mention of the fact that the function will be cleared after the WPADInit function is called.
2006/06/19 Initial version.


CONFIDENTIAL