From 49183c9953dd0a430b389a7fb6316b4e7b7e358a Mon Sep 17 00:00:00 2001 From: yellows8 Date: Sun, 29 Nov 2020 01:45:36 -0500 Subject: [PATCH] hidsys: Updated the {Home/Sleep/Capture}Button cmds. --- nx/include/switch/services/hidsys.h | 49 +++++++++++++++++------------ nx/source/services/hidsys.c | 27 ++++++++-------- 2 files changed, 42 insertions(+), 34 deletions(-) diff --git a/nx/include/switch/services/hidsys.h b/nx/include/switch/services/hidsys.h index 325b12fa..70bbd540 100644 --- a/nx/include/switch/services/hidsys.h +++ b/nx/include/switch/services/hidsys.h @@ -196,38 +196,47 @@ Service* hidsysGetServiceSession(void); Result hidsysSendKeyboardLockKeyEvent(u32 events); /** - * @brief Returns an event that fires when the home button is pressed, this will prevent the home menu from opening when the button is pressed. + * @brief Gets an Event which is signaled when HidHomeButtonState is updated. * @note The Event must be closed by the user once finished with it. - * @param[out] out_event Output Event with autoclear=false. + * @note This generally shouldn't be used, since AM-sysmodule uses it internally. + * @param[out] out_event Output Event. + * @param[in] Event autoclear. **/ -Result hidsysAcquireHomeButtonEventHandle(Event* out_event); +Result hidsysAcquireHomeButtonEventHandle(Event* out_event, bool autoclear); /** - * @brief Returns an event that fires when the sleep button is pressed. - * @note The Event must be closed by the user once finished with it. - * @param[out] out_event Output Event with autoclear=false. -**/ -Result hidsysAcquireSleepButtonEventHandle(Event* out_event); - -/** - * @brief Returns an event that fires when the capture button is pressed. - * @note The Event must be closed by the user once finished with it. - * @param[out] out_event Output Event with autoclear=false. -**/ -Result hidsysAcquireCaptureButtonEventHandle(Event* out_event); - -/** - * @brief ActivateHomeButton + * @brief Activates the HomeButton sharedmem. + * @note This generally shouldn't be used, since AM-sysmodule uses it internally. **/ Result hidsysActivateHomeButton(void); /** - * @brief ActivateSleepButton + * @brief Gets an Event which is signaled when HidSleepButtonState is updated. + * @note The Event must be closed by the user once finished with it. + * @note This generally shouldn't be used, since AM-sysmodule uses it internally. + * @param[out] out_event Output Event. + * @param[in] Event autoclear. +**/ +Result hidsysAcquireSleepButtonEventHandle(Event* out_event, bool autoclear); + +/** + * @brief Activates the SleepButton sharedmem. + * @note This generally shouldn't be used, since AM-sysmodule uses it internally. **/ Result hidsysActivateSleepButton(void); /** - * @brief ActivateCaptureButton + * @brief Gets an Event which is signaled when HidCaptureButtonState is updated. + * @note The Event must be closed by the user once finished with it. + * @note This generally shouldn't be used, since AM-sysmodule uses it internally. + * @param[out] out_event Output Event. + * @param[in] Event autoclear. +**/ +Result hidsysAcquireCaptureButtonEventHandle(Event* out_event, bool autoclear); + +/** + * @brief Activates the CaptureButton sharedmem. + * @note This generally shouldn't be used, since AM-sysmodule uses it internally. **/ Result hidsysActivateCaptureButton(void); diff --git a/nx/source/services/hidsys.c b/nx/source/services/hidsys.c index 059bb4c3..31ffbb81 100644 --- a/nx/source/services/hidsys.c +++ b/nx/source/services/hidsys.c @@ -108,7 +108,7 @@ static Result _hidsysCmdInU64OutBool(u64 inval, bool *out, u32 cmd_id) { return rc; } -static Result _hidsysCmdGetHandle(Handle* handle_out, u32 cmd_id) { +static Result _hidsysCmdInPidAruidOutHandle(Handle* handle_out, u32 cmd_id) { return serviceDispatchIn(&g_hidsysSrv, cmd_id, g_hidsysAppletResourceUserId, .in_send_pid = true, .out_handle_attrs = { SfOutHandleAttr_HipcCopy }, @@ -116,11 +116,11 @@ static Result _hidsysCmdGetHandle(Handle* handle_out, u32 cmd_id) { ); } -static Result _hidsysCmdGetEvent(Event* out_event, bool autoclear, u32 cmd_id) { +static Result _hidsysCmdInPidAruidOutEvent(Event* out_event, bool autoclear, u32 cmd_id) { Handle tmp_handle = INVALID_HANDLE; Result rc = 0; - rc = _hidsysCmdGetHandle(&tmp_handle, cmd_id); + rc = _hidsysCmdInPidAruidOutHandle(&tmp_handle, cmd_id); if (R_SUCCEEDED(rc)) eventLoadRemote(out_event, tmp_handle, autoclear); return rc; } @@ -167,27 +167,26 @@ Result hidsysSendKeyboardLockKeyEvent(u32 events) { return _hidsysCmdInU32NoOut(events, 31); } -Result hidsysAcquireHomeButtonEventHandle(Event* out_event) { - return _hidsysCmdGetEvent(out_event, false, 101); -} - -//These functions don't seem to work in the overlaydisp applet context -Result hidsysAcquireSleepButtonEventHandle(Event* out_event) { - return _hidsysCmdGetEvent(out_event, false, 121); -} - -Result hidsysAcquireCaptureButtonEventHandle(Event* out_event) { - return _hidsysCmdGetEvent(out_event, false, 141); +Result hidsysAcquireHomeButtonEventHandle(Event* out_event, bool autoclear) { + return _hidsysCmdInPidAruidOutEvent(out_event, autoclear, 101); } Result hidsysActivateHomeButton(void) { return _hidsysCmdWithResIdAndPid(111); } +Result hidsysAcquireSleepButtonEventHandle(Event* out_event, bool autoclear) { + return _hidsysCmdInPidAruidOutEvent(out_event, autoclear, 121); +} + Result hidsysActivateSleepButton(void) { return _hidsysCmdWithResIdAndPid(131); } +Result hidsysAcquireCaptureButtonEventHandle(Event* out_event, bool autoclear) { + return _hidsysCmdInPidAruidOutEvent(out_event, autoclear, 141); +} + Result hidsysActivateCaptureButton(void) { return _hidsysCmdWithResIdAndPid(151); }