From 6e54615b16df2004af0bfbb9543a3fd21c678dbb Mon Sep 17 00:00:00 2001 From: german77 Date: Sun, 14 May 2023 09:22:00 -0600 Subject: [PATCH] service: hid: Use span instead of vector reference --- src/core/hle/service/hid/controllers/npad.cpp | 4 ++-- src/core/hle/service/hid/controllers/npad.h | 4 ++-- src/core/hle/service/hid/hid.cpp | 18 +++++++++--------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index ef4aec4ea..28818c813 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp @@ -979,8 +979,8 @@ void Controller_NPad::VibrateController( } void Controller_NPad::VibrateControllers( - const std::vector& vibration_device_handles, - const std::vector& vibration_values) { + std::span vibration_device_handles, + std::span vibration_values) { if (!Settings::values.vibration_enabled.GetValue() && !permit_vibration_session_enabled) { return; } diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index 9cfe298f1..776411261 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h @@ -112,8 +112,8 @@ public: const Core::HID::VibrationValue& vibration_value); void VibrateControllers( - const std::vector& vibration_device_handles, - const std::vector& vibration_values); + std::span vibration_device_handles, + std::span vibration_values); Core::HID::VibrationValue GetLastVibration( const Core::HID::VibrationDeviceHandle& vibration_device_handle) const; diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 87e7b864a..2bf1d8a27 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp @@ -1601,16 +1601,16 @@ void Hid::SendVibrationValues(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop()}; - const auto handles = ctx.ReadBuffer(0); - const auto vibrations = ctx.ReadBuffer(1); + const auto handle_data = ctx.ReadBuffer(0); + const auto handle_count = ctx.GetReadBufferNumElements(0); + const auto vibration_data = ctx.ReadBuffer(1); + const auto vibration_count = ctx.GetReadBufferNumElements(1); - std::vector vibration_device_handles( - handles.size() / sizeof(Core::HID::VibrationDeviceHandle)); - std::vector vibration_values(vibrations.size() / - sizeof(Core::HID::VibrationValue)); - - std::memcpy(vibration_device_handles.data(), handles.data(), handles.size()); - std::memcpy(vibration_values.data(), vibrations.data(), vibrations.size()); + auto vibration_device_handles = + std::span(reinterpret_cast(handle_data.data()), + handle_count); + auto vibration_values = std::span( + reinterpret_cast(vibration_data.data()), vibration_count); applet_resource->GetController(HidController::NPad) .VibrateControllers(vibration_device_handles, vibration_values);