3ds: implement apt hooks

This commit is contained in:
Joshua Peisach 2025-06-29 11:41:54 -04:00
parent 2b7287452c
commit 511acfe82d
No known key found for this signature in database
GPG Key ID: 41C3D4189AFEDB5A
5 changed files with 42 additions and 0 deletions

View File

@ -647,6 +647,7 @@ set(CPACK_PACKAGE_DIRECTORY "dist")
set(CPACK_PACKAGE_FILE_NAME "isle-${PROJECT_VERSION}-${ISLE_PACKAGE_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
if(NINTENDO_3DS)
target_sources(isle PRIVATE
ISLE/3ds/apthooks.cpp
ISLE/3ds/filesystem.cpp
)
ctr_generate_smdh(isle.smdh

24
ISLE/3ds/apthooks.cpp Normal file
View File

@ -0,0 +1,24 @@
#include "apthooks.h"
#include "../isleapp.h"
#include "legomain.h"
#include "misc.h"
void N3DS_AptHookCallback(APT_HookType hookType, void* param)
{
switch (hookType) {
case APTHOOK_ONSLEEP:
case APTHOOK_ONSUSPEND:
Lego()->Pause();
break;
case APTHOOK_ONWAKEUP:
case APTHOOK_ONRESTORE:
Lego()->Resume();
break;
case APTHOOK_ONEXIT:
Lego()->CloseMainWindow();
break;
default:
break;
}
}

8
ISLE/3ds/apthooks.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef N3DS_APTHOOKS_H
#define N3DS_APTHOOKS_H
#include <3ds.h>
void N3DS_AptHookCallback(APT_HookType hookType, void* param);
#endif // N3DS_APTHOOKS_H

View File

@ -51,7 +51,10 @@
#endif
#ifdef __3DS__
#include "3ds/apthooks.h"
#include "3ds/filesystem.h"
aptHookCookie g_aptCookie;
#endif
DECOMP_SIZE_ASSERT(IsleApp, 0x8c)
@ -318,6 +321,11 @@ SDL_AppResult SDL_AppInit(void** appstate, int argc, char** argv)
NULL
);
#endif
#ifdef __3DS__
aptHook(&g_aptCookie, N3DS_AptHookCallback, NULL);
#endif
return SDL_APP_CONTINUE;
}

View File

@ -96,6 +96,7 @@ class IsleApp {
};
extern IsleApp* g_isle;
extern MxS32 g_closed;
extern IDirect3DRMMiniwinDevice* GetD3DRMMiniwinDevice();