diff --git a/nx/include/switch/services/hid.h b/nx/include/switch/services/hid.h index 8d39f23b..9b3eba0e 100644 --- a/nx/include/switch/services/hid.h +++ b/nx/include/switch/services/hid.h @@ -778,6 +778,9 @@ Result hidAcquireNpadStyleSetUpdateEventHandle(HidControllerID id, Event* out_ev /// Sets the hold-type, see \ref HidJoyHoldType. Result hidSetNpadJoyHoldType(HidJoyHoldType type); +/// Gets the hold-type, see \ref HidJoyHoldType. +Result hidGetNpadJoyHoldType(HidJoyHoldType *type); + /// Use this if you want to use a single joy-con as a dedicated CONTROLLER_PLAYER_*. /// When used, both joy-cons in a pair should be used with this (CONTROLLER_PLAYER_1 and CONTROLLER_PLAYER_2 for example). /// id must be CONTROLLER_PLAYER_*. diff --git a/nx/source/services/hid.c b/nx/source/services/hid.c index 74046d1a..0c5c0702 100644 --- a/nx/source/services/hid.c +++ b/nx/source/services/hid.c @@ -719,6 +719,19 @@ static Result _hidCmdOutU32(u32 *out, u32 cmd_id) { ); } +static Result _hidCmdOutU64(u64 *out, u32 cmd_id) { + Result rc; + u64 AppletResourceUserId; + + rc = appletGetAppletResourceUserId(&AppletResourceUserId); + if (R_FAILED(rc)) + AppletResourceUserId = 0; + + return serviceDispatchInOut(&g_hidSrv, cmd_id, AppletResourceUserId, *out, + .in_send_pid = true, + ); +} + static Result _hidCmdNoInOutU8(u8 *out, u32 cmd_id) { return serviceDispatchOut(&g_hidSrv, cmd_id, *out); } @@ -835,6 +848,13 @@ Result hidSetNpadJoyHoldType(HidJoyHoldType type) { return _hidCmdWithInputU64(type, 120); } +Result hidGetNpadJoyHoldType(HidJoyHoldType *type) { + u64 tmp=0; + Result rc = _hidCmdOutU64(&tmp, 121); + if (R_SUCCEEDED(rc) && type) *type = tmp; + return rc; +} + Result hidSetNpadJoyAssignmentModeSingleByDefault(HidControllerID id) { return _hidCmdWithInputU32(hidControllerIDToOfficial(id), 122); }