From bed9213f41758da3b107faf94e86c1011a79e16e Mon Sep 17 00:00:00 2001 From: yellows8 Date: Thu, 25 Apr 2019 19:27:45 -0400 Subject: [PATCH] Added hidsysSetNotificationLedPattern and the struct for it. --- nx/include/switch/services/hidsys.h | 12 +++++++++ nx/source/services/hidsys.c | 40 +++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/nx/include/switch/services/hidsys.h b/nx/include/switch/services/hidsys.h index ea92d997..2bfb6536 100644 --- a/nx/include/switch/services/hidsys.h +++ b/nx/include/switch/services/hidsys.h @@ -9,6 +9,11 @@ #include "../services/hid.h" #include "../services/sm.h" +/// Structure for \ref hidsysSetNotificationLedPattern. +typedef struct { + u8 unk_x0[0x48]; ///< TODO +} HidsysNotificationLedPattern; + Result hidsysInitialize(void); void hidsysExit(void); @@ -41,3 +46,10 @@ Result hidsysGetUniquePadsFromNpad(HidControllerID id, u64 *UniquePadIds, size_t */ Result hidsysGetUniquePadIds(u64 *UniquePadIds, size_t count, size_t *total_entries); +/** + * @brief Sets the HOME-button notification LED pattern, for the specified controller. + * @param pattern \ref HidsysNotificationLedPattern + * @param UniquePadId UniquePadId for the controller. + */ +Result hidsysSetNotificationLedPattern(HidsysNotificationLedPattern *pattern, u64 UniquePadId); + diff --git a/nx/source/services/hidsys.c b/nx/source/services/hidsys.c index 7ff208a5..5e2dd0ec 100644 --- a/nx/source/services/hidsys.c +++ b/nx/source/services/hidsys.c @@ -261,3 +261,43 @@ Result hidsysGetUniquePadIds(u64 *UniquePadIds, size_t count, size_t *total_entr return rc; } +Result hidsysSetNotificationLedPattern(HidsysNotificationLedPattern *pattern, u64 UniquePadId) { + if (hosversionBefore(7,0,0)) + return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + + Result rc; + + IpcCommand c; + ipcInitialize(&c); + + struct { + u64 magic; + u64 cmd_id; + HidsysNotificationLedPattern pattern; + u64 UniquePadId; + } *raw; + + raw = serviceIpcPrepareHeader(&g_hidsysSrv, &c, sizeof(*raw)); + + raw->magic = SFCI_MAGIC; + raw->cmd_id = 830; + memcpy(&raw->pattern, pattern, sizeof(*pattern)); + raw->UniquePadId = UniquePadId; + + rc = serviceIpcDispatch(&g_hidsysSrv); + + if (R_SUCCEEDED(rc)) { + IpcParsedCommand r; + struct { + u64 magic; + u64 result; + u64 total_entries; + } *resp; + + serviceIpcParse(&g_hidsysSrv, &r, sizeof(*resp)); + resp = r.Raw; + } + + return rc; +} +