mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 12:32:40 +02:00
Added hidGetSupportedNpadStyleSet. Moved hidSetSupportedNpadStyleSet to match cmd order. Added hidsysGetSupportedNpadStyleSetOfCallerApplet.
This commit is contained in:
parent
7310c8f880
commit
4fa878f4b1
@ -705,13 +705,16 @@ u32 hidSixAxisSensorValuesRead(SixAxisSensorValues *values, HidControllerID id,
|
||||
/// Returns 0 when CONTROLLER_PLAYER_1 is connected, otherwise returns 1 for handheld-mode.
|
||||
bool hidGetHandheldMode(void);
|
||||
|
||||
/// Sets which controller types are supported. This is automatically called with all types in \ref hidInitialize.
|
||||
Result hidSetSupportedNpadStyleSet(HidControllerType type);
|
||||
|
||||
/// Gets which controller types are supported.
|
||||
Result hidGetSupportedNpadStyleSet(HidControllerType *type);
|
||||
|
||||
/// This is automatically called with CONTROLLER_PLAYER_{1-8} and CONTROLLER_HANDHELD in \ref hidInitialize.
|
||||
/// count must be <=10. Each entry in buf must be CONTROLLER_PLAYER_{1-8} or CONTROLLER_HANDHELD.
|
||||
Result hidSetSupportedNpadIdType(HidControllerID *buf, size_t count);
|
||||
|
||||
/// Sets which controller types are supported. This is automatically called with all types in \ref hidInitialize.
|
||||
Result hidSetSupportedNpadStyleSet(HidControllerType type);
|
||||
|
||||
/// Gets an event with the specified autoclear for the input controller.
|
||||
/// The user *must* close the event when finished with it / before the app exits.
|
||||
/// This is signaled when the \ref hidGetControllerType output is updated for the controller.
|
||||
|
@ -47,6 +47,13 @@ Result hidsysActivateHomeButton(void);
|
||||
Result hidsysActivateSleepButton(void);
|
||||
Result hidsysActivateCaptureButton(void);
|
||||
|
||||
/**
|
||||
* @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+].
|
||||
* @param[out] out \ref HidControllerType
|
||||
*/
|
||||
Result hidsysGetSupportedNpadStyleSetOfCallerApplet(HidControllerType *out);
|
||||
|
||||
/**
|
||||
* @brief Gets the UniquePadIds for the specified controller.
|
||||
* @note Only available on [3.0.0+].
|
||||
|
@ -723,69 +723,6 @@ static Result _hidGetSharedMemoryHandle(Service* srv, Handle* handle_out) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result hidSetSupportedNpadIdType(HidControllerID *buf, size_t count) {
|
||||
Result rc;
|
||||
u64 AppletResourceUserId;
|
||||
size_t i;
|
||||
u32 tmpval=0;
|
||||
u32 tmpbuf[10];
|
||||
|
||||
rc = appletGetAppletResourceUserId(&AppletResourceUserId);
|
||||
if (R_FAILED(rc))
|
||||
AppletResourceUserId = 0;
|
||||
|
||||
if (count > 10)
|
||||
return MAKERESULT(Module_Libnx, LibnxError_OutOfMemory);
|
||||
|
||||
memset(tmpbuf, 0, sizeof(tmpbuf));
|
||||
for (i=0; i<count; i++) {
|
||||
tmpval = buf[i];
|
||||
if (tmpval == CONTROLLER_HANDHELD) {
|
||||
tmpval = 0x20;
|
||||
}
|
||||
else if (tmpval >= CONTROLLER_UNKNOWN) {
|
||||
return MAKERESULT(Module_Libnx, LibnxError_BadInput);
|
||||
}
|
||||
|
||||
tmpbuf[i] = tmpval;
|
||||
}
|
||||
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
u64 AppletResourceUserId;
|
||||
} *raw;
|
||||
|
||||
ipcSendPid(&c);
|
||||
|
||||
ipcAddSendStatic(&c, tmpbuf, sizeof(u32)*count, 0);
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 102;
|
||||
raw->AppletResourceUserId = AppletResourceUserId;
|
||||
|
||||
rc = serviceIpcDispatch(&g_hidSrv);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static Result _hidCmdWithInputU32(u64 cmd_id, u32 inputval) {
|
||||
Result rc;
|
||||
u64 AppletResourceUserId;
|
||||
@ -830,6 +767,51 @@ static Result _hidCmdWithInputU32(u64 cmd_id, u32 inputval) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
static Result _hidCmdOutU32(u64 cmd_id, u32 *out) {
|
||||
Result rc;
|
||||
u64 AppletResourceUserId;
|
||||
|
||||
rc = appletGetAppletResourceUserId(&AppletResourceUserId);
|
||||
if (R_FAILED(rc))
|
||||
AppletResourceUserId = 0;
|
||||
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
u64 AppletResourceUserId;
|
||||
} *raw;
|
||||
|
||||
ipcSendPid(&c);
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = cmd_id;
|
||||
raw->AppletResourceUserId = AppletResourceUserId;
|
||||
|
||||
rc = serviceIpcDispatch(&g_hidSrv);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
u32 out;
|
||||
} *resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
|
||||
if (R_SUCCEEDED(rc) && out) *out = resp->out;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static Result _hidCmdWithInputU64(u64 cmd_id, u64 inputval) {
|
||||
Result rc;
|
||||
u64 AppletResourceUserId;
|
||||
@ -920,6 +902,73 @@ Result hidSetSupportedNpadStyleSet(HidControllerType type) {
|
||||
return _hidCmdWithInputU32(100, type);
|
||||
}
|
||||
|
||||
Result hidGetSupportedNpadStyleSet(HidControllerType *type) {
|
||||
return _hidCmdOutU32(101, type);
|
||||
}
|
||||
|
||||
Result hidSetSupportedNpadIdType(HidControllerID *buf, size_t count) {
|
||||
Result rc;
|
||||
u64 AppletResourceUserId;
|
||||
size_t i;
|
||||
u32 tmpval=0;
|
||||
u32 tmpbuf[10];
|
||||
|
||||
rc = appletGetAppletResourceUserId(&AppletResourceUserId);
|
||||
if (R_FAILED(rc))
|
||||
AppletResourceUserId = 0;
|
||||
|
||||
if (count > 10)
|
||||
return MAKERESULT(Module_Libnx, LibnxError_OutOfMemory);
|
||||
|
||||
memset(tmpbuf, 0, sizeof(tmpbuf));
|
||||
for (i=0; i<count; i++) {
|
||||
tmpval = buf[i];
|
||||
if (tmpval == CONTROLLER_HANDHELD) {
|
||||
tmpval = 0x20;
|
||||
}
|
||||
else if (tmpval >= CONTROLLER_UNKNOWN) {
|
||||
return MAKERESULT(Module_Libnx, LibnxError_BadInput);
|
||||
}
|
||||
|
||||
tmpbuf[i] = tmpval;
|
||||
}
|
||||
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
u64 AppletResourceUserId;
|
||||
} *raw;
|
||||
|
||||
ipcSendPid(&c);
|
||||
|
||||
ipcAddSendStatic(&c, tmpbuf, sizeof(u32)*count, 0);
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 102;
|
||||
raw->AppletResourceUserId = AppletResourceUserId;
|
||||
|
||||
rc = serviceIpcDispatch(&g_hidSrv);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static Result _hidActivateNpad(void) {
|
||||
return _hidCmdWithNoInput(103);
|
||||
}
|
||||
|
@ -186,6 +186,56 @@ Result hidsysActivateCaptureButton(void) {
|
||||
return _hidsysCmdWithResIdAndPid(151);
|
||||
}
|
||||
|
||||
static Result _hidsysGetMaskedSupportedNpadStyleSet(u64 AppletResourceUserId, HidControllerType *out) {
|
||||
if (hosversionBefore(6,0,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
u64 AppletResourceUserId;
|
||||
} *raw;
|
||||
|
||||
raw = serviceIpcPrepareHeader(&g_hidsysSrv, &c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 310;
|
||||
raw->AppletResourceUserId = g_hidsysAppletResourceUserId;
|
||||
|
||||
Result rc = serviceIpcDispatch(&g_hidsysSrv);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
u32 out;
|
||||
} *resp;
|
||||
|
||||
serviceIpcParse(&g_hidsysSrv, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
|
||||
if (R_SUCCEEDED(rc) && out) *out = resp->out;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result hidsysGetSupportedNpadStyleSetOfCallerApplet(HidControllerType *out) {
|
||||
u64 AppletResourceUserId=0;
|
||||
Result rc=0;
|
||||
|
||||
rc = appletGetAppletResourceUserIdOfCallerApplet(&AppletResourceUserId);
|
||||
if (R_FAILED(rc) && rc != MAKERESULT(128, 82)) return rc;
|
||||
|
||||
return _hidsysGetMaskedSupportedNpadStyleSet(AppletResourceUserId, out);
|
||||
}
|
||||
|
||||
Result hidsysGetUniquePadsFromNpad(HidControllerID id, u64 *UniquePadIds, size_t count, size_t *total_entries) {
|
||||
if (hosversionBefore(3,0,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
|
Loading…
Reference in New Issue
Block a user