From e02ef3c3bed2f8e98ec9481cdea1a6253c34e9d1 Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Thu, 8 Oct 2020 08:18:50 -0400 Subject: [PATCH] controllers/npad: Stop games from vibrating incorrect controllers Fixes vibration in 1-2 Switch and potentially other games where they would vibrate both players' joycons at the same time. --- src/core/hle/service/hid/controllers/npad.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index 8a5e5abcf2..f865e3f5fc 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp @@ -688,6 +688,16 @@ void Controller_NPad::VibrateController(const std::vector& vibrati continue; } + // Some games try to send mismatched parameters in the device handle, block these. + if ((connected_controllers[npad_index].type == NPadControllerType::JoyLeft && + (vibration_device_handles[i].npad_type == NpadType::JoyconRight || + vibration_device_handles[i].device_index == DeviceIndex::Right)) || + (connected_controllers[npad_index].type == NPadControllerType::JoyRight && + (vibration_device_handles[i].npad_type == NpadType::JoyconLeft || + vibration_device_handles[i].device_index == DeviceIndex::Left))) { + continue; + } + using namespace Settings::NativeButton; const auto& button_state = buttons[npad_index];