From 4fcdb6eb34b20f1f65eb9791fe513a710a001bea Mon Sep 17 00:00:00 2001 From: Narr the Reg Date: Thu, 10 Aug 2023 22:11:38 -0600 Subject: [PATCH] service: hidsys: Implement functions needed by QLaunch --- nx/include/switch/services/hidsys.h | 26 +++++++++++++++++++++++++- nx/source/services/hidsys.c | 23 +++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/nx/include/switch/services/hidsys.h b/nx/include/switch/services/hidsys.h index 36f13139..7adb7d70 100644 --- a/nx/include/switch/services/hidsys.h +++ b/nx/include/switch/services/hidsys.h @@ -255,6 +255,17 @@ Result hidsysAcquireCaptureButtonEventHandle(Event* out_event, bool autoclear); **/ Result hidsysActivateCaptureButton(void); +/** + * @brief Applies npad system common policy. + */ +Result hidsysApplyNpadSystemCommonPolicy(void); + +/** + * @brief Gets the npad id type of the last controller that was active. + * @param[out] out of \ref HidNpadIdType. + */ +Result hidsysGetLastActiveNpad(u32 *out); + /** * @brief Gets the SupportedNpadStyleSet for the CallerApplet. applet must be initialized in order to use this (uses \ref appletGetAppletResourceUserIdOfCallerApplet). * @note Only available on [6.0.0+]. @@ -326,6 +337,13 @@ Result hidsysAcquireUniquePadConnectionEventHandle(Event *out_event); */ Result hidsysGetUniquePadIds(HidsysUniquePadId *unique_pad_ids, s32 count, s32 *total_out); +/** + * @brief AcquireJoyDetachOnBluetoothOffEventHandle + * @param[out] out_event Output Event. + * @param[in] Event autoclear. + */ +Result hidsysAcquireJoyDetachOnBluetoothOffEventHandle(Event *out_event, bool autoclear); + /** * @brief GetUniquePadBluetoothAddress * @note Only available on [3.0.0+]. @@ -413,6 +431,13 @@ Result hidsysEnableUsbFullKeyController(bool flag); */ Result hidsysIsUsbConnected(HidsysUniquePadId unique_pad_id, bool *out); +/** + * @brief GetTouchScreenDefaultConfiguration + * @note Only available on [9.0.0+]. + * @param[out] touch_screen_configuration \ref HidTouchScreenConfigurationForNx. + */ +Result hidsysGetTouchScreenDefaultConfiguration(HidTouchScreenConfigurationForNx *touch_screen_configuration); + /** * @brief IsFirmwareUpdateNeededForNotification * @note Only available on [9.0.0+]. @@ -964,4 +989,3 @@ Result hidsysSetButtonConfigStorageLeft(s32 index, const HidcfgButtonConfigLeft * @param[in] name \ref HidcfgStorageName */ Result hidsysSetButtonConfigStorageRight(s32 index, const HidcfgButtonConfigRight *config, const HidcfgStorageName *name); - diff --git a/nx/source/services/hidsys.c b/nx/source/services/hidsys.c index 53310ddb..1255ba0e 100644 --- a/nx/source/services/hidsys.c +++ b/nx/source/services/hidsys.c @@ -81,6 +81,10 @@ static Result _hidsysCmdNoInOutU8(u8 *out, u32 cmd_id) { return serviceDispatchOut(&g_hidsysSrv, cmd_id, *out); } +static Result _hidsysCmdNoInOutU32(u32 *out, u32 cmd_id) { + return serviceDispatchOut(&g_hidsysSrv, cmd_id, *out); +} + static Result _hidsysCmdNoInOutBool(bool *out, u32 cmd_id) { u8 tmp=0; Result rc = _hidsysCmdNoInOutU8(&tmp, cmd_id); @@ -251,6 +255,14 @@ Result hidsysActivateCaptureButton(void) { return _hidsysCmdWithResIdAndPid(151); } +Result hidsysApplyNpadSystemCommonPolicy(void) { + return _hidsysCmdNoIO(303); +} + +Result hidsysGetLastActiveNpad(u32 *out) { + return _hidsysCmdNoInOutU32(out, 306); +} + static Result _hidsysGetMaskedSupportedNpadStyleSet(u64 AppletResourceUserId, u32 *out) { if (hosversionBefore(6,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); @@ -350,6 +362,10 @@ Result hidsysGetUniquePadIds(HidsysUniquePadId *unique_pad_ids, s32 count, s32 * return rc; } +Result hidsysAcquireJoyDetachOnBluetoothOffEventHandle(Event *out_event, bool autoclear) { + return _hidsysCmdInPidAruidOutEvent(out_event, autoclear, 751); +} + Result hidsysGetUniquePadBluetoothAddress(HidsysUniquePadId unique_pad_id, BtdrvAddress *address) { if (hosversionBefore(3,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); @@ -445,6 +461,13 @@ Result hidsysIsUsbConnected(HidsysUniquePadId unique_pad_id, bool *out) { return _hidsysCmdInU64OutBool(unique_pad_id.id, out, 852); } +Result hidsysGetTouchScreenDefaultConfiguration(HidTouchScreenConfigurationForNx *touch_screen_configuration) { + if (hosversionBefore(9,0,0)) + return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + + return serviceDispatchOut(&g_hidsysSrv, 1153, *touch_screen_configuration); +} + Result hidsysIsFirmwareUpdateNeededForNotification(HidsysUniquePadId unique_pad_id, bool *out) { if (hosversionBefore(9,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);