Merge pull request #9747 from german77/SetSupportedNpadIdTypes
service: hid: Return error if arguments of SetSupportedNpadIdType is invalid
This commit is contained in:
commit
f6477b91f9
|
@ -758,12 +758,20 @@ Core::HID::NpadStyleTag Controller_NPad::GetSupportedStyleSet() const {
|
||||||
return hid_core.GetSupportedStyleTag();
|
return hid_core.GetSupportedStyleTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller_NPad::SetSupportedNpadIdTypes(std::span<const u8> data) {
|
Result Controller_NPad::SetSupportedNpadIdTypes(std::span<const u8> data) {
|
||||||
|
constexpr std::size_t max_number_npad_ids = 0xa;
|
||||||
const auto length = data.size();
|
const auto length = data.size();
|
||||||
ASSERT(length > 0 && (length % sizeof(u32)) == 0);
|
ASSERT(length > 0 && (length % sizeof(u32)) == 0);
|
||||||
|
const std::size_t elements = length / sizeof(u32);
|
||||||
|
|
||||||
|
if (elements > max_number_npad_ids) {
|
||||||
|
return InvalidArraySize;
|
||||||
|
}
|
||||||
|
|
||||||
supported_npad_id_types.clear();
|
supported_npad_id_types.clear();
|
||||||
supported_npad_id_types.resize(length / sizeof(u32));
|
supported_npad_id_types.resize(elements);
|
||||||
std::memcpy(supported_npad_id_types.data(), data.data(), length);
|
std::memcpy(supported_npad_id_types.data(), data.data(), length);
|
||||||
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller_NPad::GetSupportedNpadIdTypes(u32* data, std::size_t max_length) {
|
void Controller_NPad::GetSupportedNpadIdTypes(u32* data, std::size_t max_length) {
|
||||||
|
|
|
@ -96,7 +96,7 @@ public:
|
||||||
void SetSupportedStyleSet(Core::HID::NpadStyleTag style_set);
|
void SetSupportedStyleSet(Core::HID::NpadStyleTag style_set);
|
||||||
Core::HID::NpadStyleTag GetSupportedStyleSet() const;
|
Core::HID::NpadStyleTag GetSupportedStyleSet() const;
|
||||||
|
|
||||||
void SetSupportedNpadIdTypes(std::span<const u8> data);
|
Result SetSupportedNpadIdTypes(std::span<const u8> data);
|
||||||
void GetSupportedNpadIdTypes(u32* data, std::size_t max_length);
|
void GetSupportedNpadIdTypes(u32* data, std::size_t max_length);
|
||||||
std::size_t GetSupportedNpadIdTypesSize() const;
|
std::size_t GetSupportedNpadIdTypesSize() const;
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ constexpr Result NpadIsDualJoycon{ErrorModule::HID, 601};
|
||||||
constexpr Result NpadIsSameType{ErrorModule::HID, 602};
|
constexpr Result NpadIsSameType{ErrorModule::HID, 602};
|
||||||
constexpr Result InvalidNpadId{ErrorModule::HID, 709};
|
constexpr Result InvalidNpadId{ErrorModule::HID, 709};
|
||||||
constexpr Result NpadNotConnected{ErrorModule::HID, 710};
|
constexpr Result NpadNotConnected{ErrorModule::HID, 710};
|
||||||
|
constexpr Result InvalidArraySize{ErrorModule::HID, 715};
|
||||||
constexpr Result InvalidPalmaHandle{ErrorModule::HID, 3302};
|
constexpr Result InvalidPalmaHandle{ErrorModule::HID, 3302};
|
||||||
|
|
||||||
} // namespace Service::HID
|
} // namespace Service::HID
|
||||||
|
|
|
@ -1025,13 +1025,13 @@ void Hid::SetSupportedNpadIdType(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
const auto applet_resource_user_id{rp.Pop<u64>()};
|
const auto applet_resource_user_id{rp.Pop<u64>()};
|
||||||
|
|
||||||
applet_resource->GetController<Controller_NPad>(HidController::NPad)
|
const auto result = applet_resource->GetController<Controller_NPad>(HidController::NPad)
|
||||||
.SetSupportedNpadIdTypes(ctx.ReadBuffer());
|
.SetSupportedNpadIdTypes(ctx.ReadBuffer());
|
||||||
|
|
||||||
LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
|
LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hid::ActivateNpad(Kernel::HLERequestContext& ctx) {
|
void Hid::ActivateNpad(Kernel::HLERequestContext& ctx) {
|
||||||
|
|
Loading…
Reference in New Issue