From 3c6344d7f3afd1dbf71b28d0f774bb3b0ac34ac0 Mon Sep 17 00:00:00 2001 From: Joel Date: Thu, 7 Jun 2018 15:06:36 -0500 Subject: [PATCH] Add more set:sys Get*/Set* functions (#108) * Use setsysGetFlag/setsysSetFlag instead of setsysGet*/setsysSet*. * Added more setsys Flags (now handled via an enum). --- nx/include/switch/services/set.h | 58 ++++++------- nx/source/services/set.c | 143 ++----------------------------- 2 files changed, 34 insertions(+), 167 deletions(-) diff --git a/nx/include/switch/services/set.h b/nx/include/switch/services/set.h index 02d59708..8516180f 100644 --- a/nx/include/switch/services/set.h +++ b/nx/include/switch/services/set.h @@ -35,6 +35,26 @@ typedef enum SetLanguage_Total, ///< Total languages supported by this enum. } SetLanguage; +/// Command IDs for setsysGetFlag/setsysSetFlag. +typedef enum { + SetSysFlag_LockScreen = 7, + SetSysFlag_ConsoleInformationUpload = 25, + SetSysFlag_AutomaticApplicationDownload = 27, + SetSysFlag_Quest = 47, + SetSysFlag_Usb30Enable = 65, + SetSysFlag_NfcEnable = 69, + SetSysFlag_WirelessLanEnable = 73, + SetSysFlag_BluetoothEnable = 88, + SetSysFlag_AutoUpdateEnable = 95, + SetSysFlag_BatteryPercentage = 99, + SetSysFlag_ExternalRtcReset = 101, + SetSysFlag_UsbFullKeyEnable = 103, + SetSysFlag_BluetoothAfhEnable = 111, + SetSysFlag_BluetoothBoostEnable = 113, + SetSysFlag_InRepairProcessEnable = 115, + SetSysFlag_HeadphoneVolumeUpdate = 117, +} SetSysFlag; + Result setInitialize(void); void setExit(void); @@ -88,37 +108,15 @@ Result setsysGetSettingsItemValue(const char *name, const char *item_key, void * Result setsysGetSerialNumber(char *serial); /** - * @brief Gets the lockscreen status. - * @param out Pointer to output the status to. + * @brief Gets the status of the specified settings flag. + * @param flag The specified settings flag. + * @param out Output pointer for the status. */ -Result setsysGetLockScreenFlag(bool *out); +Result setsysGetFlag(SetSysFlag flag, bool *out); /** - * @brief Gets the console information upload status. - * @param out Pointer to output the status to. + * @brief Enables/disables the specified settings flag. + * @param flag The specified settings flag. + * @param enable To enable/disable the flag. */ -Result setsysGetConsoleInformationUploadFlag(bool *out); - -/** - * @brief Gets the automatic application download status. - * @param out Pointer to output the status to. - */ -Result setsysGetAutomaticApplicationDownloadFlag(bool *out); - -/** - * @brief Gets the NFC status. - * @param out Pointer to output the status to. - */ -Result setsysGetNfcEnableFlag(bool *out); - -/** - * @brief Gets the wireless LAN status. - * @param out Pointer to output the status to. - */ -Result setsysGetWirelessLanEnableFlag(bool *out); - -/** - * @brief Gets the bluetooth status. - * @param out Pointer to output the status to. - */ -Result setsysGetBluetoothEnableFlag(bool *out); +Result setsysSetFlag(SetSysFlag flag, bool enable); \ No newline at end of file diff --git a/nx/source/services/set.c b/nx/source/services/set.c index 3c0ee614..9e5f23da 100644 --- a/nx/source/services/set.c +++ b/nx/source/services/set.c @@ -471,7 +471,7 @@ Result setsysGetSerialNumber(char *serial) { return rc; } -Result setsysGetLockScreenFlag(bool *out) { +Result setsysGetFlag(SetSysFlag flag, bool *out) { IpcCommand c; ipcInitialize(&c); @@ -483,7 +483,7 @@ Result setsysGetLockScreenFlag(bool *out) { raw = ipcPrepareHeader(&c, sizeof(*raw)); raw->magic = SFCI_MAGIC; - raw->cmd_id = 7; + raw->cmd_id = flag; Result rc = serviceIpcDispatch(&g_setsysSrv); @@ -504,19 +504,21 @@ Result setsysGetLockScreenFlag(bool *out) { return rc; } -Result setsysGetConsoleInformationUploadFlag(bool *out) { +Result setsysSetFlag(SetSysFlag flag, bool enable) { IpcCommand c; ipcInitialize(&c); struct { u64 magic; u64 cmd_id; + u8 flag; } *raw; raw = ipcPrepareHeader(&c, sizeof(*raw)); raw->magic = SFCI_MAGIC; - raw->cmd_id = 25; + raw->cmd_id = flag + 1; + raw->flag = enable; Result rc = serviceIpcDispatch(&g_setsysSrv); @@ -530,139 +532,6 @@ Result setsysGetConsoleInformationUploadFlag(bool *out) { u8 flag; } *resp = r.Raw; - *out = resp->flag; - rc = resp->result; - } - - return rc; -} - -Result setsysGetAutomaticApplicationDownloadFlag(bool *out) { - IpcCommand c; - ipcInitialize(&c); - - struct { - u64 magic; - u64 cmd_id; - } *raw; - - raw = ipcPrepareHeader(&c, sizeof(*raw)); - - raw->magic = SFCI_MAGIC; - raw->cmd_id = 27; - - Result rc = serviceIpcDispatch(&g_setsysSrv); - - if (R_SUCCEEDED(rc)) { - IpcParsedCommand r; - ipcParse(&r); - - struct { - u64 magic; - u64 result; - u8 flag; - } *resp = r.Raw; - - *out = resp->flag; - rc = resp->result; - } - - return rc; -} - -Result setsysGetNfcEnableFlag(bool *out) { - IpcCommand c; - ipcInitialize(&c); - - struct { - u64 magic; - u64 cmd_id; - } *raw; - - raw = ipcPrepareHeader(&c, sizeof(*raw)); - - raw->magic = SFCI_MAGIC; - raw->cmd_id = 69; - - Result rc = serviceIpcDispatch(&g_setsysSrv); - - if (R_SUCCEEDED(rc)) { - IpcParsedCommand r; - ipcParse(&r); - - struct { - u64 magic; - u64 result; - u8 flag; - } *resp = r.Raw; - - *out = resp->flag; - rc = resp->result; - } - - return rc; -} - -Result setsysGetWirelessLanEnableFlag(bool *out) { - IpcCommand c; - ipcInitialize(&c); - - struct { - u64 magic; - u64 cmd_id; - } *raw; - - raw = ipcPrepareHeader(&c, sizeof(*raw)); - - raw->magic = SFCI_MAGIC; - raw->cmd_id = 73; - - Result rc = serviceIpcDispatch(&g_setsysSrv); - - if (R_SUCCEEDED(rc)) { - IpcParsedCommand r; - ipcParse(&r); - - struct { - u64 magic; - u64 result; - u8 flag; - } *resp = r.Raw; - - *out = resp->flag; - rc = resp->result; - } - - return rc; -} - -Result setsysGetBluetoothEnableFlag(bool *out) { - IpcCommand c; - ipcInitialize(&c); - - struct { - u64 magic; - u64 cmd_id; - } *raw; - - raw = ipcPrepareHeader(&c, sizeof(*raw)); - - raw->magic = SFCI_MAGIC; - raw->cmd_id = 88; - - Result rc = serviceIpcDispatch(&g_setsysSrv); - - if (R_SUCCEEDED(rc)) { - IpcParsedCommand r; - ipcParse(&r); - - struct { - u64 magic; - u64 result; - u8 flag; - } *resp = r.Raw; - - *out = resp->flag; rc = resp->result; }