From 0403c988ba8280b161ad29b3b1974da6ece1daf7 Mon Sep 17 00:00:00 2001 From: yellows8 Date: Sun, 20 Oct 2019 02:35:30 -0400 Subject: [PATCH] hidsys: Fixed cmd order. Fixed output size for hidsysGetUniquePadSerialNumber. --- nx/include/switch/services/hidsys.h | 16 ++++++++-------- nx/source/services/hidsys.c | 22 +++++++++++----------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/nx/include/switch/services/hidsys.h b/nx/include/switch/services/hidsys.h index 6da6b5e2..73b2320c 100644 --- a/nx/include/switch/services/hidsys.h +++ b/nx/include/switch/services/hidsys.h @@ -108,6 +108,14 @@ Result hidsysEnableAppletToGetInput(bool enable); */ Result hidsysGetUniquePadIds(u64 *UniquePadIds, s32 count, s32 *total_entries); +/** + * @brief Gets the unique pad's serial number. + * @note Only available on [5.0.0+]. + * @param UniquePadId UniquePadId for the controller. + * @param serial Pointer to output the serial to. (The buffer size needs to be at least 0x11 bytes) + */ +Result hidsysGetUniquePadSerialNumber(u64 UniquePadId, char *serial); + /** * @brief Sets the HOME-button notification LED pattern, for the specified controller. * @note Generally this should only be used if \ref hidsysSetNotificationLedPatternWithTimeout is not usable. @@ -125,11 +133,3 @@ Result hidsysSetNotificationLedPattern(const HidsysNotificationLedPattern *patte * @param[in] timeout Timeout in nanoseconds. */ Result hidsysSetNotificationLedPatternWithTimeout(const HidsysNotificationLedPattern *pattern, u64 UniquePadId, u64 timeout); - -/** - * @brief Gets the unique pad's serial number. - * @note Only available on [5.0.0+]. - * @param UniquePadId UniquePadId for the controller. - * @param serial Pointer to output the serial to. (The buffer size needs to be at least 0x19 bytes) - */ -Result hidsysGetUniquePadSerialNumber(u64 UniquePadId, char *serial); diff --git a/nx/source/services/hidsys.c b/nx/source/services/hidsys.c index 79315b4a..746cadc2 100644 --- a/nx/source/services/hidsys.c +++ b/nx/source/services/hidsys.c @@ -134,6 +134,17 @@ Result hidsysGetUniquePadIds(u64 *UniquePadIds, s32 count, s32 *total_entries) { return rc; } +Result hidsysGetUniquePadSerialNumber(u64 UniquePadId, char *serial) { + if (hosversionBefore(5,0,0)) + return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + + char out[0x10]={0}; + if (serial) memset(serial, 0, 0x11); + Result rc = serviceDispatchInOut(&g_hidsysSrv, 809, UniquePadId, out); + if (R_SUCCEEDED(rc) && serial) memcpy(serial, out, 0x10); + return rc; +} + Result hidsysSetNotificationLedPattern(const HidsysNotificationLedPattern *pattern, u64 UniquePadId) { if (hosversionBefore(7,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); @@ -158,14 +169,3 @@ Result hidsysSetNotificationLedPatternWithTimeout(const HidsysNotificationLedPat return serviceDispatchIn(&g_hidsysSrv, 831, in); } - -Result hidsysGetUniquePadSerialNumber(u64 UniquePadId, char *serial) { - if (hosversionBefore(5,0,0)) - return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); - - char out[0x18]={0}; - if (serial) memset(serial, 0, 0x19); - Result rc = serviceDispatchInOut(&g_hidsysSrv, 809, UniquePadId, out); - if (R_SUCCEEDED(rc) && serial) memcpy(serial, out, 0x18); - return rc; -}