mirror of
https://github.com/switchbrew/libnx.git
synced 2025-07-05 10:52:15 +02:00
Init nifm in the proper context, add SetWirelessCommunicationEnabled
This commit is contained in:
parent
b19c35fe2c
commit
d8c631b65c
@ -16,6 +16,11 @@ Result nifmGetCurrentIpAddress(u32* out);
|
|||||||
|
|
||||||
Result nifmIsWirelessCommunicationEnabled(bool* out);
|
Result nifmIsWirelessCommunicationEnabled(bool* out);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @note Works only if called from nifm:a or nifm:s.
|
||||||
|
*/
|
||||||
|
Result nifmSetWirelessCommunicationEnabled(bool enable);
|
||||||
|
|
||||||
Result nifmIsEthernetCommunicationEnabled(bool* out);
|
Result nifmIsEthernetCommunicationEnabled(bool* out);
|
||||||
Result nifmIsAnyForegroundRequestAccepted(bool* out);
|
Result nifmIsAnyForegroundRequestAccepted(bool* out);
|
||||||
Result nifmPutToSleep(void);
|
Result nifmPutToSleep(void);
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "services/nifm.h"
|
#include "services/nifm.h"
|
||||||
#include "arm/atomics.h"
|
#include "arm/atomics.h"
|
||||||
#include "runtime/hosversion.h"
|
#include "runtime/hosversion.h"
|
||||||
|
#include "services/applet.h"
|
||||||
|
|
||||||
static Service g_nifmSrv;
|
static Service g_nifmSrv;
|
||||||
static Service g_nifmIGS;
|
static Service g_nifmIGS;
|
||||||
@ -23,7 +24,25 @@ Result nifmInitialize(void) {
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
Result rc;
|
Result rc;
|
||||||
rc = smGetService(&g_nifmSrv, "nifm:u");
|
|
||||||
|
switch (appletGetAppletType()) {
|
||||||
|
case AppletType_None:
|
||||||
|
rc = smGetService(&g_nifmSrv, "nifm:s");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AppletType_Default:
|
||||||
|
case AppletType_Application:
|
||||||
|
case AppletType_SystemApplication:
|
||||||
|
default:
|
||||||
|
rc = smGetService(&g_nifmSrv, "nifm:u");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AppletType_SystemApplet:
|
||||||
|
case AppletType_LibraryApplet:
|
||||||
|
case AppletType_OverlayApplet:
|
||||||
|
rc = smGetService(&g_nifmSrv, "nifm:a");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) rc = serviceConvertToDomain(&g_nifmSrv);
|
if (R_SUCCEEDED(rc)) rc = serviceConvertToDomain(&g_nifmSrv);
|
||||||
|
|
||||||
@ -119,6 +138,41 @@ Result nifmIsWirelessCommunicationEnabled(bool* out) {
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result nifmSetWirelessCommunicationEnabled(bool enable) {
|
||||||
|
IpcCommand c;
|
||||||
|
ipcInitialize(&c);
|
||||||
|
|
||||||
|
struct {
|
||||||
|
u64 magic;
|
||||||
|
u64 cmd_id;
|
||||||
|
u8 value;
|
||||||
|
} *raw;
|
||||||
|
|
||||||
|
raw = serviceIpcPrepareHeader(&g_nifmIGS, &c, sizeof(*raw));
|
||||||
|
|
||||||
|
raw->magic = SFCI_MAGIC;
|
||||||
|
raw->cmd_id = 16;
|
||||||
|
raw->value = enable;
|
||||||
|
|
||||||
|
Result rc = serviceIpcDispatch(&g_nifmIGS);
|
||||||
|
|
||||||
|
if (R_SUCCEEDED(rc)) {
|
||||||
|
IpcParsedCommand r;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
u64 magic;
|
||||||
|
u64 result;
|
||||||
|
} *resp;
|
||||||
|
|
||||||
|
serviceIpcParse(&g_nifmIGS, &r, sizeof(*resp));
|
||||||
|
resp = r.Raw;
|
||||||
|
|
||||||
|
rc = resp->result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
Result nifmIsEthernetCommunicationEnabled(bool* out) {
|
Result nifmIsEthernetCommunicationEnabled(bool* out) {
|
||||||
IpcCommand c;
|
IpcCommand c;
|
||||||
ipcInitialize(&c);
|
ipcInitialize(&c);
|
||||||
|
Loading…
Reference in New Issue
Block a user