summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar ameerj2022-12-25 14:00:20 -0500
committerGravatar ameerj2022-12-28 18:46:53 -0500
commite7032d9e641f99366242000fbc9ca59a55d1a95f (patch)
treebb5b6ae1d1f4bf1db9cd0d3d2b2ddcdb9336cdd6 /src
parentnvflinger: Split Parcel class into InputParcel and OutputParcel (diff)
downloadyuzu-e7032d9e641f99366242000fbc9ca59a55d1a95f.tar.gz
yuzu-e7032d9e641f99366242000fbc9ca59a55d1a95f.tar.xz
yuzu-e7032d9e641f99366242000fbc9ca59a55d1a95f.zip
hidbus: Use ReadBufferSpan
Diffstat (limited to '')
-rw-r--r--src/core/hle/service/hid/controllers/npad.cpp5
-rw-r--r--src/core/hle/service/hid/controllers/npad.h3
-rw-r--r--src/core/hle/service/hid/hid.cpp2
-rw-r--r--src/core/hle/service/hid/hidbus.cpp2
-rw-r--r--src/core/hle/service/hid/hidbus/hidbus_base.h3
-rw-r--r--src/core/hle/service/hid/hidbus/ringcon.cpp2
-rw-r--r--src/core/hle/service/hid/hidbus/ringcon.h3
-rw-r--r--src/core/hle/service/hid/hidbus/starlink.cpp2
-rw-r--r--src/core/hle/service/hid/hidbus/starlink.h2
-rw-r--r--src/core/hle/service/hid/hidbus/stubbed.cpp2
-rw-r--r--src/core/hle/service/hid/hidbus/stubbed.h2
11 files changed, 16 insertions, 12 deletions
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp
index df63083a8..713f8e0c6 100644
--- a/src/core/hle/service/hid/controllers/npad.cpp
+++ b/src/core/hle/service/hid/controllers/npad.cpp
@@ -737,11 +737,12 @@ Core::HID::NpadStyleTag Controller_NPad::GetSupportedStyleSet() const {
737 return hid_core.GetSupportedStyleTag(); 737 return hid_core.GetSupportedStyleTag();
738} 738}
739 739
740void Controller_NPad::SetSupportedNpadIdTypes(const u8* const data, std::size_t length) { 740void Controller_NPad::SetSupportedNpadIdTypes(std::span<const u8> data) {
741 const auto length = data.size();
741 ASSERT(length > 0 && (length % sizeof(u32)) == 0); 742 ASSERT(length > 0 && (length % sizeof(u32)) == 0);
742 supported_npad_id_types.clear(); 743 supported_npad_id_types.clear();
743 supported_npad_id_types.resize(length / sizeof(u32)); 744 supported_npad_id_types.resize(length / sizeof(u32));
744 std::memcpy(supported_npad_id_types.data(), data, length); 745 std::memcpy(supported_npad_id_types.data(), data.data(), length);
745} 746}
746 747
747void Controller_NPad::GetSupportedNpadIdTypes(u32* data, std::size_t max_length) { 748void Controller_NPad::GetSupportedNpadIdTypes(u32* data, std::size_t max_length) {
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h
index 988ac8ec4..1f7d33459 100644
--- a/src/core/hle/service/hid/controllers/npad.h
+++ b/src/core/hle/service/hid/controllers/npad.h
@@ -6,6 +6,7 @@
6#include <array> 6#include <array>
7#include <atomic> 7#include <atomic>
8#include <mutex> 8#include <mutex>
9#include <span>
9 10
10#include "common/bit_field.h" 11#include "common/bit_field.h"
11#include "common/common_types.h" 12#include "common/common_types.h"
@@ -95,7 +96,7 @@ public:
95 void SetSupportedStyleSet(Core::HID::NpadStyleTag style_set); 96 void SetSupportedStyleSet(Core::HID::NpadStyleTag style_set);
96 Core::HID::NpadStyleTag GetSupportedStyleSet() const; 97 Core::HID::NpadStyleTag GetSupportedStyleSet() const;
97 98
98 void SetSupportedNpadIdTypes(const u8* const data, std::size_t length); 99 void SetSupportedNpadIdTypes(std::span<const u8> data);
99 void GetSupportedNpadIdTypes(u32* data, std::size_t max_length); 100 void GetSupportedNpadIdTypes(u32* data, std::size_t max_length);
100 std::size_t GetSupportedNpadIdTypesSize() const; 101 std::size_t GetSupportedNpadIdTypesSize() const;
101 102
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp
index 80db6af06..294fe927b 100644
--- a/src/core/hle/service/hid/hid.cpp
+++ b/src/core/hle/service/hid/hid.cpp
@@ -1026,7 +1026,7 @@ void Hid::SetSupportedNpadIdType(Kernel::HLERequestContext& ctx) {
1026 const auto applet_resource_user_id{rp.Pop<u64>()}; 1026 const auto applet_resource_user_id{rp.Pop<u64>()};
1027 1027
1028 applet_resource->GetController<Controller_NPad>(HidController::NPad) 1028 applet_resource->GetController<Controller_NPad>(HidController::NPad)
1029 .SetSupportedNpadIdTypes(ctx.ReadBufferSpan().data(), ctx.GetReadBufferSize()); 1029 .SetSupportedNpadIdTypes(ctx.ReadBufferSpan());
1030 1030
1031 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); 1031 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
1032 1032
diff --git a/src/core/hle/service/hid/hidbus.cpp b/src/core/hle/service/hid/hidbus.cpp
index e5e50845f..abc15c34e 100644
--- a/src/core/hle/service/hid/hidbus.cpp
+++ b/src/core/hle/service/hid/hidbus.cpp
@@ -351,7 +351,7 @@ void HidBus::GetExternalDeviceId(Kernel::HLERequestContext& ctx) {
351 351
352void HidBus::SendCommandAsync(Kernel::HLERequestContext& ctx) { 352void HidBus::SendCommandAsync(Kernel::HLERequestContext& ctx) {
353 IPC::RequestParser rp{ctx}; 353 IPC::RequestParser rp{ctx};
354 const auto data = ctx.ReadBuffer(); 354 const auto data = ctx.ReadBufferSpan();
355 const auto bus_handle_{rp.PopRaw<BusHandle>()}; 355 const auto bus_handle_{rp.PopRaw<BusHandle>()};
356 356
357 LOG_DEBUG(Service_HID, 357 LOG_DEBUG(Service_HID,
diff --git a/src/core/hle/service/hid/hidbus/hidbus_base.h b/src/core/hle/service/hid/hidbus/hidbus_base.h
index d3960f506..65e301137 100644
--- a/src/core/hle/service/hid/hidbus/hidbus_base.h
+++ b/src/core/hle/service/hid/hidbus/hidbus_base.h
@@ -4,6 +4,7 @@
4#pragma once 4#pragma once
5 5
6#include <array> 6#include <array>
7#include <span>
7#include "common/common_types.h" 8#include "common/common_types.h"
8#include "core/hle/result.h" 9#include "core/hle/result.h"
9 10
@@ -150,7 +151,7 @@ public:
150 } 151 }
151 152
152 // Assigns a command from data 153 // Assigns a command from data
153 virtual bool SetCommand(const std::vector<u8>& data) { 154 virtual bool SetCommand(std::span<const u8> data) {
154 return {}; 155 return {};
155 } 156 }
156 157
diff --git a/src/core/hle/service/hid/hidbus/ringcon.cpp b/src/core/hle/service/hid/hidbus/ringcon.cpp
index 57f1a2a26..7ab3903dc 100644
--- a/src/core/hle/service/hid/hidbus/ringcon.cpp
+++ b/src/core/hle/service/hid/hidbus/ringcon.cpp
@@ -112,7 +112,7 @@ std::vector<u8> RingController::GetReply() const {
112 } 112 }
113} 113}
114 114
115bool RingController::SetCommand(const std::vector<u8>& data) { 115bool RingController::SetCommand(std::span<const u8> data) {
116 if (data.size() < 4) { 116 if (data.size() < 4) {
117 LOG_ERROR(Service_HID, "Command size not supported {}", data.size()); 117 LOG_ERROR(Service_HID, "Command size not supported {}", data.size());
118 command = RingConCommands::Error; 118 command = RingConCommands::Error;
diff --git a/src/core/hle/service/hid/hidbus/ringcon.h b/src/core/hle/service/hid/hidbus/ringcon.h
index b37df50ac..8e195ca79 100644
--- a/src/core/hle/service/hid/hidbus/ringcon.h
+++ b/src/core/hle/service/hid/hidbus/ringcon.h
@@ -4,6 +4,7 @@
4#pragma once 4#pragma once
5 5
6#include <array> 6#include <array>
7#include <span>
7 8
8#include "common/common_types.h" 9#include "common/common_types.h"
9#include "core/hle/service/hid/hidbus/hidbus_base.h" 10#include "core/hle/service/hid/hidbus/hidbus_base.h"
@@ -31,7 +32,7 @@ public:
31 u8 GetDeviceId() const override; 32 u8 GetDeviceId() const override;
32 33
33 // Assigns a command from data 34 // Assigns a command from data
34 bool SetCommand(const std::vector<u8>& data) override; 35 bool SetCommand(std::span<const u8> data) override;
35 36
36 // Returns a reply from a command 37 // Returns a reply from a command
37 std::vector<u8> GetReply() const override; 38 std::vector<u8> GetReply() const override;
diff --git a/src/core/hle/service/hid/hidbus/starlink.cpp b/src/core/hle/service/hid/hidbus/starlink.cpp
index dd439f60a..d0e760314 100644
--- a/src/core/hle/service/hid/hidbus/starlink.cpp
+++ b/src/core/hle/service/hid/hidbus/starlink.cpp
@@ -42,7 +42,7 @@ std::vector<u8> Starlink::GetReply() const {
42 return {}; 42 return {};
43} 43}
44 44
45bool Starlink::SetCommand(const std::vector<u8>& data) { 45bool Starlink::SetCommand(std::span<const u8> data) {
46 LOG_ERROR(Service_HID, "Command not implemented"); 46 LOG_ERROR(Service_HID, "Command not implemented");
47 return false; 47 return false;
48} 48}
diff --git a/src/core/hle/service/hid/hidbus/starlink.h b/src/core/hle/service/hid/hidbus/starlink.h
index 0b1b7ba49..07c800e6e 100644
--- a/src/core/hle/service/hid/hidbus/starlink.h
+++ b/src/core/hle/service/hid/hidbus/starlink.h
@@ -29,7 +29,7 @@ public:
29 u8 GetDeviceId() const override; 29 u8 GetDeviceId() const override;
30 30
31 // Assigns a command from data 31 // Assigns a command from data
32 bool SetCommand(const std::vector<u8>& data) override; 32 bool SetCommand(std::span<const u8> data) override;
33 33
34 // Returns a reply from a command 34 // Returns a reply from a command
35 std::vector<u8> GetReply() const override; 35 std::vector<u8> GetReply() const override;
diff --git a/src/core/hle/service/hid/hidbus/stubbed.cpp b/src/core/hle/service/hid/hidbus/stubbed.cpp
index e477443e3..07632c872 100644
--- a/src/core/hle/service/hid/hidbus/stubbed.cpp
+++ b/src/core/hle/service/hid/hidbus/stubbed.cpp
@@ -43,7 +43,7 @@ std::vector<u8> HidbusStubbed::GetReply() const {
43 return {}; 43 return {};
44} 44}
45 45
46bool HidbusStubbed::SetCommand(const std::vector<u8>& data) { 46bool HidbusStubbed::SetCommand(std::span<const u8> data) {
47 LOG_ERROR(Service_HID, "Command not implemented"); 47 LOG_ERROR(Service_HID, "Command not implemented");
48 return false; 48 return false;
49} 49}
diff --git a/src/core/hle/service/hid/hidbus/stubbed.h b/src/core/hle/service/hid/hidbus/stubbed.h
index 91165ceff..38eaa0ecc 100644
--- a/src/core/hle/service/hid/hidbus/stubbed.h
+++ b/src/core/hle/service/hid/hidbus/stubbed.h
@@ -29,7 +29,7 @@ public:
29 u8 GetDeviceId() const override; 29 u8 GetDeviceId() const override;
30 30
31 // Assigns a command from data 31 // Assigns a command from data
32 bool SetCommand(const std::vector<u8>& data) override; 32 bool SetCommand(std::span<const u8> data) override;
33 33
34 // Returns a reply from a command 34 // Returns a reply from a command
35 std::vector<u8> GetReply() const override; 35 std::vector<u8> GetReply() const override;