nn::applet::CTR::AppletHomeButtonCallback Typetypedef bool(* nn::applet::CTR::AppletHomeButtonCallback)(uptr arg, bool isActive, nn::applet::CTR::HomeButtonState state);
The type of the callback function invoked when HOME is pressed.
The callback is called when a HOME Button press is detected.
Note: The thread that calls this callback has a stack size of roughly 4 KB. Take care to avoid overflows.
Use the nn::applet::CTR::SetHomeButtonCallback function to set the callback.
The value specified in arg is passed as is when setting the callback. Use as appropriate.
The isActive argument specifies whether the application is active. A value of true means the application is active.
The state argument specifies the HOME Button state. This is similar to the value obtained by calling the nn::applet::CTR::GetHomeButtonState function.
The return value determines whether to enable detection of HOME Button presses after this callback. A return value of false disables HOME Button detection. If HOME Button presses are detected after this callback, the nn::applet::CTR::IsExpectedToProcessHomeButton function returns true. When the application is inactive, normally there is no need to detect HOME Button presses, so we recommend setting the same value as isActive.
Use as shown in the example below.
Example
bool myHomeButtonCallback( uptr arg, bool isActive, applet::HomeButtonState state )
{
NN_UNUSED_VAR(arg);
if ( isActive )
{
if ( state == applet::HOME_BUTTON_SINGLE_PRESSED )
{
NN_LOG("HOME BUTTON is clicked.\n");
}
else
{
NN_LOG("HOME BUTTON is double-clicked.\n");
}
return true;
}
else
{
return false;
}
}
nnMain()
{
applet::SetHomeButtonCallback( myHomeButtonCallback, 0 );
…
}
Note:
In CTR-SDK 4.0 and later versions, the double-click is no longer returned as a state parameter for the callback. The process does not enter the portion of the sample code that displays "HOME BUTTON is double-clicked." The definition for the double-click itself remains for purposes of compatibility, but in the future it might be deleted.
CONFIDENTIAL