From ebcbc5b05b7b76e9db81e9b6400ace8f2523d2b4 Mon Sep 17 00:00:00 2001 From: Dima Date: Tue, 22 Nov 2022 14:53:50 +0300 Subject: [PATCH] Validate NpadId for ActivateVibrationDevice --- app/src/main/cpp/skyline/input/npad.h | 2 +- .../cpp/skyline/services/hid/IActiveVibrationDeviceList.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/cpp/skyline/input/npad.h b/app/src/main/cpp/skyline/input/npad.h index 35391061..d3b9e129 100644 --- a/app/src/main/cpp/skyline/input/npad.h +++ b/app/src/main/cpp/skyline/input/npad.h @@ -83,7 +83,7 @@ namespace skyline::input { /** * @brief Checks if the NpadId is valid */ - bool IsNpadIdValid(NpadId id) { + static bool IsNpadIdValid(NpadId id) { switch (id) { case NpadId::Player1: case NpadId::Player2: diff --git a/app/src/main/cpp/skyline/services/hid/IActiveVibrationDeviceList.cpp b/app/src/main/cpp/skyline/services/hid/IActiveVibrationDeviceList.cpp index f79109b9..98b1f0a0 100644 --- a/app/src/main/cpp/skyline/services/hid/IActiveVibrationDeviceList.cpp +++ b/app/src/main/cpp/skyline/services/hid/IActiveVibrationDeviceList.cpp @@ -12,8 +12,9 @@ namespace skyline::service::hid { Result IActiveVibrationDeviceList::ActivateVibrationDevice(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { auto handle{request.Pop()}; - if (!handle.isRight) - state.input->npad.at(handle.id).vibrationRight = NpadVibrationValue{}; + if (NpadManager::IsNpadIdValid(handle.id)) + if (!handle.isRight) + state.input->npad.at(handle.id).vibrationRight = NpadVibrationValue{}; return {}; }