Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hidsys: add commands for setting/checking state of joycons attached via rails #657

Merged
merged 1 commit into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading