mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 04:22:50 +02:00
Add hidsysGetUniquePadSerialNumber (#303)
This commit is contained in:
parent
2c1763c692
commit
61c0f4b2d9
@ -71,3 +71,9 @@ Result hidsysGetUniquePadIds(u64 *UniquePadIds, size_t count, size_t *total_entr
|
||||
*/
|
||||
Result hidsysSetNotificationLedPattern(const HidsysNotificationLedPattern *pattern, u64 UniquePadId);
|
||||
|
||||
/**
|
||||
* @brief Gets the unique pad's serial number.
|
||||
* @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);
|
||||
|
@ -300,3 +300,46 @@ Result hidsysSetNotificationLedPattern(const HidsysNotificationLedPattern *patte
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result hidsysGetUniquePadSerialNumber(u64 UniquePadId, char *serial) {
|
||||
if (hosversionBefore(5,0,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
if (serial) memset(serial, 0, 0x19);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
u64 UniquePadId;
|
||||
} *raw;
|
||||
|
||||
raw = serviceIpcPrepareHeader(&g_hidsysSrv, &c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 809;
|
||||
raw->UniquePadId = UniquePadId;
|
||||
|
||||
Result rc = serviceIpcDispatch(&g_hidsysSrv);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
char serial[0x18];
|
||||
} *resp;
|
||||
|
||||
serviceIpcParse(&g_hidsysSrv, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
|
||||
if (R_SUCCEEDED(rc) && serial)
|
||||
memcpy(serial, resp->serial, 0x18);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user