diff --git a/nx/include/switch.h b/nx/include/switch.h index 2745edc7..b687f14c 100644 --- a/nx/include/switch.h +++ b/nx/include/switch.h @@ -42,6 +42,7 @@ extern "C" { #include "switch/services/vi.h" #include "switch/services/nv.h" #include "switch/services/pm.h" +#include "switch/services/set.h" #include "switch/gfx/gfx.h" #include "switch/gfx/binder.h" diff --git a/nx/include/switch/services/set.h b/nx/include/switch/services/set.h new file mode 100644 index 00000000..c21ae4ee --- /dev/null +++ b/nx/include/switch/services/set.h @@ -0,0 +1,13 @@ +// Copyright 2018 plutoo +#include "result.h" + +typedef enum { + ColorSetId_Light=0, + ColorSetId_Dark=1 +} ColorSetId; + +Result setsysInitialize(void); +void setsysExit(void); + +/// Gets the current system theme. +Result setsysGetColorSetId(ColorSetId* out); diff --git a/nx/source/services/set.c b/nx/source/services/set.c new file mode 100644 index 00000000..3953b722 --- /dev/null +++ b/nx/source/services/set.c @@ -0,0 +1,56 @@ +// Copyright 2018 plutoo +#include "types.h" +#include "result.h" +#include "ipc.h" +#include "services/set.h" +#include "services/sm.h" + +static Service g_setsysSrv; + +Result setsysInitialize(void) +{ + if (serviceIsActive(&g_setsysSrv)) + return MAKERESULT(Module_Libnx, LibnxError_AlreadyInitialized); + + return smGetService(&g_setsysSrv, "set:sys"); +} + +void setsysExit(void) +{ + serviceClose(&g_setsysSrv); +} + +Result setsysGetColorSetId(ColorSetId* out) +{ + IpcCommand c; + ipcInitialize(&c); + + struct { + u64 magic; + u64 cmd_id; + } *raw; + + raw = ipcPrepareHeader(&c, sizeof(*raw)); + + raw->magic = SFCI_MAGIC; + raw->cmd_id = 23; + + Result rc = serviceIpcDispatch(&g_setsysSrv); + + if (R_SUCCEEDED(rc)) { + IpcParsedCommand r; + ipcParse(&r); + + struct { + u64 magic; + u64 result; + u32 color_set; + } *resp = r.Raw; + + *out = resp->color_set; + rc = resp->result; + } + + return rc; + +}