mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-26 00:24:14 +01:00
Correct GetNpadIrCameraHandle return value
This commit is contained in:
parent
a8b32c3cef
commit
fd5c141dbf
@ -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<size_t>(id);
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
std::recursive_mutex mutex; //!< This mutex must be locked before any modifications to class members
|
||||
std::array<NpadDevice, constant::NpadCount> 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<size_t>(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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -13,6 +13,17 @@ namespace skyline::service::irs {
|
||||
auto id{request.Pop<NpadId>()};
|
||||
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<u8>(state.input->npad.NpadIdToIndex(id)),
|
||||
};
|
||||
|
||||
response.Push(handle);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user