Added hidGetNpadInterfaceType.

This commit is contained in:
yellows8 2019-09-13 00:05:43 -04:00
parent 81781f0782
commit 326619c271
No known key found for this signature in database
GPG Key ID: 0AF90DA3F1E60E43
2 changed files with 45 additions and 0 deletions

View File

@ -792,3 +792,7 @@ Result hidGetSevenSixAxisSensorFusionStrength(float *strength);
/// Resets the timestamp for the SevenSixAxisSensor. Only available on [6.0.0+].
Result hidResetSevenSixAxisSensorTimestamp(void);
/// Gets the NpadInterfaceType for the specified controller.
/// Only available on [4.0.0+].
Result hidGetNpadInterfaceType(HidControllerID id, u8 *out);

View File

@ -1739,3 +1739,44 @@ Result hidResetSevenSixAxisSensorTimestamp(void) {
return _hidCmdWithNoInput(310);
}
Result hidGetNpadInterfaceType(HidControllerID id, u8 *out) {
if (hosversionBefore(4,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
Result rc;
IpcCommand c;
ipcInitialize(&c);
struct {
u64 magic;
u64 cmd_id;
u32 id;
} *raw;
raw = ipcPrepareHeader(&c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
raw->cmd_id = 405;
raw->id = hidControllerIDToOfficial(id);
rc = serviceIpcDispatch(&g_hidSrv);
if (R_SUCCEEDED(rc)) {
IpcParsedCommand r;
ipcParse(&r);
struct {
u64 magic;
u64 result;
u8 out;
} *resp = r.Raw;
rc = resp->result;
if (R_SUCCEEDED(rc) && out) *out = resp->out;
}
return rc;
}