diff --git a/nx/include/switch/services/pl.h b/nx/include/switch/services/pl.h index ed5acd7d..d1a29a84 100644 --- a/nx/include/switch/services/pl.h +++ b/nx/include/switch/services/pl.h @@ -8,6 +8,11 @@ #include "../types.h" #include "../sf/service.h" +typedef enum { + PlServiceType_User = 0, ///< Initializes pl:u. + PlServiceType_System = 1, ///< Initializes pl:s. +} PlServiceType; + /// SharedFontType typedef enum { PlSharedFontType_Standard = 0, ///< Japan, US and Europe @@ -28,7 +33,7 @@ typedef struct { } PlFontData; /// Initialize pl. -Result plInitialize(void); +Result plInitialize(PlServiceType service_type); /// Exit pl. void plExit(void); diff --git a/nx/source/services/pl.c b/nx/source/services/pl.c index 9e33e77b..71d34831 100644 --- a/nx/source/services/pl.c +++ b/nx/source/services/pl.c @@ -6,18 +6,27 @@ #define SHAREDMEMFONT_SIZE 0x1100000 +static PlServiceType g_plServiceType; static Service g_plSrv; static SharedMemory g_plSharedmem; static Result _plGetSharedMemoryNativeHandle(Handle* handle_out); -NX_GENERATE_SERVICE_GUARD(pl); +NX_GENERATE_SERVICE_GUARD_PARAMS(pl, (PlServiceType service_type), (service_type)); -Result _plInitialize(void) { - Result rc=0; +Result _plInitialize(PlServiceType service_type) { + Result rc = MAKERESULT(Module_Libnx, LibnxError_BadInput); Handle sharedmem_handle=0; - rc = smGetService(&g_plSrv, "pl:u"); + g_plServiceType = service_type; + switch (g_plServiceType) { + case PlServiceType_User: + rc = smGetService(&g_plSrv, "pl:u"); + break; + case PlServiceType_System: + rc = smGetService(&g_plSrv, "pl:s"); + break; + } if (R_SUCCEEDED(rc)) { rc = _plGetSharedMemoryNativeHandle(&sharedmem_handle);