Skip to content

Commit

Permalink
hidsys: add commands for setting/checking state of joycons attached v…
Browse files Browse the repository at this point in the history
…ia rails
  • Loading branch information
ndeadly committed Jan 15, 2025
1 parent a063ceb commit 6ff67db
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
45 changes: 45 additions & 0 deletions nx/include/switch/services/hidsys.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,51 @@ Result hidsysGetUniquePadsFromNpad(HidNpadIdType id, HidsysUniquePadId *unique_p
**/
Result hidsysEnableAppletToGetInput(bool enable);

/**
* @brief EnableHandheldHids
**/
Result hidsysEnableHandheldHids(void);

/**
* @brief DisableHandheldHids
**/
Result hidsysDisableHandheldHids(void);

/**
* @brief SetJoyConRailEnabled
* @note Only available on [9.0.0+].
* @param[in] enable Input flag.
**/
Result hidsysSetJoyConRailEnabled(bool enable);

/**
* @brief IsJoyConRailEnabled
* @note Only available on [9.0.0+].
* @param[out] out Output flag.
**/
Result hidsysIsJoyConRailEnabled(bool *out);

/**
* @brief IsHandheldHidsEnabled
* @note Only available on [10.0.0+].
* @param[out] out Output flag.
**/
Result hidsysIsHandheldHidsEnabled(bool *out);

/**
* @brief IsJoyConAttachedOnAllRail
* @note Only available on [11.0.0+].
* @param[out] out Output flag.
**/
Result hidsysIsJoyConAttachedOnAllRail(bool *out);

/**
* @brief IsInvertedControllerConnectedOnRail
* @note Only available on [19.0.0+].
* @param[out] out Output flag.
**/
Result hidsysIsInvertedControllerConnectedOnRail(bool *out);

/**
* @brief AcquireUniquePadConnectionEventHandle
* @param[out] out_event Output Event.
Expand Down
43 changes: 43 additions & 0 deletions nx/source/services/hidsys.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,49 @@ Result hidsysEnableAppletToGetInput(bool enable) {
return serviceDispatchIn(&g_hidsysSrv, 503, in);
}

Result hidsysEnableHandheldHids(void) {
return _hidsysCmdNoIO(520);
}

Result hidsysDisableHandheldHids(void) {
return _hidsysCmdNoIO(521);
}

Result hidsysSetJoyConRailEnabled(bool enable) {
if (hosversionBefore(9,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);

return _hidsysCmdInBoolNoOut(enable, 522);
}

Result hidsysIsJoyConRailEnabled(bool *out) {
if (hosversionBefore(9,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);

return _hidsysCmdNoInOutBool(out, 523);
}

Result hidsysIsHandheldHidsEnabled(bool *out) {
if (hosversionBefore(10,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);

return _hidsysCmdNoInOutBool(out, 524);
}

Result hidsysIsJoyConAttachedOnAllRail(bool *out) {
if (hosversionBefore(11,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);

return _hidsysCmdNoInOutBool(out, 525);
}

Result hidsysIsInvertedControllerConnectedOnRail(bool *out) {
if (hosversionBefore(19,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);

return _hidsysCmdNoInOutBool(out, 526);
}

Result hidsysAcquireUniquePadConnectionEventHandle(Event *out_event) {
Handle tmp_handle = INVALID_HANDLE;

Expand Down

0 comments on commit 6ff67db

Please sign in to comment.