mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-22 13:02:38 +02:00
Expose appletSetFocusHandlingMode
This commit is contained in:
parent
5a078b1205
commit
fd4afacb01
@ -32,6 +32,21 @@ typedef enum {
|
|||||||
AppletHookType_Max, ///< Number of applet hook types.
|
AppletHookType_Max, ///< Number of applet hook types.
|
||||||
} AppletHookType;
|
} AppletHookType;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
AppletFocusState_Focused = 1, ///< Applet is focused.
|
||||||
|
AppletFocusState_NotFocusedUnknown = 2, ///< Out of focus - unknown reason (LibraryApplet open?).
|
||||||
|
AppletFocusState_NotFocusedHomeSleep = 3 ///< Out of focus - HOME menu is open / console is sleeping.
|
||||||
|
} AppletFocusState;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
AppletFocusHandlingMode_Suspend1 = 0, ///< Suspend when out of focus.
|
||||||
|
AppletFocusHandlingMode_NoSuspend, ///< Don't suspend when out of focus.
|
||||||
|
AppletFocusHandlingMode_Suspend2, ///< Suspend when out of focus (unknown variant 1).
|
||||||
|
AppletFocusHandlingMode_Suspend3, ///< Suspend when out of focus (unknown variant 2).
|
||||||
|
|
||||||
|
AppletFocusHandlingMode_Max, //< Number of focus handling modes
|
||||||
|
} AppletFocusHandlingMode;
|
||||||
|
|
||||||
/// applet hook function.
|
/// applet hook function.
|
||||||
typedef void (*AppletHookFn)(AppletHookType hook, void* param);
|
typedef void (*AppletHookFn)(AppletHookType hook, void* param);
|
||||||
|
|
||||||
@ -119,4 +134,6 @@ void appletUnhook(AppletHookCookie* cookie);
|
|||||||
/// These return state which is updated by appletMainLoop() when notifications are received.
|
/// These return state which is updated by appletMainLoop() when notifications are received.
|
||||||
u8 appletGetOperationMode(void);
|
u8 appletGetOperationMode(void);
|
||||||
u32 appletGetPerformanceMode(void);
|
u32 appletGetPerformanceMode(void);
|
||||||
u8 appletGetFocusState(void);
|
AppletFocusState appletGetFocusState(void);
|
||||||
|
|
||||||
|
Result appletSetFocusHandlingMode(AppletFocusHandlingMode mode);
|
||||||
|
@ -62,7 +62,6 @@ static Result _appletGetSessionProxy(Service* srv_out, u64 cmd_id, Handle procha
|
|||||||
|
|
||||||
static Result _appletGetAppletResourceUserId(u64 *out);
|
static Result _appletGetAppletResourceUserId(u64 *out);
|
||||||
|
|
||||||
static Result appletSetFocusHandlingMode(u32 mode);
|
|
||||||
static Result _appletGetCurrentFocusState(u8 *out);
|
static Result _appletGetCurrentFocusState(u8 *out);
|
||||||
static Result _appletSetFocusHandlingMode(u8 inval0, u8 inval1, u8 inval2);
|
static Result _appletSetFocusHandlingMode(u8 inval0, u8 inval1, u8 inval2);
|
||||||
static Result _appletSetOutOfFocusSuspendingEnabled(u8 inval);
|
static Result _appletSetOutOfFocusSuspendingEnabled(u8 inval);
|
||||||
@ -194,7 +193,7 @@ Result appletInitialize(void)
|
|||||||
rc = _appletGetCurrentFocusState(&g_appletFocusState);
|
rc = _appletGetCurrentFocusState(&g_appletFocusState);
|
||||||
|
|
||||||
//Don't enter this msg-loop when g_appletFocusState is already 1, it will hang when applet was previously initialized in the context of the current process for AppletType_Application.
|
//Don't enter this msg-loop when g_appletFocusState is already 1, it will hang when applet was previously initialized in the context of the current process for AppletType_Application.
|
||||||
if (R_SUCCEEDED(rc) && g_appletFocusState!=1) {
|
if (R_SUCCEEDED(rc) && g_appletFocusState != AppletFocusState_Focused) {
|
||||||
do {
|
do {
|
||||||
eventWait(&g_appletMessageEvent, U64_MAX);
|
eventWait(&g_appletMessageEvent, U64_MAX);
|
||||||
|
|
||||||
@ -217,14 +216,14 @@ Result appletInitialize(void)
|
|||||||
if (R_FAILED(rc))
|
if (R_FAILED(rc))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
} while(g_appletFocusState!=1);
|
} while(g_appletFocusState != AppletFocusState_Focused);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc))
|
if (R_SUCCEEDED(rc))
|
||||||
rc = _appletAcquireForegroundRights();
|
rc = _appletAcquireForegroundRights();
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc))
|
if (R_SUCCEEDED(rc))
|
||||||
rc = appletSetFocusHandlingMode(0);
|
rc = appletSetFocusHandlingMode(AppletFocusHandlingMode_Suspend1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc) && __nx_applet_auto_notifyrunning)
|
if (R_SUCCEEDED(rc) && __nx_applet_auto_notifyrunning)
|
||||||
@ -286,7 +285,7 @@ void appletExit(void)
|
|||||||
if (g_appletRecordingInitialized == 2) appletSetGamePlayRecordingState(0);
|
if (g_appletRecordingInitialized == 2) appletSetGamePlayRecordingState(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (__nx_applet_type == AppletType_Application) appletSetFocusHandlingMode(1);
|
if (__nx_applet_type == AppletType_Application) appletSetFocusHandlingMode(AppletFocusHandlingMode_NoSuspend);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((envIsNso() && __nx_applet_exit_mode==0) || __nx_applet_exit_mode==1) {
|
if ((envIsNso() && __nx_applet_exit_mode==0) || __nx_applet_exit_mode==1) {
|
||||||
@ -381,30 +380,30 @@ void appletUnhook(AppletHookCookie* cookie)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Result appletSetFocusHandlingMode(u32 mode) {
|
Result appletSetFocusHandlingMode(AppletFocusHandlingMode mode) {
|
||||||
Result rc;
|
Result rc;
|
||||||
u8 invals[4];
|
u8 invals[4];
|
||||||
|
|
||||||
if (mode > 3)
|
if (mode >= AppletFocusHandlingMode_Max)
|
||||||
return MAKERESULT(Module_Libnx, LibnxError_BadInput);
|
return MAKERESULT(Module_Libnx, LibnxError_BadInput);
|
||||||
|
|
||||||
memset(invals, 0, sizeof(invals));
|
memset(invals, 0, sizeof(invals));
|
||||||
|
|
||||||
if ((mode == 0) || (mode == 3)) {
|
if ((mode == AppletFocusHandlingMode_Suspend1) || (mode == AppletFocusHandlingMode_Suspend3)) {
|
||||||
invals[0] = 0;
|
invals[0] = 0;
|
||||||
invals[1] = 0;
|
invals[1] = 0;
|
||||||
invals[2] = 1;
|
invals[2] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode != 3) {
|
if (mode != AppletFocusHandlingMode_Suspend3) {
|
||||||
invals[3] = 0;
|
invals[3] = 0;
|
||||||
|
|
||||||
if (mode == 1) {
|
if (mode == AppletFocusHandlingMode_NoSuspend) {
|
||||||
invals[0] = 1;
|
invals[0] = 1;
|
||||||
invals[1] = 1;
|
invals[1] = 1;
|
||||||
invals[2] = 0;
|
invals[2] = 0;
|
||||||
}
|
}
|
||||||
else if (mode == 2) {
|
else if (mode == AppletFocusHandlingMode_Suspend2) {
|
||||||
invals[0] = 1;
|
invals[0] = 1;
|
||||||
invals[1] = 0;
|
invals[1] = 0;
|
||||||
invals[2] = 1;
|
invals[2] = 1;
|
||||||
@ -1365,8 +1364,8 @@ u32 appletGetPerformanceMode(void) {
|
|||||||
return g_appletPerformanceMode;
|
return g_appletPerformanceMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 appletGetFocusState(void) {
|
AppletFocusState appletGetFocusState(void) {
|
||||||
return g_appletFocusState;
|
return (AppletFocusState)g_appletFocusState;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool appletMainLoop(void) {
|
bool appletMainLoop(void) {
|
||||||
|
Loading…
Reference in New Issue
Block a user