diff --git a/nx/include/switch/services/hid.h b/nx/include/switch/services/hid.h index a41cc89c..b2c6b21a 100644 --- a/nx/include/switch/services/hid.h +++ b/nx/include/switch/services/hid.h @@ -814,6 +814,9 @@ Result hidIsVibrationPermitted(bool *flag); /// Send VibrationValues[index] to VibrationDeviceHandles[index], where count is the number of entries in the VibrationDeviceHandles/VibrationValues arrays. Result hidSendVibrationValues(u32 *VibrationDeviceHandles, HidVibrationValue *VibrationValues, s32 count); +/// Gets whether vibration is available with the specified device. Only available on [7.0.0+]. +Result hidIsVibrationDeviceMounted(u32 *VibrationDeviceHandle, bool *flag); + /// Gets SixAxisSensorHandles. total_handles==2 can only be used with TYPE_JOYCON_PAIR. Result hidGetSixAxisSensorHandles(u32 *SixAxisSensorHandles, s32 total_handles, HidControllerID id, HidControllerType type); diff --git a/nx/source/services/hid.c b/nx/source/services/hid.c index 7228f7f5..7ab7e615 100644 --- a/nx/source/services/hid.c +++ b/nx/source/services/hid.c @@ -929,6 +929,30 @@ Result hidSendVibrationValues(u32 *VibrationDeviceHandles, HidVibrationValue *Vi ); } +Result hidIsVibrationDeviceMounted(u32 *VibrationDeviceHandle, bool *flag) { + if (hosversionBefore(7,0,0)) + return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + + Result rc; + u64 AppletResourceUserId; + + rc = appletGetAppletResourceUserId(&AppletResourceUserId); + if (R_FAILED(rc)) + AppletResourceUserId = 0; + + const struct { + u32 VibrationDeviceHandle; + u64 AppletResourceUserId; + } in = { *VibrationDeviceHandle, AppletResourceUserId }; + + u8 tmp=0; + rc = serviceDispatchInOut(&g_hidSrv, 211, in, tmp, + .in_send_pid = true, + ); + if (R_SUCCEEDED(rc) && flag) *flag = tmp & 1; + return rc; +} + static Result _hidGetDeviceHandles(u32 devicetype, u32 *DeviceHandles, s32 total_handles, HidControllerID id, HidControllerType type) { Result rc=0; u32 tmp_type = type & 0xff;