Просмотр исходного кода

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.
Morph 5 лет назад
Родитель
Сommit
e02ef3c3be
1 измененных файлов с 10 добавлено и 0 удалено
  1. 10 0
      src/core/hle/service/hid/controllers/npad.cpp

+ 10 - 0
src/core/hle/service/hid/controllers/npad.cpp

@@ -688,6 +688,16 @@ void Controller_NPad::VibrateController(const std::vector<DeviceHandle>& vibrati
             continue;
             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;
         using namespace Settings::NativeButton;
         const auto& button_state = buttons[npad_index];
         const auto& button_state = buttons[npad_index];