Better formatting, remove UnknownMessageHandler

This commit is contained in:
exelix 2019-02-25 17:22:13 +01:00
parent 88328709e0
commit 9d536520b3
4 changed files with 44 additions and 49 deletions

View File

@ -470,13 +470,13 @@ AppletFocusState appletGetFocusState(void);
Result appletSetFocusHandlingMode(AppletFocusHandlingMode mode);
/**
* @brief Stops forwarding the input to the foreground app, works only in the Overlay applet context
* @brief Stops forwarding the input to the foreground app, works only in the Overlay applet context.
* @note You have to call this to receive inputs through the hid service when running as the overlay applet.
*/
Result appletBeginToWatchShortHomeButtonMessage(void);
/**
* @brief Forwards input to the foreground app, works only in the Overlay applet context
* @brief Forwards input to the foreground app, works only in the Overlay applet context.
* @note After calling this the overlay applet won't receive any input until \ref appletBeginToWatchShortHomeButtonMessage is called again.
*/
Result appletEndToWatchShortHomeButtonMessage(void);

View File

@ -14,6 +14,6 @@ void hidsysExit(void);
Result hidsysEnableAppletToGetInput(bool enable);
/**
* @brief Returns an event that fires when the home button is pressed, this will prevent the home menu from opening when the button is pressed. This event does not auto clear
* @brief Returns an event that fires when the home button is pressed, this will prevent the home menu from opening when the button is pressed. This event does not auto clear.
**/
Result hidsysAcquireHomeButtonEventHandle(Event* event_out);

View File

@ -19,8 +19,6 @@ __attribute__((weak)) u32 __nx_applet_PerformanceConfiguration[2] = {/*0x9222000
//// Controls whether to use applet exit cmds during \ref appletExit. 0 (default): Only run exit cmds when running under a NSO. 1: Use exit cmds regardless. >1: Skip exit cmds.
__attribute__((weak)) u32 __nx_applet_exit_mode = 0;
void __attribute__((weak)) __nx_applet_UnknownMessageHandler(u32);
static Service g_appletSrv;
static Service g_appletProxySession;
static u64 g_refCnt;
@ -1384,8 +1382,44 @@ Result appletQueryApplicationPlayStatistics(AppletApplicationPlayStatistics *sta
return rc;
}
// IOverlayFunctions
Result appletBeginToWatchShortHomeButtonMessage(void) {
if (__nx_applet_type != AppletType_OverlayApplet)
return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
return _appletCmdNoIO(&g_appletIFunctions, 0);
}
Result appletEndToWatchShortHomeButtonMessage(void) {
if (__nx_applet_type != AppletType_OverlayApplet)
return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
return _appletCmdNoIO(&g_appletIFunctions, 1);
}
// ICommonStateGetter
Result appletHomeButtonReaderLockAccessorGetEvent(Event *out_event) {
if (eventActive(&HomeButtonReaderLockAccessorEvent))
{
*out_event = HomeButtonReaderLockAccessorEvent;
return 0;
}
Service ILockAccessor = {0};
Result rc = _appletGetSession(&g_appletICommonStateGetter, &ILockAccessor, 30);
if (R_FAILED(rc))
return rc;
rc = _appletGetEvent(&ILockAccessor, &HomeButtonReaderLockAccessorEvent, 3, false);
if (R_SUCCEEDED(rc))
*out_event = HomeButtonReaderLockAccessorEvent;
serviceClose(&ILockAccessor);
return rc;
}
static Result _appletReceiveMessage(u32 *out) {
IpcCommand c;
ipcInitialize(&c);
@ -2318,46 +2352,7 @@ bool appletMainLoop(void) {
appletCallHook(AppletHookType_OnPerformanceMode);
break;
default:
if (__nx_applet_UnknownMessageHandler)
__nx_applet_UnknownMessageHandler(msg);
break;
}
return true;
}
Result appletBeginToWatchShortHomeButtonMessage(void) {
if (__nx_applet_type != AppletType_OverlayApplet)
return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
return _appletCmdNoIO(&g_appletIFunctions, 0);
}
Result appletEndToWatchShortHomeButtonMessage(void) {
if (__nx_applet_type != AppletType_OverlayApplet)
return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
return _appletCmdNoIO(&g_appletIFunctions, 1);
}
Result appletHomeButtonReaderLockAccessorGetEvent(Event *out_event)
{
if (eventActive(&HomeButtonReaderLockAccessorEvent))
{
*out_event = HomeButtonReaderLockAccessorEvent;
return 0;
}
Service ILockAccessor = {0};
Result rc = _appletGetSession(&g_appletICommonStateGetter, &ILockAccessor, 30);
if (R_FAILED(rc))
return rc;
rc = _appletGetEvent(&ILockAccessor, &HomeButtonReaderLockAccessorEvent, 3, false);
if (R_SUCCEEDED(rc))
*out_event = HomeButtonReaderLockAccessorEvent;
serviceClose(&ILockAccessor);
return rc;
}

View File

@ -53,7 +53,7 @@ Result hidsysEnableAppletToGetInput(bool enable) {
struct {
u64 magic;
u64 cmdid;
bool permitInput;
u8 permitInput;
u64 appletResourceUserId;
} *raw;
@ -61,7 +61,7 @@ Result hidsysEnableAppletToGetInput(bool enable) {
raw->magic = SFCI_MAGIC;
raw->cmdid = 503;
raw->permitInput = enable;
raw->permitInput = enable != 0;
raw->appletResourceUserId = g_hidsysAppletResourceUserId;
Result rc = serviceIpcDispatch(&g_hidsysSrv);