From fd5c141dbf296fba2d3308b4295509be35eb4fd9 Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Sun, 8 Jan 2023 21:07:58 +0000 Subject: [PATCH] Correct GetNpadIrCameraHandle return value --- app/src/main/cpp/skyline/input/npad.h | 35 +++++++++---------- .../skyline/services/irs/IIrSensorServer.cpp | 11 ++++++ 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/app/src/main/cpp/skyline/input/npad.h b/app/src/main/cpp/skyline/input/npad.h index d3b9e129..c788975b 100644 --- a/app/src/main/cpp/skyline/input/npad.h +++ b/app/src/main/cpp/skyline/input/npad.h @@ -26,22 +26,6 @@ namespace skyline::input { friend NpadDevice; - /** - * @brief Translates an NPad's ID into its index in the array - * @param id The ID of the NPad to translate - * @return The corresponding index of the NPad in the array - */ - static constexpr size_t Translate(NpadId id) { - switch (id) { - case NpadId::Handheld: - return 8; - case NpadId::Unknown: - return 9; - default: - return static_cast(id); - } - } - public: std::recursive_mutex mutex; //!< This mutex must be locked before any modifications to class members std::array npads; @@ -56,18 +40,33 @@ namespace skyline::input { */ NpadManager(const DeviceState &state, input::HidSharedMemory *hid); + /** + * @brief Translates an NPad's ID into its index in the npad array + * @param id The ID of the NPad to translate + */ + static constexpr size_t NpadIdToIndex(NpadId id) { + switch (id) { + case NpadId::Handheld: + return 8; + case NpadId::Unknown: + return 9; + default: + return static_cast(id); + } + } + /** * @return A reference to the NPad with the specified ID */ constexpr NpadDevice &at(NpadId id) { - return npads.at(Translate(id)); + return npads.at(NpadIdToIndex(id)); } /** * @return A reference to the NPad with the specified ID */ constexpr NpadDevice &operator[](NpadId id) noexcept { - return npads.operator[](Translate(id)); + return npads.operator[](NpadIdToIndex(id)); } /** diff --git a/app/src/main/cpp/skyline/services/irs/IIrSensorServer.cpp b/app/src/main/cpp/skyline/services/irs/IIrSensorServer.cpp index 747f6a5a..0a6512b2 100644 --- a/app/src/main/cpp/skyline/services/irs/IIrSensorServer.cpp +++ b/app/src/main/cpp/skyline/services/irs/IIrSensorServer.cpp @@ -13,6 +13,17 @@ namespace skyline::service::irs { auto id{request.Pop()}; if (id > NpadId::Player8 && id != NpadId::Handheld && id != NpadId::Unknown) return result::InvalidNpadId; + + struct IrCameraHandle { + u8 npadIndex; + u8 npadType; + u8 _pad0_[2]; + } handle{ + .npadIndex = static_cast(state.input->npad.NpadIdToIndex(id)), + }; + + response.Push(handle); + return {}; }