Revert "hle_ipc: Use std::span to avoid heap allocations/copies when calling ReadBuffer"

This commit is contained in:
liamwhite
2023-02-02 15:53:28 -05:00
committed by GitHub
parent 8a33f8bd30
commit b01698775b
61 changed files with 326 additions and 368 deletions

View File

@ -758,12 +758,11 @@ Core::HID::NpadStyleTag Controller_NPad::GetSupportedStyleSet() const {
return hid_core.GetSupportedStyleTag();
}
void Controller_NPad::SetSupportedNpadIdTypes(std::span<const u8> data) {
const auto length = data.size();
void Controller_NPad::SetSupportedNpadIdTypes(u8* data, std::size_t length) {
ASSERT(length > 0 && (length % sizeof(u32)) == 0);
supported_npad_id_types.clear();
supported_npad_id_types.resize(length / sizeof(u32));
std::memcpy(supported_npad_id_types.data(), data.data(), length);
std::memcpy(supported_npad_id_types.data(), data, length);
}
void Controller_NPad::GetSupportedNpadIdTypes(u32* data, std::size_t max_length) {

View File

@ -6,7 +6,6 @@
#include <array>
#include <atomic>
#include <mutex>
#include <span>
#include "common/bit_field.h"
#include "common/common_types.h"
@ -96,7 +95,7 @@ public:
void SetSupportedStyleSet(Core::HID::NpadStyleTag style_set);
Core::HID::NpadStyleTag GetSupportedStyleSet() const;
void SetSupportedNpadIdTypes(std::span<const u8> data);
void SetSupportedNpadIdTypes(u8* data, std::size_t length);
void GetSupportedNpadIdTypes(u32* data, std::size_t max_length);
std::size_t GetSupportedNpadIdTypesSize() const;

View File

@ -1026,7 +1026,7 @@ void Hid::SetSupportedNpadIdType(Kernel::HLERequestContext& ctx) {
const auto applet_resource_user_id{rp.Pop<u64>()};
applet_resource->GetController<Controller_NPad>(HidController::NPad)
.SetSupportedNpadIdTypes(ctx.ReadBuffer());
.SetSupportedNpadIdTypes(ctx.ReadBuffer().data(), ctx.GetReadBufferSize());
LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
@ -2104,7 +2104,7 @@ void Hid::WritePalmaRgbLedPatternEntry(Kernel::HLERequestContext& ctx) {
const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()};
const auto unknown{rp.Pop<u64>()};
[[maybe_unused]] const auto buffer = ctx.ReadBuffer();
const auto buffer = ctx.ReadBuffer();
LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}, unknown={}",
connection_handle.npad_id, unknown);

View File

@ -4,7 +4,6 @@
#pragma once
#include <array>
#include <span>
#include "common/common_types.h"
#include "core/hle/result.h"
@ -151,7 +150,7 @@ public:
}
// Assigns a command from data
virtual bool SetCommand(std::span<const u8> data) {
virtual bool SetCommand(const std::vector<u8>& data) {
return {};
}

View File

@ -116,7 +116,7 @@ std::vector<u8> RingController::GetReply() const {
}
}
bool RingController::SetCommand(std::span<const u8> data) {
bool RingController::SetCommand(const std::vector<u8>& data) {
if (data.size() < 4) {
LOG_ERROR(Service_HID, "Command size not supported {}", data.size());
command = RingConCommands::Error;

View File

@ -4,7 +4,6 @@
#pragma once
#include <array>
#include <span>
#include "common/common_types.h"
#include "core/hle/service/hid/hidbus/hidbus_base.h"
@ -32,7 +31,7 @@ public:
u8 GetDeviceId() const override;
// Assigns a command from data
bool SetCommand(std::span<const u8> data) override;
bool SetCommand(const std::vector<u8>& data) override;
// Returns a reply from a command
std::vector<u8> GetReply() const override;

View File

@ -42,7 +42,7 @@ std::vector<u8> Starlink::GetReply() const {
return {};
}
bool Starlink::SetCommand(std::span<const u8> data) {
bool Starlink::SetCommand(const std::vector<u8>& data) {
LOG_ERROR(Service_HID, "Command not implemented");
return false;
}

View File

@ -29,7 +29,7 @@ public:
u8 GetDeviceId() const override;
// Assigns a command from data
bool SetCommand(std::span<const u8> data) override;
bool SetCommand(const std::vector<u8>& data) override;
// Returns a reply from a command
std::vector<u8> GetReply() const override;

View File

@ -43,7 +43,7 @@ std::vector<u8> HidbusStubbed::GetReply() const {
return {};
}
bool HidbusStubbed::SetCommand(std::span<const u8> data) {
bool HidbusStubbed::SetCommand(const std::vector<u8>& data) {
LOG_ERROR(Service_HID, "Command not implemented");
return false;
}

View File

@ -29,7 +29,7 @@ public:
u8 GetDeviceId() const override;
// Assigns a command from data
bool SetCommand(std::span<const u8> data) override;
bool SetCommand(const std::vector<u8>& data) override;
// Returns a reply from a command
std::vector<u8> GetReply() const override;