mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 12:32:40 +02:00
Add bpcGetSleepButtonState
This commit is contained in:
parent
ee55b63f79
commit
94dc8f75f9
@ -1,14 +1,20 @@
|
||||
/**
|
||||
* @file bpc.h
|
||||
* @brief Board power control (bpc) service IPC wrapper.
|
||||
* @author XorTroll
|
||||
* @author XorTroll, SciresM
|
||||
* @copyright libnx Authors
|
||||
*/
|
||||
#pragma once
|
||||
#include "../types.h"
|
||||
|
||||
typedef enum {
|
||||
BpcSleepButtonState_Held = 0,
|
||||
BpcSleepButtonState_Released = 1,
|
||||
} BpcSleepButtonState;
|
||||
|
||||
Result bpcInitialize(void);
|
||||
void bpcExit(void);
|
||||
|
||||
Result bpcShutdownSystem(void);
|
||||
Result bpcRebootSystem(void);
|
||||
Result bpcGetSleepButtonState(BpcSleepButtonState *out);
|
||||
|
@ -39,8 +39,7 @@ Result bpcShutdownSystem(void)
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
|
||||
raw = serviceIpcPrepareHeader(&g_bpcSrv, &c, sizeof(*raw));
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 0;
|
||||
|
||||
@ -48,12 +47,13 @@ Result bpcShutdownSystem(void)
|
||||
|
||||
if(R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = r.Raw;
|
||||
} *resp;
|
||||
|
||||
serviceIpcParse(&g_bpcSrv, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
}
|
||||
@ -71,7 +71,7 @@ Result bpcRebootSystem(void)
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
raw = serviceIpcPrepareHeader(&g_bpcSrv, &c, sizeof(*raw));
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 1;
|
||||
|
||||
@ -79,15 +79,52 @@ Result bpcRebootSystem(void)
|
||||
|
||||
if(R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = r.Raw;
|
||||
} *resp;
|
||||
|
||||
serviceIpcParse(&g_bpcSrv, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result bpcGetSleepButtonState(BpcSleepButtonState *out) {
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = serviceIpcPrepareHeader(&g_bpcSrv, &c, sizeof(*raw));
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 6;
|
||||
|
||||
Result rc = serviceIpcDispatch(&g_bpcSrv);
|
||||
|
||||
if(R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
u8 state;
|
||||
} *resp;
|
||||
|
||||
serviceIpcParse(&g_bpcSrv, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
*out = (BpcSleepButtonState)resp->state;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
Loading…
Reference in New Issue
Block a user