mirror of
https://github.com/libretro/RetroArch
synced 2025-02-28 22:13:51 +00:00
libnx: implement focus gain and loss callbacks
This commit is contained in:
parent
1fa89d67c5
commit
9cad7135a9
@ -55,6 +55,8 @@ static const char *elf_path_cst = "/switch/retroarch_switch.nro";
|
|||||||
|
|
||||||
static uint64_t frontend_switch_get_mem_used(void);
|
static uint64_t frontend_switch_get_mem_used(void);
|
||||||
|
|
||||||
|
bool platform_switch_has_focus = true;
|
||||||
|
|
||||||
#ifdef HAVE_LIBNX
|
#ifdef HAVE_LIBNX
|
||||||
|
|
||||||
/* Splash */
|
/* Splash */
|
||||||
@ -69,10 +71,18 @@ extern bool nxlink_connected;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void on_applet_hook(AppletHookType hook, void* param) {
|
static void on_applet_hook(AppletHookType hook, void* param) {
|
||||||
|
/* Exit request */
|
||||||
if(hook == AppletHookType_OnExitRequest) {
|
if(hook == AppletHookType_OnExitRequest) {
|
||||||
RARCH_LOG("Got AppletHook OnExitRequest, exiting.\n");
|
RARCH_LOG("Got AppletHook OnExitRequest, exiting.\n");
|
||||||
retroarch_main_quit();
|
retroarch_main_quit();
|
||||||
}
|
}
|
||||||
|
/* Focus state*/
|
||||||
|
else if (hook == AppletHookType_OnFocusState) {
|
||||||
|
AppletFocusState focus_state = appletGetFocusState();
|
||||||
|
RARCH_LOG("Got AppletHook OnFocusState - new focus state is %d\n", focus_state);
|
||||||
|
|
||||||
|
platform_switch_has_focus = focus_state == AppletFocusState_Focused;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* HAVE_LIBNX */
|
#endif /* HAVE_LIBNX */
|
||||||
@ -621,6 +631,8 @@ static void frontend_switch_init(void *data)
|
|||||||
nifmInitialize();
|
nifmInitialize();
|
||||||
appletLockExit();
|
appletLockExit();
|
||||||
appletHook(&applet_hook_cookie, on_applet_hook, NULL);
|
appletHook(&applet_hook_cookie, on_applet_hook, NULL);
|
||||||
|
|
||||||
|
appletSetFocusHandlingMode(AppletFocusHandlingMode_NoSuspend);
|
||||||
#ifndef HAVE_OPENGL
|
#ifndef HAVE_OPENGL
|
||||||
/* Init Resolution before initDefault */
|
/* Init Resolution before initDefault */
|
||||||
gfxInitResolution(1280, 720);
|
gfxInitResolution(1280, 720);
|
||||||
|
@ -957,12 +957,6 @@ static bool gl_frame(void *data, const void *frame,
|
|||||||
if (!gl)
|
if (!gl)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#ifdef HAVE_LIBNX
|
|
||||||
// Should be called once per frame
|
|
||||||
if(!appletMainLoop())
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
gl_context_bind_hw_render(gl, false);
|
gl_context_bind_hw_render(gl, false);
|
||||||
|
|
||||||
if (gl->core_context_in_use && gl->renderchain_driver->bind_vao)
|
if (gl->core_context_in_use && gl->renderchain_driver->bind_vao)
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
static enum gfx_ctx_api ctx_nx_api = GFX_CTX_OPENGL_API;
|
static enum gfx_ctx_api ctx_nx_api = GFX_CTX_OPENGL_API;
|
||||||
switch_ctx_data_t *nx_ctx_ptr = NULL;
|
switch_ctx_data_t *nx_ctx_ptr = NULL;
|
||||||
|
|
||||||
|
extern bool platform_switch_has_focus;
|
||||||
|
|
||||||
void switch_ctx_destroy(void *data)
|
void switch_ctx_destroy(void *data)
|
||||||
{
|
{
|
||||||
switch_ctx_data_t *ctx_nx = (switch_ctx_data_t *)data;
|
switch_ctx_data_t *ctx_nx = (switch_ctx_data_t *)data;
|
||||||
@ -190,7 +192,7 @@ static bool switch_ctx_bind_api(void *data,
|
|||||||
static bool switch_ctx_has_focus(void *data)
|
static bool switch_ctx_has_focus(void *data)
|
||||||
{
|
{
|
||||||
(void)data;
|
(void)data;
|
||||||
return true;
|
return platform_switch_has_focus;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool switch_ctx_suppress_screensaver(void *data, bool enable)
|
static bool switch_ctx_suppress_screensaver(void *data, bool enable)
|
||||||
|
@ -2522,6 +2522,12 @@ static enum runloop_state runloop_check_state(
|
|||||||
bool menu_is_alive = menu_driver_is_alive();
|
bool menu_is_alive = menu_driver_is_alive();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBNX
|
||||||
|
// Should be called once per frame
|
||||||
|
if(!appletMainLoop())
|
||||||
|
return RUNLOOP_STATE_QUIT;
|
||||||
|
#endif
|
||||||
|
|
||||||
BIT256_CLEAR_ALL_PTR(¤t_input);
|
BIT256_CLEAR_ALL_PTR(¤t_input);
|
||||||
|
|
||||||
#ifdef HAVE_MENU
|
#ifdef HAVE_MENU
|
||||||
|
Loading…
x
Reference in New Issue
Block a user