mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-27 01:02:48 +01:00
hidbus: Use ReadBufferSpan
This commit is contained in:
parent
32d01a39b0
commit
e7032d9e64
11 changed files with 16 additions and 12 deletions
|
@ -737,11 +737,12 @@ Core::HID::NpadStyleTag Controller_NPad::GetSupportedStyleSet() const {
|
|||
return hid_core.GetSupportedStyleTag();
|
||||
}
|
||||
|
||||
void Controller_NPad::SetSupportedNpadIdTypes(const u8* const data, std::size_t length) {
|
||||
void Controller_NPad::SetSupportedNpadIdTypes(std::span<const u8> data) {
|
||||
const auto length = data.size();
|
||||
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, length);
|
||||
std::memcpy(supported_npad_id_types.data(), data.data(), length);
|
||||
}
|
||||
|
||||
void Controller_NPad::GetSupportedNpadIdTypes(u32* data, std::size_t max_length) {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <array>
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
#include <span>
|
||||
|
||||
#include "common/bit_field.h"
|
||||
#include "common/common_types.h"
|
||||
|
@ -95,7 +96,7 @@ public:
|
|||
void SetSupportedStyleSet(Core::HID::NpadStyleTag style_set);
|
||||
Core::HID::NpadStyleTag GetSupportedStyleSet() const;
|
||||
|
||||
void SetSupportedNpadIdTypes(const u8* const data, std::size_t length);
|
||||
void SetSupportedNpadIdTypes(std::span<const u8> data);
|
||||
void GetSupportedNpadIdTypes(u32* data, std::size_t max_length);
|
||||
std::size_t GetSupportedNpadIdTypesSize() const;
|
||||
|
||||
|
|
|
@ -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.ReadBufferSpan().data(), ctx.GetReadBufferSize());
|
||||
.SetSupportedNpadIdTypes(ctx.ReadBufferSpan());
|
||||
|
||||
LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
|
||||
|
||||
|
|
|
@ -351,7 +351,7 @@ void HidBus::GetExternalDeviceId(Kernel::HLERequestContext& ctx) {
|
|||
|
||||
void HidBus::SendCommandAsync(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto data = ctx.ReadBuffer();
|
||||
const auto data = ctx.ReadBufferSpan();
|
||||
const auto bus_handle_{rp.PopRaw<BusHandle>()};
|
||||
|
||||
LOG_DEBUG(Service_HID,
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <span>
|
||||
#include "common/common_types.h"
|
||||
#include "core/hle/result.h"
|
||||
|
||||
|
@ -150,7 +151,7 @@ public:
|
|||
}
|
||||
|
||||
// Assigns a command from data
|
||||
virtual bool SetCommand(const std::vector<u8>& data) {
|
||||
virtual bool SetCommand(std::span<const u8> data) {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ std::vector<u8> RingController::GetReply() const {
|
|||
}
|
||||
}
|
||||
|
||||
bool RingController::SetCommand(const std::vector<u8>& data) {
|
||||
bool RingController::SetCommand(std::span<const u8> data) {
|
||||
if (data.size() < 4) {
|
||||
LOG_ERROR(Service_HID, "Command size not supported {}", data.size());
|
||||
command = RingConCommands::Error;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <span>
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "core/hle/service/hid/hidbus/hidbus_base.h"
|
||||
|
@ -31,7 +32,7 @@ public:
|
|||
u8 GetDeviceId() const override;
|
||||
|
||||
// Assigns a command from data
|
||||
bool SetCommand(const std::vector<u8>& data) override;
|
||||
bool SetCommand(std::span<const u8> data) override;
|
||||
|
||||
// Returns a reply from a command
|
||||
std::vector<u8> GetReply() const override;
|
||||
|
|
|
@ -42,7 +42,7 @@ std::vector<u8> Starlink::GetReply() const {
|
|||
return {};
|
||||
}
|
||||
|
||||
bool Starlink::SetCommand(const std::vector<u8>& data) {
|
||||
bool Starlink::SetCommand(std::span<const u8> data) {
|
||||
LOG_ERROR(Service_HID, "Command not implemented");
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
u8 GetDeviceId() const override;
|
||||
|
||||
// Assigns a command from data
|
||||
bool SetCommand(const std::vector<u8>& data) override;
|
||||
bool SetCommand(std::span<const u8> data) override;
|
||||
|
||||
// Returns a reply from a command
|
||||
std::vector<u8> GetReply() const override;
|
||||
|
|
|
@ -43,7 +43,7 @@ std::vector<u8> HidbusStubbed::GetReply() const {
|
|||
return {};
|
||||
}
|
||||
|
||||
bool HidbusStubbed::SetCommand(const std::vector<u8>& data) {
|
||||
bool HidbusStubbed::SetCommand(std::span<const u8> data) {
|
||||
LOG_ERROR(Service_HID, "Command not implemented");
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
u8 GetDeviceId() const override;
|
||||
|
||||
// Assigns a command from data
|
||||
bool SetCommand(const std::vector<u8>& data) override;
|
||||
bool SetCommand(std::span<const u8> data) override;
|
||||
|
||||
// Returns a reply from a command
|
||||
std::vector<u8> GetReply() const override;
|
||||
|
|
Loading…
Reference in a new issue