From d4542ec9b01c7a3291e341dd830edca41d714f5f Mon Sep 17 00:00:00 2001 From: yellows8 Date: Sat, 13 Feb 2021 14:20:44 -0500 Subject: [PATCH] hiddbg: Added support for SleepButton AutoPilot. --- nx/include/switch/services/hiddbg.h | 16 ++++++++++++++++ nx/source/services/hiddbg.c | 8 ++++++++ 2 files changed, 24 insertions(+) diff --git a/nx/include/switch/services/hiddbg.h b/nx/include/switch/services/hiddbg.h index 5a6c9d97..658c13f1 100644 --- a/nx/include/switch/services/hiddbg.h +++ b/nx/include/switch/services/hiddbg.h @@ -40,6 +40,11 @@ typedef struct { u64 keys[4]; } HiddbgKeyboardAutoPilotState; +/// State for overriding SleepButtonState. +typedef struct { + u64 buttons; ///< Bitfield of buttons, only bit0 is used. +} HiddbgSleepButtonAutoPilotState; + /// HdlsHandle typedef struct { u64 handle; ///< Handle @@ -215,6 +220,17 @@ Result hiddbgUnsetKeyboardAutoPilotState(void); */ Result hiddbgDeactivateHomeButton(void); +/** + * @brief SetSleepButtonAutoPilotState + * @param[in] state \ref HiddbgSleepButtonAutoPilotState + */ +Result hiddbgSetSleepButtonAutoPilotState(const HiddbgSleepButtonAutoPilotState *state); + +/** + * @brief UnsetSleepButtonAutoPilotState + */ +Result hiddbgUnsetSleepButtonAutoPilotState(void); + /** * @brief Writes the input RGB colors to the spi-flash for the specified UniquePad (offset 0x6050 size 0x6). * @note Only available with [3.0.0+]. diff --git a/nx/source/services/hiddbg.c b/nx/source/services/hiddbg.c index b9022259..3281666d 100644 --- a/nx/source/services/hiddbg.c +++ b/nx/source/services/hiddbg.c @@ -115,6 +115,14 @@ Result hiddbgDeactivateHomeButton(void) { return _hiddbgCmdNoIO(110); } +Result hiddbgSetSleepButtonAutoPilotState(const HiddbgSleepButtonAutoPilotState *state) { + return serviceDispatchIn(&g_hiddbgSrv, 121, *state); +} + +Result hiddbgUnsetSleepButtonAutoPilotState(void) { + return _hiddbgCmdNoIO(122); +} + Result hiddbgUpdateControllerColor(u32 colorBody, u32 colorButtons, HidsysUniquePadId unique_pad_id) { if (hosversionBefore(3,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);